From c77f1879eb5d9aba789879ada8c65dd7663dd2cf Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 11 Feb 2013 14:42:47 +0100 Subject: [PATCH 001/242] Upped to new internal version after pushing changes to main branch p4#: 20444 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 29995e5fee..2570559524 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -1,7 +1,7 @@ set(CMAKE_MAJOR_VERSION 0) set(CMAKE_MINOR_VERSION 9) -set(CMAKE_PATCH_VERSION 2) +set(CMAKE_PATCH_VERSION 3) set(PRODUCTVER ${CMAKE_MAJOR_VERSION},${CMAKE_MINOR_VERSION},0,${CMAKE_PATCH_VERSION}) set(STRPRODUCTVER ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}) From 8fd8a31aecba80de135d97b5dbb88f9bfb69c328 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 11 Feb 2013 15:12:53 +0100 Subject: [PATCH 002/242] Added RigActiveCellInfo Started refactoring aiming for extracting all active cell information into RigActiveCellInfo. p4#: 20445 --- ApplicationCode/CMakeLists.txt | 2 + .../FileInterface_UnitTests/CMakeLists.txt | 2 + .../FileInterface/RifReaderEclipseOutput.cpp | 22 +---- .../FileInterface/RifReaderEclipseOutput.h | 2 - .../ReservoirDataModel/RigActiveCellInfo.cpp | 20 ++++ .../ReservoirDataModel/RigActiveCellInfo.h | 91 +++++++++++++++++++ ApplicationCode/ReservoirDataModel/RigCell.h | 3 +- .../ReservoirDataModel/RigGridBase.cpp | 16 ---- .../ReservoirDataModel/RigGridBase.h | 1 - .../ReservoirDataModel/RigReservoir.h | 11 +++ CommonCode/cvfStructGrid.cpp | 2 +- CommonCode/cvfStructGrid.h | 1 - 12 files changed, 132 insertions(+), 41 deletions(-) create mode 100644 ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp create mode 100644 ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index 08b69aa413..b866c131bc 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -103,6 +103,7 @@ list( APPEND CPP_SOURCES ReservoirDataModel/RigReservoirBuilderMock.cpp ReservoirDataModel/RigWellResults.cpp ReservoirDataModel/RigGridScalarDataAccess.cpp + ReservoirDataModel/RigActiveCellInfo.cpp ) list( APPEND CPP_SOURCES @@ -158,6 +159,7 @@ set( RAW_SOURCES ${CPP_SOURCES} ) list( REMOVE_ITEM RAW_SOURCES RIStdInclude.cpp) list( REMOVE_ITEM RAW_SOURCES ReservoirDataModel/RigReaderInterfaceECL.cpp) list( REMOVE_ITEM RAW_SOURCES ReservoirDataModel/RigGridScalarDataAccess.cpp) +list( REMOVE_ITEM RAW_SOURCES ReservoirDataModel/RigActiveCellInfo.cpp) list( REMOVE_ITEM RAW_SOURCES ModelVisualization/RivCellEdgeEffectGenerator.cpp) list( REMOVE_ITEM RAW_SOURCES ModelVisualization/RivPipeGeometryGenerator.cpp) list( REMOVE_ITEM RAW_SOURCES ModelVisualization/RivWellPipesPartMgr.cpp) diff --git a/ApplicationCode/FileInterface/FileInterface_UnitTests/CMakeLists.txt b/ApplicationCode/FileInterface/FileInterface_UnitTests/CMakeLists.txt index 7ae8924546..ab6a2ed919 100644 --- a/ApplicationCode/FileInterface/FileInterface_UnitTests/CMakeLists.txt +++ b/ApplicationCode/FileInterface/FileInterface_UnitTests/CMakeLists.txt @@ -41,6 +41,8 @@ set( RESERVOIRDATAMODEL_CPP_SOURCES ${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp ${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigWellResults.cpp ${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp + ${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp + ${ResInsight_SOURCE_DIR}/cafUserInterface/cafProgressInfo.cpp ) diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index bd2ec9b0b6..cf02ee6218 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -169,7 +169,9 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigGridBase* localGrid, const e } // Mark inactive long pyramid looking cells as invalid - if (!invalid && (cell.isInCoarseCell() || (!cell.isActiveInMatrixModel() && !cell.isActiveInFractureModel()) ) ) + // Forslag + //if (!invalid && (cell.isInCoarseCell() || (!cell.isActiveInMatrixModel() && !cell.isActiveInFractureModel()) ) ) + if (!invalid) { cell.setInvalid(cell.isLongPyramidCell()); } @@ -746,24 +748,6 @@ void RifReaderEclipseOutput::readWellCells(RigReservoir* reservoir) reservoir->setWellResults(wells); } -//-------------------------------------------------------------------------------------------------- -// For case DUALPORO, the well K index is reported outside the grid. If this happens, -// for the given IJ position, search from K=0 and upwards for first active cell. -//-------------------------------------------------------------------------------------------------- -int RifReaderEclipseOutput::findSmallestActiveCellIndexK(const RigGridBase* grid, int cellI, int cellJ) -{ - if (!grid) return -1; - - for (int candidateCellK = 0; candidateCellK < grid->cellCountK(); candidateCellK++ ) - { - if (grid->isCellActive(cellI, cellJ, candidateCellK)) - { - return candidateCellK; - } - } - - return -1; -} //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.h b/ApplicationCode/FileInterface/RifReaderEclipseOutput.h index 1b961feea1..4886b0bf41 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.h +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.h @@ -57,8 +57,6 @@ private: void extractResultValuesBasedOnPorosityModel(PorosityModelResultType matrixOrFracture, std::vector* values, const std::vector& fileValues); - int findSmallestActiveCellIndexK( const RigGridBase* grid, int cellI, int cellJ); - static RifEclipseRestartDataAccess* staticResultsAccess(const QStringList& fileSet); static RifEclipseRestartDataAccess* dynamicResultsAccess(const QStringList& fileSet); diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp new file mode 100644 index 0000000000..cbbc279c5b --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp @@ -0,0 +1,20 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 "RigActiveCellInfo.h" + diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h new file mode 100644 index 0000000000..446cc9df21 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h @@ -0,0 +1,91 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 "cvfBase.h" +#include "cvfObject.h" +#include "cvfVector3.h" +#include "cvfBoundingBox.h" + +#include + + + +class RigActiveCellInfo +{ +public: + RigActiveCellInfo(); + + void setGlobalCellCount(size_t globalCellCount); + + bool isActiveInMatrixModel(size_t globalCellIndex) const; + size_t activeIndexInMatrixModel(size_t globalCellIndex) const; + void setActiveIndexInMatrixModel(size_t globalCellIndex, size_t globalActiveCellIndex); + + bool isActiveInFractureModel(size_t globalCellIndex) const; + size_t activeIndexInFractureModel(size_t globalCellIndex) const; + void setActiveIndexInFractureModel(size_t globalCellIndex, size_t globalActiveCellIndex); + + // From RigBase + + + // From RigMainGrid + size_t globalMatrixModelActiveCellCount() const; + size_t globalFractureModelActiveCellCount() const; + void setGlobalMatrixModelActiveCellCount (size_t globalMatrixModelActiveCellCount) { m_globalMatrixModelActiveCellCount = globalMatrixModelActiveCellCount; } + void setGlobalFractureModelActiveCellCount(size_t globalFractureModelActiveCellCount) { m_globalFractureModelActiveCellCount = globalFractureModelActiveCellCount;} + + void matrixModelActiveCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const; + void validCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const; + + + +private: + class GridActiveCellCounts + { + public: + size_t matrixModelActiveCellCount() const; + void setMatrixModelActiveCellCount(size_t activeMatrixModelCellCount); + size_t fractureModelActiveCellCount() const ; + void setFractureModelActiveCellCount(size_t activeFractureModelCellCount); + + private: + size_t m_matrixModelActiveCellCount; + size_t m_fractureModelActiveCellCount; + }; + + +private: + std::vector m_activeInMatrixModel; + std::vector m_activeInFractureModel; + + std::vector m_perGridActiveCellInfo; + + // From RigMainGrid + size_t m_globalMatrixModelActiveCellCount; + size_t m_globalFractureModelActiveCellCount; + + cvf::Vec3st m_activeCellPositionMin; + cvf::Vec3st m_activeCellPositionMax; + cvf::Vec3st m_validCellPositionMin; + cvf::Vec3st m_validCellPositionMax; + + cvf::BoundingBox m_activeCellsBoundingBox; + +}; diff --git a/ApplicationCode/ReservoirDataModel/RigCell.h b/ApplicationCode/ReservoirDataModel/RigCell.h index 8e60ac1850..4e3ac4abe2 100644 --- a/ApplicationCode/ReservoirDataModel/RigCell.h +++ b/ApplicationCode/ReservoirDataModel/RigCell.h @@ -89,8 +89,9 @@ private: bool m_cellFaceFaults[6]; - // Result case specific data bool m_isInvalid; + + // Result case specific data bool m_isWellCell; size_t m_activeIndexInMatrixModel; ///< This cell's running index of all the active calls (matrix) in the reservoir diff --git a/ApplicationCode/ReservoirDataModel/RigGridBase.cpp b/ApplicationCode/ReservoirDataModel/RigGridBase.cpp index e806998c92..ace4c9b1b0 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridBase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridBase.cpp @@ -303,22 +303,6 @@ bool RigGridBase::isCellValid(size_t i, size_t j, size_t k) const return !c.isInvalid(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RigGridBase::isCellActive(size_t i, size_t j, size_t k) const -{ - size_t idx = cellIndexFromIJK(i, j, k); - const RigCell& c = cell(idx); - if (!c.isActiveInMatrixModel() || c.isInvalid()) - { - return false; - } - else - { - return true; - } -} //-------------------------------------------------------------------------------------------------- /// TODO: Use structgrid::neighborIJKAtCellFace diff --git a/ApplicationCode/ReservoirDataModel/RigGridBase.h b/ApplicationCode/ReservoirDataModel/RigGridBase.h index c9233e82d6..feb6e76f24 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridBase.h +++ b/ApplicationCode/ReservoirDataModel/RigGridBase.h @@ -93,7 +93,6 @@ public: virtual size_t gridPointIndexFromIJK( size_t i, size_t j, size_t k ) const; virtual cvf::Vec3d gridPointCoordinate( size_t i, size_t j, size_t k ) const; - virtual bool isCellActive( 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; diff --git a/ApplicationCode/ReservoirDataModel/RigReservoir.h b/ApplicationCode/ReservoirDataModel/RigReservoir.h index d7518d1245..73be5c1a79 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoir.h +++ b/ApplicationCode/ReservoirDataModel/RigReservoir.h @@ -51,6 +51,17 @@ public: bool findSharedSourceFace(cvf::StructGridInterface::FaceType& sharedSourceFace, const RigWellResultCell& sourceWellCellResult, const RigWellResultCell& otherWellCellResult) const; + // From RigMainGrid, can this function be moved to Octave socket server? + void calculateMatrixModelActiveCellInfo(std::vector& gridNumber, + std::vector& i, + std::vector& j, + std::vector& k, + std::vector& parentGridNumber, + std::vector& hostCellI, + std::vector& hostCellJ, + std::vector& hostCellK); + + private: void computeWellCellsPrGrid(); diff --git a/CommonCode/cvfStructGrid.cpp b/CommonCode/cvfStructGrid.cpp index 6cc7830321..6b0e204e24 100644 --- a/CommonCode/cvfStructGrid.cpp +++ b/CommonCode/cvfStructGrid.cpp @@ -230,7 +230,7 @@ void StructGridInterface::characteristicCellSizes(double* iSize, double* jSize, size_t i; for (i = 0; i < cellCountI(); i += 10) // NB! Evaluate every n-th cell { - if (isCellActive(i, j, k)) + if (isCellValid(i, j, k)) { size_t cellIndex = cellIndexFromIJK(i, j, k); cellCornerVertices(cellIndex, cornerVerts); diff --git a/CommonCode/cvfStructGrid.h b/CommonCode/cvfStructGrid.h index a08e67e2f1..4353192b74 100644 --- a/CommonCode/cvfStructGrid.h +++ b/CommonCode/cvfStructGrid.h @@ -57,7 +57,6 @@ public: size_t cellCountK() const; virtual bool isCellValid(size_t i, size_t j, size_t k) const = 0; - virtual bool isCellActive(size_t i, size_t j, size_t k) const = 0; virtual cvf::Vec3d minCoordinate() const = 0; virtual cvf::Vec3d maxCoordinate() const = 0; From 0bc3d9f2058bc2495fbc7b6bbf7866b32d25bf84 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 12 Feb 2013 07:11:32 +0100 Subject: [PATCH 003/242] More tests and moved more functions p4#: 20447 --- .../CMakeLists.txt | 15 +- .../RigReservoir-Test.cpp | 3 + .../ReservoirDataModel/RigActiveCellInfo.cpp | 204 ++++++++++++++++++ .../ReservoirDataModel/RigActiveCellInfo.h | 50 +++-- 4 files changed, 249 insertions(+), 23 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/CMakeLists.txt b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/CMakeLists.txt index ca2ec9976e..c53267760c 100644 --- a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/CMakeLists.txt +++ b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/CMakeLists.txt @@ -25,7 +25,20 @@ include_directories( ) file( GLOB CPP_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../*.cpp ) -file( GLOB UNIT_TEST_CPP_SOURCES *.cpp ) + +set( UNIT_TEST_CPP_SOURCES + main.cpp + RigActiveCellInfo-Test.cpp + RigReservoir-Test.cpp +) + + +############################################################################# +# Adds folders for Visual Studio solution explorer (and for Xcode explorer) +############################################################################# +source_group( "ResInsight" FILES ${CPP_SOURCES} ) +source_group( "UnitTests" FILES ${UNIT_TEST_CPP_SOURCES} ) + set( LINK_LIBRARIES diff --git a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp index 6157a4751e..9ac5448b5d 100644 --- a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp +++ b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp @@ -24,6 +24,7 @@ #include "RigReservoir.h" +/* //-------------------------------------------------------------------------------------------------- /// @@ -62,3 +63,5 @@ TEST(RigReservoirTest, BasicTest) } + +*/ \ No newline at end of file diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp index cbbc279c5b..a54dda9e7d 100644 --- a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp @@ -18,3 +18,207 @@ #include "RigActiveCellInfo.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigActiveCellInfo::RigActiveCellInfo() + : m_globalMatrixModelActiveCellCount(0), + m_globalFractureModelActiveCellCount(0), + m_activeCellPositionMin(cvf::Vec3d::ZERO), + m_activeCellPositionMax(cvf::Vec3d::ZERO) +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigActiveCellInfo::setGlobalCellCount(size_t globalCellCount) +{ + m_activeInMatrixModel.resize(globalCellCount, cvf::UNDEFINED_SIZE_T); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigActiveCellInfo::isActiveInMatrixModel(size_t globalCellIndex) const +{ + if (globalCellIndex >= m_activeInMatrixModel.size()) return false; + + return m_activeInMatrixModel[globalCellIndex] != cvf::UNDEFINED_SIZE_T; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigActiveCellInfo::activeIndexInMatrixModel(size_t globalCellIndex) const +{ + if (globalCellIndex >= m_activeInMatrixModel.size()) return cvf::UNDEFINED_SIZE_T; + + return m_activeInMatrixModel[globalCellIndex]; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigActiveCellInfo::setActiveIndexInMatrixModel(size_t globalCellIndex, size_t globalActiveCellIndex) +{ + CVF_TIGHT_ASSERT(globalActiveCellIndex < m_activeInMatrixModel.size()); + + m_activeInMatrixModel[globalCellIndex] = globalActiveCellIndex; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigActiveCellInfo::isActiveInFractureModel(size_t globalCellIndex) const +{ + if (globalCellIndex >= m_activeInFractureModel.size()) return false; + + return m_activeInFractureModel[globalCellIndex] != cvf::UNDEFINED_SIZE_T; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigActiveCellInfo::activeIndexInFractureModel(size_t globalCellIndex) const +{ + if (globalCellIndex >= m_activeInFractureModel.size()) return cvf::UNDEFINED_SIZE_T; + + return m_activeInFractureModel[globalCellIndex]; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigActiveCellInfo::setActiveIndexInFractureModel(size_t globalCellIndex, size_t globalActiveCellIndex) +{ + if (m_activeInFractureModel.size() == 0) + { + m_activeInFractureModel.resize(m_activeInMatrixModel.size(), cvf::UNDEFINED_SIZE_T); + } + + CVF_TIGHT_ASSERT(globalActiveCellIndex < m_activeInFractureModel.size()); + + m_activeInFractureModel[globalCellIndex] = globalActiveCellIndex; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigActiveCellInfo::setGridCount(size_t gridCount) +{ + m_perGridActiveCellInfo.resize(gridCount); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigActiveCellInfo::setGridActiveCellCounts(size_t gridIndex, size_t matrixActiveCellCount, size_t fractureActiveCellCount) +{ + CVF_ASSERT(gridIndex < m_perGridActiveCellInfo.size()); + + m_perGridActiveCellInfo[gridIndex].setMatrixModelActiveCellCount(matrixActiveCellCount); + m_perGridActiveCellInfo[gridIndex].setFractureModelActiveCellCount(fractureActiveCellCount); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigActiveCellInfo::computeDerivedData() +{ + m_globalMatrixModelActiveCellCount = 0; + m_globalFractureModelActiveCellCount = 0; + + for (size_t i = 0; i < m_perGridActiveCellInfo.size(); i++) + { + m_globalMatrixModelActiveCellCount += m_perGridActiveCellInfo[i].matrixModelActiveCellCount(); + m_globalFractureModelActiveCellCount += m_perGridActiveCellInfo[i].fractureModelActiveCellCount(); + } + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigActiveCellInfo::globalMatrixModelActiveCellCount() const +{ + return m_globalMatrixModelActiveCellCount; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigActiveCellInfo::globalFractureModelActiveCellCount() const +{ + return m_globalFractureModelActiveCellCount; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigActiveCellInfo::setMatrixModelActiveCellsBoundingBox(const cvf::Vec3st& min, const cvf::Vec3st& max) +{ + m_activeCellPositionMin = min; + m_activeCellPositionMax = max; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigActiveCellInfo::matrixModelActiveCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const +{ + min = m_activeCellPositionMin; + max = m_activeCellPositionMax; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigActiveCellInfo::setFractureModelActiveCellsBoundingBox(const cvf::Vec3st& min, const cvf::Vec3st& max) +{ + m_fractureModelActiveCellPositionMin = min; + m_fractureModelActiveCellPositionMax = max; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigActiveCellInfo::fractureModelActiveCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const +{ + min = m_fractureModelActiveCellPositionMin; + max = m_fractureModelActiveCellPositionMax; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigActiveCellInfo::GridActiveCellCounts::matrixModelActiveCellCount() const +{ + return m_matrixModelActiveCellCount; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigActiveCellInfo::GridActiveCellCounts::setMatrixModelActiveCellCount(size_t activeMatrixModelCellCount) +{ + m_matrixModelActiveCellCount = activeMatrixModelCellCount; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigActiveCellInfo::GridActiveCellCounts::fractureModelActiveCellCount() const +{ + return m_fractureModelActiveCellCount; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigActiveCellInfo::GridActiveCellCounts::setFractureModelActiveCellCount(size_t activeFractureModelCellCount) +{ + m_fractureModelActiveCellCount = activeFractureModelCellCount; +} diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h index 446cc9df21..74510868c7 100644 --- a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h @@ -32,27 +32,30 @@ class RigActiveCellInfo public: RigActiveCellInfo(); - void setGlobalCellCount(size_t globalCellCount); + void setGlobalCellCount(size_t globalCellCount); - bool isActiveInMatrixModel(size_t globalCellIndex) const; - size_t activeIndexInMatrixModel(size_t globalCellIndex) const; - void setActiveIndexInMatrixModel(size_t globalCellIndex, size_t globalActiveCellIndex); + bool isActiveInMatrixModel(size_t globalCellIndex) const; + size_t activeIndexInMatrixModel(size_t globalCellIndex) const; + void setActiveIndexInMatrixModel(size_t globalCellIndex, size_t globalActiveCellIndex); - bool isActiveInFractureModel(size_t globalCellIndex) const; - size_t activeIndexInFractureModel(size_t globalCellIndex) const; - void setActiveIndexInFractureModel(size_t globalCellIndex, size_t globalActiveCellIndex); + bool isActiveInFractureModel(size_t globalCellIndex) const; + size_t activeIndexInFractureModel(size_t globalCellIndex) const; + void setActiveIndexInFractureModel(size_t globalCellIndex, size_t globalActiveCellIndex); // From RigBase + void setGridCount(size_t gridCount); + void setGridActiveCellCounts(size_t gridIndex, size_t matrixActiveCellCount, size_t fractureActiveCellCount); + void computeDerivedData(); // From RigMainGrid - size_t globalMatrixModelActiveCellCount() const; - size_t globalFractureModelActiveCellCount() const; - void setGlobalMatrixModelActiveCellCount (size_t globalMatrixModelActiveCellCount) { m_globalMatrixModelActiveCellCount = globalMatrixModelActiveCellCount; } - void setGlobalFractureModelActiveCellCount(size_t globalFractureModelActiveCellCount) { m_globalFractureModelActiveCellCount = globalFractureModelActiveCellCount;} + size_t globalMatrixModelActiveCellCount() const; + size_t globalFractureModelActiveCellCount() const; - void matrixModelActiveCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const; - void validCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const; + void setMatrixModelActiveCellsBoundingBox(const cvf::Vec3st& min, const cvf::Vec3st& max); + void matrixModelActiveCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const; + void setFractureModelActiveCellsBoundingBox(const cvf::Vec3st& min, const cvf::Vec3st& max); + void fractureModelActiveCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const; @@ -60,14 +63,14 @@ private: class GridActiveCellCounts { public: - size_t matrixModelActiveCellCount() const; - void setMatrixModelActiveCellCount(size_t activeMatrixModelCellCount); - size_t fractureModelActiveCellCount() const ; - void setFractureModelActiveCellCount(size_t activeFractureModelCellCount); + size_t matrixModelActiveCellCount() const; + void setMatrixModelActiveCellCount(size_t activeMatrixModelCellCount); + size_t fractureModelActiveCellCount() const; + void setFractureModelActiveCellCount(size_t activeFractureModelCellCount); private: - size_t m_matrixModelActiveCellCount; - size_t m_fractureModelActiveCellCount; + size_t m_matrixModelActiveCellCount; + size_t m_fractureModelActiveCellCount; }; @@ -83,9 +86,12 @@ private: cvf::Vec3st m_activeCellPositionMin; cvf::Vec3st m_activeCellPositionMax; - cvf::Vec3st m_validCellPositionMin; - cvf::Vec3st m_validCellPositionMax; + cvf::Vec3st m_fractureModelActiveCellPositionMin; + cvf::Vec3st m_fractureModelActiveCellPositionMax; - cvf::BoundingBox m_activeCellsBoundingBox; + // NOT USED +// cvf::Vec3st m_validCellPositionMin; +// cvf::Vec3st m_validCellPositionMax; +// cvf::BoundingBox m_activeCellsBoundingBox; }; From 2b4edf39d1073e7fa3cee0057fb70cbce3daab03 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 12 Feb 2013 11:15:36 +0100 Subject: [PATCH 004/242] Use active cell info structure p4#: 20455 --- .../FileInterface/RifReaderEclipseOutput.cpp | 111 +++++++++++------- .../FileInterface/RifReaderEclipseOutput.h | 5 +- .../ProjectDataModel/RimInputReservoir.cpp | 4 +- .../ProjectDataModel/RimResultReservoir.cpp | 2 +- .../ReservoirDataModel/RigActiveCellInfo.cpp | 10 ++ .../ReservoirDataModel/RigActiveCellInfo.h | 1 + .../ReservoirDataModel/RigGridBase.cpp | 7 ++ .../ReservoirDataModel/RigGridBase.h | 2 + .../ReservoirDataModel/RigReservoir.cpp | 88 ++++++++++++++ .../ReservoirDataModel/RigReservoir.h | 12 +- 10 files changed, 190 insertions(+), 52 deletions(-) diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index cf02ee6218..83a63d5bce 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -84,8 +84,10 @@ static const size_t cellMappingECLRi[8] = { 0, 1, 3, 2, 4, 5, 7, 6 }; // Static functions //************************************************************************************************** -bool transferGridCellData(RigMainGrid* mainGrid, RigGridBase* localGrid, const ecl_grid_type* localEclGrid, size_t matrixActiveStartIndex, size_t fractureActiveStartIndex) +bool transferGridCellData(RigMainGrid* mainGrid, RigActiveCellInfo* activeCellInfo, RigGridBase* localGrid, const ecl_grid_type* localEclGrid, size_t matrixActiveStartIndex, size_t fractureActiveStartIndex) { + CVF_ASSERT(activeCellInfo); + int cellCount = ecl_grid_get_global_size(localEclGrid); size_t cellStartIndex = mainGrid->cells().size(); size_t nodeStartIndex = mainGrid->nodes().size(); @@ -103,30 +105,32 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigGridBase* localGrid, const e // Loop over cells and fill them with data #pragma omp parallel for - for (int gIdx = 0; gIdx < cellCount; ++gIdx) + for (int localCellIdx = 0; localCellIdx < cellCount; ++localCellIdx) { - RigCell& cell = mainGrid->cells()[cellStartIndex + gIdx]; + RigCell& cell = mainGrid->cells()[cellStartIndex + localCellIdx]; - bool invalid = ecl_grid_cell_invalid1(localEclGrid, gIdx); + bool invalid = ecl_grid_cell_invalid1(localEclGrid, localCellIdx); cell.setInvalid(invalid); - cell.setCellIndex(gIdx); + cell.setCellIndex(localCellIdx); // Active cell index - int matrixActiveIndex = ecl_grid_get_active_index1(localEclGrid, gIdx); + int matrixActiveIndex = ecl_grid_get_active_index1(localEclGrid, localCellIdx); if (matrixActiveIndex != -1) { cell.setActiveIndexInMatrixModel(matrixActiveStartIndex + matrixActiveIndex); + activeCellInfo->setActiveIndexInMatrixModel(localCellIdx, matrixActiveStartIndex + matrixActiveIndex); } else { cell.setActiveIndexInMatrixModel(cvf::UNDEFINED_SIZE_T); } - int fractureActiveIndex = ecl_grid_get_active_fracture_index1(localEclGrid, gIdx); + int fractureActiveIndex = ecl_grid_get_active_fracture_index1(localEclGrid, localCellIdx); if (fractureActiveIndex != -1) { cell.setActiveIndexInFractureModel(fractureActiveStartIndex + fractureActiveIndex); + activeCellInfo->setActiveIndexInFractureModel(localCellIdx, fractureActiveStartIndex + fractureActiveIndex); } else { @@ -135,7 +139,7 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigGridBase* localGrid, const e // Parent cell index - int parentCellIndex = ecl_grid_get_parent_cell1(localEclGrid, gIdx); + int parentCellIndex = ecl_grid_get_parent_cell1(localEclGrid, localCellIdx); if (parentCellIndex == -1) { cell.setParentCellIndex(cvf::UNDEFINED_SIZE_T); @@ -146,21 +150,21 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigGridBase* localGrid, const e } // Coarse cell info - ecl_coarse_cell_type * coarseCellData = ecl_grid_get_cell_coarse_group1( localEclGrid , gIdx); + ecl_coarse_cell_type * coarseCellData = ecl_grid_get_cell_coarse_group1( localEclGrid , localCellIdx); cell.setInCoarseCell(coarseCellData != NULL); // Corner coordinates int cIdx; for (cIdx = 0; cIdx < 8; ++cIdx) { - double * point = mainGrid->nodes()[nodeStartIndex + gIdx * 8 + cellMappingECLRi[cIdx]].ptr(); - ecl_grid_get_corner_xyz1(localEclGrid, gIdx, cIdx, &(point[0]), &(point[1]), &(point[2])); + double * point = mainGrid->nodes()[nodeStartIndex + localCellIdx * 8 + cellMappingECLRi[cIdx]].ptr(); + ecl_grid_get_corner_xyz1(localEclGrid, localCellIdx, cIdx, &(point[0]), &(point[1]), &(point[2])); point[2] = -point[2]; - cell.cornerIndices()[cIdx] = nodeStartIndex + gIdx*8 + cIdx; + cell.cornerIndices()[cIdx] = nodeStartIndex + localCellIdx*8 + cIdx; } // Sub grid in cell - const ecl_grid_type* subGrid = ecl_grid_get_cell_lgr1(localEclGrid, gIdx); + const ecl_grid_type* subGrid = ecl_grid_get_cell_lgr1(localEclGrid, localCellIdx); if (subGrid != NULL) { int subGridFileIndex = ecl_grid_get_grid_nr(subGrid); @@ -214,7 +218,7 @@ void RifReaderEclipseOutput::ground() m_fileSet.clear(); m_timeSteps.clear(); - m_mainGrid = NULL; + m_reservoir = NULL; } //-------------------------------------------------------------------------------------------------- @@ -241,6 +245,9 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid, return false; } + RigActiveCellInfo* activeCellInfo = reservoir->activeCellInfo(); + CVF_ASSERT(activeCellInfo); + RigMainGrid* mainGrid = reservoir->mainGrid(); { cvf::Vec3st gridPointDim(0,0,0); @@ -275,6 +282,8 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid, totalCellCount += ecl_grid_get_global_size(localEclGrid); } + + activeCellInfo->setGlobalCellCount(totalCellCount); // Reserve room for the cells and nodes and fill them with data @@ -285,13 +294,16 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid, progInfo.setProgressDescription("Main Grid"); progInfo.setNextProgressIncrement(3); - transferGridCellData(mainGrid, mainGrid, mainEclGrid, 0, 0); + transferGridCellData(mainGrid, activeCellInfo, mainGrid, mainEclGrid, 0, 0); progInfo.setProgress(3); size_t globalMatrixActiveSize = ecl_grid_get_nactive(mainEclGrid); size_t globalFractureActiveSize = ecl_grid_get_nactive_fracture(mainEclGrid); + activeCellInfo->setGridCount(1 + numLGRs); + activeCellInfo->setGridActiveCellCounts(0, globalMatrixActiveSize, globalFractureActiveSize); + mainGrid->setMatrixModelActiveCellCount(globalMatrixActiveSize); mainGrid->setFractureModelActiveCellCount(globalFractureActiveSize); @@ -302,23 +314,26 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid, ecl_grid_type* localEclGrid = ecl_grid_iget_lgr(mainEclGrid, lgrIdx); RigLocalGrid* localGrid = static_cast(mainGrid->gridByIndex(lgrIdx+1)); - transferGridCellData(mainGrid, localGrid, localEclGrid, globalMatrixActiveSize, globalFractureActiveSize); + transferGridCellData(mainGrid, activeCellInfo, localGrid, localEclGrid, globalMatrixActiveSize, globalFractureActiveSize); - int activeCellCount = ecl_grid_get_nactive(localEclGrid); - localGrid->setMatrixModelActiveCellCount(activeCellCount); - globalMatrixActiveSize += activeCellCount; + int matrixActiveCellCount = ecl_grid_get_nactive(localEclGrid); + localGrid->setMatrixModelActiveCellCount(matrixActiveCellCount); + globalMatrixActiveSize += matrixActiveCellCount; - activeCellCount = ecl_grid_get_nactive_fracture(localEclGrid); - localGrid->setFractureModelActiveCellCount(activeCellCount); - globalFractureActiveSize += activeCellCount; + int fractureActiveCellCount = ecl_grid_get_nactive_fracture(localEclGrid); + localGrid->setFractureModelActiveCellCount(fractureActiveCellCount); + globalFractureActiveSize += fractureActiveCellCount; + + activeCellInfo->setGridActiveCellCounts(lgrIdx + 1, matrixActiveCellCount, fractureActiveCellCount); progInfo.setProgress(3 + lgrIdx); } - mainGrid->setGlobalMatrixModelActiveCellCount(globalMatrixActiveSize); mainGrid->setGlobalFractureModelActiveCellCount(globalFractureActiveSize); + activeCellInfo->computeDerivedData(); + return true; } @@ -363,7 +378,7 @@ bool RifReaderEclipseOutput::open(const QString& fileName, RigReservoir* reservo progInfo.setProgressDescription("Reading Result index"); progInfo.setNextProgressIncrement(60); - m_mainGrid = reservoir->mainGrid(); + m_reservoir = reservoir; reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(this); reservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(this); @@ -386,7 +401,7 @@ bool RifReaderEclipseOutput::open(const QString& fileName, RigReservoir* reservo //-------------------------------------------------------------------------------------------------- bool RifReaderEclipseOutput::buildMetaData(RigReservoir* reservoir) { - CVF_ASSERT(reservoir); + CVF_ASSERT(m_reservoir.notNull()); CVF_ASSERT(m_fileSet.size() > 0); caf::ProgressInfo progInfo(m_fileSet.size() + 3,""); @@ -402,8 +417,8 @@ bool RifReaderEclipseOutput::buildMetaData(RigReservoir* reservoir) progInfo.incrementProgress(); - RigReservoirCellResults* matrixModelResults = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS); - RigReservoirCellResults* fractureModelResults = reservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS); + RigReservoirCellResults* matrixModelResults = m_reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS); + RigReservoirCellResults* fractureModelResults = m_reservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS); if (m_dynamicResultsAccess.notNull()) { @@ -415,7 +430,7 @@ bool RifReaderEclipseOutput::buildMetaData(RigReservoir* reservoir) m_dynamicResultsAccess->resultNames(&resultNames, &resultNamesDataItemCounts); { - QStringList matrixResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, RifReaderInterface::MATRIX_RESULTS, m_dynamicResultsAccess->timeStepCount()); + QStringList matrixResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, m_reservoir->activeCellInfo(), RifReaderInterface::MATRIX_RESULTS, m_dynamicResultsAccess->timeStepCount()); for (int i = 0; i < matrixResultNames.size(); ++i) { @@ -425,7 +440,7 @@ bool RifReaderEclipseOutput::buildMetaData(RigReservoir* reservoir) } { - QStringList fractureResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, RifReaderInterface::FRACTURE_RESULTS, m_dynamicResultsAccess->timeStepCount()); + QStringList fractureResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, m_reservoir->activeCellInfo(), RifReaderInterface::FRACTURE_RESULTS, m_dynamicResultsAccess->timeStepCount()); for (int i = 0; i < fractureResultNames.size(); ++i) { @@ -451,7 +466,7 @@ bool RifReaderEclipseOutput::buildMetaData(RigReservoir* reservoir) RifEclipseOutputFileTools::findKeywordsAndDataItemCounts(ecl_file, &resultNames, &resultNamesDataItemCounts); { - QStringList matrixResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, RifReaderInterface::MATRIX_RESULTS, 1); + QStringList matrixResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, m_reservoir->activeCellInfo(), RifReaderInterface::MATRIX_RESULTS, 1); QList staticDate; if (m_timeSteps.size() > 0) @@ -467,7 +482,7 @@ bool RifReaderEclipseOutput::buildMetaData(RigReservoir* reservoir) } { - QStringList fractureResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, RifReaderInterface::FRACTURE_RESULTS, 1); + QStringList fractureResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, m_reservoir->activeCellInfo(), RifReaderInterface::FRACTURE_RESULTS, 1); QList staticDate; if (m_timeSteps.size() > 0) @@ -559,7 +574,7 @@ bool RifReaderEclipseOutput::dynamicResult(const QString& result, PorosityModelR CVF_ASSERT(m_dynamicResultsAccess.notNull()); std::vector fileValues; - if (!m_dynamicResultsAccess->results(result, stepIndex, m_mainGrid->gridCount(), &fileValues)) + if (!m_dynamicResultsAccess->results(result, stepIndex, m_reservoir->mainGrid()->gridCount(), &fileValues)) { return false; } @@ -752,8 +767,10 @@ void RifReaderEclipseOutput::readWellCells(RigReservoir* reservoir) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringList& keywords, const std::vector& keywordDataItemCounts, PorosityModelResultType matrixOrFracture, size_t timeStepCount) const +QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringList& keywords, const std::vector& keywordDataItemCounts, const RigActiveCellInfo* activeCellInfo, PorosityModelResultType matrixOrFracture, size_t timeStepCount) const { + CVF_ASSERT(activeCellInfo); + if (keywords.size() != keywordDataItemCounts.size()) { return QStringList(); @@ -761,7 +778,7 @@ QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringL if (matrixOrFracture == RifReaderInterface::FRACTURE_RESULTS) { - if (m_mainGrid->globalFractureModelActiveCellCount() == 0) + if (activeCellInfo->globalFractureModelActiveCellCount() == 0) { return QStringList(); } @@ -774,11 +791,11 @@ QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringL QString keyword = keywords[i]; size_t keywordDataCount = keywordDataItemCounts[i]; - size_t timeStepsMatrix = keywordDataItemCounts[i] / m_mainGrid->globalMatrixModelActiveCellCount(); - size_t timeStepsMatrixRest = keywordDataItemCounts[i] % m_mainGrid->globalMatrixModelActiveCellCount(); + size_t timeStepsMatrix = keywordDataItemCounts[i] / activeCellInfo->globalMatrixModelActiveCellCount(); + size_t timeStepsMatrixRest = keywordDataItemCounts[i] % activeCellInfo->globalMatrixModelActiveCellCount(); - size_t timeStepsMatrixAndFracture = keywordDataItemCounts[i] / (m_mainGrid->globalMatrixModelActiveCellCount() + m_mainGrid->globalFractureModelActiveCellCount()); - size_t timeStepsMatrixAndFractureRest = keywordDataItemCounts[i] % (m_mainGrid->globalMatrixModelActiveCellCount() + m_mainGrid->globalFractureModelActiveCellCount()); + size_t timeStepsMatrixAndFracture = keywordDataItemCounts[i] / (activeCellInfo->globalMatrixModelActiveCellCount() + activeCellInfo->globalFractureModelActiveCellCount()); + size_t timeStepsMatrixAndFractureRest = keywordDataItemCounts[i] % (activeCellInfo->globalMatrixModelActiveCellCount() + activeCellInfo->globalFractureModelActiveCellCount()); if (matrixOrFracture == RifReaderInterface::MATRIX_RESULTS) { @@ -807,9 +824,11 @@ QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringL //-------------------------------------------------------------------------------------------------- void RifReaderEclipseOutput::extractResultValuesBasedOnPorosityModel(PorosityModelResultType matrixOrFracture, std::vector* destinationResultValues, const std::vector& sourceResultValues) { + RigActiveCellInfo* actCellInfo = m_reservoir->activeCellInfo(); + if (matrixOrFracture == RifReaderInterface::MATRIX_RESULTS) { - if (m_mainGrid->globalFractureModelActiveCellCount() == 0) + if (actCellInfo->globalFractureModelActiveCellCount() == 0) { destinationResultValues->insert(destinationResultValues->end(), sourceResultValues.begin(), sourceResultValues.end()); } @@ -818,10 +837,11 @@ void RifReaderEclipseOutput::extractResultValuesBasedOnPorosityModel(PorosityMod size_t dataItemCount = 0; size_t sourceStartPosition = 0; - for (size_t i = 0; i < m_mainGrid->gridCount(); i++) + for (size_t i = 0; i < m_reservoir->mainGrid()->gridCount(); i++) { - size_t matrixActiveCellCount = m_mainGrid->gridByIndex(i)->matrixModelActiveCellCount(); - size_t fractureActiveCellCount = m_mainGrid->gridByIndex(i)->matrixModelActiveCellCount(); + size_t matrixActiveCellCount = 0; + size_t fractureActiveCellCount = 0; + actCellInfo->gridActiveCellCounts(i, matrixActiveCellCount, fractureActiveCellCount); destinationResultValues->insert(destinationResultValues->end(), sourceResultValues.begin() + sourceStartPosition, sourceResultValues.begin() + sourceStartPosition + matrixActiveCellCount); @@ -834,10 +854,11 @@ void RifReaderEclipseOutput::extractResultValuesBasedOnPorosityModel(PorosityMod size_t dataItemCount = 0; size_t sourceStartPosition = 0; - for (size_t i = 0; i < m_mainGrid->gridCount(); i++) + for (size_t i = 0; i < m_reservoir->mainGrid()->gridCount(); i++) { - size_t matrixActiveCellCount = m_mainGrid->gridByIndex(i)->matrixModelActiveCellCount(); - size_t fractureActiveCellCount = m_mainGrid->gridByIndex(i)->matrixModelActiveCellCount(); + size_t matrixActiveCellCount = 0; + size_t fractureActiveCellCount = 0; + actCellInfo->gridActiveCellCounts(i, matrixActiveCellCount, fractureActiveCellCount); destinationResultValues->insert(destinationResultValues->end(), sourceResultValues.begin() + sourceStartPosition + matrixActiveCellCount, sourceResultValues.begin() + sourceStartPosition + matrixActiveCellCount + fractureActiveCellCount); diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.h b/ApplicationCode/FileInterface/RifReaderEclipseOutput.h index 4886b0bf41..4d53ceb6c9 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.h +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.h @@ -26,6 +26,7 @@ class RifEclipseOutputFileTools; class RifEclipseRestartDataAccess; class RigGridBase; class RigMainGrid; +class RigActiveCellInfo; typedef struct ecl_grid_struct ecl_grid_type; typedef struct ecl_file_struct ecl_file_type; @@ -60,13 +61,13 @@ private: static RifEclipseRestartDataAccess* staticResultsAccess(const QStringList& fileSet); static RifEclipseRestartDataAccess* dynamicResultsAccess(const QStringList& fileSet); - QStringList validKeywordsForPorosityModel(const QStringList& keywords, const std::vector& keywordDataItemCounts, PorosityModelResultType matrixOrFracture, size_t timeStepCount) const; + QStringList validKeywordsForPorosityModel(const QStringList& keywords, const std::vector& keywordDataItemCounts, const RigActiveCellInfo* activeCellInfo, PorosityModelResultType matrixOrFracture, size_t timeStepCount) const; private: QString m_fileName; // Name of file used to start accessing Eclipse output files QStringList m_fileSet; // Set of files in filename's path with same base name as filename - cvf::cref m_mainGrid; + cvf::ref m_reservoir; QList m_timeSteps; diff --git a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp index b2f5544dbe..bfb6815eef 100644 --- a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp @@ -114,7 +114,7 @@ void RimInputReservoir::openDataFileSet(const QStringList& filenames) { m_gridFileName = filenames[i]; - m_rigReservoir->computeFaults(); + m_rigReservoir->computeCachedData(); m_rigReservoir->mainGrid()->computeCachedData(); break; @@ -204,7 +204,7 @@ bool RimInputReservoir::openEclipseGridFile() m_rigReservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p()); m_rigReservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p()); - m_rigReservoir->computeFaults(); + m_rigReservoir->computeCachedData(); m_rigReservoir->mainGrid()->computeCachedData(); } diff --git a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp index fb42bda412..c3af3f4a8f 100644 --- a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp @@ -106,7 +106,7 @@ bool RimResultReservoir::openEclipseGridFile() CVF_ASSERT(readerInterface.notNull()); progInfo.setProgressDescription("Computing Faults"); - m_rigReservoir->computeFaults(); + m_rigReservoir->computeCachedData(); progInfo.incrementProgress(); progInfo.setProgressDescription("Computing Cache"); diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp index a54dda9e7d..598f481805 100644 --- a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp @@ -37,6 +37,7 @@ RigActiveCellInfo::RigActiveCellInfo() void RigActiveCellInfo::setGlobalCellCount(size_t globalCellCount) { m_activeInMatrixModel.resize(globalCellCount, cvf::UNDEFINED_SIZE_T); + m_activeInFractureModel.resize(globalCellCount, cvf::UNDEFINED_SIZE_T); } //-------------------------------------------------------------------------------------------------- @@ -191,6 +192,15 @@ void RigActiveCellInfo::fractureModelActiveCellsBoundingBox(cvf::Vec3st& min, cv max = m_fractureModelActiveCellPositionMax; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigActiveCellInfo::gridActiveCellCounts(size_t gridIndex, size_t& matrixActiveCellCount, size_t& fractureActiveCellCount) +{ + matrixActiveCellCount = m_perGridActiveCellInfo[gridIndex].matrixModelActiveCellCount(); + fractureActiveCellCount = m_perGridActiveCellInfo[gridIndex].fractureModelActiveCellCount(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h index 74510868c7..b436396a41 100644 --- a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h @@ -45,6 +45,7 @@ public: // From RigBase void setGridCount(size_t gridCount); void setGridActiveCellCounts(size_t gridIndex, size_t matrixActiveCellCount, size_t fractureActiveCellCount); + void gridActiveCellCounts(size_t gridIndex, size_t& matrixActiveCellCount, size_t& fractureActiveCellCount); void computeDerivedData(); diff --git a/ApplicationCode/ReservoirDataModel/RigGridBase.cpp b/ApplicationCode/ReservoirDataModel/RigGridBase.cpp index ace4c9b1b0..dac8ae9c83 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridBase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridBase.cpp @@ -499,6 +499,13 @@ void RigGridBase::setMatrixModelActiveCellCount(size_t activeMatrixModelCellCoun m_matrixModelActiveCellCount = activeMatrixModelCellCount; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigGridBase::mainGridCellIndex(size_t localGridCellIndex) const +{ + return m_indexToStartOfCells + localGridCellIndex; +} //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/ReservoirDataModel/RigGridBase.h b/ApplicationCode/ReservoirDataModel/RigGridBase.h index feb6e76f24..8cdc541f3e 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridBase.h +++ b/ApplicationCode/ReservoirDataModel/RigGridBase.h @@ -48,7 +48,9 @@ public: RigCell& cell(size_t gridCellIndex); const RigCell& cell(size_t gridCellIndex) const; + size_t mainGridCellIndex(size_t localGridCellIndex) const; void setIndexToStartOfCells(size_t indexToStartOfCells) { m_indexToStartOfCells = indexToStartOfCells; } + void setGridIndex(size_t index) { m_gridIndex = index; } size_t gridIndex() { return m_gridIndex; } diff --git a/ApplicationCode/ReservoirDataModel/RigReservoir.cpp b/ApplicationCode/ReservoirDataModel/RigReservoir.cpp index cfaa91f668..ac557ca21c 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoir.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoir.cpp @@ -222,3 +222,91 @@ bool RigReservoir::findSharedSourceFace(cvf::StructGridInterface::FaceType& shar return false; } + + + +//-------------------------------------------------------------------------------------------------- +/// Helper class used to find min/max range for valid and active cells +//-------------------------------------------------------------------------------------------------- +class CellRangeBB +{ +public: + CellRangeBB() + : m_min(cvf::UNDEFINED_SIZE_T, cvf::UNDEFINED_SIZE_T, cvf::UNDEFINED_SIZE_T), + m_max(cvf::Vec3st::ZERO) + { + + } + + void add(size_t i, size_t j, size_t k) + { + if (i < m_min.x()) m_min.x() = i; + if (j < m_min.y()) m_min.y() = j; + if (k < m_min.z()) m_min.z() = k; + + if (i > m_max.x()) m_max.x() = i; + if (j > m_max.y()) m_max.y() = j; + if (k > m_max.z()) m_max.z() = k; + } + +public: + cvf::Vec3st m_min; + cvf::Vec3st m_max; +}; + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigReservoir::computeActiveCellData() +{ + CellRangeBB matrixModelActiveBB; + CellRangeBB fractureModelActiveBB; + + size_t idx; + for (idx = 0; idx < m_mainGrid->cellCount(); idx++) + { + const RigCell& c = m_mainGrid->cell(idx); + + size_t i, j, k; + m_mainGrid->ijkFromCellIndex(idx, &i, &j, &k); + + if (c.isActiveInMatrixModel()) + { + matrixModelActiveBB.add(i, j, k); + } + + if (c.isActiveInFractureModel()) + { + fractureModelActiveBB.add(i, j, k); + } + } + + m_activeCellInfo.setMatrixModelActiveCellsBoundingBox(matrixModelActiveBB.m_min, matrixModelActiveBB.m_max); + m_activeCellInfo.setFractureModelActiveCellsBoundingBox(fractureModelActiveBB.m_min, fractureModelActiveBB.m_max); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigReservoir::computeCachedData() +{ + computeFaults(); + computeActiveCellData(); + + //TODO Set display model offset + /* + if (m_mainGrid.notNull()) + { + m_mainGrid->setDisplayModelOffset(m_activeCellInfo.m_activeCellPositionMin); + } + */ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigActiveCellInfo* RigReservoir::activeCellInfo() +{ + return &m_activeCellInfo; +} diff --git a/ApplicationCode/ReservoirDataModel/RigReservoir.h b/ApplicationCode/ReservoirDataModel/RigReservoir.h index 73be5c1a79..b0af9923b5 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoir.h +++ b/ApplicationCode/ReservoirDataModel/RigReservoir.h @@ -25,6 +25,7 @@ #include "cvfObject.h" #include "RigMainGrid.h" #include "RigWellResults.h" +#include "RigActiveCellInfo.h" class RigReservoir: public cvf::Object @@ -40,17 +41,20 @@ public: void allGrids(std::vector* grids) const; const RigGridBase* grid(size_t index) const; + void computeCachedData(); + void setWellResults(const cvf::Collection& data); const cvf::Collection& wellResults() { return m_wellResults; } cvf::UByteArray* wellCellsInGrid(size_t gridIndex); - void computeFaults(); RigCell& cellFromWellResultCell(const RigWellResultCell& wellResultCell); bool findSharedSourceFace(cvf::StructGridInterface::FaceType& sharedSourceFace, const RigWellResultCell& sourceWellCellResult, const RigWellResultCell& otherWellCellResult) const; + RigActiveCellInfo* activeCellInfo(); + /* // From RigMainGrid, can this function be moved to Octave socket server? void calculateMatrixModelActiveCellInfo(std::vector& gridNumber, std::vector& i, @@ -60,11 +64,15 @@ public: std::vector& hostCellI, std::vector& hostCellJ, std::vector& hostCellK); - + */ private: + void computeFaults(); + void computeActiveCellData(); void computeWellCellsPrGrid(); +private: + RigActiveCellInfo m_activeCellInfo; cvf::ref m_mainGrid; cvf::Collection m_wellResults; From 99f52990308b7eccfba68e81e44785b4bd43459e Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 12 Feb 2013 11:26:33 +0100 Subject: [PATCH 005/242] Release active cell info if no fracture cells is present. p4#: 20456 --- ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp index 598f481805..d66fe3b473 100644 --- a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp @@ -95,11 +95,6 @@ size_t RigActiveCellInfo::activeIndexInFractureModel(size_t globalCellIndex) con //-------------------------------------------------------------------------------------------------- void RigActiveCellInfo::setActiveIndexInFractureModel(size_t globalCellIndex, size_t globalActiveCellIndex) { - if (m_activeInFractureModel.size() == 0) - { - m_activeInFractureModel.resize(m_activeInMatrixModel.size(), cvf::UNDEFINED_SIZE_T); - } - CVF_TIGHT_ASSERT(globalActiveCellIndex < m_activeInFractureModel.size()); m_activeInFractureModel[globalCellIndex] = globalActiveCellIndex; @@ -138,6 +133,10 @@ void RigActiveCellInfo::computeDerivedData() m_globalFractureModelActiveCellCount += m_perGridActiveCellInfo[i].fractureModelActiveCellCount(); } + if (m_globalFractureModelActiveCellCount == 0) + { + m_activeInFractureModel.resize(0); + } } //-------------------------------------------------------------------------------------------------- From 3377f0ef90d46d13939217e46cb4ea12da6eda38 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 12 Feb 2013 11:49:38 +0100 Subject: [PATCH 006/242] Update .gitignore --- .gitignore | 3 --- 1 file changed, 3 deletions(-) diff --git a/.gitignore b/.gitignore index 4de2b1670d..e76f0c24e6 100644 --- a/.gitignore +++ b/.gitignore @@ -22,8 +22,5 @@ CMakeCache.txt /Generated/ *.qrc.depends -# Unit testing -*_UnitTests - # Target program /ApplicationCode/ResInsight From 996f2fc7eb6aa3ef30e8b9aabe73c0f6fcb7df1d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 12 Feb 2013 11:43:36 +0100 Subject: [PATCH 007/242] Release active cell info if no fracture cells is present. p4#: 20456 --- .../RigActiveCellInfo-Test.cpp | 81 +++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigActiveCellInfo-Test.cpp diff --git a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigActiveCellInfo-Test.cpp b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigActiveCellInfo-Test.cpp new file mode 100644 index 0000000000..3004cd6e45 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigActiveCellInfo-Test.cpp @@ -0,0 +1,81 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 "gtest/gtest.h" + +#include "RigActiveCellInfo.h" + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RigActiveCellInfo, BasicTest) +{ + RigActiveCellInfo rigActiveCellInfo; + + size_t globalActiveCellCount = 10; + rigActiveCellInfo.setGlobalCellCount(globalActiveCellCount); + + for (size_t i = 0; i < globalActiveCellCount; i++) + { + EXPECT_TRUE(rigActiveCellInfo.activeIndexInMatrixModel(i) == cvf::UNDEFINED_SIZE_T); + EXPECT_FALSE(rigActiveCellInfo.isActiveInMatrixModel(i)); + + EXPECT_TRUE(rigActiveCellInfo.activeIndexInFractureModel(i) == cvf::UNDEFINED_SIZE_T); + EXPECT_FALSE(rigActiveCellInfo.isActiveInFractureModel(i)); + } + + rigActiveCellInfo.setActiveIndexInMatrixModel(3, 1); + EXPECT_TRUE(rigActiveCellInfo.activeIndexInMatrixModel(3) == 1); + + rigActiveCellInfo.setActiveIndexInFractureModel(9, 3); + EXPECT_TRUE(rigActiveCellInfo.activeIndexInFractureModel(9) == 3); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RigActiveCellInfo, GridCellCounts) +{ + { + RigActiveCellInfo rigActiveCellInfo; + rigActiveCellInfo.setGridCount(3); + rigActiveCellInfo.setGridActiveCellCounts(0, 0, 0); + rigActiveCellInfo.setGridActiveCellCounts(1, 1, 0); + rigActiveCellInfo.setGridActiveCellCounts(2, 2, 0); + rigActiveCellInfo.computeDerivedData(); + + EXPECT_TRUE(rigActiveCellInfo.globalMatrixModelActiveCellCount() == 3); + EXPECT_TRUE(rigActiveCellInfo.globalFractureModelActiveCellCount() == 0); + } + + { + RigActiveCellInfo rigActiveCellInfo; + rigActiveCellInfo.setGridCount(3); + rigActiveCellInfo.setGridActiveCellCounts(0, 0, 3); + rigActiveCellInfo.setGridActiveCellCounts(1, 1, 4); + rigActiveCellInfo.setGridActiveCellCounts(2, 2, 5); + rigActiveCellInfo.computeDerivedData(); + + EXPECT_TRUE(rigActiveCellInfo.globalMatrixModelActiveCellCount() == 3); + EXPECT_TRUE(rigActiveCellInfo.globalFractureModelActiveCellCount() == 12); + } + + +} + From 6101209d40d99cf71a7292c102d2b061bb0d993a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 12 Feb 2013 11:50:23 +0100 Subject: [PATCH 008/242] Moved functionality from main grid to active cell info p4#: 20457 --- .../ProjectDataModel/Rim3dOverlayInfoConfig.cpp | 2 +- .../ReservoirDataModel/RigReservoirCellResults.cpp | 13 +------------ ApplicationCode/SocketInterface/RiaSocketServer.cpp | 2 +- 3 files changed, 3 insertions(+), 14 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index 86e6d05cb5..1598319aa2 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -89,7 +89,7 @@ void Rim3dOverlayInfoConfig::update3DInfo() { caseName = m_reservoirView->eclipseCase()->caseName(); totCellCount = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->cells().size()); - activeCellCount = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->globalMatrixModelActiveCellCount()); + activeCellCount = QString::number(m_reservoirView->eclipseCase()->reservoirData()->activeCellInfo()->globalMatrixModelActiveCellCount()); iSize = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->cellCountI()); jSize = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->cellCountJ()); kSize = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->cellCountK()); diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp index 1e0bfcea9f..954eee3ed6 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp @@ -512,18 +512,11 @@ void RigReservoirCellResults::computeDepthRelatedResults() std::vector< std::vector >& tops = cellScalarResults(topsResultGridIndex); std::vector< std::vector >& bottom = cellScalarResults(bottomResultGridIndex); - bool computeValuesForActiveCellsOnly = m_ownerMainGrid->globalMatrixModelActiveCellCount() > 0; - size_t cellIdx = 0; for (cellIdx = 0; cellIdx < m_ownerMainGrid->cells().size(); cellIdx++) { const RigCell& cell = m_ownerMainGrid->cells()[cellIdx]; - if (computeValuesForActiveCellsOnly && !cell.isActiveInMatrixModel()) - { - continue; - } - if (computeDepth) { depth[0][cellIdx] = cvf::Math::abs(cell.center().z()); @@ -653,13 +646,9 @@ bool RigReservoirCellResults::isUsingGlobalActiveIndex(size_t scalarResultIndex) if (!m_cellScalarResults[scalarResultIndex].size()) return true; size_t firstTimeStepResultValueCount = m_cellScalarResults[scalarResultIndex][0].size(); - if (firstTimeStepResultValueCount == m_ownerMainGrid->globalMatrixModelActiveCellCount()) return true; - if (firstTimeStepResultValueCount == m_ownerMainGrid->globalFractureModelActiveCellCount()) return true; if (firstTimeStepResultValueCount == m_ownerMainGrid->cells().size()) return false; - CVF_TIGHT_ASSERT(false); // Wrong number of results - - return false; + return true; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.cpp b/ApplicationCode/SocketInterface/RiaSocketServer.cpp index e5de2c2e25..34991a9592 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.cpp +++ b/ApplicationCode/SocketInterface/RiaSocketServer.cpp @@ -441,7 +441,7 @@ void RiaSocketServer::readPropertyDataFromOctave() size_t cellCountFromOctave = m_bytesPerTimeStepToRead / sizeof(double); - size_t gridActiveCellCount = m_currentReservoir->reservoirData()->mainGrid()->globalMatrixModelActiveCellCount(); + size_t gridActiveCellCount = m_currentReservoir->reservoirData()->activeCellInfo()->globalMatrixModelActiveCellCount(); size_t gridTotalCellCount = m_currentReservoir->reservoirData()->mainGrid()->cellCount(); if (cellCountFromOctave != gridActiveCellCount && cellCountFromOctave != gridTotalCellCount) From ea2c890b9504ace10eb000b60fc0d217e20b22ef Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 12 Feb 2013 12:05:41 +0100 Subject: [PATCH 009/242] Moved active cell computation from main grid to socket server p4#: 20458 --- .../ReservoirDataModel/RigMainGrid.cpp | 75 ----------------- .../ReservoirDataModel/RigMainGrid.h | 8 -- .../SocketInterface/RiaSocketServer.cpp | 84 ++++++++++++++++++- .../SocketInterface/RiaSocketServer.h | 10 +++ 4 files changed, 92 insertions(+), 85 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp index d73b78f7e5..e1e97444be 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp @@ -243,81 +243,6 @@ void RigMainGrid::computeCachedData() computeBoundingBox(); } -//-------------------------------------------------------------------------------------------------- -/// -/// -/// -//-------------------------------------------------------------------------------------------------- -void RigMainGrid::calculateMatrixModelActiveCellInfo(std::vector &gridNumber, - std::vector &cellI, - std::vector &cellJ, - std::vector &cellK, - std::vector &parentGridNumber, - std::vector &hostCellI, - std::vector &hostCellJ, - std::vector &hostCellK) -{ - size_t numMatrixModelActiveCells = this->globalMatrixModelActiveCellCount(); - - gridNumber.clear(); - cellI.clear(); - cellJ.clear(); - cellK.clear(); - parentGridNumber.clear(); - hostCellI.clear(); - hostCellJ.clear(); - hostCellK.clear(); - - gridNumber.reserve(numMatrixModelActiveCells); - cellI.reserve(numMatrixModelActiveCells); - cellJ.reserve(numMatrixModelActiveCells); - cellK.reserve(numMatrixModelActiveCells); - parentGridNumber.reserve(numMatrixModelActiveCells); - hostCellI.reserve(numMatrixModelActiveCells); - hostCellJ.reserve(numMatrixModelActiveCells); - hostCellK.reserve(numMatrixModelActiveCells); - - for (size_t cIdx = 0; cIdx < m_cells.size(); ++cIdx) - { - if (m_cells[cIdx].isActiveInMatrixModel()) - { - RigGridBase* grid = m_cells[cIdx].hostGrid(); - CVF_ASSERT(grid != NULL); - size_t cellIndex = m_cells[cIdx].cellIndex(); - - size_t i, j, k; - grid->ijkFromCellIndex(cellIndex, &i, &j, &k); - - size_t pi, pj, pk; - RigGridBase* parentGrid = NULL; - - if (grid->isMainGrid()) - { - pi = i; - pj = j; - pk = k; - parentGrid = grid; - } - else - { - size_t parentCellIdx = m_cells[cIdx].parentCellIndex(); - parentGrid = (static_cast(grid))->parentGrid(); - CVF_ASSERT(parentGrid != NULL); - parentGrid->ijkFromCellIndex(parentCellIdx, &pi, &pj, &pk); - } - - gridNumber.push_back(static_cast(grid->gridIndex())); - cellI.push_back(static_cast(i)); - cellJ.push_back(static_cast(j)); - cellK.push_back(static_cast(k)); - parentGridNumber.push_back(static_cast(parentGrid->gridIndex())); - hostCellI.push_back(static_cast(pi)); - hostCellJ.push_back(static_cast(pj)); - hostCellK.push_back(static_cast(pk)); - } - } -} - //-------------------------------------------------------------------------------------------------- /// Returns the grid with index \a localGridIndex. Main Grid itself has index 0. First LGR starts on 1 //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigMainGrid.h b/ApplicationCode/ReservoirDataModel/RigMainGrid.h index aa9d19919f..fe73c4dd78 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.h +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.h @@ -58,14 +58,6 @@ public: RigGridBase* gridByIndex(size_t localGridIndex); const RigGridBase* gridByIndex(size_t localGridIndex) const; - void calculateMatrixModelActiveCellInfo(std::vector& gridNumber, - std::vector& i, - std::vector& j, - std::vector& k, - std::vector& parentGridNumber, - std::vector& hostCellI, - std::vector& hostCellJ, - std::vector& hostCellK); void computeCachedData(); cvf::BoundingBox matrixModelActiveCellsBoundingBox() const; diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.cpp b/ApplicationCode/SocketInterface/RiaSocketServer.cpp index 34991a9592..4dd668fd82 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.cpp +++ b/ApplicationCode/SocketInterface/RiaSocketServer.cpp @@ -368,8 +368,14 @@ void RiaSocketServer::readCommandFromOctave() return; } - reservoir->reservoirData()->mainGrid()->calculateMatrixModelActiveCellInfo(activeCellInfo[0], activeCellInfo[1], activeCellInfo[2], activeCellInfo[3], - activeCellInfo[4], activeCellInfo[5], activeCellInfo[6], activeCellInfo[7]); + calculateMatrixModelActiveCellInfo(activeCellInfo[0], + activeCellInfo[1], + activeCellInfo[2], + activeCellInfo[3], + activeCellInfo[4], + activeCellInfo[5], + activeCellInfo[6], + activeCellInfo[7]); // First write timestep count quint64 timestepCount = (quint64)8; @@ -611,3 +617,77 @@ void RiaSocketServer::slotReadyRead() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaSocketServer::calculateMatrixModelActiveCellInfo(std::vector& gridNumber, std::vector& cellI, std::vector& cellJ, std::vector& cellK, std::vector& parentGridNumber, std::vector& hostCellI, std::vector& hostCellJ, std::vector& hostCellK) +{ + gridNumber.clear(); + cellI.clear(); + cellJ.clear(); + cellK.clear(); + parentGridNumber.clear(); + hostCellI.clear(); + hostCellJ.clear(); + hostCellK.clear(); + + if (!m_currentReservoir || !m_currentReservoir->reservoirData() || !m_currentReservoir->reservoirData()->mainGrid()) + { + return; + } + + RigActiveCellInfo* actCellInfo = m_currentReservoir->reservoirData()->activeCellInfo(); + size_t numMatrixModelActiveCells = actCellInfo->globalMatrixModelActiveCellCount(); + + gridNumber.reserve(numMatrixModelActiveCells); + cellI.reserve(numMatrixModelActiveCells); + cellJ.reserve(numMatrixModelActiveCells); + cellK.reserve(numMatrixModelActiveCells); + parentGridNumber.reserve(numMatrixModelActiveCells); + hostCellI.reserve(numMatrixModelActiveCells); + hostCellJ.reserve(numMatrixModelActiveCells); + hostCellK.reserve(numMatrixModelActiveCells); + + const std::vector& globalCells = m_currentReservoir->reservoirData()->mainGrid()->cells(); + + for (size_t cIdx = 0; cIdx < globalCells.size(); ++cIdx) + { + if (actCellInfo->activeIndexInMatrixModel(cIdx)) + { + RigGridBase* grid = globalCells[cIdx].hostGrid(); + CVF_ASSERT(grid != NULL); + size_t cellIndex = globalCells[cIdx].cellIndex(); + + size_t i, j, k; + grid->ijkFromCellIndex(cellIndex, &i, &j, &k); + + size_t pi, pj, pk; + RigGridBase* parentGrid = NULL; + + if (grid->isMainGrid()) + { + pi = i; + pj = j; + pk = k; + parentGrid = grid; + } + else + { + size_t parentCellIdx = globalCells[cIdx].parentCellIndex(); + parentGrid = (static_cast(grid))->parentGrid(); + CVF_ASSERT(parentGrid != NULL); + parentGrid->ijkFromCellIndex(parentCellIdx, &pi, &pj, &pk); + } + + gridNumber.push_back(static_cast(grid->gridIndex())); + cellI.push_back(static_cast(i)); + cellJ.push_back(static_cast(j)); + cellK.push_back(static_cast(k)); + parentGridNumber.push_back(static_cast(parentGrid->gridIndex())); + hostCellI.push_back(static_cast(pi)); + hostCellJ.push_back(static_cast(pj)); + hostCellK.push_back(static_cast(pk)); + } + } +} + diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.h b/ApplicationCode/SocketInterface/RiaSocketServer.h index e6e0d54553..8a6f2e7e4e 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.h +++ b/ApplicationCode/SocketInterface/RiaSocketServer.h @@ -56,6 +56,16 @@ private: RimReservoir* findReservoir(const QString &casename); void terminateCurrentConnection(); + void calculateMatrixModelActiveCellInfo(std::vector& gridNumber, + std::vector& cellI, + std::vector& cellJ, + std::vector& cellK, + std::vector& parentGridNumber, + std::vector& hostCellI, + std::vector& hostCellJ, + std::vector& hostCellK); + + private: QTcpServer* m_tcpServer; QErrorMessage* m_errorMessageDialog; From 6c7dc10791dd5251402d2a03f75691cfb525007f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 12 Feb 2013 12:55:58 +0100 Subject: [PATCH 010/242] Removed functions from MainGrid p4#: 20459 --- .../FileInterface/RifReaderEclipseOutput.cpp | 3 --- .../ProjectDataModel/RimInputReservoir.cpp | 3 +-- .../ProjectDataModel/RimReservoirView.cpp | 2 +- .../ProjectDataModel/RimResultDefinition.cpp | 4 ++-- .../ProjectDataModel/RimResultReservoir.cpp | 3 --- .../ReservoirDataModel/RigMainGrid.cpp | 20 +------------------ .../ReservoirDataModel/RigMainGrid.h | 8 -------- 7 files changed, 5 insertions(+), 38 deletions(-) diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index 83a63d5bce..d5121039f4 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -329,9 +329,6 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid, progInfo.setProgress(3 + lgrIdx); } - mainGrid->setGlobalMatrixModelActiveCellCount(globalMatrixActiveSize); - mainGrid->setGlobalFractureModelActiveCellCount(globalFractureActiveSize); - activeCellInfo->computeDerivedData(); return true; diff --git a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp index bfb6815eef..029882d30c 100644 --- a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp @@ -93,8 +93,7 @@ void RimInputReservoir::openDataFileSet(const QStringList& filenames) } - m_rigReservoir->mainGrid()->setGlobalMatrixModelActiveCellCount(matrixActiveCellCount); - m_rigReservoir->mainGrid()->setGlobalFractureModelActiveCellCount(fractureActiveCellCount); + m_rigReservoir->activeCellInfo()->computeDerivedData(); return; } diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp index ecad221c2f..7097f003a6 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp @@ -709,7 +709,7 @@ void RimReservoirView::loadDataAndUpdate() CVF_ASSERT(this->cellResult() != NULL); this->cellResult()->loadResult(); - if (m_reservoir->reservoirData()->mainGrid()->globalFractureModelActiveCellCount() == 0) + if (m_reservoir->reservoirData()->activeCellInfo()->globalFractureModelActiveCellCount() == 0) { this->cellResult->porosityModel.setUiHidden(true); } diff --git a/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp index 29ec38da4a..176dd9a2d4 100644 --- a/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp @@ -63,9 +63,9 @@ void RimResultDefinition::setReservoirView(RimReservoirView* ownerReservoirView) // TODO: This code is executed before reservoir is read, and then porosity model is never set to zero if (m_reservoirView->eclipseCase() && m_reservoirView->eclipseCase()->reservoirData() && - m_reservoirView->eclipseCase()->reservoirData()->mainGrid() ) + m_reservoirView->eclipseCase()->reservoirData()->activeCellInfo() ) { - if (m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->globalFractureModelActiveCellCount() == 0) + if (m_reservoirView->eclipseCase()->reservoirData()->activeCellInfo()->globalFractureModelActiveCellCount() == 0) { porosityModel.setUiHidden(true); } diff --git a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp index c3af3f4a8f..8b2265744c 100644 --- a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp @@ -75,9 +75,6 @@ bool RimResultReservoir::openEclipseGridFile() } } - m_rigReservoir->mainGrid()->setGlobalMatrixModelActiveCellCount(matrixActiveCellCount); - m_rigReservoir->mainGrid()->setGlobalFractureModelActiveCellCount(fractureActiveCellCount); - m_rigReservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p()); m_rigReservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p()); } diff --git a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp index e1e97444be..9bfa1d65c5 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp @@ -28,9 +28,7 @@ RigMainGrid::RigMainGrid(void) m_activeCellPositionMin(cvf::Vec3st::UNDEFINED), m_activeCellPositionMax(cvf::Vec3st::UNDEFINED), m_validCellPositionMin(cvf::Vec3st::UNDEFINED), - m_validCellPositionMax(cvf::Vec3st::UNDEFINED), - m_globalMatrixModelActiveCellCount(cvf::UNDEFINED_SIZE_T), - m_globalFractureModelActiveCellCount(cvf::UNDEFINED_SIZE_T) + m_validCellPositionMax(cvf::Vec3st::UNDEFINED) { m_matrixModelResults = new RigReservoirCellResults(this); m_fractureModelResults = new RigReservoirCellResults(this); @@ -80,22 +78,6 @@ void RigMainGrid::initAllSubCellsMainGridCellIndex() } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -size_t RigMainGrid::globalMatrixModelActiveCellCount() const -{ - return m_globalMatrixModelActiveCellCount; - -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -size_t RigMainGrid::globalFractureModelActiveCellCount() const -{ - return m_globalFractureModelActiveCellCount; -} //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/ReservoirDataModel/RigMainGrid.h b/ApplicationCode/ReservoirDataModel/RigMainGrid.h index fe73c4dd78..fbd09d325d 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.h +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.h @@ -45,11 +45,6 @@ public: RigReservoirCellResults* results(RifReaderInterface::PorosityModelResultType porosityModel); const RigReservoirCellResults* results(RifReaderInterface::PorosityModelResultType porosityModel) const; - size_t globalMatrixModelActiveCellCount() const; - size_t globalFractureModelActiveCellCount() const; - void setGlobalMatrixModelActiveCellCount (size_t globalMatrixModelActiveCellCount) { m_globalMatrixModelActiveCellCount = globalMatrixModelActiveCellCount; } - void setGlobalFractureModelActiveCellCount(size_t globalFractureModelActiveCellCount) { m_globalFractureModelActiveCellCount = globalFractureModelActiveCellCount;} - void matrixModelActiveCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const; void validCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const; @@ -79,9 +74,6 @@ private: cvf::ref m_matrixModelResults; cvf::ref m_fractureModelResults; - size_t m_globalMatrixModelActiveCellCount; - size_t m_globalFractureModelActiveCellCount; - cvf::Vec3st m_activeCellPositionMin; cvf::Vec3st m_activeCellPositionMax; cvf::Vec3st m_validCellPositionMin; From d45aded7f724aa33f65ce82d2c2c327c6d61903c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 12 Feb 2013 14:00:39 +0100 Subject: [PATCH 011/242] Removed more functions from MainGrid p4#: 20468 --- .../ProjectDataModel/RimCellRangeFilter.cpp | 13 ++-- .../RimCellRangeFilterCollection.cpp | 23 +++++-- .../RimCellRangeFilterCollection.h | 9 ++- .../ReservoirDataModel/RigMainGrid.cpp | 60 +------------------ .../ReservoirDataModel/RigMainGrid.h | 8 --- .../ReservoirDataModel/RigReservoir.h | 11 ---- 6 files changed, 34 insertions(+), 90 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp b/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp index 72d07621f2..eaa1a7f59f 100644 --- a/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp @@ -115,11 +115,11 @@ void RimCellRangeFilter::setDefaultValues() { CVF_ASSERT(m_parentContainer); - RigMainGrid* mainGrid = m_parentContainer->mainGrid(); - if (mainGrid) + RigActiveCellInfo* actCellInfo = m_parentContainer->activeCellInfo(); + if (actCellInfo) { cvf::Vec3st min, max; - mainGrid->matrixModelActiveCellsBoundingBox(min, max); + actCellInfo->matrixModelActiveCellsBoundingBox(min, max); // Adjust to Eclipse indexing min.x() = min.x() + 1; @@ -159,10 +159,13 @@ void RimCellRangeFilter::defineEditorAttribute(const caf::PdmFieldHandle* field, } RigMainGrid* mainGrid = m_parentContainer->mainGrid(); - if (mainGrid) + CVF_ASSERT(mainGrid); + + RigActiveCellInfo* actCellInfo = m_parentContainer->activeCellInfo(); + if (actCellInfo) { cvf::Vec3st min, max; - mainGrid->matrixModelActiveCellsBoundingBox(min, max); + actCellInfo->matrixModelActiveCellsBoundingBox(min, max); // Adjust to Eclipse indexing min.x() = min.x() + 1; diff --git a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp index 37be195aa2..4eed94d8bb 100644 --- a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp @@ -97,8 +97,6 @@ void RimCellRangeFilterCollection::compoundCellRangeFilter(cvf::CellRangeFilter* } } - - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -126,9 +124,25 @@ RigMainGrid* RimCellRangeFilterCollection::mainGrid() const m_reservoirView->eclipseCase()->reservoirData()->mainGrid()) { - RigMainGrid* mainGrid = m_reservoirView->eclipseCase()->reservoirData()->mainGrid(); + return m_reservoirView->eclipseCase()->reservoirData()->mainGrid(); + } - return mainGrid; + return NULL; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigActiveCellInfo* RimCellRangeFilterCollection::activeCellInfo() const +{ + if (m_reservoirView && + m_reservoirView->eclipseCase() && + m_reservoirView->eclipseCase()->reservoirData() && + m_reservoirView->eclipseCase()->reservoirData()->activeCellInfo()) + { + + return m_reservoirView->eclipseCase()->reservoirData()->activeCellInfo(); } return NULL; @@ -209,3 +223,4 @@ bool RimCellRangeFilterCollection::hasActiveFilters() const return false; } + diff --git a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.h b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.h index c85fcab117..ee0fa83543 100644 --- a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.h +++ b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.h @@ -20,6 +20,8 @@ #include "RimCellRangeFilter.h" +class RigActiveCellInfo; + //================================================================================================== /// /// @@ -42,9 +44,10 @@ public: void compoundCellRangeFilter(cvf::CellRangeFilter* cellRangeFilter) const; bool hasActiveFilters() const; - void setReservoirView(RimReservoirView* reservoirView); - RimReservoirView* reservoirView(); - RigMainGrid* mainGrid() const; + void setReservoirView(RimReservoirView* reservoirView); + RimReservoirView* reservoirView(); + RigMainGrid* mainGrid() const; + RigActiveCellInfo* activeCellInfo() const; // Overridden methods virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ); diff --git a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp index 9bfa1d65c5..f4bdb053b3 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp @@ -24,11 +24,7 @@ #include "cvfAssert.h" RigMainGrid::RigMainGrid(void) - : RigGridBase(this), - m_activeCellPositionMin(cvf::Vec3st::UNDEFINED), - m_activeCellPositionMax(cvf::Vec3st::UNDEFINED), - m_validCellPositionMin(cvf::Vec3st::UNDEFINED), - m_validCellPositionMax(cvf::Vec3st::UNDEFINED) + : RigGridBase(this) { m_matrixModelResults = new RigReservoirCellResults(this); m_fractureModelResults = new RigReservoirCellResults(this); @@ -79,15 +75,6 @@ void RigMainGrid::initAllSubCellsMainGridCellIndex() } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigMainGrid::matrixModelActiveCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const -{ - min = m_activeCellPositionMin; - max = m_activeCellPositionMax; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -96,15 +83,6 @@ cvf::BoundingBox RigMainGrid::matrixModelActiveCellsBoundingBox() const return m_activeCellsBoundingBox; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigMainGrid::validCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const -{ - min = m_validCellPositionMin; - max = m_validCellPositionMax; -} - //-------------------------------------------------------------------------------------------------- @@ -137,41 +115,6 @@ public: }; -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigMainGrid::computeActiveAndValidCellRanges() -{ - CellRangeBB validBB; - CellRangeBB activeBB; - - size_t idx; - for (idx = 0; idx < cellCount(); idx++) - { - const RigCell& c = cell(idx); - - size_t i, j, k; - ijkFromCellIndex(idx, &i, &j, &k); - - if (!c.isInvalid()) - { - validBB.add(i, j, k); - } - - if (c.isActiveInMatrixModel()) - { - activeBB.add(i, j, k); - } - } - - m_validCellPositionMin = validBB.m_min; - m_validCellPositionMax = validBB.m_max; - - m_activeCellPositionMin = activeBB.m_min; - m_activeCellPositionMax = activeBB.m_max; -} - - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -221,7 +164,6 @@ void RigMainGrid::computeCachedData() { initAllSubGridsParentGridPointer(); initAllSubCellsMainGridCellIndex(); - computeActiveAndValidCellRanges(); computeBoundingBox(); } diff --git a/ApplicationCode/ReservoirDataModel/RigMainGrid.h b/ApplicationCode/ReservoirDataModel/RigMainGrid.h index fbd09d325d..d421fc3be0 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.h +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.h @@ -45,9 +45,6 @@ public: RigReservoirCellResults* results(RifReaderInterface::PorosityModelResultType porosityModel); const RigReservoirCellResults* results(RifReaderInterface::PorosityModelResultType porosityModel) const; - void matrixModelActiveCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const; - void validCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const; - void addLocalGrid(RigLocalGrid* localGrid); size_t gridCount() const { return m_localGrids.size() + 1; } RigGridBase* gridByIndex(size_t localGridIndex); @@ -74,11 +71,6 @@ private: cvf::ref m_matrixModelResults; cvf::ref m_fractureModelResults; - cvf::Vec3st m_activeCellPositionMin; - cvf::Vec3st m_activeCellPositionMax; - cvf::Vec3st m_validCellPositionMin; - cvf::Vec3st m_validCellPositionMax; - cvf::BoundingBox m_activeCellsBoundingBox; }; diff --git a/ApplicationCode/ReservoirDataModel/RigReservoir.h b/ApplicationCode/ReservoirDataModel/RigReservoir.h index b0af9923b5..111146df83 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoir.h +++ b/ApplicationCode/ReservoirDataModel/RigReservoir.h @@ -54,17 +54,6 @@ public: RigActiveCellInfo* activeCellInfo(); - /* - // From RigMainGrid, can this function be moved to Octave socket server? - void calculateMatrixModelActiveCellInfo(std::vector& gridNumber, - std::vector& i, - std::vector& j, - std::vector& k, - std::vector& parentGridNumber, - std::vector& hostCellI, - std::vector& hostCellJ, - std::vector& hostCellK); - */ private: void computeFaults(); From 1a17875dc1b292151eb1a296cbdddd2a261b6135 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 12 Feb 2013 14:46:45 +0100 Subject: [PATCH 012/242] Restructured data access objects, added factory method p4#: 20471 --- .../RifEclipseInputFileTools.cpp | 3 +- .../FileInterface/RifReaderEclipseOutput.cpp | 4 +- .../ModelVisualization/RivGridPartMgr.cpp | 6 +- .../RivReservoirViewPartMgr.cpp | 19 +- .../RivReservoirViewPartMgr.h | 3 +- .../ProjectDataModel/RimReservoirView.cpp | 6 +- .../ReservoirDataModel/RigGridBase.cpp | 4 +- .../ReservoirDataModel/RigGridBase.h | 3 +- .../RigGridScalarDataAccess.cpp | 208 ++++++++++++++---- .../RigGridScalarDataAccess.h | 31 +-- .../ReservoirDataModel/RigReservoir.cpp | 8 + .../ReservoirDataModel/RigReservoir.h | 3 +- 12 files changed, 214 insertions(+), 84 deletions(-) diff --git a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp index 11a7335234..ac83e2e22a 100644 --- a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp @@ -418,7 +418,8 @@ bool RifEclipseInputFileTools::writeBinaryResultToTextFile(const QString& fileNa return false; } - cvf::ref dataAccessObject = reservoir->mainGrid()->dataAccessObject(porosityModel, timeStep, resultIndex); + RigActiveCellInfo* activeCellInfo = reservoir->activeCellInfo(); + cvf::ref dataAccessObject = reservoir->mainGrid()->dataAccessObject(activeCellInfo, porosityModel, timeStep, resultIndex); if (dataAccessObject.isNull()) { return false; diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index d5121039f4..b73dc55234 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -119,7 +119,7 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigActiveCellInfo* activeCellIn if (matrixActiveIndex != -1) { cell.setActiveIndexInMatrixModel(matrixActiveStartIndex + matrixActiveIndex); - activeCellInfo->setActiveIndexInMatrixModel(localCellIdx, matrixActiveStartIndex + matrixActiveIndex); + activeCellInfo->setActiveIndexInMatrixModel(cellStartIndex + localCellIdx, matrixActiveStartIndex + matrixActiveIndex); } else { @@ -130,7 +130,7 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigActiveCellInfo* activeCellIn if (fractureActiveIndex != -1) { cell.setActiveIndexInFractureModel(fractureActiveStartIndex + fractureActiveIndex); - activeCellInfo->setActiveIndexInFractureModel(localCellIdx, fractureActiveStartIndex + fractureActiveIndex); + activeCellInfo->setActiveIndexInFractureModel(cellStartIndex + localCellIdx, fractureActiveStartIndex + fractureActiveIndex); } else { diff --git a/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp b/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp index b27f38c339..269b4742b3 100644 --- a/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp @@ -29,6 +29,7 @@ #include "RimCellEdgeResultSlot.h" #include "RigGridScalarDataAccess.h" #include "RigReservoirCellResults.h" +#include "RigReservoir.h" //-------------------------------------------------------------------------------------------------- @@ -221,7 +222,10 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot* if (cellResultSlot->hasStaticResult()) resTimeStepIdx = 0; RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel()); - cvf::ref dataAccessObject = m_grid->dataAccessObject(porosityModel, resTimeStepIdx, scalarSetIndex); + + RigActiveCellInfo* activeCellInfo = cellResultSlot->reservoirView()->eclipseCase()->reservoirData()->activeCellInfo(); + cvf::ref dataAccessObject = m_grid->dataAccessObject(activeCellInfo, porosityModel, resTimeStepIdx, scalarSetIndex); + if (dataAccessObject.isNull()) return; // Outer surface diff --git a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp index a9d1817e16..5fe2acbfdf 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp @@ -246,10 +246,13 @@ void RivReservoirViewPartMgr::createGeometry(ReservoirGeometryCacheType geometry //-------------------------------------------------------------------------------------------------- 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) { case ACTIVE: - computeNativeVisibility(cellVisibility, grid, false, false, true, m_reservoirView->showMainGrid() ); + computeNativeVisibility(cellVisibility, grid, activeCellInfo, false, false, true, m_reservoirView->showMainGrid() ); break; case ALL_WELL_CELLS: computeAllWellCellsVisibility(cellVisibility, grid); @@ -287,7 +290,7 @@ void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility, } break; 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; case RANGE_FILTERED: { @@ -460,7 +463,7 @@ void RivReservoirViewPartMgr::createPropertyFilteredWellGeometry(size_t frameInd //-------------------------------------------------------------------------------------------------- /// 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 inactiveCellsIsVisible, bool activeCellsIsVisible, @@ -468,16 +471,18 @@ void RivReservoirViewPartMgr::computeNativeVisibility(cvf::UByteArray* cellVisib { CVF_ASSERT(cellVisibility != NULL); CVF_ASSERT(grid != NULL); + CVF_ASSERT(activeCellInfo != NULL); cellVisibility->resize(grid->cellCount()); #pragma omp parallel for for (int cellIndex = 0; cellIndex < static_cast(grid->cellCount()); cellIndex++) { const RigCell& cell = grid->cell(cellIndex); + size_t globalCellIndex = cell.mainGridCellIndex(); if ( !invalidCellsIsVisible && cell.isInvalid() - || !inactiveCellsIsVisible && !cell.isActiveInMatrixModel() - || !activeCellsIsVisible && cell.isActiveInMatrixModel() + || !inactiveCellsIsVisible && !activeCellInfo->isActiveInMatrixModel(globalCellIndex) + || !activeCellsIsVisible && activeCellInfo->isActiveInMatrixModel(globalCellIndex) || mainGridIsVisible && (cell.subGrid() != NULL) || cell.isWellCell() ) @@ -600,7 +605,9 @@ void RivReservoirViewPartMgr::computePropertyVisibility(cvf::UByteArray* cellVis const RimCellFilter::FilterModeType filterType = (*pfIt)->filterMode(); RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel((*pfIt)->resultDefinition()->porosityModel()); - cvf::ref dataAccessObject = grid->dataAccessObject(porosityModel, timeStepIndex, scalarResultIndex); + RigActiveCellInfo* activeCellInfo = propFilterColl->reservoirView()->eclipseCase()->reservoirData()->activeCellInfo(); + + cvf::ref dataAccessObject = grid->dataAccessObject(activeCellInfo, porosityModel, timeStepIndex, scalarResultIndex); CVF_ASSERT(dataAccessObject.notNull()); #pragma omp parallel for schedule(dynamic) diff --git a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.h b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.h index 286e2c4a45..b70bd89051 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.h @@ -28,6 +28,7 @@ class RimReservoirView; class RigGridBase; class RimCellRangeFilterCollection; class RimCellPropertyFilterCollection; +class RigActiveCellInfo; class RivReservoirViewPartMgr: public cvf::Object { @@ -77,7 +78,7 @@ private: 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 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 ); diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp index 7097f003a6..7bc85b33d8 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp @@ -870,10 +870,12 @@ void RimReservoirView::appendCellResultInfo(size_t gridIndex, size_t cellIndex, { const RigReservoir* reservoir = m_reservoir->reservoirData(); const RigGridBase* grid = reservoir->grid(gridIndex); + const RigActiveCellInfo* activeCellInfo = reservoir->activeCellInfo(); + if (this->cellResult()->hasResult()) { RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResult()->porosityModel()); - cvf::ref dataAccessObject = grid->dataAccessObject(porosityModel, m_currentTimeStep, this->cellResult()->gridScalarIndex()); + cvf::ref dataAccessObject = grid->dataAccessObject(activeCellInfo, porosityModel, m_currentTimeStep, this->cellResult()->gridScalarIndex()); if (dataAccessObject.notNull()) { 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 RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResult()->porosityModel()); - cvf::ref dataAccessObject = grid->dataAccessObject(porosityModel, 0, resultIndices[idx]); + cvf::ref dataAccessObject = grid->dataAccessObject(activeCellInfo, porosityModel, 0, resultIndices[idx]); if (dataAccessObject.notNull()) { double scalarValue = dataAccessObject->cellScalar(cellIndex); diff --git a/ApplicationCode/ReservoirDataModel/RigGridBase.cpp b/ApplicationCode/ReservoirDataModel/RigGridBase.cpp index dac8ae9c83..1bf2958108 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridBase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridBase.cpp @@ -471,12 +471,12 @@ size_t RigGridBase::fractureModelActiveCellCount() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RigGridBase::dataAccessObject(RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStepIndex, size_t scalarSetIndex) const +cvf::ref RigGridBase::dataAccessObject(const RigActiveCellInfo* activeCellInfo, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStepIndex, size_t scalarSetIndex) const { if (timeStepIndex != cvf::UNDEFINED_SIZE_T && scalarSetIndex != cvf::UNDEFINED_SIZE_T) { - cvf::ref dataAccess = RigGridScalarDataAccess::createDataAccessObject(this, porosityModel, timeStepIndex, scalarSetIndex); + cvf::ref dataAccess = RigGridScalarDataAccessFactory::createDataAccessObject(this, activeCellInfo, porosityModel, timeStepIndex, scalarSetIndex); return dataAccess; } diff --git a/ApplicationCode/ReservoirDataModel/RigGridBase.h b/ApplicationCode/ReservoirDataModel/RigGridBase.h index 8cdc541f3e..3712e77719 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridBase.h +++ b/ApplicationCode/ReservoirDataModel/RigGridBase.h @@ -34,6 +34,7 @@ class RigMainGrid; class RigCell; class RigGridScalarDataAccess; +class RigActiveCellInfo; 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 cellIJKNeighbor(size_t i, size_t j, size_t k, FaceType face, size_t* neighborCellIndex ) const; - cvf::ref dataAccessObject(RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStepIndex, size_t scalarSetIndex) const; + cvf::ref dataAccessObject(const RigActiveCellInfo* activeCellInfo, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStepIndex, size_t scalarSetIndex) const; private: std::string m_gridName; diff --git a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp index bcdef620c9..4a9fc6e2d7 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp @@ -21,53 +21,52 @@ #include "cvfLibCore.h" #include "cvfBase.h" +#include "cvfObject.h" #include "cvfAssert.h" #include "RigMainGrid.h" #include "RigReservoirCellResults.h" +#include "RigActiveCellInfo.h" +#include "RigGridBase.h" + + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigGridScalarDataAccess::RigGridScalarDataAccess(const RigGridBase* grid, bool useGlobalActiveIndex, std::vector* resultValues) : - m_grid(grid), - m_useGlobalActiveIndex(useGlobalActiveIndex), +class RigGridAllCellsScalarDataAccess : public cvf::StructGridScalarDataAccess +{ +public: + RigGridAllCellsScalarDataAccess(const RigGridBase* grid, std::vector* 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 m_grid; + std::vector* m_resultValues; +}; + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigGridAllCellsScalarDataAccess::RigGridAllCellsScalarDataAccess(const RigGridBase* grid, std::vector* resultValues) : +m_grid(grid), m_resultValues(resultValues) { } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -cvf::ref 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 > & scalarSetResults = grid->mainGrid()->results(porosityModel)->cellScalarResults(scalarSetIndex); - if (timeStepIndex >= scalarSetResults.size()) - { - return NULL; - } - - std::vector* resultValues = &(scalarSetResults[timeStepIndex]); - - cvf::ref 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); @@ -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; - size_t resultValueIndex = cellIndex; + if (m_resultValues->size() <= cellIndex) return HUGE_VAL; - if (m_useGlobalActiveIndex) - { - 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); + return m_resultValues->at(cellIndex); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -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); 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); } @@ -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); 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); return new cvf::Vec3d(); } + + + + + + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class RigGridMatrixActiveCellsScalarDataAccess : public RigGridAllCellsScalarDataAccess +{ +public: + RigGridMatrixActiveCellsScalarDataAccess(const RigGridBase* grid, std::vector* 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* 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 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 > & scalarSetResults = grid->mainGrid()->results(porosityModel)->cellScalarResults(scalarSetIndex); + if (timeStepIndex >= scalarSetResults.size()) + { + return NULL; + } + + std::vector* resultValues = &(scalarSetResults[timeStepIndex]); + + + bool useGlobalActiveIndex = grid->mainGrid()->results(porosityModel)->isUsingGlobalActiveIndex(scalarSetIndex); + if (useGlobalActiveIndex) + { + if (porosityModel == RifReaderInterface::MATRIX_RESULTS) + { + cvf::ref object = new RigGridMatrixActiveCellsScalarDataAccess(grid, resultValues, activeCellInfo); + return object; + } + else + { + cvf::ref object = new RigGridFractureActiveCellsScalarDataAccess(grid, resultValues, activeCellInfo); + return object; + } + } + else + { + cvf::ref object = new RigGridAllCellsScalarDataAccess(grid, resultValues); + return object; + } +} + diff --git a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.h b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.h index ad4f1fb46d..871a45a82f 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.h +++ b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.h @@ -20,32 +20,21 @@ #pragma once #include "cvfStructGridScalarDataAccess.h" -#include "RigGridBase.h" #include "RifReaderInterface.h" -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -class RigGridScalarDataAccess : public cvf::StructGridScalarDataAccess +class RigActiveCellInfo; +class RigGridBase; + +class RigGridScalarDataAccessFactory { -private: - RigGridScalarDataAccess(const RigGridBase* grid, bool useGlobalActiveIndex, std::vector* resultValues); - public: - static cvf::ref createDataAccessObject(const RigGridBase* grid, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStepIndex, size_t scalarSetIndex); + static cvf::ref 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 m_grid; - bool m_useGlobalActiveIndex; - std::vector* m_resultValues; }; + diff --git a/ApplicationCode/ReservoirDataModel/RigReservoir.cpp b/ApplicationCode/ReservoirDataModel/RigReservoir.cpp index ac557ca21c..3f510510c8 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoir.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoir.cpp @@ -310,3 +310,11 @@ RigActiveCellInfo* RigReservoir::activeCellInfo() { return &m_activeCellInfo; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigActiveCellInfo* RigReservoir::activeCellInfo() const +{ + return &m_activeCellInfo; +} diff --git a/ApplicationCode/ReservoirDataModel/RigReservoir.h b/ApplicationCode/ReservoirDataModel/RigReservoir.h index 111146df83..360054d18c 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoir.h +++ b/ApplicationCode/ReservoirDataModel/RigReservoir.h @@ -52,7 +52,8 @@ public: RigCell& cellFromWellResultCell(const RigWellResultCell& wellResultCell); bool findSharedSourceFace(cvf::StructGridInterface::FaceType& sharedSourceFace, const RigWellResultCell& sourceWellCellResult, const RigWellResultCell& otherWellCellResult) const; - RigActiveCellInfo* activeCellInfo(); + RigActiveCellInfo* activeCellInfo(); + const RigActiveCellInfo* activeCellInfo() const; private: From f04b4b0258fb889f7a090bbc32d5d1b8e79688f8 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 13 Feb 2013 10:27:33 +0100 Subject: [PATCH 013/242] Use data access objects for cell edge visualization p4#: 20489 --- .../RivCellEdgeEffectGenerator.cpp | 73 +++++++++++-------- 1 file changed, 42 insertions(+), 31 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp b/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp index e05c0b0e8c..2e2711e9a8 100644 --- a/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp @@ -33,20 +33,27 @@ #include "cvfShaderProgram.h" #include "cvfRenderStateCullFace.h" -#include -#include -#include - -#include "RimReservoirView.h" -#include "RigGridBase.h" -#include "RigMainGrid.h" -#include "RigReservoirCellResults.h" #include "cvfTextureImage.h" #include "cvfTexture.h" #include "cvfSampler.h" #include "cvfScalarMapper.h" #include "cafEffectGenerator.h" +#include + +#include +#include + +#include "RimReservoirView.h" +#include "RimResultSlot.h" + +#include "RigGridBase.h" +#include "RigMainGrid.h" +#include "RigReservoirCellResults.h" +#include "RigReservoir.h" +#include "RigActiveCellInfo.h" + + //-------------------------------------------------------------------------------------------------- /// @@ -87,12 +94,12 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo( cvf::ScalarMapper* edgeResultScalarMapper = cellEdgeResultSlot->legendConfig()->scalarMapper(); const RigGridBase* grid = dynamic_cast(generator->activeGrid()); - CVF_ASSERT(grid != NULL); - bool cellScalarResultUseGlobalActiveIndex = true; - bool edgeScalarResultUseGlobalActiveIndex[6]; + RigActiveCellInfo* activeCellInfo = cellResultSlot->reservoirView()->eclipseCase()->reservoirData()->activeCellInfo(); + CVF_ASSERT(activeCellInfo != NULL); + cvf::ref cellCenterDataAccessObject = NULL; if (cellResultSlot->hasResult()) { if (!cellResultSlot->hasDynamicResult()) @@ -102,22 +109,29 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo( } RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel()); - cellScalarResultUseGlobalActiveIndex = grid->mainGrid()->results(porosityModel)->isUsingGlobalActiveIndex(cellResultSlot->gridScalarIndex()); + cellCenterDataAccessObject = grid->dataAccessObject(activeCellInfo, porosityModel, timeStepIndex, cellResultSlot->gridScalarIndex()); } + CVF_ASSERT(cellEdgeResultSlot->hasResult()); + size_t resultIndices[6]; cellEdgeResultSlot->gridScalarIndices(resultIndices); - if (cellEdgeResultSlot->hasResult()) + cvf::Collection cellEdgeDataAccessObjects; + + size_t cubeFaceIdx; + for (cubeFaceIdx = 0; cubeFaceIdx < 6; cubeFaceIdx++) { - size_t cubeFaceIdx; - for (cubeFaceIdx = 0; cubeFaceIdx < 6; cubeFaceIdx++) + cvf::ref daObj; + + if (resultIndices[cubeFaceIdx] != cvf::UNDEFINED_SIZE_T) { - if (resultIndices[cubeFaceIdx] != cvf::UNDEFINED_SIZE_T) - { - edgeScalarResultUseGlobalActiveIndex[cubeFaceIdx] = grid->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->isUsingGlobalActiveIndex(resultIndices[cubeFaceIdx]); - } + // Assuming static values to be mapped onto cell edge, always using time step zero + // TODO: Now hardcoded matrix results, should it be possible to use fracture results? + daObj = grid->dataAccessObject(activeCellInfo, RifReaderInterface::MATRIX_RESULTS, 0, resultIndices[cubeFaceIdx]); } + + cellEdgeDataAccessObjects.push_back(daObj.p()); } double ignoredScalarValue = cellEdgeResultSlot->ignoredScalarValue(); @@ -138,15 +152,14 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo( float cellColorTextureCoord = 0.5f; // If no results exists, the texture will have a special color size_t cellIndex = quadToCell[quadIdx]; - size_t resultValueIndex = cellIndex; - if (cellScalarResultUseGlobalActiveIndex) { - resultValueIndex = grid->cell(cellIndex).activeIndexInMatrixModel(); - } + double scalarValue = HUGE_VAL; + + if (cellCenterDataAccessObject.notNull()) + { + scalarValue = cellCenterDataAccessObject->cellScalar(cellIndex); + } - { - RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel()); - double scalarValue = grid->mainGrid()->results(porosityModel)->cellScalarResult(timeStepIndex, cellResultSlot->gridScalarIndex(), resultValueIndex); if (scalarValue != HUGE_VAL) { cellColorTextureCoord = cellResultScalarMapper->mapToTextureCoord(scalarValue)[0]; @@ -168,14 +181,12 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo( { edgeColor = -1.0f; // Undefined texture coord. Shader handles this. - resultValueIndex = cellIndex; - if (edgeScalarResultUseGlobalActiveIndex[cubeFaceIdx]) + double scalarValue = HUGE_VAL; + if (cellEdgeDataAccessObjects[cubeFaceIdx].notNull()) { - resultValueIndex = grid->cell(cellIndex).activeIndexInMatrixModel(); + scalarValue = cellEdgeDataAccessObjects[cubeFaceIdx]->cellScalar(cellIndex); } - // Assuming static values to be mapped onto cell edge, always using time step zero - double scalarValue = grid->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResult(0, resultIndices[cubeFaceIdx], resultValueIndex); if (scalarValue != HUGE_VAL && scalarValue != ignoredScalarValue) { edgeColor = edgeResultScalarMapper->mapToTextureCoord(scalarValue)[0]; From e99c1cbfb12f758b480511623c591bd8405fa860 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 13 Feb 2013 11:04:45 +0100 Subject: [PATCH 014/242] Moved computation of geometry bounding box from main grid to reservoir p4#: 20490 --- .../ReservoirDataModel/RigActiveCellInfo.cpp | 16 ++++ .../ReservoirDataModel/RigActiveCellInfo.h | 5 +- .../ReservoirDataModel/RigMainGrid.cpp | 79 ++----------------- .../ReservoirDataModel/RigMainGrid.h | 4 +- .../ReservoirDataModel/RigReservoir.cpp | 49 ++++++++++-- .../ReservoirDataModel/RigReservoir.h | 2 + 6 files changed, 71 insertions(+), 84 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp index d66fe3b473..81766f472a 100644 --- a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp @@ -200,6 +200,22 @@ void RigActiveCellInfo::gridActiveCellCounts(size_t gridIndex, size_t& matrixAct fractureActiveCellCount = m_perGridActiveCellInfo[gridIndex].fractureModelActiveCellCount(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::BoundingBox RigActiveCellInfo::matrixActiveCellsGeometryBoundingBox() const +{ + return m_matrixActiveCellsBoundingBox; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigActiveCellInfo::setMatrixActiveCellsGeometryBoundingBox(cvf::BoundingBox bb) +{ + m_matrixActiveCellsBoundingBox = bb; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h index b436396a41..679cef10e6 100644 --- a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h @@ -58,6 +58,8 @@ public: void setFractureModelActiveCellsBoundingBox(const cvf::Vec3st& min, const cvf::Vec3st& max); void fractureModelActiveCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const; + cvf::BoundingBox matrixActiveCellsGeometryBoundingBox() const; + void setMatrixActiveCellsGeometryBoundingBox(cvf::BoundingBox bb); private: @@ -93,6 +95,5 @@ private: // NOT USED // cvf::Vec3st m_validCellPositionMin; // cvf::Vec3st m_validCellPositionMax; -// cvf::BoundingBox m_activeCellsBoundingBox; - + cvf::BoundingBox m_matrixActiveCellsBoundingBox; }; diff --git a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp index f4bdb053b3..da86e676f1 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp @@ -28,10 +28,11 @@ RigMainGrid::RigMainGrid(void) { m_matrixModelResults = new RigReservoirCellResults(this); m_fractureModelResults = new RigReservoirCellResults(this); - - m_activeCellsBoundingBox.add(cvf::Vec3d::ZERO); + + m_displayModelOffset = cvf::Vec3d::ZERO; + m_gridIndex = 0; -} +} RigMainGrid::~RigMainGrid(void) @@ -74,87 +75,22 @@ void RigMainGrid::initAllSubCellsMainGridCellIndex() } } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -cvf::BoundingBox RigMainGrid::matrixModelActiveCellsBoundingBox() const -{ - return m_activeCellsBoundingBox; -} - - - -//-------------------------------------------------------------------------------------------------- -/// Helper class used to find min/max range for valid and active cells -//-------------------------------------------------------------------------------------------------- -class CellRangeBB -{ -public: - CellRangeBB() - : m_min(cvf::UNDEFINED_SIZE_T, cvf::UNDEFINED_SIZE_T, cvf::UNDEFINED_SIZE_T), - m_max(cvf::Vec3st::ZERO) - { - - } - - void add(size_t i, size_t j, size_t k) - { - if (i < m_min.x()) m_min.x() = i; - if (j < m_min.y()) m_min.y() = j; - if (k < m_min.z()) m_min.z() = k; - - if (i > m_max.x()) m_max.x() = i; - if (j > m_max.y()) m_max.y() = j; - if (k > m_max.z()) m_max.z() = k; - } - -public: - cvf::Vec3st m_min; - cvf::Vec3st m_max; -}; - - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- cvf::Vec3d RigMainGrid::displayModelOffset() const { - return m_activeCellsBoundingBox.min(); + return m_displayModelOffset; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigMainGrid::computeBoundingBox() +void RigMainGrid::setDisplayModelOffset(cvf::Vec3d offset) { - m_activeCellsBoundingBox.reset(); - - if (m_nodes.size() == 0) - { - m_activeCellsBoundingBox.add(cvf::Vec3d::ZERO); - } - else - { - size_t i; - for (i = 0; i < cellCount(); i++) - { - const RigCell& c = cell(i); - if (c.isActiveInMatrixModel()) - { - const caf::SizeTArray8& indices = c.cornerIndices(); - - size_t idx; - for (idx = 0; idx < 8; idx++) - { - m_activeCellsBoundingBox.add(m_nodes[indices[idx]]); - } - } - } - } + m_displayModelOffset = offset; } - //-------------------------------------------------------------------------------------------------- /// Initialize pointers from grid to parent grid /// Compute cell ranges for active and valid cells @@ -164,7 +100,6 @@ void RigMainGrid::computeCachedData() { initAllSubGridsParentGridPointer(); initAllSubCellsMainGridCellIndex(); - computeBoundingBox(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigMainGrid.h b/ApplicationCode/ReservoirDataModel/RigMainGrid.h index d421fc3be0..25744fff35 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.h +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.h @@ -56,12 +56,12 @@ public: // Overrides virtual cvf::Vec3d displayModelOffset() const; + void setDisplayModelOffset(cvf::Vec3d offset); private: void initAllSubGridsParentGridPointer(); void initAllSubCellsMainGridCellIndex(); void computeActiveAndValidCellRanges(); - void computeBoundingBox(); private: std::vector m_nodes; ///< Global vertex table @@ -71,6 +71,6 @@ private: cvf::ref m_matrixModelResults; cvf::ref m_fractureModelResults; - cvf::BoundingBox m_activeCellsBoundingBox; + cvf::Vec3d m_displayModelOffset; }; diff --git a/ApplicationCode/ReservoirDataModel/RigReservoir.cpp b/ApplicationCode/ReservoirDataModel/RigReservoir.cpp index 3f510510c8..9b084135ae 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoir.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoir.cpp @@ -293,14 +293,7 @@ void RigReservoir::computeCachedData() { computeFaults(); computeActiveCellData(); - - //TODO Set display model offset - /* - if (m_mainGrid.notNull()) - { - m_mainGrid->setDisplayModelOffset(m_activeCellInfo.m_activeCellPositionMin); - } - */ + computeActiveCellsGeometryBoundingBox(); } //-------------------------------------------------------------------------------------------------- @@ -318,3 +311,43 @@ const RigActiveCellInfo* RigReservoir::activeCellInfo() const { return &m_activeCellInfo; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigReservoir::computeActiveCellsGeometryBoundingBox() +{ + if (m_mainGrid.isNull()) + { + cvf::BoundingBox bb; + m_activeCellInfo.setMatrixActiveCellsGeometryBoundingBox(bb); + return; + } + + cvf::BoundingBox bb; + if (m_mainGrid->nodes().size() == 0) + { + bb.add(cvf::Vec3d::ZERO); + } + else + { + for (size_t i = 0; i < m_mainGrid->cells().size(); i++) + { + if (m_activeCellInfo.activeIndexInMatrixModel(i)) + { + const RigCell& c = m_mainGrid->cells()[i]; + const caf::SizeTArray8& indices = c.cornerIndices(); + + size_t idx; + for (idx = 0; idx < 8; idx++) + { + bb.add(m_mainGrid->nodes()[indices[idx]]); + } + } + } + } + + m_activeCellInfo.setMatrixActiveCellsGeometryBoundingBox(bb); + + m_mainGrid->setDisplayModelOffset(bb.min()); +} diff --git a/ApplicationCode/ReservoirDataModel/RigReservoir.h b/ApplicationCode/ReservoirDataModel/RigReservoir.h index 360054d18c..a52665af67 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoir.h +++ b/ApplicationCode/ReservoirDataModel/RigReservoir.h @@ -60,6 +60,8 @@ private: void computeFaults(); void computeActiveCellData(); void computeWellCellsPrGrid(); + void computeActiveCellsGeometryBoundingBox(); + private: RigActiveCellInfo m_activeCellInfo; From a0d6890aa3d40f2df3d7dfbb9b2db553fb995032 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 13 Feb 2013 11:24:36 +0100 Subject: [PATCH 015/242] Removed obsolete code p4#: 20492 --- .../FileInterface/RifReaderEclipseOutput.cpp | 5 ----- .../ProjectDataModel/RimInputReservoir.cpp | 18 ------------------ .../ProjectDataModel/RimResultReservoir.cpp | 17 ----------------- ApplicationCode/ReservoirDataModel/RigCell.cpp | 1 - ApplicationCode/ReservoirDataModel/RigCell.h | 6 ------ .../ReservoirDataModel/RigReservoir.cpp | 6 ++---- 6 files changed, 2 insertions(+), 51 deletions(-) diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index b73dc55234..11930b2838 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -129,13 +129,8 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigActiveCellInfo* activeCellIn int fractureActiveIndex = ecl_grid_get_active_fracture_index1(localEclGrid, localCellIdx); if (fractureActiveIndex != -1) { - cell.setActiveIndexInFractureModel(fractureActiveStartIndex + fractureActiveIndex); activeCellInfo->setActiveIndexInFractureModel(cellStartIndex + localCellIdx, fractureActiveStartIndex + fractureActiveIndex); } - else - { - cell.setActiveIndexInFractureModel(cvf::UNDEFINED_SIZE_T); - } // Parent cell index diff --git a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp index 029882d30c..4f13b8d996 100644 --- a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp @@ -75,24 +75,6 @@ void RimInputReservoir::openDataFileSet(const QStringList& filenames) m_rigReservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p()); m_rigReservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p()); - size_t matrixActiveCellCount = 0; - size_t fractureActiveCellCount = 0; - - for (size_t cellIdx = 0; cellIdx < m_rigReservoir->mainGrid()->cells().size(); cellIdx++) - { - const RigCell& cell = m_rigReservoir->mainGrid()->cells()[cellIdx]; - - if (cell.isActiveInMatrixModel()) - { - matrixActiveCellCount++; - } - if (cell.isActiveInFractureModel()) - { - fractureActiveCellCount++; - } - - } - m_rigReservoir->activeCellInfo()->computeDerivedData(); return; diff --git a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp index 8b2265744c..aa6608c47c 100644 --- a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp @@ -58,23 +58,6 @@ bool RimResultReservoir::openEclipseGridFile() { readerInterface = this->createMockModel(this->caseName()); - size_t matrixActiveCellCount = 0; - size_t fractureActiveCellCount = 0; - - for (size_t cellIdx = 0; cellIdx < m_rigReservoir->mainGrid()->cells().size(); cellIdx++) - { - const RigCell& cell = m_rigReservoir->mainGrid()->cells()[cellIdx]; - - if (cell.isActiveInMatrixModel()) - { - matrixActiveCellCount++; - } - if (cell.isActiveInFractureModel()) - { - fractureActiveCellCount++; - } - - } m_rigReservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p()); m_rigReservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p()); } diff --git a/ApplicationCode/ReservoirDataModel/RigCell.cpp b/ApplicationCode/ReservoirDataModel/RigCell.cpp index 6c7bfd573c..555e748d2b 100644 --- a/ApplicationCode/ReservoirDataModel/RigCell.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCell.cpp @@ -41,7 +41,6 @@ RigCell::RigCell() : m_isInvalid(false), m_isWellCell(false), m_activeIndexInMatrixModel(cvf::UNDEFINED_SIZE_T), - m_activeIndexInFractureModel(cvf::UNDEFINED_SIZE_T), m_cellIndex(cvf::UNDEFINED_SIZE_T), m_isInCoarseCell(false) { diff --git a/ApplicationCode/ReservoirDataModel/RigCell.h b/ApplicationCode/ReservoirDataModel/RigCell.h index 4e3ac4abe2..a6ee7c6395 100644 --- a/ApplicationCode/ReservoirDataModel/RigCell.h +++ b/ApplicationCode/ReservoirDataModel/RigCell.h @@ -41,10 +41,6 @@ public: size_t activeIndexInMatrixModel() const { return m_activeIndexInMatrixModel; } void setActiveIndexInMatrixModel(size_t val) { m_activeIndexInMatrixModel = val; } - bool isActiveInFractureModel() const { return m_activeIndexInFractureModel != cvf::UNDEFINED_SIZE_T; } - size_t activeIndexInFractureModel() const { return m_activeIndexInFractureModel; } - void setActiveIndexInFractureModel(size_t val) { m_activeIndexInFractureModel = val; } - bool isInvalid() const { return m_isInvalid; } void setInvalid( bool val ) { m_isInvalid = val; } @@ -95,6 +91,4 @@ private: bool m_isWellCell; size_t m_activeIndexInMatrixModel; ///< This cell's running index of all the active calls (matrix) in the reservoir - size_t m_activeIndexInFractureModel; ///< This cell's running index of all the active calls (fracture) in the reservoir - }; diff --git a/ApplicationCode/ReservoirDataModel/RigReservoir.cpp b/ApplicationCode/ReservoirDataModel/RigReservoir.cpp index 9b084135ae..051d0d09bd 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoir.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoir.cpp @@ -266,17 +266,15 @@ void RigReservoir::computeActiveCellData() size_t idx; for (idx = 0; idx < m_mainGrid->cellCount(); idx++) { - const RigCell& c = m_mainGrid->cell(idx); - size_t i, j, k; m_mainGrid->ijkFromCellIndex(idx, &i, &j, &k); - if (c.isActiveInMatrixModel()) + if (m_activeCellInfo.activeIndexInMatrixModel(idx)) { matrixModelActiveBB.add(i, j, k); } - if (c.isActiveInFractureModel()) + if (m_activeCellInfo.activeIndexInFractureModel(idx)) { fractureModelActiveBB.add(i, j, k); } From f14c03f17268518d467c2fef0d45625085de6833 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 13 Feb 2013 11:47:29 +0100 Subject: [PATCH 016/242] Fixed index bug in data access p4#: 20498 --- ApplicationCode/ReservoirDataModel/RigGridBase.cpp | 2 +- ApplicationCode/ReservoirDataModel/RigGridBase.h | 2 +- .../ReservoirDataModel/RigGridScalarDataAccess.cpp | 10 ++++------ 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigGridBase.cpp b/ApplicationCode/ReservoirDataModel/RigGridBase.cpp index 1bf2958108..d3423e384b 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridBase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridBase.cpp @@ -502,7 +502,7 @@ void RigGridBase::setMatrixModelActiveCellCount(size_t activeMatrixModelCellCoun //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -size_t RigGridBase::mainGridCellIndex(size_t localGridCellIndex) const +size_t RigGridBase::globalGridCellIndex(size_t localGridCellIndex) const { return m_indexToStartOfCells + localGridCellIndex; } diff --git a/ApplicationCode/ReservoirDataModel/RigGridBase.h b/ApplicationCode/ReservoirDataModel/RigGridBase.h index 3712e77719..b32ce34af2 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridBase.h +++ b/ApplicationCode/ReservoirDataModel/RigGridBase.h @@ -49,7 +49,7 @@ public: RigCell& cell(size_t gridCellIndex); const RigCell& cell(size_t gridCellIndex) const; - size_t mainGridCellIndex(size_t localGridCellIndex) const; + size_t globalGridCellIndex(size_t localGridCellIndex) const; void setIndexToStartOfCells(size_t indexToStartOfCells) { m_indexToStartOfCells = indexToStartOfCells; } void setGridIndex(size_t index) { m_gridIndex = index; } diff --git a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp index 4a9fc6e2d7..f5fbc92849 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp @@ -144,9 +144,8 @@ public: { if (m_resultValues->size() == 0 ) return HUGE_VAL; - size_t mainGridCellIndex = m_grid->cell(cellIndex).mainGridCellIndex(); - - size_t resultValueIndex = m_activeCellInfo->activeIndexInMatrixModel(mainGridCellIndex); + size_t globalGridCellIndex = m_grid->globalGridCellIndex(cellIndex); + size_t resultValueIndex = m_activeCellInfo->activeIndexInMatrixModel(globalGridCellIndex); if (resultValueIndex == cvf::UNDEFINED_SIZE_T) return HUGE_VAL; if (m_resultValues->size() <= resultValueIndex) return HUGE_VAL; @@ -179,9 +178,8 @@ public: { if (m_resultValues->size() == 0 ) return HUGE_VAL; - size_t mainGridCellIndex = m_grid->cell(cellIndex).mainGridCellIndex(); - - size_t resultValueIndex = m_activeCellInfo->activeIndexInFractureModel(mainGridCellIndex); + size_t globalGridCellIndex = m_grid->globalGridCellIndex(cellIndex); + size_t resultValueIndex = m_activeCellInfo->activeIndexInFractureModel(globalGridCellIndex); if (resultValueIndex == cvf::UNDEFINED_SIZE_T) return HUGE_VAL; if (m_resultValues->size() <= resultValueIndex) return HUGE_VAL; From b1cb8a6716898c2eb0f985d36bcbdd7da63cfc43 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 13 Feb 2013 13:10:54 +0100 Subject: [PATCH 017/242] Moved result value vectors from MainGrid to Reservoir p4#: 20499 --- .../RifReaderEclipseOutput-Test.cpp | 2 +- .../RifEclipseInputFileTools.cpp | 27 +++++------ .../FileInterface/RifReaderEclipseOutput.cpp | 8 ++-- .../FileInterface/RifReaderMockModel.cpp | 2 +- .../RivCellEdgeEffectGenerator.cpp | 8 ++-- .../ModelVisualization/RivGridPartMgr.cpp | 4 +- .../RivReservoirViewPartMgr.cpp | 4 +- .../ProjectDataModel/RimInputReservoir.cpp | 16 +++---- .../ProjectDataModel/RimReservoir.cpp | 4 +- .../ProjectDataModel/RimReservoirView.cpp | 8 ++-- .../ProjectDataModel/RimResultReservoir.cpp | 4 +- .../ReservoirDataModel/RigGridBase.cpp | 15 ------ .../ReservoirDataModel/RigGridBase.h | 2 - .../RigGridScalarDataAccess.cpp | 33 +++++++------ .../RigGridScalarDataAccess.h | 9 ++-- .../ReservoirDataModel/RigMainGrid.cpp | 30 ------------ .../ReservoirDataModel/RigMainGrid.h | 8 ---- .../ReservoirDataModel/RigReservoir.cpp | 47 +++++++++++++++++++ .../ReservoirDataModel/RigReservoir.h | 14 ++++++ .../RigReservoirCellResults.cpp | 10 ++++ .../RigReservoirCellResults.h | 1 + .../SocketInterface/RiaSocketServer.cpp | 14 +++--- 22 files changed, 143 insertions(+), 127 deletions(-) diff --git a/ApplicationCode/FileInterface/FileInterface_UnitTests/RifReaderEclipseOutput-Test.cpp b/ApplicationCode/FileInterface/FileInterface_UnitTests/RifReaderEclipseOutput-Test.cpp index d61fdb185d..5f84939347 100644 --- a/ApplicationCode/FileInterface/FileInterface_UnitTests/RifReaderEclipseOutput-Test.cpp +++ b/ApplicationCode/FileInterface/FileInterface_UnitTests/RifReaderEclipseOutput-Test.cpp @@ -68,7 +68,7 @@ TEST(RigReservoirTest, FileOutputToolsTest) void buildResultInfoString(RigReservoir* reservoir, RifReaderInterface::PorosityModelResultType porosityModel, RimDefines::ResultCatType resultType) { - RigReservoirCellResults* matrixResults = reservoir->mainGrid()->results(porosityModel); + RigReservoirCellResults* matrixResults = reservoir->results(porosityModel); { QStringList resultNames = matrixResults->resultNames(resultType); diff --git a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp index ac83e2e22a..f032efba30 100644 --- a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp @@ -212,11 +212,11 @@ std::map RifEclipseInputFileTools::readProperties(const QStri ecl_kw_type* eclKeyWordData = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ECL_FLOAT_TYPE); if (eclKeyWordData) { - QString newResultName = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->makeResultNameUnique(fileKeywords[i].keyword); + QString newResultName = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->makeResultNameUnique(fileKeywords[i].keyword); - size_t resultIndex = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName); // Should really merge with inputProperty object information because we need to use PropertyName, and not keyword + size_t resultIndex = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName); // Should really merge with inputProperty object information because we need to use PropertyName, and not keyword - std::vector< std::vector >& newPropertyData = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex); + std::vector< std::vector >& newPropertyData = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex); newPropertyData.push_back(std::vector()); newPropertyData[0].resize(ecl_kw_get_size(eclKeyWordData), HUGE_VAL); ecl_kw_get_data_as_double(eclKeyWordData, newPropertyData[0].data()); @@ -294,13 +294,13 @@ bool RifEclipseInputFileTools::readProperty(const QString& fileName, RigReservoi if (eclKeyWordData) { QString newResultName = resultName; - size_t resultIndex = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(newResultName); + size_t resultIndex = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(newResultName); if (resultIndex == cvf::UNDEFINED_SIZE_T) { - resultIndex = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName); + resultIndex = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName); } - std::vector< std::vector >& newPropertyData = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex); + std::vector< std::vector >& newPropertyData = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex); newPropertyData.resize(1); newPropertyData[0].resize(ecl_kw_get_size(eclKeyWordData), HUGE_VAL); ecl_kw_get_data_as_double(eclKeyWordData, newPropertyData[0].data()); @@ -374,7 +374,7 @@ bool RifEclipseInputFileTools::writePropertyToTextFile(const QString& fileName, { CVF_ASSERT(reservoir); - size_t resultIndex = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(resultName); + size_t resultIndex = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(resultName); if (resultIndex == cvf::UNDEFINED_SIZE_T) { return false; @@ -386,7 +386,7 @@ bool RifEclipseInputFileTools::writePropertyToTextFile(const QString& fileName, return false; } - std::vector< std::vector >& resultData = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex); + std::vector< std::vector >& resultData = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex); if (resultData.size() == 0) { return false; @@ -406,7 +406,7 @@ bool RifEclipseInputFileTools::writeBinaryResultToTextFile(const QString& fileNa { CVF_ASSERT(reservoir); - size_t resultIndex = reservoir->mainGrid()->results(porosityModel)->findScalarResultIndex(resultName); + size_t resultIndex = reservoir->results(porosityModel)->findScalarResultIndex(resultName); if (resultIndex == cvf::UNDEFINED_SIZE_T) { return false; @@ -418,8 +418,7 @@ bool RifEclipseInputFileTools::writeBinaryResultToTextFile(const QString& fileNa return false; } - RigActiveCellInfo* activeCellInfo = reservoir->activeCellInfo(); - cvf::ref dataAccessObject = reservoir->mainGrid()->dataAccessObject(activeCellInfo, porosityModel, timeStep, resultIndex); + cvf::ref dataAccessObject = reservoir->dataAccessObject(reservoir->mainGrid(), porosityModel, timeStep, resultIndex); if (dataAccessObject.isNull()) { return false; @@ -533,13 +532,13 @@ bool RifEclipseInputFileTools::readPropertyAtFilePosition(const QString& fileNam if (eclKeyWordData) { QString newResultName = resultName; - size_t resultIndex = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(newResultName); + size_t resultIndex = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(newResultName); if (resultIndex == cvf::UNDEFINED_SIZE_T) { - resultIndex = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName); + resultIndex = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName); } - std::vector< std::vector >& newPropertyData = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex); + std::vector< std::vector >& newPropertyData = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex); newPropertyData.resize(1); newPropertyData[0].resize(ecl_kw_get_size(eclKeyWordData), HUGE_VAL); ecl_kw_get_data_as_double(eclKeyWordData, newPropertyData[0].data()); diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index 11930b2838..472243c48b 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -372,8 +372,8 @@ bool RifReaderEclipseOutput::open(const QString& fileName, RigReservoir* reservo m_reservoir = reservoir; - reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(this); - reservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(this); + reservoir->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(this); + reservoir->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(this); // Build results meta data if (!buildMetaData(reservoir)) return false; @@ -409,8 +409,8 @@ bool RifReaderEclipseOutput::buildMetaData(RigReservoir* reservoir) progInfo.incrementProgress(); - RigReservoirCellResults* matrixModelResults = m_reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS); - RigReservoirCellResults* fractureModelResults = m_reservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS); + RigReservoirCellResults* matrixModelResults = m_reservoir->results(RifReaderInterface::MATRIX_RESULTS); + RigReservoirCellResults* fractureModelResults = m_reservoir->results(RifReaderInterface::FRACTURE_RESULTS); if (m_dynamicResultsAccess.notNull()) { diff --git a/ApplicationCode/FileInterface/RifReaderMockModel.cpp b/ApplicationCode/FileInterface/RifReaderMockModel.cpp index 0cfb16c02d..6f036e124e 100644 --- a/ApplicationCode/FileInterface/RifReaderMockModel.cpp +++ b/ApplicationCode/FileInterface/RifReaderMockModel.cpp @@ -31,7 +31,7 @@ bool RifReaderMockModel::open(const QString& fileName, RigReservoir* reservoir) m_reservoir = reservoir; - RigReservoirCellResults* cellResults = reservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS); + RigReservoirCellResults* cellResults = reservoir->results(RifReaderInterface::MATRIX_RESULTS); QList dates; diff --git a/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp b/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp index 2e2711e9a8..fac4a1b709 100644 --- a/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp @@ -96,8 +96,8 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo( const RigGridBase* grid = dynamic_cast(generator->activeGrid()); CVF_ASSERT(grid != NULL); - RigActiveCellInfo* activeCellInfo = cellResultSlot->reservoirView()->eclipseCase()->reservoirData()->activeCellInfo(); - CVF_ASSERT(activeCellInfo != NULL); + RigReservoir* reservoir = cellResultSlot->reservoirView()->eclipseCase()->reservoirData(); + CVF_ASSERT(reservoir != NULL); cvf::ref cellCenterDataAccessObject = NULL; if (cellResultSlot->hasResult()) @@ -109,7 +109,7 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo( } RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel()); - cellCenterDataAccessObject = grid->dataAccessObject(activeCellInfo, porosityModel, timeStepIndex, cellResultSlot->gridScalarIndex()); + cellCenterDataAccessObject = reservoir->dataAccessObject(grid, porosityModel, timeStepIndex, cellResultSlot->gridScalarIndex()); } CVF_ASSERT(cellEdgeResultSlot->hasResult()); @@ -128,7 +128,7 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo( { // Assuming static values to be mapped onto cell edge, always using time step zero // TODO: Now hardcoded matrix results, should it be possible to use fracture results? - daObj = grid->dataAccessObject(activeCellInfo, RifReaderInterface::MATRIX_RESULTS, 0, resultIndices[cubeFaceIdx]); + daObj = reservoir->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, 0, resultIndices[cubeFaceIdx]); } cellEdgeDataAccessObjects.push_back(daObj.p()); diff --git a/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp b/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp index 269b4742b3..5f04d3dfc5 100644 --- a/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp @@ -223,8 +223,8 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot* RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel()); - RigActiveCellInfo* activeCellInfo = cellResultSlot->reservoirView()->eclipseCase()->reservoirData()->activeCellInfo(); - cvf::ref dataAccessObject = m_grid->dataAccessObject(activeCellInfo, porosityModel, resTimeStepIdx, scalarSetIndex); + RigReservoir* reservoir = cellResultSlot->reservoirView()->eclipseCase()->reservoirData(); + cvf::ref dataAccessObject = reservoir->dataAccessObject(m_grid.p(), porosityModel, resTimeStepIdx, scalarSetIndex); if (dataAccessObject.isNull()) return; diff --git a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp index 5fe2acbfdf..c7b15fb78a 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp @@ -605,9 +605,9 @@ void RivReservoirViewPartMgr::computePropertyVisibility(cvf::UByteArray* cellVis const RimCellFilter::FilterModeType filterType = (*pfIt)->filterMode(); RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel((*pfIt)->resultDefinition()->porosityModel()); - RigActiveCellInfo* activeCellInfo = propFilterColl->reservoirView()->eclipseCase()->reservoirData()->activeCellInfo(); + RigReservoir* reservoir = propFilterColl->reservoirView()->eclipseCase()->reservoirData(); - cvf::ref dataAccessObject = grid->dataAccessObject(activeCellInfo, porosityModel, timeStepIndex, scalarResultIndex); + cvf::ref dataAccessObject = reservoir->dataAccessObject(grid, porosityModel, timeStepIndex, scalarResultIndex); CVF_ASSERT(dataAccessObject.notNull()); #pragma omp parallel for schedule(dynamic) diff --git a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp index 4f13b8d996..21e396d441 100644 --- a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp @@ -72,8 +72,8 @@ void RimInputReservoir::openDataFileSet(const QStringList& filenames) if (caseName().contains("Input Mock Debug Model")) { cvf::ref readerInterface = this->createMockModel(this->caseName()); - m_rigReservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p()); - m_rigReservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p()); + m_rigReservoir->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p()); + m_rigReservoir->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p()); m_rigReservoir->activeCellInfo()->computeDerivedData(); @@ -183,8 +183,8 @@ bool RimInputReservoir::openEclipseGridFile() CVF_ASSERT(m_rigReservoir.notNull()); CVF_ASSERT(readerInterface.notNull()); - m_rigReservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p()); - m_rigReservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p()); + m_rigReservoir->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p()); + m_rigReservoir->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p()); m_rigReservoir->computeCachedData(); m_rigReservoir->mainGrid()->computeCachedData(); } @@ -193,8 +193,8 @@ bool RimInputReservoir::openEclipseGridFile() RIApplication* app = RIApplication::instance(); if (app->preferences()->autocomputeDepthRelatedProperties) { - RigReservoirCellResults* matrixResults = m_rigReservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS); - RigReservoirCellResults* fractureResults = m_rigReservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS); + RigReservoirCellResults* matrixResults = m_rigReservoir->results(RifReaderInterface::MATRIX_RESULTS); + RigReservoirCellResults* fractureResults = m_rigReservoir->results(RifReaderInterface::FRACTURE_RESULTS); matrixResults->computeDepthRelatedResults(); fractureResults->computeDepthRelatedResults(); @@ -286,7 +286,7 @@ void RimInputReservoir::loadAndSyncronizeInputProperties() { if (fileKeywordSet.count(knownKeywords[fkIt])) { - QString resultName = this->reservoirData()->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->makeResultNameUnique(knownKeywords[fkIt]); + QString resultName = this->reservoirData()->results(RifReaderInterface::MATRIX_RESULTS)->makeResultNameUnique(knownKeywords[fkIt]); if (RifEclipseInputFileTools::readProperty(filenames[i], this->reservoirData(), knownKeywords[fkIt], resultName)) { RimInputProperty* inputProperty = new RimInputProperty; @@ -361,7 +361,7 @@ void RimInputReservoir::removeProperty(RimInputProperty* inputProperty) } // Remove the results pointed to by this input property - RigReservoirCellResults* results = m_rigReservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS); + RigReservoirCellResults* results = m_rigReservoir->results(RifReaderInterface::MATRIX_RESULTS); results->removeResult(inputProperty->resultName); this->removeResult(inputProperty->resultName); diff --git a/ApplicationCode/ProjectDataModel/RimReservoir.cpp b/ApplicationCode/ProjectDataModel/RimReservoir.cpp index 79bd2bf00a..4d9f033285 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoir.cpp @@ -209,13 +209,13 @@ void RimReservoir::fieldChangedByUi(const caf::PdmFieldHandle* changedField, con reservoirView->createDisplayModelAndRedraw(); } - RigReservoirCellResults* matrixModelResults = m_rigReservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS); + RigReservoirCellResults* matrixModelResults = m_rigReservoir->results(RifReaderInterface::MATRIX_RESULTS); if (matrixModelResults) { matrixModelResults->clearAllResults(); } - RigReservoirCellResults* fractureModelResults = m_rigReservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS); + RigReservoirCellResults* fractureModelResults = m_rigReservoir->results(RifReaderInterface::FRACTURE_RESULTS); if (fractureModelResults) { fractureModelResults->clearAllResults(); diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp index 7bc85b33d8..dfadff16e9 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp @@ -875,7 +875,7 @@ void RimReservoirView::appendCellResultInfo(size_t gridIndex, size_t cellIndex, if (this->cellResult()->hasResult()) { RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResult()->porosityModel()); - cvf::ref dataAccessObject = grid->dataAccessObject(activeCellInfo, porosityModel, m_currentTimeStep, this->cellResult()->gridScalarIndex()); + cvf::ref dataAccessObject = reservoir->dataAccessObject(grid, porosityModel, m_currentTimeStep, this->cellResult()->gridScalarIndex()); if (dataAccessObject.notNull()) { double scalarValue = dataAccessObject->cellScalar(cellIndex); @@ -896,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 RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResult()->porosityModel()); - cvf::ref dataAccessObject = grid->dataAccessObject(activeCellInfo, porosityModel, 0, resultIndices[idx]); + cvf::ref dataAccessObject = reservoir->dataAccessObject(grid, porosityModel, 0, resultIndices[idx]); if (dataAccessObject.notNull()) { double scalarValue = dataAccessObject->cellScalar(cellIndex); @@ -968,7 +968,7 @@ RigReservoirCellResults* RimReservoirView::gridCellResults() { RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResult->porosityModel()); - return m_reservoir->reservoirData()->mainGrid()->results(porosityModel); + return m_reservoir->reservoirData()->results(porosityModel); } return NULL; @@ -1038,7 +1038,7 @@ void RimReservoirView::updateLegends() CVF_ASSERT(reservoir); RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResult()->porosityModel()); - RigReservoirCellResults* results = reservoir->mainGrid()->results(porosityModel); + RigReservoirCellResults* results = reservoir->results(porosityModel); CVF_ASSERT(results); if (this->cellResult()->hasResult()) diff --git a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp index aa6608c47c..32314a69f4 100644 --- a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp @@ -58,8 +58,8 @@ bool RimResultReservoir::openEclipseGridFile() { readerInterface = this->createMockModel(this->caseName()); - m_rigReservoir->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p()); - m_rigReservoir->mainGrid()->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p()); + m_rigReservoir->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p()); + m_rigReservoir->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p()); } else { diff --git a/ApplicationCode/ReservoirDataModel/RigGridBase.cpp b/ApplicationCode/ReservoirDataModel/RigGridBase.cpp index d3423e384b..dd733e6c32 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridBase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridBase.cpp @@ -468,21 +468,6 @@ size_t RigGridBase::fractureModelActiveCellCount() const return m_fractureModelActiveCellCount; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -cvf::ref RigGridBase::dataAccessObject(const RigActiveCellInfo* activeCellInfo, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStepIndex, size_t scalarSetIndex) const -{ - if (timeStepIndex != cvf::UNDEFINED_SIZE_T && - scalarSetIndex != cvf::UNDEFINED_SIZE_T) - { - cvf::ref dataAccess = RigGridScalarDataAccessFactory::createDataAccessObject(this, activeCellInfo, porosityModel, timeStepIndex, scalarSetIndex); - return dataAccess; - } - - return NULL; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigGridBase.h b/ApplicationCode/ReservoirDataModel/RigGridBase.h index b32ce34af2..4a9bf35373 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridBase.h +++ b/ApplicationCode/ReservoirDataModel/RigGridBase.h @@ -99,8 +99,6 @@ public: 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; - cvf::ref dataAccessObject(const RigActiveCellInfo* activeCellInfo, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStepIndex, size_t scalarSetIndex) const; - private: std::string m_gridName; cvf::Vec3st m_gridPointDimensions; diff --git a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp index f5fbc92849..909490b89a 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp @@ -28,6 +28,7 @@ #include "RigReservoirCellResults.h" #include "RigActiveCellInfo.h" #include "RigGridBase.h" +#include "RigReservoir.h" @@ -37,7 +38,7 @@ class RigGridAllCellsScalarDataAccess : public cvf::StructGridScalarDataAccess { public: - RigGridAllCellsScalarDataAccess(const RigGridBase* grid, std::vector* resultValues); + RigGridAllCellsScalarDataAccess(const RigGridBase* grid, const std::vector* resultValues); virtual double cellScalar(size_t i, size_t j, size_t k) const; virtual double cellScalar(size_t cellIndex) const; @@ -49,14 +50,14 @@ public: protected: cvf::cref m_grid; - std::vector* m_resultValues; + const std::vector* m_resultValues; }; //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigGridAllCellsScalarDataAccess::RigGridAllCellsScalarDataAccess(const RigGridBase* grid, std::vector* resultValues) : +RigGridAllCellsScalarDataAccess::RigGridAllCellsScalarDataAccess(const RigGridBase* grid, const std::vector* resultValues) : m_grid(grid), m_resultValues(resultValues) { @@ -133,7 +134,7 @@ const cvf::Vec3d* RigGridAllCellsScalarDataAccess::cellVector(size_t i, size_t j class RigGridMatrixActiveCellsScalarDataAccess : public RigGridAllCellsScalarDataAccess { public: - RigGridMatrixActiveCellsScalarDataAccess(const RigGridBase* grid, std::vector* resultValues, const RigActiveCellInfo* activeCellInfo) : + RigGridMatrixActiveCellsScalarDataAccess(const RigGridBase* grid, const std::vector* resultValues, const RigActiveCellInfo* activeCellInfo) : RigGridAllCellsScalarDataAccess(grid, resultValues), m_activeCellInfo(activeCellInfo) { @@ -168,7 +169,7 @@ protected: class RigGridFractureActiveCellsScalarDataAccess : public RigGridAllCellsScalarDataAccess { public: - RigGridFractureActiveCellsScalarDataAccess(const RigGridBase* grid, std::vector* resultValues, const RigActiveCellInfo* activeCellInfo) : + RigGridFractureActiveCellsScalarDataAccess(const RigGridBase* grid, const std::vector* resultValues, const RigActiveCellInfo* activeCellInfo) : RigGridAllCellsScalarDataAccess(grid, resultValues), m_activeCellInfo(activeCellInfo) { @@ -194,45 +195,46 @@ protected: + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- cvf::ref RigGridScalarDataAccessFactory::createDataAccessObject(const RigGridBase* grid, - const RigActiveCellInfo* activeCellInfo, + const RigReservoir* reservoir, 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); + CVF_ASSERT(reservoir); + CVF_ASSERT(reservoir->results(porosityModel)); + CVF_ASSERT(reservoir->activeCellInfo()); - if (!grid || !grid->mainGrid() || !grid->mainGrid()->results(porosityModel) || !activeCellInfo) + if (!grid || !reservoir || !reservoir->results(porosityModel) || !reservoir->activeCellInfo()) { return NULL; } - std::vector< std::vector > & scalarSetResults = grid->mainGrid()->results(porosityModel)->cellScalarResults(scalarSetIndex); + const std::vector< std::vector > & scalarSetResults = reservoir->results(porosityModel)->cellScalarResults(scalarSetIndex); if (timeStepIndex >= scalarSetResults.size()) { return NULL; } - std::vector* resultValues = &(scalarSetResults[timeStepIndex]); + const std::vector* resultValues = &(scalarSetResults[timeStepIndex]); - bool useGlobalActiveIndex = grid->mainGrid()->results(porosityModel)->isUsingGlobalActiveIndex(scalarSetIndex); + bool useGlobalActiveIndex = reservoir->results(porosityModel)->isUsingGlobalActiveIndex(scalarSetIndex); if (useGlobalActiveIndex) { if (porosityModel == RifReaderInterface::MATRIX_RESULTS) { - cvf::ref object = new RigGridMatrixActiveCellsScalarDataAccess(grid, resultValues, activeCellInfo); + cvf::ref object = new RigGridMatrixActiveCellsScalarDataAccess(grid, resultValues, reservoir->activeCellInfo()); return object; } else { - cvf::ref object = new RigGridFractureActiveCellsScalarDataAccess(grid, resultValues, activeCellInfo); + cvf::ref object = new RigGridFractureActiveCellsScalarDataAccess(grid, resultValues, reservoir->activeCellInfo()); return object; } } @@ -241,5 +243,6 @@ cvf::ref RigGridScalarDataAccessFactory::create cvf::ref object = new RigGridAllCellsScalarDataAccess(grid, resultValues); return object; } + } diff --git a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.h b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.h index 871a45a82f..708d137617 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.h +++ b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.h @@ -30,11 +30,10 @@ class RigGridScalarDataAccessFactory { public: static cvf::ref createDataAccessObject(const RigGridBase* grid, - const RigActiveCellInfo* activeCellInfo, - RifReaderInterface::PorosityModelResultType porosityModel, - size_t timeStepIndex, - size_t scalarSetIndex); - + const RigReservoir* reservoir, + RifReaderInterface::PorosityModelResultType porosityModel, + size_t timeStepIndex, + size_t scalarSetIndex); }; diff --git a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp index da86e676f1..4373527880 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp @@ -19,16 +19,12 @@ #include "RIStdInclude.h" #include "RigMainGrid.h" -#include "RigReservoirCellResults.h" #include "cvfAssert.h" RigMainGrid::RigMainGrid(void) : RigGridBase(this) { - m_matrixModelResults = new RigReservoirCellResults(this); - m_fractureModelResults = new RigReservoirCellResults(this); - m_displayModelOffset = cvf::Vec3d::ZERO; m_gridIndex = 0; @@ -122,29 +118,3 @@ const RigGridBase* RigMainGrid::gridByIndex(size_t localGridIndex) const return m_localGrids[localGridIndex-1].p(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RigReservoirCellResults* RigMainGrid::results(RifReaderInterface::PorosityModelResultType porosityModel) -{ - if (porosityModel == RifReaderInterface::MATRIX_RESULTS) - { - return m_matrixModelResults.p(); - } - - return m_fractureModelResults.p(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -const RigReservoirCellResults* RigMainGrid::results(RifReaderInterface::PorosityModelResultType porosityModel) const -{ - if (porosityModel == RifReaderInterface::MATRIX_RESULTS) - { - return m_matrixModelResults.p(); - } - - return m_fractureModelResults.p(); -} - diff --git a/ApplicationCode/ReservoirDataModel/RigMainGrid.h b/ApplicationCode/ReservoirDataModel/RigMainGrid.h index 25744fff35..32ef9258bf 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.h +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.h @@ -27,8 +27,6 @@ #include -class RigReservoirCellResults; - class RigMainGrid : public RigGridBase { public: @@ -42,9 +40,6 @@ public: std::vector& cells() {return m_cells;} const std::vector& cells() const {return m_cells;} - RigReservoirCellResults* results(RifReaderInterface::PorosityModelResultType porosityModel); - const RigReservoirCellResults* results(RifReaderInterface::PorosityModelResultType porosityModel) const; - void addLocalGrid(RigLocalGrid* localGrid); size_t gridCount() const { return m_localGrids.size() + 1; } RigGridBase* gridByIndex(size_t localGridIndex); @@ -68,9 +63,6 @@ private: std::vector m_cells; ///< Global array of all cells in the reservoir (including the ones in LGR's) cvf::Collection m_localGrids; ///< List of all the LGR's in this reservoir - cvf::ref m_matrixModelResults; - cvf::ref m_fractureModelResults; - cvf::Vec3d m_displayModelOffset; }; diff --git a/ApplicationCode/ReservoirDataModel/RigReservoir.cpp b/ApplicationCode/ReservoirDataModel/RigReservoir.cpp index 051d0d09bd..10ac75eaa3 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoir.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoir.cpp @@ -19,6 +19,8 @@ #include "RIStdInclude.h" #include "RigReservoir.h" #include "RigMainGrid.h" +#include "RigReservoirCellResults.h" +#include "RigGridScalarDataAccess.h" //-------------------------------------------------------------------------------------------------- /// @@ -26,6 +28,9 @@ RigReservoir::RigReservoir() { m_mainGrid = new RigMainGrid(); + + m_matrixModelResults = new RigReservoirCellResults(m_mainGrid.p()); + m_fractureModelResults = new RigReservoirCellResults(m_mainGrid.p()); } //-------------------------------------------------------------------------------------------------- @@ -349,3 +354,45 @@ void RigReservoir::computeActiveCellsGeometryBoundingBox() m_mainGrid->setDisplayModelOffset(bb.min()); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigReservoirCellResults* RigReservoir::results(RifReaderInterface::PorosityModelResultType porosityModel) +{ + if (porosityModel == RifReaderInterface::MATRIX_RESULTS) + { + return m_matrixModelResults.p(); + } + + return m_fractureModelResults.p(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigReservoirCellResults* RigReservoir::results(RifReaderInterface::PorosityModelResultType porosityModel) const +{ + if (porosityModel == RifReaderInterface::MATRIX_RESULTS) + { + return m_matrixModelResults.p(); + } + + return m_fractureModelResults.p(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RigReservoir::dataAccessObject(const RigGridBase* grid, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStepIndex, size_t scalarSetIndex) const +{ + if (timeStepIndex != cvf::UNDEFINED_SIZE_T && + scalarSetIndex != cvf::UNDEFINED_SIZE_T) + { + cvf::ref dataAccess = RigGridScalarDataAccessFactory::createDataAccessObject(grid, this, porosityModel, timeStepIndex, scalarSetIndex); + return dataAccess; + } + + return NULL; + +} diff --git a/ApplicationCode/ReservoirDataModel/RigReservoir.h b/ApplicationCode/ReservoirDataModel/RigReservoir.h index a52665af67..9f25da2ab0 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoir.h +++ b/ApplicationCode/ReservoirDataModel/RigReservoir.h @@ -27,6 +27,8 @@ #include "RigWellResults.h" #include "RigActiveCellInfo.h" +class RigReservoirCellResults; + class RigReservoir: public cvf::Object { @@ -41,6 +43,13 @@ public: void allGrids(std::vector* grids) const; const RigGridBase* grid(size_t index) const; + + RigReservoirCellResults* results(RifReaderInterface::PorosityModelResultType porosityModel); + const RigReservoirCellResults* results(RifReaderInterface::PorosityModelResultType porosityModel) const; + + cvf::ref dataAccessObject(const RigGridBase* grid, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStepIndex, size_t scalarSetIndex) const; + + void computeCachedData(); void setWellResults(const cvf::Collection& data); @@ -65,8 +74,13 @@ private: private: RigActiveCellInfo m_activeCellInfo; + cvf::ref m_mainGrid; + cvf::ref m_matrixModelResults; + cvf::ref m_fractureModelResults; + + cvf::Collection m_wellResults; cvf::Collection m_wellCellsInGrid; }; diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp index 954eee3ed6..aaaf6ad27c 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp @@ -231,6 +231,16 @@ size_t RigReservoirCellResults::timeStepCount(size_t scalarResultIndex) const return m_cellScalarResults[scalarResultIndex].size(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector< std::vector > & RigReservoirCellResults::cellScalarResults( size_t scalarResultIndex ) const +{ + CVF_TIGHT_ASSERT(scalarResultIndex < resultCount()); + + return m_cellScalarResults[scalarResultIndex]; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h index 577f681039..d4065cfeb2 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h +++ b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h @@ -71,6 +71,7 @@ public: void computeDepthRelatedResults(); // Access the results data + const std::vector< std::vector > & cellScalarResults(size_t scalarResultIndex) const; std::vector< std::vector > & cellScalarResults(size_t scalarResultIndex); double cellScalarResult(size_t timeStepIndex, size_t scalarResultIndex, size_t resultValueIndex); diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.cpp b/ApplicationCode/SocketInterface/RiaSocketServer.cpp index 4dd668fd82..523a2ddc96 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.cpp +++ b/ApplicationCode/SocketInterface/RiaSocketServer.cpp @@ -1,4 +1,3 @@ -///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2011-2012 Statoil ASA, Ceetron AS // @@ -281,18 +280,18 @@ void RiaSocketServer::readCommandFromOctave() size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T; std::vector< std::vector >* scalarResultFrames = NULL; - if (reservoir && reservoir->reservoirData() && reservoir->reservoirData()->mainGrid() && reservoir->reservoirData()->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)) + if (reservoir && reservoir->reservoirData() && reservoir->reservoirData()->results(RifReaderInterface::MATRIX_RESULTS)) { - scalarResultIndex = reservoir->reservoirData()->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->findOrLoadScalarResult(propertyName); + scalarResultIndex = reservoir->reservoirData()->results(RifReaderInterface::MATRIX_RESULTS)->findOrLoadScalarResult(propertyName); if (scalarResultIndex == cvf::UNDEFINED_SIZE_T && isSetProperty) { - scalarResultIndex = reservoir->reservoirData()->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::GENERATED, propertyName); + scalarResultIndex = reservoir->reservoirData()->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::GENERATED, propertyName); } if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) { - scalarResultFrames = &(reservoir->reservoirData()->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(scalarResultIndex)); + scalarResultFrames = &(reservoir->reservoirData()->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(scalarResultIndex)); m_currentScalarIndex = scalarResultIndex; m_currentPropertyName = propertyName; } @@ -523,10 +522,9 @@ void RiaSocketServer::readPropertyDataFromOctave() if( m_currentScalarIndex != cvf::UNDEFINED_SIZE_T && m_currentReservoir->reservoirData() && - m_currentReservoir->reservoirData()->mainGrid() && - m_currentReservoir->reservoirData()->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS) ) + m_currentReservoir->reservoirData()->results(RifReaderInterface::MATRIX_RESULTS) ) { - m_currentReservoir->reservoirData()->mainGrid()->results(RifReaderInterface::MATRIX_RESULTS)->recalculateMinMax(m_currentScalarIndex); + m_currentReservoir->reservoirData()->results(RifReaderInterface::MATRIX_RESULTS)->recalculateMinMax(m_currentScalarIndex); } for (size_t i = 0; i < m_currentReservoir->reservoirViews.size(); ++i) From ec8817e2075e42fb8b95f065bf8ee890c5eb51d3 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 13 Feb 2013 13:24:39 +0100 Subject: [PATCH 018/242] Renamed RigReservoir to RigEclipseCase p4#: 20500 --- ApplicationCode/Application/RIApplication.h | 2 +- .../RifReaderEclipseOutput-Test.cpp | 2 +- .../RifEclipseInputFileTools.cpp | 50 +++++++++--------- .../FileInterface/RifEclipseInputFileTools.h | 14 ++--- .../FileInterface/RifReaderEclipseInput.cpp | 8 +-- .../FileInterface/RifReaderEclipseInput.h | 2 +- .../FileInterface/RifReaderEclipseOutput.cpp | 36 ++++++------- .../FileInterface/RifReaderEclipseOutput.h | 10 ++-- .../FileInterface/RifReaderInterface.h | 4 +- .../FileInterface/RifReaderMockModel.cpp | 12 ++--- .../FileInterface/RifReaderMockModel.h | 6 +-- .../RivCellEdgeEffectGenerator.cpp | 8 +-- .../ModelVisualization/RivGridPartMgr.cpp | 4 +- .../RivReservoirPartMgr.cpp | 6 +-- .../ModelVisualization/RivReservoirPartMgr.h | 4 +- .../RivReservoirViewPartMgr.cpp | 24 ++++----- .../ModelVisualization/RivWellHeadPartMgr.cpp | 2 +- .../RivWellPipesPartMgr.cpp | 2 +- .../ProjectDataModel/RimInputReservoir.cpp | 14 ++--- .../ProjectDataModel/RimReservoir.cpp | 4 +- .../ProjectDataModel/RimReservoir.h | 8 +-- .../ProjectDataModel/RimReservoirView.cpp | 24 ++++----- .../ProjectDataModel/RimResultReservoir.cpp | 10 ++-- .../RigGridScalarDataAccess.cpp | 18 +++---- .../RigGridScalarDataAccess.h | 2 +- .../ReservoirDataModel/RigReservoir.cpp | 38 +++++++------- .../ReservoirDataModel/RigReservoir.h | 6 +-- .../RigReservoirBuilderMock.cpp | 52 +++++++++---------- .../RigReservoirBuilderMock.h | 10 ++-- 29 files changed, 191 insertions(+), 191 deletions(-) diff --git a/ApplicationCode/Application/RIApplication.h b/ApplicationCode/Application/RIApplication.h index f8f7d65eea..06c5822593 100644 --- a/ApplicationCode/Application/RIApplication.h +++ b/ApplicationCode/Application/RIApplication.h @@ -30,7 +30,7 @@ #include "RimProject.h" class RIProcess; -class RigReservoir; +class RigEclipseCase; class RimReservoir; class Drawable; class RiaSocketServer; diff --git a/ApplicationCode/FileInterface/FileInterface_UnitTests/RifReaderEclipseOutput-Test.cpp b/ApplicationCode/FileInterface/FileInterface_UnitTests/RifReaderEclipseOutput-Test.cpp index 5f84939347..b43d9c324a 100644 --- a/ApplicationCode/FileInterface/FileInterface_UnitTests/RifReaderEclipseOutput-Test.cpp +++ b/ApplicationCode/FileInterface/FileInterface_UnitTests/RifReaderEclipseOutput-Test.cpp @@ -247,7 +247,7 @@ TEST(RigReservoirTest, BasicTest) TEST(RigReservoirTest, WellTest) { cvf::ref readerInterfaceEcl = new RifReaderEclipseOutput; - cvf::ref reservoir = new RigReservoir; + cvf::ref reservoir = new RigEclipseCase; // Location of test dataset received from HÃ¥kon Høgstøl in July 2011 with 10k active cells #ifdef WIN32 diff --git a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp index f032efba30..95a754e9e0 100644 --- a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp @@ -61,9 +61,9 @@ RifEclipseInputFileTools::~RifEclipseInputFileTools() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigReservoir* reservoir) +bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigEclipseCase* eclipseCase) { - CVF_ASSERT(reservoir); + CVF_ASSERT(eclipseCase); qint64 coordPos = -1; qint64 zcornPos = -1; @@ -154,7 +154,7 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigReservoi progress.setProgress(6); - RifReaderEclipseOutput::transferGeometry(inputGrid, reservoir); + RifReaderEclipseOutput::transferGeometry(inputGrid, eclipseCase); progress.setProgress(7); progress.setProgressDescription("Cleaning up ..."); @@ -176,7 +176,7 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigReservoi //-------------------------------------------------------------------------------------------------- /// Read known properties from the input file //-------------------------------------------------------------------------------------------------- -std::map RifEclipseInputFileTools::readProperties(const QString &fileName, RigReservoir *reservoir) +std::map RifEclipseInputFileTools::readProperties(const QString &fileName, RigEclipseCase *reservoir) { CVF_ASSERT(reservoir); @@ -282,9 +282,9 @@ std::vector< RifKeywordAndFilePos > RifEclipseInputFileTools::findKeywordsOnFile /// Reads the property data requested into the \a reservoir, overwriting any previous /// propeties with the same name. //-------------------------------------------------------------------------------------------------- -bool RifEclipseInputFileTools::readProperty(const QString& fileName, RigReservoir* reservoir, const QString& eclipseKeyWord, const QString& resultName) +bool RifEclipseInputFileTools::readProperty(const QString& fileName, RigEclipseCase* eclipseCase, const QString& eclipseKeyWord, const QString& resultName) { - CVF_ASSERT(reservoir); + CVF_ASSERT(eclipseCase); FILE* filePointer = util_fopen(fileName.toLatin1().data(), "r"); if (!filePointer) return false; @@ -294,13 +294,13 @@ bool RifEclipseInputFileTools::readProperty(const QString& fileName, RigReservoi if (eclKeyWordData) { QString newResultName = resultName; - size_t resultIndex = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(newResultName); + size_t resultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(newResultName); if (resultIndex == cvf::UNDEFINED_SIZE_T) { - resultIndex = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName); + resultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName); } - std::vector< std::vector >& newPropertyData = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex); + std::vector< std::vector >& newPropertyData = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex); newPropertyData.resize(1); newPropertyData[0].resize(ecl_kw_get_size(eclKeyWordData), HUGE_VAL); ecl_kw_get_data_as_double(eclKeyWordData, newPropertyData[0].data()); @@ -370,11 +370,11 @@ const std::vector& RifEclipseInputFileTools::knownPropertyKeywords() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifEclipseInputFileTools::writePropertyToTextFile(const QString& fileName, RigReservoir* reservoir, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord) +bool RifEclipseInputFileTools::writePropertyToTextFile(const QString& fileName, RigEclipseCase* eclipseCase, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord) { - CVF_ASSERT(reservoir); + CVF_ASSERT(eclipseCase); - size_t resultIndex = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(resultName); + size_t resultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(resultName); if (resultIndex == cvf::UNDEFINED_SIZE_T) { return false; @@ -386,7 +386,7 @@ bool RifEclipseInputFileTools::writePropertyToTextFile(const QString& fileName, return false; } - std::vector< std::vector >& resultData = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex); + std::vector< std::vector >& resultData = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex); if (resultData.size() == 0) { return false; @@ -402,11 +402,11 @@ bool RifEclipseInputFileTools::writePropertyToTextFile(const QString& fileName, /// Create and write a result vector with values for all cells. /// undefinedValue is used for cells with no result //-------------------------------------------------------------------------------------------------- -bool RifEclipseInputFileTools::writeBinaryResultToTextFile(const QString& fileName, RigReservoir* reservoir, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord, const double undefinedValue) +bool RifEclipseInputFileTools::writeBinaryResultToTextFile(const QString& fileName, RigEclipseCase* eclipseCase, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord, const double undefinedValue) { - CVF_ASSERT(reservoir); + CVF_ASSERT(eclipseCase); - size_t resultIndex = reservoir->results(porosityModel)->findScalarResultIndex(resultName); + size_t resultIndex = eclipseCase->results(porosityModel)->findScalarResultIndex(resultName); if (resultIndex == cvf::UNDEFINED_SIZE_T) { return false; @@ -418,7 +418,7 @@ bool RifEclipseInputFileTools::writeBinaryResultToTextFile(const QString& fileNa return false; } - cvf::ref dataAccessObject = reservoir->dataAccessObject(reservoir->mainGrid(), porosityModel, timeStep, resultIndex); + cvf::ref dataAccessObject = eclipseCase->dataAccessObject(eclipseCase->mainGrid(), porosityModel, timeStep, resultIndex); if (dataAccessObject.isNull()) { return false; @@ -426,11 +426,11 @@ bool RifEclipseInputFileTools::writeBinaryResultToTextFile(const QString& fileNa std::vector resultData; size_t i, j, k; - for (k = 0; k < reservoir->mainGrid()->cellCountK(); k++) + for (k = 0; k < eclipseCase->mainGrid()->cellCountK(); k++) { - for (j = 0; j < reservoir->mainGrid()->cellCountJ(); j++) + for (j = 0; j < eclipseCase->mainGrid()->cellCountJ(); j++) { - for (i = 0; i < reservoir->mainGrid()->cellCountI(); i++) + for (i = 0; i < eclipseCase->mainGrid()->cellCountI(); i++) { double resultValue = dataAccessObject->cellScalar(i, j, k); if (resultValue == HUGE_VAL) @@ -519,9 +519,9 @@ void RifEclipseInputFileTools::findGridKeywordPositions(const QString& filename, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifEclipseInputFileTools::readPropertyAtFilePosition(const QString& fileName, RigReservoir* reservoir, const QString& eclipseKeyWord, qint64 filePos, const QString& resultName) +bool RifEclipseInputFileTools::readPropertyAtFilePosition(const QString& fileName, RigEclipseCase* eclipseCase, const QString& eclipseKeyWord, qint64 filePos, const QString& resultName) { - CVF_ASSERT(reservoir); + CVF_ASSERT(eclipseCase); FILE* filePointer = util_fopen(fileName.toLatin1().data(), "r"); if (!filePointer) return false; @@ -532,13 +532,13 @@ bool RifEclipseInputFileTools::readPropertyAtFilePosition(const QString& fileNam if (eclKeyWordData) { QString newResultName = resultName; - size_t resultIndex = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(newResultName); + size_t resultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(newResultName); if (resultIndex == cvf::UNDEFINED_SIZE_T) { - resultIndex = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName); + resultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName); } - std::vector< std::vector >& newPropertyData = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex); + std::vector< std::vector >& newPropertyData = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex); newPropertyData.resize(1); newPropertyData[0].resize(ecl_kw_get_size(eclKeyWordData), HUGE_VAL); ecl_kw_get_data_as_double(eclKeyWordData, newPropertyData[0].data()); diff --git a/ApplicationCode/FileInterface/RifEclipseInputFileTools.h b/ApplicationCode/FileInterface/RifEclipseInputFileTools.h index 220454ee6d..f78c29c734 100644 --- a/ApplicationCode/FileInterface/RifEclipseInputFileTools.h +++ b/ApplicationCode/FileInterface/RifEclipseInputFileTools.h @@ -27,7 +27,7 @@ #include "RifReaderInterface.h" -class RigReservoir; +class RigEclipseCase; class QFile; @@ -52,19 +52,19 @@ public: RifEclipseInputFileTools(); virtual ~RifEclipseInputFileTools(); - static bool openGridFile(const QString& fileName, RigReservoir* reservoir); + static bool openGridFile(const QString& fileName, RigEclipseCase* eclipseCase); // Returns map of assigned resultName and Eclipse Keyword. - static std::map readProperties(const QString& fileName, RigReservoir* reservoir); - static bool readProperty (const QString& fileName, RigReservoir* reservoir, const QString& eclipseKeyWord, const QString& resultName ); - static bool readPropertyAtFilePosition (const QString& fileName, RigReservoir* reservoir, const QString& eclipseKeyWord, qint64 filePos, const QString& resultName ); + static std::map readProperties(const QString& fileName, RigEclipseCase* eclipseCase); + static bool readProperty (const QString& fileName, RigEclipseCase* eclipseCase, const QString& eclipseKeyWord, const QString& resultName ); + static bool readPropertyAtFilePosition (const QString& fileName, RigEclipseCase* eclipseCase, const QString& eclipseKeyWord, qint64 filePos, const QString& resultName ); static std::vector< RifKeywordAndFilePos > findKeywordsOnFile(const QString &fileName); static const std::vector& knownPropertyKeywords(); - static bool writePropertyToTextFile(const QString& fileName, RigReservoir* reservoir, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord); - static bool writeBinaryResultToTextFile(const QString& fileName, RigReservoir* reservoir, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord, const double undefinedValue); + static bool writePropertyToTextFile(const QString& fileName, RigEclipseCase* eclipseCase, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord); + static bool writeBinaryResultToTextFile(const QString& fileName, RigEclipseCase* eclipseCase, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord, const double undefinedValue); private: static void writeDataToTextFile(QFile* file, const QString& eclipseKeyWord, const std::vector& resultData); diff --git a/ApplicationCode/FileInterface/RifReaderEclipseInput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseInput.cpp index 6a21dbeb51..85b9c2e9f0 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseInput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseInput.cpp @@ -57,9 +57,9 @@ RifReaderEclipseInput::~RifReaderEclipseInput() //-------------------------------------------------------------------------------------------------- /// Open file and read geometry into given reservoir object //-------------------------------------------------------------------------------------------------- -bool RifReaderEclipseInput::open(const QString& fileName, RigReservoir* reservoir) +bool RifReaderEclipseInput::open(const QString& fileName, RigEclipseCase* eclipseCase) { - CVF_ASSERT(reservoir); + CVF_ASSERT(eclipseCase); // Make sure everything's closed close(); @@ -84,9 +84,9 @@ bool RifReaderEclipseInput::open(const QString& fileName, RigReservoir* reservoi // create InputProperty object bool isOk = false; - if (reservoir->mainGrid()->gridPointDimensions() == cvf::Vec3st(0,0,0)) + if (eclipseCase->mainGrid()->gridPointDimensions() == cvf::Vec3st(0,0,0)) { - isOk = RifEclipseInputFileTools::openGridFile(fileName, reservoir); + isOk = RifEclipseInputFileTools::openGridFile(fileName, eclipseCase); } return isOk; diff --git a/ApplicationCode/FileInterface/RifReaderEclipseInput.h b/ApplicationCode/FileInterface/RifReaderEclipseInput.h index 94abe84af2..840dba0b96 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseInput.h +++ b/ApplicationCode/FileInterface/RifReaderEclipseInput.h @@ -32,7 +32,7 @@ public: virtual ~RifReaderEclipseInput(); // Virtual interface implementation - virtual bool open(const QString& fileName, RigReservoir* reservoir); + virtual bool open(const QString& fileName, RigEclipseCase* eclipseCase); diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index 472243c48b..209c515e98 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -230,9 +230,9 @@ void RifReaderEclipseOutput::close() //-------------------------------------------------------------------------------------------------- /// Read geometry from file given by name into given reservoir object //-------------------------------------------------------------------------------------------------- -bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid, RigReservoir* reservoir) +bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid, RigEclipseCase* eclipseCase) { - CVF_ASSERT(reservoir); + CVF_ASSERT(eclipseCase); if (!mainEclGrid) { @@ -240,10 +240,10 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid, return false; } - RigActiveCellInfo* activeCellInfo = reservoir->activeCellInfo(); + RigActiveCellInfo* activeCellInfo = eclipseCase->activeCellInfo(); CVF_ASSERT(activeCellInfo); - RigMainGrid* mainGrid = reservoir->mainGrid(); + RigMainGrid* mainGrid = eclipseCase->mainGrid(); { cvf::Vec3st gridPointDim(0,0,0); gridPointDim.x() = ecl_grid_get_nx(mainEclGrid) + 1; @@ -332,9 +332,9 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid, //-------------------------------------------------------------------------------------------------- /// Open file and read geometry into given reservoir object //-------------------------------------------------------------------------------------------------- -bool RifReaderEclipseOutput::open(const QString& fileName, RigReservoir* reservoir) +bool RifReaderEclipseOutput::open(const QString& fileName, RigEclipseCase* eclipseCase) { - CVF_ASSERT(reservoir); + CVF_ASSERT(eclipseCase); caf::ProgressInfo progInfo(100, ""); progInfo.setProgressDescription("Reading Grid"); @@ -360,7 +360,7 @@ bool RifReaderEclipseOutput::open(const QString& fileName, RigReservoir* reservo progInfo.setNextProgressIncrement(10); progInfo.setProgressDescription("Transferring grid geometry"); - if (!transferGeometry(mainEclGrid, reservoir)) return false; + if (!transferGeometry(mainEclGrid, eclipseCase)) return false; progInfo.incrementProgress(); progInfo.setProgressDescription("Releasing reader memory"); @@ -370,19 +370,19 @@ bool RifReaderEclipseOutput::open(const QString& fileName, RigReservoir* reservo progInfo.setProgressDescription("Reading Result index"); progInfo.setNextProgressIncrement(60); - m_reservoir = reservoir; + m_reservoir = eclipseCase; - reservoir->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(this); - reservoir->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(this); + eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(this); + eclipseCase->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(this); // Build results meta data - if (!buildMetaData(reservoir)) return false; + if (!buildMetaData(eclipseCase)) return false; progInfo.incrementProgress(); progInfo.setNextProgressIncrement(8); progInfo.setProgressDescription("Reading Well information"); - readWellCells(reservoir); + readWellCells(eclipseCase); return true; @@ -391,7 +391,7 @@ bool RifReaderEclipseOutput::open(const QString& fileName, RigReservoir* reservo //-------------------------------------------------------------------------------------------------- /// Build meta data - get states and results info //-------------------------------------------------------------------------------------------------- -bool RifReaderEclipseOutput::buildMetaData(RigReservoir* reservoir) +bool RifReaderEclipseOutput::buildMetaData(RigEclipseCase* eclipseCase) { CVF_ASSERT(m_reservoir.notNull()); CVF_ASSERT(m_fileSet.size() > 0); @@ -579,9 +579,9 @@ bool RifReaderEclipseOutput::dynamicResult(const QString& result, PorosityModelR //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RifReaderEclipseOutput::readWellCells(RigReservoir* reservoir) +void RifReaderEclipseOutput::readWellCells(RigEclipseCase* eclipseCase) { - CVF_ASSERT(reservoir); + CVF_ASSERT(eclipseCase); if (m_dynamicResultsAccess.isNull()) return; @@ -590,9 +590,9 @@ void RifReaderEclipseOutput::readWellCells(RigReservoir* reservoir) m_dynamicResultsAccess->readWellData(ert_well_info); - RigMainGrid* mainGrid = reservoir->mainGrid(); + RigMainGrid* mainGrid = eclipseCase->mainGrid(); std::vector grids; - reservoir->allGrids(&grids); + eclipseCase->allGrids(&grids); cvf::Collection wells; caf::ProgressInfo progress(well_info_get_num_wells(ert_well_info), ""); @@ -752,7 +752,7 @@ void RifReaderEclipseOutput::readWellCells(RigReservoir* reservoir) well_info_free(ert_well_info); - reservoir->setWellResults(wells); + eclipseCase->setWellResults(wells); } diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.h b/ApplicationCode/FileInterface/RifReaderEclipseOutput.h index 4d53ceb6c9..92f2eda1ba 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.h +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.h @@ -43,18 +43,18 @@ public: RifReaderEclipseOutput(); virtual ~RifReaderEclipseOutput(); - bool open(const QString& fileName, RigReservoir* reservoir); + bool open(const QString& fileName, RigEclipseCase* eclipseCase); void close(); bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector* values); bool dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector* values); - static bool transferGeometry(const ecl_grid_type* mainEclGrid, RigReservoir* reservoir); + static bool transferGeometry(const ecl_grid_type* mainEclGrid, RigEclipseCase* eclipseCase); private: void ground(); - bool buildMetaData(RigReservoir* reservoir); - void readWellCells(RigReservoir* reservoir); + bool buildMetaData(RigEclipseCase* eclipseCase); + void readWellCells(RigEclipseCase* eclipseCase); void extractResultValuesBasedOnPorosityModel(PorosityModelResultType matrixOrFracture, std::vector* values, const std::vector& fileValues); @@ -67,7 +67,7 @@ private: QString m_fileName; // Name of file used to start accessing Eclipse output files QStringList m_fileSet; // Set of files in filename's path with same base name as filename - cvf::ref m_reservoir; + cvf::ref m_reservoir; QList m_timeSteps; diff --git a/ApplicationCode/FileInterface/RifReaderInterface.h b/ApplicationCode/FileInterface/RifReaderInterface.h index c03ddfd0f8..4de0ca8b34 100644 --- a/ApplicationCode/FileInterface/RifReaderInterface.h +++ b/ApplicationCode/FileInterface/RifReaderInterface.h @@ -26,7 +26,7 @@ #include -class RigReservoir; +class RigEclipseCase; //================================================================================================== // @@ -46,7 +46,7 @@ public: RifReaderInterface() {} virtual ~RifReaderInterface() {} - virtual bool open(const QString& fileName, RigReservoir* reservoir) = 0; + virtual bool open(const QString& fileName, RigEclipseCase* eclipseCase) = 0; virtual void close() = 0; virtual bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector* values) = 0; diff --git a/ApplicationCode/FileInterface/RifReaderMockModel.cpp b/ApplicationCode/FileInterface/RifReaderMockModel.cpp index 6f036e124e..43d7a76e74 100644 --- a/ApplicationCode/FileInterface/RifReaderMockModel.cpp +++ b/ApplicationCode/FileInterface/RifReaderMockModel.cpp @@ -25,13 +25,13 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifReaderMockModel::open(const QString& fileName, RigReservoir* reservoir) +bool RifReaderMockModel::open(const QString& fileName, RigEclipseCase* eclipseCase) { - m_reservoirBuilder.populateReservoir(reservoir); + m_reservoirBuilder.populateReservoir(eclipseCase); - m_reservoir = reservoir; + m_reservoir = eclipseCase; - RigReservoirCellResults* cellResults = reservoir->results(RifReaderInterface::MATRIX_RESULTS); + RigReservoirCellResults* cellResults = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS); QList dates; @@ -170,8 +170,8 @@ void RifReaderMockModel::addLocalGridRefinement(const cvf::Vec3st& minCellPositi //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RifReaderMockModel::populateReservoir(RigReservoir* reservoir) +void RifReaderMockModel::populateReservoir(RigEclipseCase* eclipseCase) { - m_reservoirBuilder.populateReservoir(reservoir); + m_reservoirBuilder.populateReservoir(eclipseCase); } diff --git a/ApplicationCode/FileInterface/RifReaderMockModel.h b/ApplicationCode/FileInterface/RifReaderMockModel.h index 73e1260f66..22f9dc05e3 100644 --- a/ApplicationCode/FileInterface/RifReaderMockModel.h +++ b/ApplicationCode/FileInterface/RifReaderMockModel.h @@ -33,17 +33,17 @@ public: void addLocalGridRefinement(const cvf::Vec3st& minCellPosition, const cvf::Vec3st& maxCellPosition, const cvf::Vec3st& singleCellRefinementFactors); - virtual bool open( const QString& fileName, RigReservoir* reservoir ); + virtual bool open( const QString& fileName, RigEclipseCase* eclipseCase ); virtual void close(); virtual bool staticResult( const QString& result, RifReaderInterface::PorosityModelResultType matrixOrFracture, std::vector* values ); virtual bool dynamicResult( const QString& result, RifReaderInterface::PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector* values ); private: - void populateReservoir(RigReservoir* reservoir); + void populateReservoir(RigEclipseCase* eclipseCase); bool inputProperty( const QString& propertyName, std::vector* values ); RigReservoirBuilderMock m_reservoirBuilder; - cvf::ref m_reservoir; + cvf::ref m_reservoir; }; diff --git a/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp b/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp index fac4a1b709..f27901c7d5 100644 --- a/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp @@ -96,8 +96,8 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo( const RigGridBase* grid = dynamic_cast(generator->activeGrid()); CVF_ASSERT(grid != NULL); - RigReservoir* reservoir = cellResultSlot->reservoirView()->eclipseCase()->reservoirData(); - CVF_ASSERT(reservoir != NULL); + RigEclipseCase* eclipseCase = cellResultSlot->reservoirView()->eclipseCase()->reservoirData(); + CVF_ASSERT(eclipseCase != NULL); cvf::ref cellCenterDataAccessObject = NULL; if (cellResultSlot->hasResult()) @@ -109,7 +109,7 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo( } RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel()); - cellCenterDataAccessObject = reservoir->dataAccessObject(grid, porosityModel, timeStepIndex, cellResultSlot->gridScalarIndex()); + cellCenterDataAccessObject = eclipseCase->dataAccessObject(grid, porosityModel, timeStepIndex, cellResultSlot->gridScalarIndex()); } CVF_ASSERT(cellEdgeResultSlot->hasResult()); @@ -128,7 +128,7 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo( { // Assuming static values to be mapped onto cell edge, always using time step zero // TODO: Now hardcoded matrix results, should it be possible to use fracture results? - daObj = reservoir->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, 0, resultIndices[cubeFaceIdx]); + daObj = eclipseCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, 0, resultIndices[cubeFaceIdx]); } cellEdgeDataAccessObjects.push_back(daObj.p()); diff --git a/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp b/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp index 5f04d3dfc5..7ff08c7f84 100644 --- a/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp @@ -223,8 +223,8 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot* RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel()); - RigReservoir* reservoir = cellResultSlot->reservoirView()->eclipseCase()->reservoirData(); - cvf::ref dataAccessObject = reservoir->dataAccessObject(m_grid.p(), porosityModel, resTimeStepIdx, scalarSetIndex); + RigEclipseCase* eclipseCase = cellResultSlot->reservoirView()->eclipseCase()->reservoirData(); + cvf::ref dataAccessObject = eclipseCase->dataAccessObject(m_grid.p(), porosityModel, resTimeStepIdx, scalarSetIndex); if (dataAccessObject.isNull()) return; diff --git a/ApplicationCode/ModelVisualization/RivReservoirPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirPartMgr.cpp index 369f3279f0..f2c6656d6f 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirPartMgr.cpp @@ -26,13 +26,13 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivReservoirPartMgr::clearAndSetReservoir(const RigReservoir* reservoir) +void RivReservoirPartMgr::clearAndSetReservoir(const RigEclipseCase* eclipseCase) { m_allGrids.clear(); - if (reservoir) + if (eclipseCase) { std::vector grids; - reservoir->allGrids(&grids); + eclipseCase->allGrids(&grids); for (size_t i = 0; i < grids.size() ; ++i) { m_allGrids.push_back(new RivGridPartMgr(grids[i], i) ); diff --git a/ApplicationCode/ModelVisualization/RivReservoirPartMgr.h b/ApplicationCode/ModelVisualization/RivReservoirPartMgr.h index 7ae4eb5b57..601558216f 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivReservoirPartMgr.h @@ -30,7 +30,7 @@ namespace cvf class RimResultSlot; class RimCellEdgeResultSlot; class RivGridPartMgr; -class RigReservoir; +class RigEclipseCase; //================================================================================================== @@ -43,7 +43,7 @@ class RigReservoir; class RivReservoirPartMgr: public cvf::Object { public: - void clearAndSetReservoir(const RigReservoir* reservoir); + void clearAndSetReservoir(const RigEclipseCase* eclipseCase); void setTransform(cvf::Transform* scaleTransform); void setCellVisibility(size_t gridIndex, cvf::UByteArray* cellVisibilities ); diff --git a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp index c7b15fb78a..89198d9ab4 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp @@ -125,10 +125,10 @@ void RivReservoirViewPartMgr::scheduleGeometryRegen(ReservoirGeometryCacheType g //-------------------------------------------------------------------------------------------------- void RivReservoirViewPartMgr::clearGeometryCache(ReservoirGeometryCacheType geomType) { - RigReservoir* reservoir = NULL; + RigEclipseCase* eclipseCase = NULL; if (m_reservoirView != NULL && m_reservoirView->eclipseCase()) { - reservoir = m_reservoirView->eclipseCase()->reservoirData(); + eclipseCase = m_reservoirView->eclipseCase()->reservoirData(); } if (geomType == PROPERTY_FILTERED) @@ -138,7 +138,7 @@ void RivReservoirViewPartMgr::clearGeometryCache(ReservoirGeometryCacheType geom m_propFilteredGeometryFramesNeedsRegen[i] = true; if (m_propFilteredGeometryFrames[i].notNull()) { - m_propFilteredGeometryFrames[i]->clearAndSetReservoir(reservoir); + m_propFilteredGeometryFrames[i]->clearAndSetReservoir(eclipseCase); m_propFilteredGeometryFrames[i]->setTransform(m_scaleTransform.p()); } } @@ -150,7 +150,7 @@ void RivReservoirViewPartMgr::clearGeometryCache(ReservoirGeometryCacheType geom m_propFilteredWellGeometryFramesNeedsRegen[i] = true; if (m_propFilteredWellGeometryFrames[i].notNull()) { - m_propFilteredWellGeometryFrames[i]->clearAndSetReservoir(reservoir); + m_propFilteredWellGeometryFrames[i]->clearAndSetReservoir(eclipseCase); m_propFilteredWellGeometryFrames[i]->setTransform(m_scaleTransform.p()); } } @@ -158,7 +158,7 @@ void RivReservoirViewPartMgr::clearGeometryCache(ReservoirGeometryCacheType geom else { m_geometriesNeedsRegen[geomType] = true; - m_geometries[geomType].clearAndSetReservoir(reservoir); + m_geometries[geomType].clearAndSetReservoir(eclipseCase); m_geometries[geomType].setTransform(m_scaleTransform.p()); } } @@ -224,7 +224,7 @@ void RivReservoirViewPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicL //-------------------------------------------------------------------------------------------------- void RivReservoirViewPartMgr::createGeometry(ReservoirGeometryCacheType geometryType) { - RigReservoir* res = m_reservoirView->eclipseCase()->reservoirData(); + RigEclipseCase* res = m_reservoirView->eclipseCase()->reservoirData(); m_geometries[geometryType].clearAndSetReservoir(res); m_geometries[geometryType].setTransform(m_scaleTransform.p()); std::vector grids; @@ -246,8 +246,8 @@ void RivReservoirViewPartMgr::createGeometry(ReservoirGeometryCacheType geometry //-------------------------------------------------------------------------------------------------- void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility, ReservoirGeometryCacheType geometryType, RigGridBase* grid, size_t gridIdx) { - RigReservoir* reservoir = m_reservoirView->eclipseCase()->reservoirData(); - RigActiveCellInfo* activeCellInfo = reservoir->activeCellInfo(); + RigEclipseCase* eclipseCase = m_reservoirView->eclipseCase()->reservoirData(); + RigActiveCellInfo* activeCellInfo = eclipseCase->activeCellInfo(); switch (geometryType) { @@ -370,7 +370,7 @@ void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility, //-------------------------------------------------------------------------------------------------- void RivReservoirViewPartMgr::createPropertyFilteredGeometry(size_t frameIndex) { - RigReservoir* res = m_reservoirView->eclipseCase()->reservoirData(); + RigEclipseCase* res = m_reservoirView->eclipseCase()->reservoirData(); if ( frameIndex >= m_propFilteredGeometryFrames.size()) { @@ -417,7 +417,7 @@ void RivReservoirViewPartMgr::createPropertyFilteredGeometry(size_t frameIndex) //-------------------------------------------------------------------------------------------------- void RivReservoirViewPartMgr::createPropertyFilteredWellGeometry(size_t frameIndex) { - RigReservoir* res = m_reservoirView->eclipseCase()->reservoirData(); + RigEclipseCase* res = m_reservoirView->eclipseCase()->reservoirData(); if ( frameIndex >= m_propFilteredWellGeometryFrames.size()) { @@ -605,9 +605,9 @@ void RivReservoirViewPartMgr::computePropertyVisibility(cvf::UByteArray* cellVis const RimCellFilter::FilterModeType filterType = (*pfIt)->filterMode(); RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel((*pfIt)->resultDefinition()->porosityModel()); - RigReservoir* reservoir = propFilterColl->reservoirView()->eclipseCase()->reservoirData(); + RigEclipseCase* eclipseCase = propFilterColl->reservoirView()->eclipseCase()->reservoirData(); - cvf::ref dataAccessObject = reservoir->dataAccessObject(grid, porosityModel, timeStepIndex, scalarResultIndex); + cvf::ref dataAccessObject = eclipseCase->dataAccessObject(grid, porosityModel, timeStepIndex, scalarResultIndex); CVF_ASSERT(dataAccessObject.notNull()); #pragma omp parallel for schedule(dynamic) diff --git a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp index 8eba80f828..a1abf0a727 100644 --- a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp @@ -72,7 +72,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex) if (m_rimReservoirView.isNull()) return; - RigReservoir* rigReservoir = m_rimReservoirView->eclipseCase()->reservoirData(); + RigEclipseCase* rigReservoir = m_rimReservoirView->eclipseCase()->reservoirData(); RimWell* well = m_rimWell; diff --git a/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp index 46929737c8..944ba06fa6 100644 --- a/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp @@ -158,7 +158,7 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector bool isAutoDetectBranches = m_rimReservoirView->wellCollection()->isAutoDetectingBranches(); - RigReservoir* rigReservoir = m_rimReservoirView->eclipseCase()->reservoirData(); + RigEclipseCase* rigReservoir = m_rimReservoirView->eclipseCase()->reservoirData(); RigWellResults* wellResults = m_rimWell->wellResults(); const RigWellResultFrame& staticWellFrame = m_rimWell->wellResults()->m_staticWellCells; diff --git a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp index 21e396d441..e701534a45 100644 --- a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp @@ -82,8 +82,8 @@ void RimInputReservoir::openDataFileSet(const QStringList& filenames) if (m_rigReservoir.isNull()) { - RigReservoir* reservoir = new RigReservoir; - m_rigReservoir = reservoir; + RigEclipseCase* eclipseCase = new RigEclipseCase; + m_rigReservoir = eclipseCase; } // First find and read the grid data @@ -168,15 +168,15 @@ bool RimInputReservoir::openEclipseGridFile() } else { - RigReservoir* reservoir = new RigReservoir; + RigEclipseCase* eclipseCase = new RigEclipseCase; readerInterface = new RifReaderEclipseInput; - if (!readerInterface->open(m_gridFileName, reservoir)) + if (!readerInterface->open(m_gridFileName, eclipseCase)) { - delete reservoir; + delete eclipseCase; return false; } - m_rigReservoir = reservoir; + m_rigReservoir = eclipseCase; loadAndSyncronizeInputProperties(); } @@ -372,7 +372,7 @@ void RimInputReservoir::removeProperty(RimInputProperty* inputProperty) //-------------------------------------------------------------------------------------------------- cvf::ref RimInputReservoir::createMockModel(QString modelName) { - cvf::ref reservoir = new RigReservoir; + cvf::ref reservoir = new RigEclipseCase; cvf::ref mockFileInterface = new RifReaderMockModel; if (modelName == "Input Mock Debug Model Simple") diff --git a/ApplicationCode/ProjectDataModel/RimReservoir.cpp b/ApplicationCode/ProjectDataModel/RimReservoir.cpp index 4d9f033285..7a5359b845 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoir.cpp @@ -53,7 +53,7 @@ RimReservoir::RimReservoir() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigReservoir* RimReservoir::reservoirData() +RigEclipseCase* RimReservoir::reservoirData() { return m_rigReservoir.p(); } @@ -61,7 +61,7 @@ RigReservoir* RimReservoir::reservoirData() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const RigReservoir* RimReservoir::reservoirData() const +const RigEclipseCase* RimReservoir::reservoirData() const { return m_rigReservoir.p(); } diff --git a/ApplicationCode/ProjectDataModel/RimReservoir.h b/ApplicationCode/ProjectDataModel/RimReservoir.h index 0a8be97631..de173d9491 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoir.h +++ b/ApplicationCode/ProjectDataModel/RimReservoir.h @@ -26,7 +26,7 @@ class QString; -class RigReservoir; +class RigEclipseCase; class RigGridBase; class RimReservoirView; @@ -46,8 +46,8 @@ public: virtual bool openEclipseGridFile() = 0; - RigReservoir* reservoirData(); - const RigReservoir* reservoirData() const; + RigEclipseCase* reservoirData(); + const RigEclipseCase* reservoirData() const; RimReservoirView* createAndAddReservoirView(); void removeReservoirView(RimReservoirView* reservoirView); @@ -71,6 +71,6 @@ protected: virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ); protected: - cvf::ref m_rigReservoir; + cvf::ref m_rigReservoir; }; diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp index dfadff16e9..e90c66bf4c 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp @@ -835,20 +835,20 @@ bool RimReservoirView::pickInfo(size_t gridIndex, size_t cellIndex, const cvf::V if (m_reservoir) { - const RigReservoir* reservoir = m_reservoir->reservoirData(); - if (reservoir) + const RigEclipseCase* eclipseCase = m_reservoir->reservoirData(); + if (eclipseCase) { size_t i = 0; size_t j = 0; size_t k = 0; - if (reservoir->grid(gridIndex)->ijkFromCellIndex(cellIndex, &i, &j, &k)) + if (eclipseCase->grid(gridIndex)->ijkFromCellIndex(cellIndex, &i, &j, &k)) { // Adjust to 1-based Eclipse indexing i++; j++; k++; - cvf::Vec3d domainCoord = point + reservoir->grid(gridIndex)->displayModelOffset(); + cvf::Vec3d domainCoord = point + eclipseCase->grid(gridIndex)->displayModelOffset(); pickInfoText->sprintf("Hit grid %u, cell [%u, %u, %u], intersection point: [E: %.2f, N: %.2f, Depth: %.2f]", static_cast(gridIndex), static_cast(i), static_cast(j), static_cast(k), domainCoord.x(), domainCoord.y(), -domainCoord.z()); return true; @@ -868,14 +868,14 @@ void RimReservoirView::appendCellResultInfo(size_t gridIndex, size_t cellIndex, if (m_reservoir && m_reservoir->reservoirData()) { - const RigReservoir* reservoir = m_reservoir->reservoirData(); - const RigGridBase* grid = reservoir->grid(gridIndex); - const RigActiveCellInfo* activeCellInfo = reservoir->activeCellInfo(); + const RigEclipseCase* eclipseCase = m_reservoir->reservoirData(); + const RigGridBase* grid = eclipseCase->grid(gridIndex); + const RigActiveCellInfo* activeCellInfo = eclipseCase->activeCellInfo(); if (this->cellResult()->hasResult()) { RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResult()->porosityModel()); - cvf::ref dataAccessObject = reservoir->dataAccessObject(grid, porosityModel, m_currentTimeStep, this->cellResult()->gridScalarIndex()); + cvf::ref dataAccessObject = eclipseCase->dataAccessObject(grid, porosityModel, m_currentTimeStep, this->cellResult()->gridScalarIndex()); if (dataAccessObject.notNull()) { double scalarValue = dataAccessObject->cellScalar(cellIndex); @@ -896,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 RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResult()->porosityModel()); - cvf::ref dataAccessObject = reservoir->dataAccessObject(grid, porosityModel, 0, resultIndices[idx]); + cvf::ref dataAccessObject = eclipseCase->dataAccessObject(grid, porosityModel, 0, resultIndices[idx]); if (dataAccessObject.notNull()) { double scalarValue = dataAccessObject->cellScalar(cellIndex); @@ -1034,11 +1034,11 @@ void RimReservoirView::updateLegends() return; } - RigReservoir* reservoir = m_reservoir->reservoirData(); - CVF_ASSERT(reservoir); + RigEclipseCase* eclipseCase = m_reservoir->reservoirData(); + CVF_ASSERT(eclipseCase); RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResult()->porosityModel()); - RigReservoirCellResults* results = reservoir->results(porosityModel); + RigReservoirCellResults* results = eclipseCase->results(porosityModel); CVF_ASSERT(results); if (this->cellResult()->hasResult()) diff --git a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp index 32314a69f4..717403af76 100644 --- a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp @@ -69,15 +69,15 @@ bool RimResultReservoir::openEclipseGridFile() return false; } - RigReservoir* reservoir = new RigReservoir; + RigEclipseCase* eclipseCase = new RigEclipseCase; readerInterface = new RifReaderEclipseOutput; - if (!readerInterface->open(fname, reservoir)) + if (!readerInterface->open(fname, eclipseCase)) { - delete reservoir; + delete eclipseCase; return false; } - m_rigReservoir = reservoir; + m_rigReservoir = eclipseCase; } progInfo.incrementProgress(); @@ -102,7 +102,7 @@ bool RimResultReservoir::openEclipseGridFile() cvf::ref RimResultReservoir::createMockModel(QString modelName) { cvf::ref mockFileInterface = new RifReaderMockModel; - cvf::ref reservoir = new RigReservoir; + cvf::ref reservoir = new RigEclipseCase; if (modelName == "Result Mock Debug Model Simple") { diff --git a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp index 909490b89a..f291ddc390 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp @@ -200,22 +200,22 @@ protected: /// //-------------------------------------------------------------------------------------------------- cvf::ref RigGridScalarDataAccessFactory::createDataAccessObject(const RigGridBase* grid, - const RigReservoir* reservoir, + const RigEclipseCase* eclipseCase, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStepIndex, size_t scalarSetIndex) { CVF_ASSERT(grid); - CVF_ASSERT(reservoir); - CVF_ASSERT(reservoir->results(porosityModel)); - CVF_ASSERT(reservoir->activeCellInfo()); + CVF_ASSERT(eclipseCase); + CVF_ASSERT(eclipseCase->results(porosityModel)); + CVF_ASSERT(eclipseCase->activeCellInfo()); - if (!grid || !reservoir || !reservoir->results(porosityModel) || !reservoir->activeCellInfo()) + if (!grid || !eclipseCase || !eclipseCase->results(porosityModel) || !eclipseCase->activeCellInfo()) { return NULL; } - const std::vector< std::vector > & scalarSetResults = reservoir->results(porosityModel)->cellScalarResults(scalarSetIndex); + const std::vector< std::vector > & scalarSetResults = eclipseCase->results(porosityModel)->cellScalarResults(scalarSetIndex); if (timeStepIndex >= scalarSetResults.size()) { return NULL; @@ -224,17 +224,17 @@ cvf::ref RigGridScalarDataAccessFactory::create const std::vector* resultValues = &(scalarSetResults[timeStepIndex]); - bool useGlobalActiveIndex = reservoir->results(porosityModel)->isUsingGlobalActiveIndex(scalarSetIndex); + bool useGlobalActiveIndex = eclipseCase->results(porosityModel)->isUsingGlobalActiveIndex(scalarSetIndex); if (useGlobalActiveIndex) { if (porosityModel == RifReaderInterface::MATRIX_RESULTS) { - cvf::ref object = new RigGridMatrixActiveCellsScalarDataAccess(grid, resultValues, reservoir->activeCellInfo()); + cvf::ref object = new RigGridMatrixActiveCellsScalarDataAccess(grid, resultValues, eclipseCase->activeCellInfo()); return object; } else { - cvf::ref object = new RigGridFractureActiveCellsScalarDataAccess(grid, resultValues, reservoir->activeCellInfo()); + cvf::ref object = new RigGridFractureActiveCellsScalarDataAccess(grid, resultValues, eclipseCase->activeCellInfo()); return object; } } diff --git a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.h b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.h index 708d137617..520750bf12 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.h +++ b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.h @@ -30,7 +30,7 @@ class RigGridScalarDataAccessFactory { public: static cvf::ref createDataAccessObject(const RigGridBase* grid, - const RigReservoir* reservoir, + const RigEclipseCase* eclipseCase, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStepIndex, size_t scalarSetIndex); diff --git a/ApplicationCode/ReservoirDataModel/RigReservoir.cpp b/ApplicationCode/ReservoirDataModel/RigReservoir.cpp index 10ac75eaa3..294be83600 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoir.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoir.cpp @@ -25,7 +25,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigReservoir::RigReservoir() +RigEclipseCase::RigEclipseCase() { m_mainGrid = new RigMainGrid(); @@ -36,7 +36,7 @@ RigReservoir::RigReservoir() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigReservoir::~RigReservoir() +RigEclipseCase::~RigEclipseCase() { } @@ -44,7 +44,7 @@ RigReservoir::~RigReservoir() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigReservoir::computeFaults() +void RigEclipseCase::computeFaults() { std::vector grids; allGrids(&grids); @@ -59,7 +59,7 @@ void RigReservoir::computeFaults() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigReservoir::allGrids(std::vector* grids) +void RigEclipseCase::allGrids(std::vector* grids) { CVF_ASSERT(grids); @@ -73,7 +73,7 @@ void RigReservoir::allGrids(std::vector* grids) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigReservoir::allGrids(std::vector* grids) const +void RigEclipseCase::allGrids(std::vector* grids) const { CVF_ASSERT(grids); size_t i; @@ -86,7 +86,7 @@ void RigReservoir::allGrids(std::vector* grids) const //-------------------------------------------------------------------------------------------------- /// Get grid by index. The main grid has index 0, so the first lgr has index 1 //-------------------------------------------------------------------------------------------------- -const RigGridBase* RigReservoir::grid(size_t index) const +const RigGridBase* RigEclipseCase::grid(size_t index) const { return m_mainGrid->gridByIndex(index); } @@ -94,7 +94,7 @@ const RigGridBase* RigReservoir::grid(size_t index) const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigReservoir::computeWellCellsPrGrid() +void RigEclipseCase::computeWellCellsPrGrid() { // If we have computed this already, return if (m_wellCellsInGrid.size()) return; @@ -157,7 +157,7 @@ void RigReservoir::computeWellCellsPrGrid() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigReservoir::setWellResults(const cvf::Collection& data) +void RigEclipseCase::setWellResults(const cvf::Collection& data) { m_wellResults = data; m_wellCellsInGrid.clear(); @@ -167,7 +167,7 @@ void RigReservoir::setWellResults(const cvf::Collection& data) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::UByteArray* RigReservoir::wellCellsInGrid(size_t gridIndex) +cvf::UByteArray* RigEclipseCase::wellCellsInGrid(size_t gridIndex) { computeWellCellsPrGrid(); CVF_ASSERT(gridIndex < m_wellCellsInGrid.size()); @@ -178,7 +178,7 @@ cvf::UByteArray* RigReservoir::wellCellsInGrid(size_t gridIndex) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigCell& RigReservoir::cellFromWellResultCell(const RigWellResultCell& wellResultCell) +RigCell& RigEclipseCase::cellFromWellResultCell(const RigWellResultCell& wellResultCell) { size_t gridIndex = wellResultCell.m_gridIndex; size_t gridCellIndex = wellResultCell.m_gridCellIndex; @@ -192,7 +192,7 @@ RigCell& RigReservoir::cellFromWellResultCell(const RigWellResultCell& wellResul //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RigReservoir::findSharedSourceFace(cvf::StructGridInterface::FaceType& sharedSourceFace,const RigWellResultCell& sourceWellCellResult, const RigWellResultCell& otherWellCellResult) const +bool RigEclipseCase::findSharedSourceFace(cvf::StructGridInterface::FaceType& sharedSourceFace,const RigWellResultCell& sourceWellCellResult, const RigWellResultCell& otherWellCellResult) const { size_t gridIndex = sourceWellCellResult.m_gridIndex; size_t gridCellIndex = sourceWellCellResult.m_gridCellIndex; @@ -263,7 +263,7 @@ public: //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigReservoir::computeActiveCellData() +void RigEclipseCase::computeActiveCellData() { CellRangeBB matrixModelActiveBB; CellRangeBB fractureModelActiveBB; @@ -292,7 +292,7 @@ void RigReservoir::computeActiveCellData() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigReservoir::computeCachedData() +void RigEclipseCase::computeCachedData() { computeFaults(); computeActiveCellData(); @@ -302,7 +302,7 @@ void RigReservoir::computeCachedData() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigActiveCellInfo* RigReservoir::activeCellInfo() +RigActiveCellInfo* RigEclipseCase::activeCellInfo() { return &m_activeCellInfo; } @@ -310,7 +310,7 @@ RigActiveCellInfo* RigReservoir::activeCellInfo() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const RigActiveCellInfo* RigReservoir::activeCellInfo() const +const RigActiveCellInfo* RigEclipseCase::activeCellInfo() const { return &m_activeCellInfo; } @@ -318,7 +318,7 @@ const RigActiveCellInfo* RigReservoir::activeCellInfo() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigReservoir::computeActiveCellsGeometryBoundingBox() +void RigEclipseCase::computeActiveCellsGeometryBoundingBox() { if (m_mainGrid.isNull()) { @@ -358,7 +358,7 @@ void RigReservoir::computeActiveCellsGeometryBoundingBox() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigReservoirCellResults* RigReservoir::results(RifReaderInterface::PorosityModelResultType porosityModel) +RigReservoirCellResults* RigEclipseCase::results(RifReaderInterface::PorosityModelResultType porosityModel) { if (porosityModel == RifReaderInterface::MATRIX_RESULTS) { @@ -371,7 +371,7 @@ RigReservoirCellResults* RigReservoir::results(RifReaderInterface::PorosityModel //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const RigReservoirCellResults* RigReservoir::results(RifReaderInterface::PorosityModelResultType porosityModel) const +const RigReservoirCellResults* RigEclipseCase::results(RifReaderInterface::PorosityModelResultType porosityModel) const { if (porosityModel == RifReaderInterface::MATRIX_RESULTS) { @@ -384,7 +384,7 @@ const RigReservoirCellResults* RigReservoir::results(RifReaderInterface::Porosit //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RigReservoir::dataAccessObject(const RigGridBase* grid, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStepIndex, size_t scalarSetIndex) const +cvf::ref RigEclipseCase::dataAccessObject(const RigGridBase* grid, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStepIndex, size_t scalarSetIndex) const { if (timeStepIndex != cvf::UNDEFINED_SIZE_T && scalarSetIndex != cvf::UNDEFINED_SIZE_T) diff --git a/ApplicationCode/ReservoirDataModel/RigReservoir.h b/ApplicationCode/ReservoirDataModel/RigReservoir.h index 9f25da2ab0..bd40b70c8c 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoir.h +++ b/ApplicationCode/ReservoirDataModel/RigReservoir.h @@ -30,11 +30,11 @@ class RigReservoirCellResults; -class RigReservoir: public cvf::Object +class RigEclipseCase: public cvf::Object { public: - RigReservoir(); - ~RigReservoir(); + RigEclipseCase(); + ~RigEclipseCase(); RigMainGrid* mainGrid() { return m_mainGrid.p(); } const RigMainGrid* mainGrid() const { return m_mainGrid.p(); } diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp index 8a2679c2d4..3be1a70a35 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp @@ -170,15 +170,15 @@ void RigReservoirBuilderMock::appendCells(size_t nodeStartIndex, size_t cellCoun //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigReservoirBuilderMock::populateReservoir(RigReservoir* reservoir) +void RigReservoirBuilderMock::populateReservoir(RigEclipseCase* eclipseCase) { - std::vector& mainGridNodes = reservoir->mainGrid()->nodes(); + std::vector& mainGridNodes = eclipseCase->mainGrid()->nodes(); appendNodes(m_minWorldCoordinate, m_maxWorldCoordinate, cellDimension(), mainGridNodes); size_t mainGridNodeCount = mainGridNodes.size(); size_t mainGridCellCount = mainGridNodeCount / 8; // Must create cells in main grid here, as this information is used when creating LGRs - appendCells(0, mainGridCellCount, reservoir->mainGrid(), reservoir->mainGrid()->cells()); + appendCells(0, mainGridCellCount, eclipseCase->mainGrid(), eclipseCase->mainGrid()->cells()); size_t totalCellCount = mainGridCellCount; @@ -206,9 +206,9 @@ void RigReservoirBuilderMock::populateReservoir(RigReservoir* reservoir) } // Create local grid and set local grid dimensions - RigLocalGrid* localGrid = new RigLocalGrid(reservoir->mainGrid()); - reservoir->mainGrid()->addLocalGrid(localGrid); - localGrid->setParentGrid(reservoir->mainGrid()); + RigLocalGrid* localGrid = new RigLocalGrid(eclipseCase->mainGrid()); + eclipseCase->mainGrid()->addLocalGrid(localGrid); + localGrid->setParentGrid(eclipseCase->mainGrid()); localGrid->setIndexToStartOfCells(mainGridNodes.size() / 8); cvf::Vec3st gridPointDimensions( @@ -221,13 +221,13 @@ void RigReservoirBuilderMock::populateReservoir(RigReservoir* reservoir) size_t cellIdx; for (cellIdx = 0; cellIdx < mainGridIndicesWithSubGrid.size(); cellIdx++) { - RigCell& cell = reservoir->mainGrid()->cells()[mainGridIndicesWithSubGrid[cellIdx]]; + RigCell& cell = eclipseCase->mainGrid()->cells()[mainGridIndicesWithSubGrid[cellIdx]]; caf::SizeTArray8& indices = cell.cornerIndices(); int nodeIdx; for (nodeIdx = 0; nodeIdx < 8; nodeIdx++) { - bb.add(reservoir->mainGrid()->nodes()[indices[nodeIdx]]); + bb.add(eclipseCase->mainGrid()->nodes()[indices[nodeIdx]]); } // Deactivate cell in main grid cell.setSubGrid(localGrid); @@ -237,13 +237,13 @@ void RigReservoirBuilderMock::populateReservoir(RigReservoir* reservoir) appendNodes(bb.min(), bb.max(), lgrCellDimensions, mainGridNodes); size_t subGridCellCount = (mainGridNodes.size() / 8) - totalCellCount; - appendCells(totalCellCount*8, subGridCellCount, localGrid, reservoir->mainGrid()->cells()); + appendCells(totalCellCount*8, subGridCellCount, localGrid, eclipseCase->mainGrid()->cells()); totalCellCount += subGridCellCount; } - reservoir->mainGrid()->setGridPointDimensions(m_gridPointDimensions); + eclipseCase->mainGrid()->setGridPointDimensions(m_gridPointDimensions); - addWellData(reservoir, reservoir->mainGrid()); + addWellData(eclipseCase, eclipseCase->mainGrid()); } @@ -268,7 +268,7 @@ void RigReservoirBuilderMock::setWorldCoordinates(cvf::Vec3d minWorldCoordinate, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RigReservoirBuilderMock::inputProperty(RigReservoir* reservoir, const QString& propertyName, std::vector* values) +bool RigReservoirBuilderMock::inputProperty(RigEclipseCase* eclipseCase, const QString& propertyName, std::vector* values) { size_t k; @@ -278,7 +278,7 @@ bool RigReservoirBuilderMock::inputProperty(RigReservoir* reservoir, const QStri /* generate secret number: */ int iSecret = rand() % 20 + 1; - for (k = 0; k < reservoir->mainGrid()->cells().size(); k++) + for (k = 0; k < eclipseCase->mainGrid()->cells().size(); k++) { values->push_back(k * iSecret); } @@ -289,18 +289,18 @@ bool RigReservoirBuilderMock::inputProperty(RigReservoir* reservoir, const QStri //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RigReservoirBuilderMock::staticResult(RigReservoir* reservoir, const QString& result, std::vector* values) +bool RigReservoirBuilderMock::staticResult(RigEclipseCase* eclipseCase, const QString& result, std::vector* values) { size_t k; - for (k = 0; k < reservoir->mainGrid()->cells().size(); k++) + for (k = 0; k < eclipseCase->mainGrid()->cells().size(); k++) { - RigCell& cell = reservoir->mainGrid()->cells()[k]; + RigCell& cell = eclipseCase->mainGrid()->cells()[k]; if (cell.isActiveInMatrixModel()) { - if (cell.hostGrid() == reservoir->mainGrid()) + if (cell.hostGrid() == eclipseCase->mainGrid()) { - values->push_back((k * 2) % reservoir->mainGrid()->cells().size()); + values->push_back((k * 2) % eclipseCase->mainGrid()->cells().size()); } else { @@ -315,7 +315,7 @@ bool RigReservoirBuilderMock::staticResult(RigReservoir* reservoir, const QStrin //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RigReservoirBuilderMock::dynamicResult(RigReservoir* reservoir, const QString& result, size_t stepIndex, std::vector* values) +bool RigReservoirBuilderMock::dynamicResult(RigEclipseCase* eclipseCase, const QString& result, size_t stepIndex, std::vector* values) { int resultIndex = 1; @@ -330,14 +330,14 @@ bool RigReservoirBuilderMock::dynamicResult(RigReservoir* reservoir, const QStri double offsetValue = 100 * resultIndex; size_t k; - for (k = 0; k < reservoir->mainGrid()->cells().size(); k++) + for (k = 0; k < eclipseCase->mainGrid()->cells().size(); k++) { - RigCell& cell = reservoir->mainGrid()->cells()[k]; + RigCell& cell = eclipseCase->mainGrid()->cells()[k]; if (cell.isActiveInMatrixModel()) { - if (cell.hostGrid() == reservoir->mainGrid()) + if (cell.hostGrid() == eclipseCase->mainGrid()) { - double val = offsetValue + scaleValue * ( (stepIndex * 1000 + k) % reservoir->mainGrid()->cells().size() ); + double val = offsetValue + scaleValue * ( (stepIndex * 1000 + k) % eclipseCase->mainGrid()->cells().size() ); values->push_back(val); } else @@ -359,9 +359,9 @@ bool RigReservoirBuilderMock::dynamicResult(RigReservoir* reservoir, const QStri //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigReservoirBuilderMock::addWellData(RigReservoir* reservoir, RigGridBase* grid) +void RigReservoirBuilderMock::addWellData(RigEclipseCase* eclipseCase, RigGridBase* grid) { - CVF_ASSERT(reservoir); + CVF_ASSERT(eclipseCase); CVF_ASSERT(grid); cvf::Vec3st dim = grid->gridPointDimensions(); @@ -469,6 +469,6 @@ void RigReservoirBuilderMock::addWellData(RigReservoir* reservoir, RigGridBase* wells.push_back(wellCellsTimeHistory.p()); } - reservoir->setWellResults(wells); + eclipseCase->setWellResults(wells); } diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.h b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.h index 2d802b03d5..1707d413e1 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.h +++ b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.h @@ -55,14 +55,14 @@ public: void addLocalGridRefinement(const cvf::Vec3st& minCellPosition, const cvf::Vec3st& maxCellPosition, const cvf::Vec3st& singleCellRefinementFactors); - void populateReservoir(RigReservoir* reservoir); + void populateReservoir(RigEclipseCase* eclipseCase); - bool inputProperty(RigReservoir* reservoir, const QString& propertyName, std::vector* values ); - bool staticResult(RigReservoir* reservoir, const QString& result, std::vector* values ); - bool dynamicResult(RigReservoir* reservoir, const QString& result, size_t stepIndex, std::vector* values ); + bool inputProperty(RigEclipseCase* eclipseCase, const QString& propertyName, std::vector* values ); + bool staticResult(RigEclipseCase* eclipseCase, const QString& result, std::vector* values ); + bool dynamicResult(RigEclipseCase* eclipseCase, const QString& result, size_t stepIndex, std::vector* values ); private: - void addWellData(RigReservoir* reservoir, RigGridBase* grid); + void addWellData(RigEclipseCase* eclipseCase, RigGridBase* grid); static void appendCells(size_t nodeStartIndex, size_t cellCount, RigGridBase* hostGrid, std::vector& cells); static void appendNodes(const cvf::Vec3d& min, const cvf::Vec3d& max, const cvf::Vec3st& cubeDimension, std::vector& nodes); From a09dba2670d211d66dd13e7760bd1870acfe1b22 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 13 Feb 2013 13:33:35 +0100 Subject: [PATCH 019/242] File rename from RigReservoir to RigEclipseCase p4#: 20503 --- ApplicationCode/Application/RIApplication.cpp | 2 +- ApplicationCode/CMakeLists.txt | 2 +- .../FileInterface/FileInterface_UnitTests/CMakeLists.txt | 2 +- .../FileInterface/FileInterface_UnitTests/Ert-Test.cpp | 2 +- .../FileInterface_UnitTests/RifReaderEclipseOutput-Test.cpp | 2 +- ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp | 2 +- ApplicationCode/FileInterface/RifReaderEclipseInput.cpp | 2 +- ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp | 2 +- .../ModelVisualization/RivCellEdgeEffectGenerator.cpp | 2 +- ApplicationCode/ModelVisualization/RivGridPartMgr.cpp | 2 +- ApplicationCode/ModelVisualization/RivReservoirPartMgr.cpp | 2 +- ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp | 2 +- ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp | 2 +- ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp | 2 +- ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp | 2 +- ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp | 2 +- ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp | 2 +- .../ProjectDataModel/RimCellRangeFilterCollection.cpp | 2 +- ApplicationCode/ProjectDataModel/RimInputReservoir.cpp | 2 +- ApplicationCode/ProjectDataModel/RimReservoir.cpp | 2 +- ApplicationCode/ProjectDataModel/RimReservoirView.cpp | 2 +- ApplicationCode/ProjectDataModel/RimResultDefinition.cpp | 2 +- ApplicationCode/ProjectDataModel/RimResultReservoir.cpp | 2 +- .../ReservoirDataModel_UnitTests/RigReservoir-Test.cpp | 2 +- .../ReservoirDataModel/{RigReservoir.cpp => RigEclipseCase.cpp} | 2 +- .../ReservoirDataModel/{RigReservoir.h => RigEclipseCase.h} | 0 ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp | 2 +- ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp | 2 +- ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.h | 2 +- ApplicationCode/SocketInterface/RiaSocketServer.cpp | 2 +- ApplicationCode/UserInterface/RIMainWindow.cpp | 2 +- ApplicationCode/UserInterface/RIViewer.cpp | 2 +- 32 files changed, 31 insertions(+), 31 deletions(-) rename ApplicationCode/ReservoirDataModel/{RigReservoir.cpp => RigEclipseCase.cpp} (99%) rename ApplicationCode/ReservoirDataModel/{RigReservoir.h => RigEclipseCase.h} (100%) diff --git a/ApplicationCode/Application/RIApplication.cpp b/ApplicationCode/Application/RIApplication.cpp index 4222dfd27e..1423818f87 100644 --- a/ApplicationCode/Application/RIApplication.cpp +++ b/ApplicationCode/Application/RIApplication.cpp @@ -39,7 +39,7 @@ #include "RimInputReservoir.h" #include "RimReservoirView.h" -#include "RigReservoir.h" +#include "RigEclipseCase.h" #include "RigCell.h" #include "RigReservoirBuilderMock.h" diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index b866c131bc..fa78527b25 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -99,7 +99,7 @@ list( APPEND CPP_SOURCES ReservoirDataModel/RigReservoirCellResults.cpp ReservoirDataModel/RigLocalGrid.cpp ReservoirDataModel/RigMainGrid.cpp - ReservoirDataModel/RigReservoir.cpp + ReservoirDataModel/RigEclipseCase.cpp ReservoirDataModel/RigReservoirBuilderMock.cpp ReservoirDataModel/RigWellResults.cpp ReservoirDataModel/RigGridScalarDataAccess.cpp diff --git a/ApplicationCode/FileInterface/FileInterface_UnitTests/CMakeLists.txt b/ApplicationCode/FileInterface/FileInterface_UnitTests/CMakeLists.txt index ab6a2ed919..deb53d65b9 100644 --- a/ApplicationCode/FileInterface/FileInterface_UnitTests/CMakeLists.txt +++ b/ApplicationCode/FileInterface/FileInterface_UnitTests/CMakeLists.txt @@ -36,7 +36,7 @@ set( RESERVOIRDATAMODEL_CPP_SOURCES ${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigGridBase.cpp ${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigLocalGrid.cpp ${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp - ${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigReservoir.cpp + ${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp ${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp ${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp ${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigWellResults.cpp diff --git a/ApplicationCode/FileInterface/FileInterface_UnitTests/Ert-Test.cpp b/ApplicationCode/FileInterface/FileInterface_UnitTests/Ert-Test.cpp index 7a2aef0cfd..02324bd68a 100644 --- a/ApplicationCode/FileInterface/FileInterface_UnitTests/Ert-Test.cpp +++ b/ApplicationCode/FileInterface/FileInterface_UnitTests/Ert-Test.cpp @@ -37,7 +37,7 @@ #include "gtest/gtest.h" -#include "RigReservoir.h" +#include "RigEclipseCase.h" #include "RifReaderEclipseInput.h" #if 0 diff --git a/ApplicationCode/FileInterface/FileInterface_UnitTests/RifReaderEclipseOutput-Test.cpp b/ApplicationCode/FileInterface/FileInterface_UnitTests/RifReaderEclipseOutput-Test.cpp index b43d9c324a..bb81b1f16d 100644 --- a/ApplicationCode/FileInterface/FileInterface_UnitTests/RifReaderEclipseOutput-Test.cpp +++ b/ApplicationCode/FileInterface/FileInterface_UnitTests/RifReaderEclipseOutput-Test.cpp @@ -21,7 +21,7 @@ #include "RIStdInclude.h" #include "gtest/gtest.h" -#include "RigReservoir.h" +#include "RigEclipseCase.h" #include "RifReaderEclipseOutput.h" #include "ecl_file.h" diff --git a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp index 95a754e9e0..59db59045f 100644 --- a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp @@ -20,7 +20,7 @@ #include "RifReaderEclipseOutput.h" #include "RigReservoirCellResults.h" -#include "RigReservoir.h" +#include "RigEclipseCase.h" #include "cafProgressInfo.h" #include diff --git a/ApplicationCode/FileInterface/RifReaderEclipseInput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseInput.cpp index 85b9c2e9f0..11fb5512e5 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseInput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseInput.cpp @@ -19,7 +19,7 @@ #include "cvfBase.h" #include "RigMainGrid.h" -#include "RigReservoir.h" +#include "RigEclipseCase.h" #include "RigReservoirCellResults.h" #include "RifReaderEclipseInput.h" diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index 209c515e98..597da8587e 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -19,7 +19,7 @@ #include "cvfBase.h" #include "RigMainGrid.h" -#include "RigReservoir.h" +#include "RigEclipseCase.h" #include "RigReservoirCellResults.h" #include "RifReaderEclipseOutput.h" diff --git a/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp b/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp index f27901c7d5..fc640b69ab 100644 --- a/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp @@ -50,7 +50,7 @@ #include "RigGridBase.h" #include "RigMainGrid.h" #include "RigReservoirCellResults.h" -#include "RigReservoir.h" +#include "RigEclipseCase.h" #include "RigActiveCellInfo.h" diff --git a/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp b/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp index 7ff08c7f84..bed02b5a73 100644 --- a/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp @@ -29,7 +29,7 @@ #include "RimCellEdgeResultSlot.h" #include "RigGridScalarDataAccess.h" #include "RigReservoirCellResults.h" -#include "RigReservoir.h" +#include "RigEclipseCase.h" //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/RivReservoirPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirPartMgr.cpp index f2c6656d6f..9d6be7e290 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirPartMgr.cpp @@ -21,7 +21,7 @@ #include "RivGridPartMgr.h" #include "cvfStructGrid.h" #include "cvfModelBasicList.h" -#include "RigReservoir.h" +#include "RigEclipseCase.h" //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp index 89198d9ab4..dde461ce42 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp @@ -20,7 +20,7 @@ #include "RivReservoirViewPartMgr.h" #include "RivGridPartMgr.h" #include "RimReservoirView.h" -#include "RigReservoir.h" +#include "RigEclipseCase.h" #include "RigGridBase.h" #include "RigReservoirCellResults.h" #include "RigGridScalarDataAccess.h" diff --git a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp index a1abf0a727..8012ff1172 100644 --- a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp @@ -36,7 +36,7 @@ #include "RimReservoirView.h" -#include "RigReservoir.h" +#include "RigEclipseCase.h" #include "RigCell.h" #include "RivPipeGeometryGenerator.h" diff --git a/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp index 944ba06fa6..183f952248 100644 --- a/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp @@ -20,7 +20,7 @@ #include "cvfLibCore.h" #include "RimReservoir.h" -#include "RigReservoir.h" +#include "RigEclipseCase.h" #include "RivWellPipesPartMgr.h" #include "RigCell.h" #include "RivPipeGeometryGenerator.h" diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index 1598319aa2..0865c45cb8 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -22,7 +22,7 @@ #include "RimReservoirView.h" #include "RIViewer.h" #include "RimReservoir.h" -#include "RigReservoir.h" +#include "RigEclipseCase.h" #include "RigMainGrid.h" #include "RigReservoirCellResults.h" diff --git a/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp b/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp index 00c2b06d67..fc7e1987da 100644 --- a/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp @@ -24,7 +24,7 @@ #include "RimReservoir.h" #include "RimReservoirView.h" #include "RigReservoirCellResults.h" -#include "RigReservoir.h" +#include "RigEclipseCase.h" #include "cafPdmUiListEditor.h" diff --git a/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp b/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp index eaa1a7f59f..ed23615d52 100644 --- a/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp @@ -21,7 +21,7 @@ #include "RimCellRangeFilter.h" #include "RimCellRangeFilterCollection.h" #include "RimReservoirView.h" -#include "RigReservoir.h" +#include "RigEclipseCase.h" #include "cafPdmUiSliderEditor.h" diff --git a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp index 4eed94d8bb..4301aabd26 100644 --- a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp @@ -21,7 +21,7 @@ #include "RimCellRangeFilterCollection.h" #include "RimReservoirView.h" -#include "RigReservoir.h" +#include "RigEclipseCase.h" diff --git a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp index e701534a45..4b43da38e7 100644 --- a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp @@ -24,7 +24,7 @@ #include "RifReaderEclipseInput.h" -#include "RigReservoir.h" +#include "RigEclipseCase.h" #include "RigReservoirCellResults.h" #include "cvfAssert.h" diff --git a/ApplicationCode/ProjectDataModel/RimReservoir.cpp b/ApplicationCode/ProjectDataModel/RimReservoir.cpp index 7a5359b845..1ff6d1ca35 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoir.cpp @@ -24,7 +24,7 @@ #include "RimReservoir.h" #include "RimReservoirView.h" -#include "RigReservoir.h" +#include "RigEclipseCase.h" #include "RigMainGrid.h" #include "RigReservoirCellResults.h" diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp index e90c66bf4c..7e7cbf39d2 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp @@ -22,7 +22,7 @@ #include "RimReservoirView.h" #include "RIMainWindow.h" #include "RigGridBase.h" -#include "RigReservoir.h" +#include "RigEclipseCase.h" #include "RIApplication.h" #include "RIPreferences.h" diff --git a/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp index 176dd9a2d4..0c2a122621 100644 --- a/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp @@ -23,7 +23,7 @@ #include "RimReservoirView.h" #include "RimReservoir.h" #include "RigReservoirCellResults.h" -#include "RigReservoir.h" +#include "RigEclipseCase.h" #include "RigMainGrid.h" #include "cafPdmUiListEditor.h" diff --git a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp index 717403af76..4e50dc9548 100644 --- a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp @@ -18,7 +18,7 @@ #include "RIStdInclude.h" #include "RimResultReservoir.h" -#include "RigReservoir.h" +#include "RigEclipseCase.h" #include "RifReaderEclipseOutput.h" #include "RigReservoirCellResults.h" #include "RimReservoirView.h" diff --git a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp index 9ac5448b5d..bd78999b7a 100644 --- a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp +++ b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp @@ -21,7 +21,7 @@ #include "RIStdInclude.h" #include "gtest/gtest.h" -#include "RigReservoir.h" +#include "RigEclipseCase.h" /* diff --git a/ApplicationCode/ReservoirDataModel/RigReservoir.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp similarity index 99% rename from ApplicationCode/ReservoirDataModel/RigReservoir.cpp rename to ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp index 294be83600..43d37d6747 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoir.cpp +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp @@ -17,7 +17,7 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RIStdInclude.h" -#include "RigReservoir.h" +#include "RigEclipseCase.h" #include "RigMainGrid.h" #include "RigReservoirCellResults.h" #include "RigGridScalarDataAccess.h" diff --git a/ApplicationCode/ReservoirDataModel/RigReservoir.h b/ApplicationCode/ReservoirDataModel/RigEclipseCase.h similarity index 100% rename from ApplicationCode/ReservoirDataModel/RigReservoir.h rename to ApplicationCode/ReservoirDataModel/RigEclipseCase.h diff --git a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp index f291ddc390..b6fb763703 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp @@ -28,7 +28,7 @@ #include "RigReservoirCellResults.h" #include "RigActiveCellInfo.h" #include "RigGridBase.h" -#include "RigReservoir.h" +#include "RigEclipseCase.h" diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp index 3be1a70a35..18e0d68bda 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp @@ -19,7 +19,7 @@ #include "RIStdInclude.h" #include "RigReservoirBuilderMock.h" -#include "RigReservoir.h" +#include "RigEclipseCase.h" /* rand example: guess the number */ diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.h b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.h index 1707d413e1..9ea0149b1d 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.h +++ b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.h @@ -23,7 +23,7 @@ #include "cvfArray.h" #include "cvfVector3.h" #include "RigCell.h" -#include "RigReservoir.h" +#include "RigEclipseCase.h" class LocalGridRefinement { diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.cpp b/ApplicationCode/SocketInterface/RiaSocketServer.cpp index 523a2ddc96..c818ec1185 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.cpp +++ b/ApplicationCode/SocketInterface/RiaSocketServer.cpp @@ -26,7 +26,7 @@ #include "RIApplication.h" #include "RIMainWindow.h" #include "RimReservoir.h" -#include "RigReservoir.h" +#include "RigEclipseCase.h" #include "RigReservoirCellResults.h" #include "RimInputProperty.h" #include "RimInputReservoir.h" diff --git a/ApplicationCode/UserInterface/RIMainWindow.cpp b/ApplicationCode/UserInterface/RIMainWindow.cpp index d26340fb8f..625373fcf2 100644 --- a/ApplicationCode/UserInterface/RIMainWindow.cpp +++ b/ApplicationCode/UserInterface/RIMainWindow.cpp @@ -27,7 +27,7 @@ #include "RIPreferences.h" #include "RIPreferencesDialog.h" -#include "RigReservoir.h" +#include "RigEclipseCase.h" #include "RigReservoirCellResults.h" #include "RimReservoir.h" #include "RimUiTreeModelPdm.h" diff --git a/ApplicationCode/UserInterface/RIViewer.cpp b/ApplicationCode/UserInterface/RIViewer.cpp index f612fc6aee..204a2a66d6 100644 --- a/ApplicationCode/UserInterface/RIViewer.cpp +++ b/ApplicationCode/UserInterface/RIViewer.cpp @@ -28,7 +28,7 @@ #include "cvfRendering.h" #include "cvfDrawableGeo.h" #include "RICursors.h" -#include "RigReservoir.h" +#include "RigEclipseCase.h" #include "cafUtils.h" #include "cafFrameAnimationControl.h" From 33a6157906264a03bff0b313009377d3d898f229 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 13 Feb 2013 13:50:37 +0100 Subject: [PATCH 020/242] Cleanup of comments p4#: 20504 --- .../ReservoirDataModel/RigActiveCellInfo.h | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h index 679cef10e6..7d5955ac2d 100644 --- a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h @@ -42,14 +42,11 @@ public: size_t activeIndexInFractureModel(size_t globalCellIndex) const; void setActiveIndexInFractureModel(size_t globalCellIndex, size_t globalActiveCellIndex); - // From RigBase void setGridCount(size_t gridCount); void setGridActiveCellCounts(size_t gridIndex, size_t matrixActiveCellCount, size_t fractureActiveCellCount); void gridActiveCellCounts(size_t gridIndex, size_t& matrixActiveCellCount, size_t& fractureActiveCellCount); void computeDerivedData(); - - // From RigMainGrid size_t globalMatrixModelActiveCellCount() const; size_t globalFractureModelActiveCellCount() const; @@ -78,22 +75,18 @@ private: private: + std::vector m_perGridActiveCellInfo; + std::vector m_activeInMatrixModel; std::vector m_activeInFractureModel; - std::vector m_perGridActiveCellInfo; + size_t m_globalMatrixModelActiveCellCount; + size_t m_globalFractureModelActiveCellCount; - // From RigMainGrid - size_t m_globalMatrixModelActiveCellCount; - size_t m_globalFractureModelActiveCellCount; + cvf::Vec3st m_activeCellPositionMin; + cvf::Vec3st m_activeCellPositionMax; + cvf::Vec3st m_fractureModelActiveCellPositionMin; + cvf::Vec3st m_fractureModelActiveCellPositionMax; - cvf::Vec3st m_activeCellPositionMin; - cvf::Vec3st m_activeCellPositionMax; - cvf::Vec3st m_fractureModelActiveCellPositionMin; - cvf::Vec3st m_fractureModelActiveCellPositionMax; - - // NOT USED -// cvf::Vec3st m_validCellPositionMin; -// cvf::Vec3st m_validCellPositionMax; - cvf::BoundingBox m_matrixActiveCellsBoundingBox; + cvf::BoundingBox m_matrixActiveCellsBoundingBox; }; From b8e663da03ea98e5e3f65f74c19a3c4672dfdc12 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 13 Feb 2013 14:50:37 +0100 Subject: [PATCH 021/242] Added list of files in CMakeLists_files.cmake Do not use precompiled headers for ReservoirDataModel files p4#: 20506 --- ApplicationCode/CMakeLists.txt | 21 +++++------ .../ReservoirDataModel/CMakeLists_files.cmake | 36 +++++++++++++++++++ .../CMakeLists.txt | 8 +++-- .../ReservoirDataModel/RigCell.cpp | 2 +- .../ReservoirDataModel/RigEclipseCase.cpp | 1 - .../ReservoirDataModel/RigGridBase.cpp | 1 - .../ReservoirDataModel/RigGridCollection.cpp | 20 +++++++++++ .../ReservoirDataModel/RigGridCollection.h | 20 +++++++++++ .../ReservoirDataModel/RigLocalGrid.cpp | 1 - .../ReservoirDataModel/RigMainGrid.cpp | 2 -- .../RigReservoirBuilderMock.cpp | 2 -- .../RigReservoirCellResults.cpp | 2 -- .../ReservoirDataModel/RigWellResults.cpp | 3 +- .../ReservoirDataModel/RigWellResults.h | 5 +++ 14 files changed, 96 insertions(+), 28 deletions(-) create mode 100644 ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake create mode 100644 ApplicationCode/ReservoirDataModel/RigGridCollection.cpp create mode 100644 ApplicationCode/ReservoirDataModel/RigGridCollection.h diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index fa78527b25..d124b84e2d 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -93,19 +93,14 @@ list( APPEND CPP_SOURCES ProjectDataModel/RimUiTreeView.cpp ) +# Populate the filenames into variable lists +include ("ReservoirDataModel/CMakeLists_files.cmake") list( APPEND CPP_SOURCES - ReservoirDataModel/RigCell.cpp - ReservoirDataModel/RigGridBase.cpp - ReservoirDataModel/RigReservoirCellResults.cpp - ReservoirDataModel/RigLocalGrid.cpp - ReservoirDataModel/RigMainGrid.cpp - ReservoirDataModel/RigEclipseCase.cpp - ReservoirDataModel/RigReservoirBuilderMock.cpp - ReservoirDataModel/RigWellResults.cpp - ReservoirDataModel/RigGridScalarDataAccess.cpp - ReservoirDataModel/RigActiveCellInfo.cpp + ${CODE_SOURCE_FILES} ) +message(${CODE_SOURCE_FILES}) + list( APPEND CPP_SOURCES UserInterface/RICursors.cpp UserInterface/RIMainWindow.cpp @@ -157,13 +152,13 @@ qt4_add_resources( QRC_FILES_CPP ${QRC_FILES} ) set( RAW_SOURCES ${CPP_SOURCES} ) list( REMOVE_ITEM RAW_SOURCES RIStdInclude.cpp) -list( REMOVE_ITEM RAW_SOURCES ReservoirDataModel/RigReaderInterfaceECL.cpp) -list( REMOVE_ITEM RAW_SOURCES ReservoirDataModel/RigGridScalarDataAccess.cpp) -list( REMOVE_ITEM RAW_SOURCES ReservoirDataModel/RigActiveCellInfo.cpp) +list( REMOVE_ITEM RAW_SOURCES ${CODE_SOURCE_FILES}) + list( REMOVE_ITEM RAW_SOURCES ModelVisualization/RivCellEdgeEffectGenerator.cpp) list( REMOVE_ITEM RAW_SOURCES ModelVisualization/RivPipeGeometryGenerator.cpp) list( REMOVE_ITEM RAW_SOURCES ModelVisualization/RivWellPipesPartMgr.cpp) list( REMOVE_ITEM RAW_SOURCES ModelVisualization/RivWellHeadPartMgr.cpp) + list( REMOVE_ITEM RAW_SOURCES Application/RiaImageFileCompare.cpp) list( REMOVE_ITEM RAW_SOURCES Application/RiaImageCompareReporter.cpp) diff --git a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake new file mode 100644 index 0000000000..5239d1e831 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake @@ -0,0 +1,36 @@ + +# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly +if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") + set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) +endif() + + +list(APPEND CODE_HEADER_FILES +${CEE_CURRENT_LIST_DIR}RigActiveCellInfo.h +${CEE_CURRENT_LIST_DIR}RigCell.h +${CEE_CURRENT_LIST_DIR}RigEclipseCase.h +${CEE_CURRENT_LIST_DIR}RigGridBase.h +${CEE_CURRENT_LIST_DIR}RigGridCollection.h +${CEE_CURRENT_LIST_DIR}RigGridScalarDataAccess.h +${CEE_CURRENT_LIST_DIR}RigLocalGrid.h +${CEE_CURRENT_LIST_DIR}RigMainGrid.h +${CEE_CURRENT_LIST_DIR}RigReservoirBuilderMock.h +${CEE_CURRENT_LIST_DIR}RigReservoirCellResults.h +${CEE_CURRENT_LIST_DIR}RigWellResults.h +) + +list(APPEND CODE_SOURCE_FILES +${CEE_CURRENT_LIST_DIR}RigActiveCellInfo.cpp +${CEE_CURRENT_LIST_DIR}RigCell.cpp +${CEE_CURRENT_LIST_DIR}RigEclipseCase.cpp +${CEE_CURRENT_LIST_DIR}RigGridBase.cpp +${CEE_CURRENT_LIST_DIR}RigGridCollection.cpp +${CEE_CURRENT_LIST_DIR}RigGridScalarDataAccess.cpp +${CEE_CURRENT_LIST_DIR}RigLocalGrid.cpp +${CEE_CURRENT_LIST_DIR}RigMainGrid.cpp +${CEE_CURRENT_LIST_DIR}RigReservoirBuilderMock.cpp +${CEE_CURRENT_LIST_DIR}RigReservoirCellResults.cpp +${CEE_CURRENT_LIST_DIR}RigWellResults.cpp +) + + diff --git a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/CMakeLists.txt b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/CMakeLists.txt index c53267760c..b78efa2a45 100644 --- a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/CMakeLists.txt +++ b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/CMakeLists.txt @@ -24,7 +24,9 @@ include_directories( ${ResInsight_SOURCE_DIR}/CommonCode ) -file( GLOB CPP_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../*.cpp ) +# Populate the filenames into variable lists +include ("${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists_files.cmake") + set( UNIT_TEST_CPP_SOURCES main.cpp @@ -36,7 +38,6 @@ set( UNIT_TEST_CPP_SOURCES ############################################################################# # Adds folders for Visual Studio solution explorer (and for Xcode explorer) ############################################################################# -source_group( "ResInsight" FILES ${CPP_SOURCES} ) source_group( "UnitTests" FILES ${UNIT_TEST_CPP_SOURCES} ) @@ -58,8 +59,9 @@ set( LINK_LIBRARIES add_executable( ${ProjectName} - ${CPP_SOURCES} + ${CODE_SOURCE_FILES} ${UNIT_TEST_CPP_SOURCES} + ${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists_files.cmake ${ResInsight_SOURCE_DIR}/ThirdParty/gtest/gtest-all.cc ) diff --git a/ApplicationCode/ReservoirDataModel/RigCell.cpp b/ApplicationCode/ReservoirDataModel/RigCell.cpp index 555e748d2b..8dc8b0ff5e 100644 --- a/ApplicationCode/ReservoirDataModel/RigCell.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCell.cpp @@ -16,11 +16,11 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" #include "RigCell.h" #include "RigMainGrid.h" #include "cvfPlane.h" +#include "cvfRay.h" static size_t undefinedCornersArray[8] = {cvf::UNDEFINED_SIZE_T, cvf::UNDEFINED_SIZE_T, diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp index 43d37d6747..b50b63e77c 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp @@ -16,7 +16,6 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" #include "RigEclipseCase.h" #include "RigMainGrid.h" #include "RigReservoirCellResults.h" diff --git a/ApplicationCode/ReservoirDataModel/RigGridBase.cpp b/ApplicationCode/ReservoirDataModel/RigGridBase.cpp index dd733e6c32..f00160f6c2 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridBase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridBase.cpp @@ -16,7 +16,6 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" #include "RigGridBase.h" #include "RigMainGrid.h" #include "RigCell.h" diff --git a/ApplicationCode/ReservoirDataModel/RigGridCollection.cpp b/ApplicationCode/ReservoirDataModel/RigGridCollection.cpp new file mode 100644 index 0000000000..59a39aa7c3 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigGridCollection.cpp @@ -0,0 +1,20 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 "RigGridCollection.h" + diff --git a/ApplicationCode/ReservoirDataModel/RigGridCollection.h b/ApplicationCode/ReservoirDataModel/RigGridCollection.h new file mode 100644 index 0000000000..a268817723 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigGridCollection.h @@ -0,0 +1,20 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 + diff --git a/ApplicationCode/ReservoirDataModel/RigLocalGrid.cpp b/ApplicationCode/ReservoirDataModel/RigLocalGrid.cpp index c67e81bb66..9b4ebbe248 100644 --- a/ApplicationCode/ReservoirDataModel/RigLocalGrid.cpp +++ b/ApplicationCode/ReservoirDataModel/RigLocalGrid.cpp @@ -16,7 +16,6 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" #include "RigLocalGrid.h" diff --git a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp index 4373527880..a5194dc79b 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp @@ -16,8 +16,6 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" - #include "RigMainGrid.h" #include "cvfAssert.h" diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp index 18e0d68bda..3b6fc38cd0 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp @@ -16,8 +16,6 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" - #include "RigReservoirBuilderMock.h" #include "RigEclipseCase.h" diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp index aaaf6ad27c..d830e826fe 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp @@ -16,8 +16,6 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" - #include "RigReservoirCellResults.h" #include "RifReaderInterface.h" #include "RigMainGrid.h" diff --git a/ApplicationCode/ReservoirDataModel/RigWellResults.cpp b/ApplicationCode/ReservoirDataModel/RigWellResults.cpp index e577d2dc6d..43436bec64 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellResults.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellResults.cpp @@ -16,11 +16,10 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" - #include "RigWellResults.h" #include +#include //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/ReservoirDataModel/RigWellResults.h b/ApplicationCode/ReservoirDataModel/RigWellResults.h index 9c247c4cf9..0cc0553adc 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellResults.h +++ b/ApplicationCode/ReservoirDataModel/RigWellResults.h @@ -18,8 +18,13 @@ #pragma once +#include "cvfBase.h" +#include "cvfObject.h" +#include "cvfMath.h" + #include "RimDefines.h" #include +#include struct RigWellResultCell { From b4a6cccfb06a0dbebb3ff60c40ce238b30dfdaf9 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 13 Feb 2013 14:59:30 +0100 Subject: [PATCH 022/242] Added include of math.h p4#: 20508 --- ApplicationCode/ReservoirDataModel/RigCell.cpp | 2 ++ ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp | 1 + ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp | 1 + 3 files changed, 4 insertions(+) diff --git a/ApplicationCode/ReservoirDataModel/RigCell.cpp b/ApplicationCode/ReservoirDataModel/RigCell.cpp index 8dc8b0ff5e..1228fa9860 100644 --- a/ApplicationCode/ReservoirDataModel/RigCell.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCell.cpp @@ -22,6 +22,8 @@ #include "cvfPlane.h" #include "cvfRay.h" +#include + static size_t undefinedCornersArray[8] = {cvf::UNDEFINED_SIZE_T, cvf::UNDEFINED_SIZE_T, cvf::UNDEFINED_SIZE_T, diff --git a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp index b6fb763703..f7f492d06c 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp @@ -29,6 +29,7 @@ #include "RigActiveCellInfo.h" #include "RigGridBase.h" #include "RigEclipseCase.h" +#include diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp index d830e826fe..10d3916be0 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp @@ -21,6 +21,7 @@ #include "RigMainGrid.h" #include +#include //-------------------------------------------------------------------------------------------------- From f344466037952fb1dd5de62ddb25dc0a57aa331c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 14 Feb 2013 10:02:49 +0100 Subject: [PATCH 023/242] Always use smart pointers p4#: 20513 --- ApplicationCode/ProjectDataModel/RimInputReservoir.cpp | 8 +++----- ApplicationCode/ProjectDataModel/RimResultReservoir.cpp | 5 ++--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp index 4b43da38e7..58365395c7 100644 --- a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp @@ -82,8 +82,7 @@ void RimInputReservoir::openDataFileSet(const QStringList& filenames) if (m_rigReservoir.isNull()) { - RigEclipseCase* eclipseCase = new RigEclipseCase; - m_rigReservoir = eclipseCase; + m_rigReservoir = new RigEclipseCase; } // First find and read the grid data @@ -168,11 +167,10 @@ bool RimInputReservoir::openEclipseGridFile() } else { - RigEclipseCase* eclipseCase = new RigEclipseCase; + cvf::ref eclipseCase = new RigEclipseCase; readerInterface = new RifReaderEclipseInput; - if (!readerInterface->open(m_gridFileName, eclipseCase)) + if (!readerInterface->open(m_gridFileName, eclipseCase.p())) { - delete eclipseCase; return false; } diff --git a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp index 4e50dc9548..42817a67dd 100644 --- a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp @@ -69,11 +69,10 @@ bool RimResultReservoir::openEclipseGridFile() return false; } - RigEclipseCase* eclipseCase = new RigEclipseCase; + cvf::ref eclipseCase = new RigEclipseCase; readerInterface = new RifReaderEclipseOutput; - if (!readerInterface->open(fname, eclipseCase)) + if (!readerInterface->open(fname, eclipseCase.p())) { - delete eclipseCase; return false; } From b1531c5454d7fef47592919143ae6a9880f1b28a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 14 Feb 2013 10:08:56 +0100 Subject: [PATCH 024/242] Initial version of RigGridCollection p4#: 20514 --- .../RigReservoir-Test.cpp | 61 ++++++++++++++++ .../ReservoirDataModel/RigGridCollection.cpp | 72 +++++++++++++++++++ .../ReservoirDataModel/RigGridCollection.h | 38 ++++++++++ 3 files changed, 171 insertions(+) diff --git a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp index bd78999b7a..0fbeda6508 100644 --- a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp +++ b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp @@ -22,8 +22,69 @@ #include "gtest/gtest.h" #include "RigEclipseCase.h" +#include "RigGridCollection.h" +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RigGridCollection, BasicTest) +{ + cvf::ref mainGridA = new RigMainGrid; + + cvf::ref eclipseCase = new RigEclipseCase; + + RigGridCollection gridCollection; + gridCollection.addGrid(eclipseCase.p(), mainGridA.p()); + + int count = mainGridA->refCount(); + EXPECT_TRUE(mainGridA->refCount() == 2); + + cvf::ref mainGridB = mainGridA; + EXPECT_TRUE(mainGridA->refCount() == 3); + + cvf::ref existingGrid = gridCollection.findEqualGrid(mainGridB.p()); + EXPECT_TRUE(existingGrid.notNull()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RigGridCollection, EqualTests) +{ + cvf::ref mainGridA = new RigMainGrid; + mainGridA->nodes().push_back(cvf::Vec3d(0, 0, 0)); + mainGridA->nodes().push_back(cvf::Vec3d(0, 0, 1)); + mainGridA->nodes().push_back(cvf::Vec3d(0, 0, 2)); + + cvf::ref eclipseCase = new RigEclipseCase; + + RigGridCollection gridCollection; + gridCollection.addGrid(eclipseCase.p(), mainGridA.p()); + + + cvf::ref mainGridB = new RigMainGrid; + cvf::ref existingGrid = gridCollection.findEqualGrid(mainGridB.p()); + EXPECT_TRUE(existingGrid.isNull()); + + mainGridB->nodes().push_back(cvf::Vec3d(0, 0, 0)); + existingGrid = gridCollection.findEqualGrid(mainGridB.p()); + EXPECT_TRUE(existingGrid.isNull()); + + // Insert nodes in opposite direction + mainGridB->nodes().push_back(cvf::Vec3d(0, 0, 2)); + mainGridB->nodes().push_back(cvf::Vec3d(0, 0, 1)); + existingGrid = gridCollection.findEqualGrid(mainGridB.p()); + EXPECT_TRUE(existingGrid.isNull()); + + // Overwrite to match the node structure of mainGridA + mainGridB->nodes()[1] = cvf::Vec3d(0, 0, 1); + mainGridB->nodes()[2] = cvf::Vec3d(0, 0, 2); + existingGrid = gridCollection.findEqualGrid(mainGridB.p()); + EXPECT_TRUE(existingGrid.notNull()); + +} + /* //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigGridCollection.cpp b/ApplicationCode/ReservoirDataModel/RigGridCollection.cpp index 59a39aa7c3..d9ff012767 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridCollection.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridCollection.cpp @@ -17,4 +17,76 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RigGridCollection.h" +#include "RigEclipseCase.h" +#include "RigMainGrid.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigGridCollection::addGrid(RigEclipseCase* eclipseCase, RigMainGrid* mainGrid) +{ + m_caseToGrid.push_back(CaseToGridMap(eclipseCase, mainGrid)); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigGridCollection::removeCase(RigEclipseCase* eclipseCase) +{ + size_t indexToErase = cvf::UNDEFINED_SIZE_T; + + for (size_t i = 0; i < m_caseToGrid.size(); i++) + { + if (m_caseToGrid[i].m_eclipseCase == eclipseCase) + { + indexToErase = i; + } + } + + if (indexToErase != cvf::UNDEFINED_SIZE_T) + { + m_caseToGrid.erase(m_caseToGrid.begin() + indexToErase); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigMainGrid* RigGridCollection::findEqualGrid(RigMainGrid* candidateGrid) +{ + for (size_t i = 0; i < m_caseToGrid.size(); i++) + { + RigMainGrid* mainGrid = m_caseToGrid.at(i).m_mainGrid.p(); + if (RigGridCollection::isEqual(mainGrid, candidateGrid)) + { + return mainGrid; + } + } + return NULL; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigGridCollection::isEqual(RigMainGrid* gridA, RigMainGrid* gridB) +{ + if (gridA == NULL || gridB == NULL) return false; + + if (gridA == gridB) return true; + + if (gridA->gridCount() != gridB->gridCount()) return false; + + if (gridA->nodes().size() != gridB->nodes().size()) return false; + + for (size_t i = 0; i < gridA->nodes().size(); i++) + { + if (!gridA->nodes()[i].equals(gridB->nodes()[i])) + { + return false; + } + } + + return true; +} diff --git a/ApplicationCode/ReservoirDataModel/RigGridCollection.h b/ApplicationCode/ReservoirDataModel/RigGridCollection.h index a268817723..abaa6903b3 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridCollection.h +++ b/ApplicationCode/ReservoirDataModel/RigGridCollection.h @@ -18,3 +18,41 @@ #pragma once +#include "cvfBase.h" +#include "cvfObject.h" +#include "cvfCollection.h" + +#include + +class RigMainGrid; +class RigEclipseCase; + +class RigGridCollection +{ +public: + void addGrid(RigEclipseCase* eclipseCase, RigMainGrid* mainGrid); + void removeCase(RigEclipseCase* eclipseCase); + + RigMainGrid* findEqualGrid(RigMainGrid* candidateGrid); + +private: + + static bool isEqual(RigMainGrid* gridA, RigMainGrid* gridB); + + class CaseToGridMap + { + public: + CaseToGridMap(RigEclipseCase* eclipseCase, RigMainGrid* mainGrid) : + m_eclipseCase(eclipseCase), + m_mainGrid(mainGrid) + { + } + + cvf::ref m_eclipseCase; + cvf::ref m_mainGrid; + }; + + +private: + std::vector m_caseToGrid; +}; \ No newline at end of file From 46cb61e85963ffafa8a4092cac611fadbc4349e0 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 14 Feb 2013 10:19:27 +0100 Subject: [PATCH 025/242] Rename p4#: 20515 --- .../ProjectDataModel/RimInputReservoir.cpp | 38 +++++++++---------- .../ProjectDataModel/RimReservoir.cpp | 12 +++--- .../ProjectDataModel/RimReservoir.h | 8 ++-- .../ProjectDataModel/RimResultReservoir.cpp | 16 ++++---- 4 files changed, 37 insertions(+), 37 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp index 58365395c7..7e18b426f9 100644 --- a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp @@ -72,17 +72,17 @@ void RimInputReservoir::openDataFileSet(const QStringList& filenames) if (caseName().contains("Input Mock Debug Model")) { cvf::ref readerInterface = this->createMockModel(this->caseName()); - m_rigReservoir->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p()); - m_rigReservoir->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p()); + m_rigEclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p()); + m_rigEclipseCase->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p()); - m_rigReservoir->activeCellInfo()->computeDerivedData(); + m_rigEclipseCase->activeCellInfo()->computeDerivedData(); return; } - if (m_rigReservoir.isNull()) + if (m_rigEclipseCase.isNull()) { - m_rigReservoir = new RigEclipseCase; + m_rigEclipseCase = new RigEclipseCase; } // First find and read the grid data @@ -94,8 +94,8 @@ void RimInputReservoir::openDataFileSet(const QStringList& filenames) { m_gridFileName = filenames[i]; - m_rigReservoir->computeCachedData(); - m_rigReservoir->mainGrid()->computeCachedData(); + m_rigEclipseCase->computeCachedData(); + m_rigEclipseCase->mainGrid()->computeCachedData(); break; } @@ -157,7 +157,7 @@ void RimInputReservoir::openDataFileSet(const QStringList& filenames) bool RimInputReservoir::openEclipseGridFile() { // Early exit if reservoir data is created - if (m_rigReservoir.isNull()) + if (m_rigEclipseCase.isNull()) { cvf::ref readerInterface; @@ -174,25 +174,25 @@ bool RimInputReservoir::openEclipseGridFile() return false; } - m_rigReservoir = eclipseCase; + m_rigEclipseCase = eclipseCase; loadAndSyncronizeInputProperties(); } - CVF_ASSERT(m_rigReservoir.notNull()); + CVF_ASSERT(m_rigEclipseCase.notNull()); CVF_ASSERT(readerInterface.notNull()); - m_rigReservoir->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p()); - m_rigReservoir->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p()); - m_rigReservoir->computeCachedData(); - m_rigReservoir->mainGrid()->computeCachedData(); + m_rigEclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p()); + m_rigEclipseCase->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p()); + m_rigEclipseCase->computeCachedData(); + m_rigEclipseCase->mainGrid()->computeCachedData(); } RIApplication* app = RIApplication::instance(); if (app->preferences()->autocomputeDepthRelatedProperties) { - RigReservoirCellResults* matrixResults = m_rigReservoir->results(RifReaderInterface::MATRIX_RESULTS); - RigReservoirCellResults* fractureResults = m_rigReservoir->results(RifReaderInterface::FRACTURE_RESULTS); + RigReservoirCellResults* matrixResults = m_rigEclipseCase->results(RifReaderInterface::MATRIX_RESULTS); + RigReservoirCellResults* fractureResults = m_rigEclipseCase->results(RifReaderInterface::FRACTURE_RESULTS); matrixResults->computeDepthRelatedResults(); fractureResults->computeDepthRelatedResults(); @@ -210,7 +210,7 @@ void RimInputReservoir::loadAndSyncronizeInputProperties() { // Make sure we actually have reservoir data - CVF_ASSERT(m_rigReservoir.notNull()); + CVF_ASSERT(m_rigEclipseCase.notNull()); CVF_ASSERT(this->reservoirData()->mainGrid()->gridPointDimensions() != cvf::Vec3st(0,0,0)); // Then read the properties from all the files referenced by the InputReservoir @@ -359,7 +359,7 @@ void RimInputReservoir::removeProperty(RimInputProperty* inputProperty) } // Remove the results pointed to by this input property - RigReservoirCellResults* results = m_rigReservoir->results(RifReaderInterface::MATRIX_RESULTS); + RigReservoirCellResults* results = m_rigEclipseCase->results(RifReaderInterface::MATRIX_RESULTS); results->removeResult(inputProperty->resultName); this->removeResult(inputProperty->resultName); @@ -400,7 +400,7 @@ cvf::ref RimInputReservoir::createMockModel(QString modelNam m_inputPropertyCollection->inputProperties.push_back(inputProperty); } - m_rigReservoir = reservoir; + m_rigEclipseCase = reservoir; return mockFileInterface.p(); } diff --git a/ApplicationCode/ProjectDataModel/RimReservoir.cpp b/ApplicationCode/ProjectDataModel/RimReservoir.cpp index 1ff6d1ca35..cf44afe9b7 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoir.cpp @@ -39,7 +39,7 @@ //-------------------------------------------------------------------------------------------------- RimReservoir::RimReservoir() { - m_rigReservoir = NULL; + m_rigEclipseCase = NULL; CAF_PDM_InitField(&caseName, "CaseName", QString(), "Case name", "", "" ,""); // CAF_PDM_InitField(&releaseResultMemory, "ReleaseResultMemory", true, "Release result memory", "", "" ,""); @@ -55,7 +55,7 @@ RimReservoir::RimReservoir() //-------------------------------------------------------------------------------------------------- RigEclipseCase* RimReservoir::reservoirData() { - return m_rigReservoir.p(); + return m_rigEclipseCase.p(); } //-------------------------------------------------------------------------------------------------- @@ -63,7 +63,7 @@ RigEclipseCase* RimReservoir::reservoirData() //-------------------------------------------------------------------------------------------------- const RigEclipseCase* RimReservoir::reservoirData() const { - return m_rigReservoir.p(); + return m_rigEclipseCase.p(); } //-------------------------------------------------------------------------------------------------- @@ -187,7 +187,7 @@ void RimReservoir::fieldChangedByUi(const caf::PdmFieldHandle* changedField, con { if (changedField == &releaseResultMemory) { - if (m_rigReservoir.notNull()) + if (m_rigEclipseCase.notNull()) { for (size_t i = 0; i < reservoirViews().size(); i++) { @@ -209,13 +209,13 @@ void RimReservoir::fieldChangedByUi(const caf::PdmFieldHandle* changedField, con reservoirView->createDisplayModelAndRedraw(); } - RigReservoirCellResults* matrixModelResults = m_rigReservoir->results(RifReaderInterface::MATRIX_RESULTS); + RigReservoirCellResults* matrixModelResults = m_rigEclipseCase->results(RifReaderInterface::MATRIX_RESULTS); if (matrixModelResults) { matrixModelResults->clearAllResults(); } - RigReservoirCellResults* fractureModelResults = m_rigReservoir->results(RifReaderInterface::FRACTURE_RESULTS); + RigReservoirCellResults* fractureModelResults = m_rigEclipseCase->results(RifReaderInterface::FRACTURE_RESULTS); if (fractureModelResults) { fractureModelResults->clearAllResults(); diff --git a/ApplicationCode/ProjectDataModel/RimReservoir.h b/ApplicationCode/ProjectDataModel/RimReservoir.h index de173d9491..0ab03caceb 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoir.h +++ b/ApplicationCode/ProjectDataModel/RimReservoir.h @@ -46,8 +46,8 @@ public: virtual bool openEclipseGridFile() = 0; - RigEclipseCase* reservoirData(); - const RigEclipseCase* reservoirData() const; + RigEclipseCase* reservoirData(); + const RigEclipseCase* reservoirData() const; RimReservoirView* createAndAddReservoirView(); void removeReservoirView(RimReservoirView* reservoirView); @@ -62,7 +62,7 @@ public: virtual caf::PdmFieldHandle* userDescriptionField() { return &caseName; } - virtual QString locationOnDisc() const { return QString(); } + virtual QString locationOnDisc() const { return QString(); } protected: // Overridden methods @@ -71,6 +71,6 @@ protected: virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ); protected: - cvf::ref m_rigReservoir; + cvf::ref m_rigEclipseCase; }; diff --git a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp index 42817a67dd..244c43c724 100644 --- a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp @@ -50,7 +50,7 @@ bool RimResultReservoir::openEclipseGridFile() progInfo.setProgressDescription("Open Grid File"); progInfo.setNextProgressIncrement(48); // Early exit if reservoir data is created - if (m_rigReservoir.notNull()) return true; + if (m_rigEclipseCase.notNull()) return true; cvf::ref readerInterface; @@ -58,8 +58,8 @@ bool RimResultReservoir::openEclipseGridFile() { readerInterface = this->createMockModel(this->caseName()); - m_rigReservoir->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p()); - m_rigReservoir->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p()); + m_rigEclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p()); + m_rigEclipseCase->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p()); } else { @@ -76,20 +76,20 @@ bool RimResultReservoir::openEclipseGridFile() return false; } - m_rigReservoir = eclipseCase; + m_rigEclipseCase = eclipseCase; } progInfo.incrementProgress(); - CVF_ASSERT(m_rigReservoir.notNull()); + CVF_ASSERT(m_rigEclipseCase.notNull()); CVF_ASSERT(readerInterface.notNull()); progInfo.setProgressDescription("Computing Faults"); - m_rigReservoir->computeCachedData(); + m_rigEclipseCase->computeCachedData(); progInfo.incrementProgress(); progInfo.setProgressDescription("Computing Cache"); - m_rigReservoir->mainGrid()->computeCachedData(); + m_rigEclipseCase->mainGrid()->computeCachedData(); return true; } @@ -163,7 +163,7 @@ cvf::ref RimResultReservoir::createMockModel(QString modelNa } - m_rigReservoir = reservoir; + m_rigEclipseCase = reservoir; return mockFileInterface.p(); } From 8f50b90216a5c48e7e9647150f8071e0ac2e7da6 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 14 Feb 2013 13:16:56 +0100 Subject: [PATCH 026/242] Added grid collection and reuse of MainGrid if the grids are equal p4#: 20517 --- .../ProjectDataModel/RimInputReservoir.cpp | 6 ++- .../ProjectDataModel/RimProject.cpp | 44 +++++++++++++++++++ ApplicationCode/ProjectDataModel/RimProject.h | 6 +++ .../ProjectDataModel/RimReservoir.cpp | 25 +++++++++++ .../ProjectDataModel/RimReservoir.h | 2 + .../ProjectDataModel/RimResultReservoir.cpp | 9 ++-- .../RigReservoir-Test.cpp | 4 +- .../ReservoirDataModel/RigEclipseCase.cpp | 13 ++---- .../ReservoirDataModel/RigEclipseCase.h | 2 +- .../ReservoirDataModel/RigGridCollection.cpp | 26 ++++++----- .../ReservoirDataModel/RigGridCollection.h | 15 +++---- 11 files changed, 114 insertions(+), 38 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp index 7e18b426f9..df7a33a8c7 100644 --- a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp @@ -94,8 +94,9 @@ void RimInputReservoir::openDataFileSet(const QStringList& filenames) { m_gridFileName = filenames[i]; + registerEclipseCase(); + m_rigEclipseCase->computeCachedData(); - m_rigEclipseCase->mainGrid()->computeCachedData(); break; } @@ -175,6 +176,8 @@ bool RimInputReservoir::openEclipseGridFile() } m_rigEclipseCase = eclipseCase; + + registerEclipseCase(); loadAndSyncronizeInputProperties(); } @@ -184,7 +187,6 @@ bool RimInputReservoir::openEclipseGridFile() m_rigEclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p()); m_rigEclipseCase->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p()); m_rigEclipseCase->computeCachedData(); - m_rigEclipseCase->mainGrid()->computeCachedData(); } diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 4a07ccbb52..a8672481c6 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -22,6 +22,9 @@ #include "RIApplication.h" #include "RIVersionInfo.h" #include "RimScriptCollection.h" +#include "RigGridCollection.h" +#include "RigEclipseCase.h" + CAF_PDM_SOURCE_INIT(RimProject, "ResInsightProject"); //-------------------------------------------------------------------------------------------------- @@ -38,6 +41,8 @@ RimProject::RimProject(void) scriptCollection = new RimScriptCollection(); scriptCollection->directory.setUiHidden(true); + m_gridCollection = new RigGridCollection; + initAfterRead(); } @@ -46,6 +51,8 @@ RimProject::RimProject(void) //-------------------------------------------------------------------------------------------------- RimProject::~RimProject(void) { + close(); + if (scriptCollection()) delete scriptCollection(); reservoirs.deleteAllChildObjects(); @@ -56,6 +63,11 @@ RimProject::~RimProject(void) //-------------------------------------------------------------------------------------------------- void RimProject::close() { + for (size_t i = 0; i < reservoirs.size(); i++) + { + m_gridCollection->removeCase(reservoirs[i]->reservoirData()); + } + reservoirs.deleteAllChildObjects(); fileName = ""; @@ -113,3 +125,35 @@ QString RimProject::projectFileVersionString() const { return m_projectFileVersionString; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimProject::registerEclipseCase(RigEclipseCase* eclipseCase) +{ + CVF_ASSERT(eclipseCase); + + RigMainGrid* equalGrid = m_gridCollection->findEqualGrid(eclipseCase->mainGrid()); + + if (equalGrid) + { + // Replace the grid with an already registered grid + eclipseCase->setMainGrid(equalGrid); + } + else + { + // This is the first insertion of this grid, compute cached data + eclipseCase->mainGrid()->computeCachedData(); + + std::vector grids; + eclipseCase->allGrids(&grids); + + size_t i; + for (i = 0; i < grids.size(); i++) + { + grids[i]->computeFaults(); + } + } + + m_gridCollection->addCase(eclipseCase); +} diff --git a/ApplicationCode/ProjectDataModel/RimProject.h b/ApplicationCode/ProjectDataModel/RimProject.h index c295f230d7..1212a20aad 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.h +++ b/ApplicationCode/ProjectDataModel/RimProject.h @@ -22,6 +22,8 @@ #include "RimScriptCollection.h" class RimReservoir; +class RigGridCollection; +class RigEclipseCase; //================================================================================================== /// @@ -45,6 +47,8 @@ public: void close(); + void registerEclipseCase(RigEclipseCase* eclipseCase); + protected: // Overridden methods virtual void initAfterRead(); @@ -52,4 +56,6 @@ protected: private: caf::PdmField m_projectFileVersionString; + + cvf::ref m_gridCollection; }; diff --git a/ApplicationCode/ProjectDataModel/RimReservoir.cpp b/ApplicationCode/ProjectDataModel/RimReservoir.cpp index cf44afe9b7..318760e08f 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoir.cpp @@ -33,6 +33,7 @@ #include "cafPdmUiPushButtonEditor.h" #include +#include "RimProject.h" //-------------------------------------------------------------------------------------------------- /// @@ -226,3 +227,27 @@ void RimReservoir::fieldChangedByUi(const caf::PdmFieldHandle* changedField, con } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimReservoir::registerEclipseCase() +{ + std::vector parentObjects; + this->parentObjects(parentObjects); + + RimProject* proj = NULL; + for (size_t i = 0; i < parentObjects.size(); i++) + { + if (proj) continue; + + caf::PdmObject* obj = parentObjects[i]; + proj = dynamic_cast(obj); + } + + CVF_ASSERT(proj); + if (proj) + { + proj->registerEclipseCase(m_rigEclipseCase.p()); + } +} + diff --git a/ApplicationCode/ProjectDataModel/RimReservoir.h b/ApplicationCode/ProjectDataModel/RimReservoir.h index 0ab03caceb..5b4e99f3f8 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoir.h +++ b/ApplicationCode/ProjectDataModel/RimReservoir.h @@ -70,6 +70,8 @@ protected: virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ); + void registerEclipseCase(); + protected: cvf::ref m_rigEclipseCase; }; diff --git a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp index 244c43c724..30215beece 100644 --- a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp @@ -84,12 +84,13 @@ bool RimResultReservoir::openEclipseGridFile() CVF_ASSERT(m_rigEclipseCase.notNull()); CVF_ASSERT(readerInterface.notNull()); - progInfo.setProgressDescription("Computing Faults"); - m_rigEclipseCase->computeCachedData(); + + progInfo.setProgressDescription("Registering Case and Grid"); + registerEclipseCase(); progInfo.incrementProgress(); - progInfo.setProgressDescription("Computing Cache"); - m_rigEclipseCase->mainGrid()->computeCachedData(); + progInfo.setProgressDescription("Computing Case Cache"); + m_rigEclipseCase->computeCachedData(); return true; } diff --git a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp index 0fbeda6508..ad17a3348f 100644 --- a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp +++ b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp @@ -35,7 +35,7 @@ TEST(RigGridCollection, BasicTest) cvf::ref eclipseCase = new RigEclipseCase; RigGridCollection gridCollection; - gridCollection.addGrid(eclipseCase.p(), mainGridA.p()); + gridCollection.addCase(eclipseCase.p()); int count = mainGridA->refCount(); EXPECT_TRUE(mainGridA->refCount() == 2); @@ -60,7 +60,7 @@ TEST(RigGridCollection, EqualTests) cvf::ref eclipseCase = new RigEclipseCase; RigGridCollection gridCollection; - gridCollection.addGrid(eclipseCase.p(), mainGridA.p()); + gridCollection.addCase(eclipseCase.p()); cvf::ref mainGridB = new RigMainGrid; diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp index b50b63e77c..1f476b3f65 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp @@ -43,16 +43,9 @@ RigEclipseCase::~RigEclipseCase() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigEclipseCase::computeFaults() +void RigEclipseCase::setMainGrid(RigMainGrid* mainGrid) { - std::vector grids; - allGrids(&grids); - - size_t i; - for (i = 0; i < grids.size(); i++) - { - grids[i]->computeFaults(); - } + m_mainGrid = mainGrid; } //-------------------------------------------------------------------------------------------------- @@ -293,7 +286,6 @@ void RigEclipseCase::computeActiveCellData() //-------------------------------------------------------------------------------------------------- void RigEclipseCase::computeCachedData() { - computeFaults(); computeActiveCellData(); computeActiveCellsGeometryBoundingBox(); } @@ -395,3 +387,4 @@ cvf::ref RigEclipseCase::dataAccessObject(const return NULL; } + diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCase.h b/ApplicationCode/ReservoirDataModel/RigEclipseCase.h index bd40b70c8c..4dd62bd912 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCase.h +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCase.h @@ -38,6 +38,7 @@ public: RigMainGrid* mainGrid() { return m_mainGrid.p(); } const RigMainGrid* mainGrid() const { return m_mainGrid.p(); } + void setMainGrid(RigMainGrid* mainGrid); void allGrids(std::vector* grids); void allGrids(std::vector* grids) const; @@ -66,7 +67,6 @@ public: private: - void computeFaults(); void computeActiveCellData(); void computeWellCellsPrGrid(); void computeActiveCellsGeometryBoundingBox(); diff --git a/ApplicationCode/ReservoirDataModel/RigGridCollection.cpp b/ApplicationCode/ReservoirDataModel/RigGridCollection.cpp index d9ff012767..fa6c0822a9 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridCollection.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridCollection.cpp @@ -24,9 +24,10 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigGridCollection::addGrid(RigEclipseCase* eclipseCase, RigMainGrid* mainGrid) +void RigGridCollection::addCase(RigEclipseCase* eclipseCase) { - m_caseToGrid.push_back(CaseToGridMap(eclipseCase, mainGrid)); + cvf::ref caseAndGrid = new CaseToGridMap(eclipseCase, eclipseCase->mainGrid()); + m_caseToGrid.push_back(caseAndGrid.p()); } //-------------------------------------------------------------------------------------------------- @@ -38,16 +39,12 @@ void RigGridCollection::removeCase(RigEclipseCase* eclipseCase) for (size_t i = 0; i < m_caseToGrid.size(); i++) { - if (m_caseToGrid[i].m_eclipseCase == eclipseCase) + if (m_caseToGrid[i]->m_eclipseCase == eclipseCase) { - indexToErase = i; + m_caseToGrid.eraseAt(i); + return; } } - - if (indexToErase != cvf::UNDEFINED_SIZE_T) - { - m_caseToGrid.erase(m_caseToGrid.begin() + indexToErase); - } } //-------------------------------------------------------------------------------------------------- @@ -57,7 +54,7 @@ RigMainGrid* RigGridCollection::findEqualGrid(RigMainGrid* candidateGrid) { for (size_t i = 0; i < m_caseToGrid.size(); i++) { - RigMainGrid* mainGrid = m_caseToGrid.at(i).m_mainGrid.p(); + RigMainGrid* mainGrid = m_caseToGrid.at(i)->m_mainGrid.p(); if (RigGridCollection::isEqual(mainGrid, candidateGrid)) { return mainGrid; @@ -90,3 +87,12 @@ bool RigGridCollection::isEqual(RigMainGrid* gridA, RigMainGrid* gridB) return true; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigGridCollection::CaseToGridMap::CaseToGridMap(RigEclipseCase* eclipseCase, RigMainGrid* mainGrid) : +m_eclipseCase(eclipseCase), + m_mainGrid(mainGrid) +{ +} diff --git a/ApplicationCode/ReservoirDataModel/RigGridCollection.h b/ApplicationCode/ReservoirDataModel/RigGridCollection.h index abaa6903b3..2a1df86574 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridCollection.h +++ b/ApplicationCode/ReservoirDataModel/RigGridCollection.h @@ -27,10 +27,11 @@ class RigMainGrid; class RigEclipseCase; -class RigGridCollection +class RigGridCollection : public cvf::Object { public: - void addGrid(RigEclipseCase* eclipseCase, RigMainGrid* mainGrid); + void addCase(RigEclipseCase* eclipseCase); + void removeCase(RigEclipseCase* eclipseCase); RigMainGrid* findEqualGrid(RigMainGrid* candidateGrid); @@ -39,14 +40,10 @@ private: static bool isEqual(RigMainGrid* gridA, RigMainGrid* gridB); - class CaseToGridMap + class CaseToGridMap : public cvf::Object { public: - CaseToGridMap(RigEclipseCase* eclipseCase, RigMainGrid* mainGrid) : - m_eclipseCase(eclipseCase), - m_mainGrid(mainGrid) - { - } + CaseToGridMap(RigEclipseCase* eclipseCase, RigMainGrid* mainGrid); cvf::ref m_eclipseCase; cvf::ref m_mainGrid; @@ -54,5 +51,5 @@ private: private: - std::vector m_caseToGrid; + cvf::Collection m_caseToGrid; }; \ No newline at end of file From 3490d07dd12a18f441ace5d7be9c7826276778a4 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 14 Feb 2013 14:30:01 +0100 Subject: [PATCH 027/242] Added IdenticalGridCaseGroup, now displayed in tree view p4#: 20518 --- ApplicationCode/CMakeLists.txt | 1 + .../RimIdenticalGridCaseGroup.cpp | 83 +++++++++++++++++++ .../RimIdenticalGridCaseGroup.h | 51 ++++++++++++ .../ProjectDataModel/RimProject.cpp | 44 ++++++++-- ApplicationCode/ProjectDataModel/RimProject.h | 9 +- .../ProjectDataModel/RimReservoir.cpp | 3 +- 6 files changed, 178 insertions(+), 13 deletions(-) create mode 100644 ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp create mode 100644 ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index d124b84e2d..8b12d131ed 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -74,6 +74,7 @@ list( APPEND CPP_SOURCES ProjectDataModel/RimLegendConfig.cpp ProjectDataModel/RimProject.cpp ProjectDataModel/RimReservoir.cpp + ProjectDataModel/RimIdenticalGridCaseGroup.cpp ProjectDataModel/RimInputProperty.cpp ProjectDataModel/RimInputPropertyCollection.cpp ProjectDataModel/RimInputReservoir.cpp diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp new file mode 100644 index 0000000000..002ab57a39 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -0,0 +1,83 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 "RIStdInclude.h" + +#include "RimIdenticalGridCaseGroup.h" +#include "RimReservoir.h" +#include "RimReservoirView.h" +#include "RigEclipseCase.h" + + +CAF_PDM_SOURCE_INIT(RimIdenticalGridCaseGroup, "RimIdenticalGridCaseGroup"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimIdenticalGridCaseGroup::RimIdenticalGridCaseGroup() +{ + CAF_PDM_InitObject("Identical Grids", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&reservoirs, "Reservoirs", "", "", "", ""); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimIdenticalGridCaseGroup::~RimIdenticalGridCaseGroup() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIdenticalGridCaseGroup::addCase(RimReservoir* reservoir) +{ + CVF_ASSERT(reservoir); + + if (!reservoir) return; + + RigMainGrid* incomingMainGrid = reservoir->reservoirData()->mainGrid(); + + if (m_mainGrid.isNull()) + { + m_mainGrid = incomingMainGrid; + } + else + { + if (m_mainGrid.p() != incomingMainGrid) + { + CVF_ASSERT(false); + return; + } + } + + reservoirs.push_back(reservoir); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigMainGrid* RimIdenticalGridCaseGroup::mainGrid() +{ + if (m_mainGrid.notNull()) return m_mainGrid.p(); + + return NULL; +} + diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h new file mode 100644 index 0000000000..45ec34cacd --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h @@ -0,0 +1,51 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 "cvfBase.h" +#include "cvfObject.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" + +class RimReservoir; +class RigMainGrid; + +//================================================================================================== +// +// +// +//================================================================================================== +class RimIdenticalGridCaseGroup : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimIdenticalGridCaseGroup(); + virtual ~RimIdenticalGridCaseGroup(); + + void addCase(RimReservoir* reservoir); + + caf::PdmPointersField reservoirs; + + RigMainGrid* mainGrid(); + +private: + cvf::ref m_mainGrid; + +}; diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index a8672481c6..81d5bff863 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -21,7 +21,7 @@ #include "RimProject.h" #include "RIApplication.h" #include "RIVersionInfo.h" -#include "RimScriptCollection.h" + #include "RigGridCollection.h" #include "RigEclipseCase.h" @@ -36,6 +36,8 @@ RimProject::RimProject(void) m_projectFileVersionString.setUiHidden(true); CAF_PDM_InitFieldNoDefault(&reservoirs, "Reservoirs", "", "", "", ""); + CAF_PDM_InitFieldNoDefault(&caseGroups, "CaseGroups", "", "", "", ""); + CAF_PDM_InitFieldNoDefault(&scriptCollection, "ScriptCollection", "Scripts", ":/Default.png", "", ""); scriptCollection = new RimScriptCollection(); @@ -69,6 +71,7 @@ void RimProject::close() } reservoirs.deleteAllChildObjects(); + caseGroups.deleteAllChildObjects(); fileName = ""; } @@ -129,24 +132,26 @@ QString RimProject::projectFileVersionString() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimProject::registerEclipseCase(RigEclipseCase* eclipseCase) +void RimProject::registerEclipseCase(RimReservoir* rimReservoir) { - CVF_ASSERT(eclipseCase); + CVF_ASSERT(rimReservoir); - RigMainGrid* equalGrid = m_gridCollection->findEqualGrid(eclipseCase->mainGrid()); + RigEclipseCase* rigEclipseCase = rimReservoir->reservoirData(); + + RigMainGrid* equalGrid = m_gridCollection->findEqualGrid(rigEclipseCase->mainGrid()); if (equalGrid) { // Replace the grid with an already registered grid - eclipseCase->setMainGrid(equalGrid); + rigEclipseCase->setMainGrid(equalGrid); } else { // This is the first insertion of this grid, compute cached data - eclipseCase->mainGrid()->computeCachedData(); + rigEclipseCase->mainGrid()->computeCachedData(); std::vector grids; - eclipseCase->allGrids(&grids); + rigEclipseCase->allGrids(&grids); size_t i; for (i = 0; i < grids.size(); i++) @@ -155,5 +160,28 @@ void RimProject::registerEclipseCase(RigEclipseCase* eclipseCase) } } - m_gridCollection->addCase(eclipseCase); + m_gridCollection->addCase(rigEclipseCase); + + + // Insert in identical grid group + bool foundGroup = false; + + for (size_t i = 0; i < caseGroups.size(); i++) + { + RimIdenticalGridCaseGroup* cg = caseGroups()[i]; + + if (cg->mainGrid() == equalGrid) + { + cg->addCase(rimReservoir); + foundGroup = true; + } + } + + if (!foundGroup) + { + RimIdenticalGridCaseGroup* group = new RimIdenticalGridCaseGroup; + group->addCase(rimReservoir); + + caseGroups().push_back(group); + } } diff --git a/ApplicationCode/ProjectDataModel/RimProject.h b/ApplicationCode/ProjectDataModel/RimProject.h index 1212a20aad..cf42fdf146 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.h +++ b/ApplicationCode/ProjectDataModel/RimProject.h @@ -20,10 +20,10 @@ #include "cafPdmDocument.h" #include "RimScriptCollection.h" +#include "RimIdenticalGridCaseGroup.h" class RimReservoir; class RigGridCollection; -class RigEclipseCase; //================================================================================================== /// @@ -34,8 +34,9 @@ class RimProject : public caf::PdmDocument CAF_PDM_HEADER_INIT; public: - caf::PdmPointersField reservoirs; - caf::PdmField scriptCollection; + caf::PdmPointersField reservoirs; + caf::PdmPointersField caseGroups; + caf::PdmField scriptCollection; void setUserScriptPath(const QString& path); //void updateProjectScriptPath(); @@ -47,7 +48,7 @@ public: void close(); - void registerEclipseCase(RigEclipseCase* eclipseCase); + void registerEclipseCase(RimReservoir* rimReservoir); protected: // Overridden methods diff --git a/ApplicationCode/ProjectDataModel/RimReservoir.cpp b/ApplicationCode/ProjectDataModel/RimReservoir.cpp index 318760e08f..28f0154b11 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoir.cpp @@ -247,7 +247,8 @@ void RimReservoir::registerEclipseCase() CVF_ASSERT(proj); if (proj) { - proj->registerEclipseCase(m_rigEclipseCase.p()); + + proj->registerEclipseCase(this); } } From 67cab9448ee57e10e6af437cb35ef7af0fcbda78 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 14 Feb 2013 15:27:35 +0100 Subject: [PATCH 028/242] Added statistical calculation framework p4#: 20521 --- ApplicationCode/CMakeLists.txt | 1 + .../RimStatisticalCalculation.cpp | 53 +++++++++++++++++++ .../RimStatisticalCalculation.h | 51 ++++++++++++++++++ 3 files changed, 105 insertions(+) create mode 100644 ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp create mode 100644 ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index 8b12d131ed..f17fe1ad1b 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -86,6 +86,7 @@ list( APPEND CPP_SOURCES ProjectDataModel/RimWell.cpp ProjectDataModel/RimWellCollection.cpp ProjectDataModel/RimScriptCollection.cpp + ProjectDataModel/RimStatisticalCalculation.cpp ProjectDataModel/RimCalcScript.cpp ProjectDataModel/RimExportInputPropertySettings.cpp ProjectDataModel/RimBinaryExportSettings.cpp diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp new file mode 100644 index 0000000000..b4000d482a --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp @@ -0,0 +1,53 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 "RIStdInclude.h" + +#include "RimStatisticalCalculation.h" +#include "RimReservoirView.h" + + +CAF_PDM_SOURCE_INIT(RimStatisticalCalculation, "RimStatisticalCalculation"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimStatisticalCalculation::RimStatisticalCalculation() + : RimReservoir() +{ + CAF_PDM_InitField(&statisticsMin, "StatisticsMin", true, "Minimum", "", "" ,""); + CAF_PDM_InitField(&statisticsMax, "StatisticsMax", true, "Maximum", "", "" ,""); + CAF_PDM_InitField(&statisticsMean, "StatisticsMean", true, "Mean", "", "" ,""); + CAF_PDM_InitField(&statisticsStdDev, "StatisticsStdDev", true, "Std dev", "", "" ,""); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimStatisticalCalculation::~RimStatisticalCalculation() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimStatisticalCalculation::openEclipseGridFile() +{ + return true; +} diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h new file mode 100644 index 0000000000..46d443b1fb --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h @@ -0,0 +1,51 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 "cvfBase.h" +#include "cvfObject.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" + +#include "RimReservoir.h" + + +//================================================================================================== +// +// +// +//================================================================================================== +class RimStatisticalCalculation : public RimReservoir +{ + CAF_PDM_HEADER_INIT; + +public: + RimStatisticalCalculation(); + virtual ~RimStatisticalCalculation(); + + virtual bool openEclipseGridFile(); + + caf::PdmField statisticsMin; + caf::PdmField statisticsMax; + caf::PdmField statisticsMean; + caf::PdmField statisticsStdDev; + +private: + +}; From c92e822f3fbba78cef27fd9be850ee1ac66bc804 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 15 Feb 2013 08:44:45 +0100 Subject: [PATCH 029/242] Added context menu items for adding new statistical case p4#: 20523 --- .../RimIdenticalGridCaseGroup.cpp | 21 ++++ .../RimIdenticalGridCaseGroup.h | 3 + .../RimStatisticalCalculation.cpp | 100 ++++++++++++++++++ .../RimStatisticalCalculation.h | 12 +++ .../ProjectDataModel/RimUiTreeModelPdm.cpp | 41 +++++++ .../ProjectDataModel/RimUiTreeModelPdm.h | 3 + .../ProjectDataModel/RimUiTreeView.cpp | 43 ++++++++ .../ProjectDataModel/RimUiTreeView.h | 3 + 8 files changed, 226 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index 002ab57a39..cc892787c9 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -22,6 +22,7 @@ #include "RimReservoir.h" #include "RimReservoirView.h" #include "RigEclipseCase.h" +#include "RimStatisticalCalculation.h" CAF_PDM_SOURCE_INIT(RimIdenticalGridCaseGroup, "RimIdenticalGridCaseGroup"); @@ -34,6 +35,12 @@ RimIdenticalGridCaseGroup::RimIdenticalGridCaseGroup() CAF_PDM_InitObject("Identical Grids", "", "", ""); CAF_PDM_InitFieldNoDefault(&reservoirs, "Reservoirs", "", "", "", ""); + CAF_PDM_InitFieldNoDefault(&statisticalReservoirs, "StatisticalReservoirs", "", "", "", ""); + + RimStatisticalCalculation* dummyStat = new RimStatisticalCalculation; + dummyStat->caseName = "Statistics 1"; + + statisticalReservoirs.push_back(dummyStat); } //-------------------------------------------------------------------------------------------------- @@ -81,3 +88,17 @@ RigMainGrid* RimIdenticalGridCaseGroup::mainGrid() return NULL; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimStatisticalCalculation* RimIdenticalGridCaseGroup::createAndAppendStatisticalCalculation() +{ + RimStatisticalCalculation* newObject = new RimStatisticalCalculation; + + newObject->caseName = "Statistics 1"; + + statisticalReservoirs.push_back(newObject); + + return newObject; +} + diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h index 45ec34cacd..871ac4c1c6 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h @@ -25,6 +25,7 @@ class RimReservoir; class RigMainGrid; +class RimStatisticalCalculation; //================================================================================================== // @@ -42,9 +43,11 @@ public: void addCase(RimReservoir* reservoir); caf::PdmPointersField reservoirs; + caf::PdmPointersField statisticalReservoirs; RigMainGrid* mainGrid(); + RimStatisticalCalculation* createAndAppendStatisticalCalculation(); private: cvf::ref m_mainGrid; diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp index b4000d482a..946768af61 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp @@ -20,6 +20,8 @@ #include "RimStatisticalCalculation.h" #include "RimReservoirView.h" +#include "cafPdmUiOrdering.h" +#include "RimIdenticalGridCaseGroup.h" CAF_PDM_SOURCE_INIT(RimStatisticalCalculation, "RimStatisticalCalculation"); @@ -34,6 +36,7 @@ RimStatisticalCalculation::RimStatisticalCalculation() CAF_PDM_InitField(&statisticsMax, "StatisticsMax", true, "Maximum", "", "" ,""); CAF_PDM_InitField(&statisticsMean, "StatisticsMean", true, "Mean", "", "" ,""); CAF_PDM_InitField(&statisticsStdDev, "StatisticsStdDev", true, "Std dev", "", "" ,""); + } //-------------------------------------------------------------------------------------------------- @@ -51,3 +54,100 @@ bool RimStatisticalCalculation::openEclipseGridFile() { return true; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimStatisticalCalculation::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const +{ + // Fields declared in RimCellFilter + uiOrdering.add(&caseName); + + // Fields declared in RimResultDefinition + caf::PdmUiGroup* group1 = uiOrdering.addNewGroup("Statistical parameters"); + group1->add(&statisticsMin); + group1->add(&statisticsMax); + group1->add(&statisticsMean); + group1->add(&statisticsStdDev); + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimIdenticalGridCaseGroup* RimStatisticalCalculation::parent() +{ + std::vector parentObjects; + this->parentObjects(parentObjects); + + RimIdenticalGridCaseGroup* parentObject = NULL; + for (size_t i = 0; i < parentObjects.size(); i++) + { + if (parentObject) continue; + + caf::PdmObject* obj = parentObjects[i]; + parentObject = dynamic_cast(obj); + } + + CVF_ASSERT(parentObject); + + return parentObject; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimStatisticalCalculation::computeStatistics() +{ + if (statisticsMin) + { + createAndComputeMin(); + } + + if (statisticsMax) + { + createAndComputeMax(); + } + + if (statisticsMean) + { + createAndComputeMean(); + } + + if (statisticsStdDev) + { + createAndComputeStdDev(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimStatisticalCalculation::createAndComputeMin() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimStatisticalCalculation::createAndComputeMax() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimStatisticalCalculation::createAndComputeMean() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimStatisticalCalculation::createAndComputeStdDev() +{ + +} diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h index 46d443b1fb..01e3be7428 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h @@ -25,6 +25,9 @@ #include "RimReservoir.h" +class RimIdenticalGridCaseGroup; +class RimResultDefinition; + //================================================================================================== // @@ -46,6 +49,15 @@ public: caf::PdmField statisticsMean; caf::PdmField statisticsStdDev; + RimIdenticalGridCaseGroup* parent(); + + virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) const; + void computeStatistics(); + private: + void createAndComputeMin(); + void createAndComputeMax(); + void createAndComputeMean(); + void createAndComputeStdDev(); }; diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index 34713d1ba4..ea5371925c 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -35,6 +35,7 @@ #include "RimInputPropertyCollection.h" #include "cafPdmField.h" #include "RimInputReservoir.h" +#include "RimStatisticalCalculation.h" //-------------------------------------------------------------------------------------------------- /// @@ -442,3 +443,43 @@ void RimUiTreeModelPdm::deleteInputProperty(const QModelIndex& itemIndex) delete inputProperty; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimStatisticalCalculation* RimUiTreeModelPdm::addStatisticalCalculation(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex) +{ + caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex); + + QModelIndex collectionIndex; + RimIdenticalGridCaseGroup* caseGroup = NULL; + caf::PdmUiTreeItem* parentCollectionItem = NULL; + int position = 0; + + if (dynamic_cast(currentItem->dataObject().p())) + { + RimStatisticalCalculation* currentObject = dynamic_cast(currentItem->dataObject().p()); + caseGroup = currentObject->parent(); + parentCollectionItem = currentItem->parent(); + position = itemIndex.row(); + collectionIndex = itemIndex.parent(); + } + else if (dynamic_cast(currentItem->dataObject().p())) + { + caseGroup = dynamic_cast(currentItem->dataObject().p()); + parentCollectionItem = currentItem; + position = parentCollectionItem->childCount(); + collectionIndex = itemIndex; + } + + beginInsertRows(collectionIndex, position, position); + + RimStatisticalCalculation* createdObject = caseGroup->createAndAppendStatisticalCalculation(); + caf::PdmUiTreeItem* childItem = new caf::PdmUiTreeItem(parentCollectionItem, position, createdObject); + + endInsertRows(); + + insertedModelIndex = index(position, 0, collectionIndex); + + return createdObject; +} + diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h index 1e41d090a3..7e8e51db88 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h @@ -28,6 +28,7 @@ class RimCellPropertyFilter; class RimCellRangeFilter; class RimReservoirView; class RimInputProperty; +class RimStatisticalCalculation; //================================================================================================== /// @@ -54,6 +55,8 @@ public: RimCellRangeFilter* addRangeFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); RimReservoirView* addReservoirView(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); void addInputProperty(const QModelIndex& itemIndex, const QStringList& fileNames); + + RimStatisticalCalculation* addStatisticalCalculation(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); void updateScriptPaths(); diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index 624104775e..84e41c024f 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -31,6 +31,7 @@ #include "RimInputReservoir.h" #include "RimBinaryExportSettings.h" #include "RigReservoirCellResults.h" +#include "RimStatisticalCalculation.h" //-------------------------------------------------------------------------------------------------- /// @@ -143,6 +144,19 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event) menu.addAction(QString("Save Property To File"), this, SLOT(slotWriteBinaryResultAsInputProperty())); menu.exec(event->globalPos()); } + else if (dynamic_cast(uiItem->dataObject().p())) + { + QMenu menu; + menu.addAction(QString("New Statistical Case"), this, SLOT(slotNewStatisticalCase())); + menu.exec(event->globalPos()); + } + else if (dynamic_cast(uiItem->dataObject().p())) + { + QMenu menu; + menu.addAction(QString("Compute"), this, SLOT(slotComputeStatisticalCases())); + menu.addAction(QString("Close"), this, SLOT(slotCloseCase())); + menu.exec(event->globalPos()); + } else if (dynamic_cast(uiItem->dataObject().p())) { QMenu menu; @@ -750,3 +764,32 @@ void RimUiTreeView::slotCloseCase() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUiTreeView::slotNewStatisticalCase() +{ + RimUiTreeModelPdm* myModel = dynamic_cast(model()); + if (myModel) + { + QModelIndex insertedIndex; + RimStatisticalCalculation* newObject = myModel->addStatisticalCalculation(currentIndex(), insertedIndex); + setCurrentIndex(insertedIndex); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUiTreeView::slotComputeStatisticalCases() +{ + QModelIndex index = currentIndex(); + RimUiTreeModelPdm* myModel = dynamic_cast(model()); + caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex()); + + RimStatisticalCalculation* statisticalObject = dynamic_cast(uiItem->dataObject().p()); + if (!statisticalObject) return; + + statisticalObject->computeStatistics(); +} + diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.h b/ApplicationCode/ProjectDataModel/RimUiTreeView.h index 30c4723e76..aa4a9e27ef 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.h @@ -69,6 +69,9 @@ private slots: void slotCloseCase(); + void slotNewStatisticalCase(); + void slotComputeStatisticalCases(); + void slotSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected); signals: From 73c945927603fc3a60dc5f05c8430b1bb681e5ae Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 15 Feb 2013 09:21:28 +0100 Subject: [PATCH 030/242] Simplified adding of view p4#: 20524 --- .../ProjectDataModel/RimUiTreeModelPdm.cpp | 37 +++++++++++++------ .../ProjectDataModel/RimUiTreeView.cpp | 9 ++--- 2 files changed, 28 insertions(+), 18 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index ea5371925c..bfa5e39fe9 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -323,24 +323,37 @@ RimReservoirView* RimUiTreeModelPdm::addReservoirView(const QModelIndex& itemInd caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex); if (!currentItem) return NULL; - RimReservoirView* reservoirView = dynamic_cast(currentItem->dataObject().p()); - if (!reservoirView) return NULL; + caf::PdmUiTreeItem* collectionItem = NULL; - RimReservoirView* insertedView = reservoirView->eclipseCase()->createAndAddReservoirView(); - caf::PdmUiTreeItem* collectionItem = currentItem->parent(); + if (dynamic_cast(currentItem->dataObject().p())) + { + collectionItem = currentItem->parent(); + } + else if (dynamic_cast(currentItem->dataObject().p())) + { + collectionItem = currentItem; + } - int viewCount = rowCount(itemIndex.parent()); - beginInsertRows(itemIndex.parent(), viewCount, viewCount); + if (collectionItem) + { + RimReservoir* rimReservoir = dynamic_cast(collectionItem->dataObject().p()); + RimReservoirView* insertedView = rimReservoir->createAndAddReservoirView(); - caf::PdmUiTreeItem* childItem = new caf::PdmUiTreeItem(collectionItem, viewCount, insertedView); + int viewCount = rowCount(itemIndex); + beginInsertRows(itemIndex, viewCount, viewCount); - endInsertRows(); + caf::PdmUiTreeItem* childItem = new caf::PdmUiTreeItem(collectionItem, viewCount, insertedView); - insertedView->loadDataAndUpdate(); + endInsertRows(); - rebuildUiSubTree(insertedView); - - return insertedView; + insertedView->loadDataAndUpdate(); + + rebuildUiSubTree(insertedView); + + return insertedView; + } + + return NULL; } diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index 84e41c024f..f9c5b4d122 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -161,6 +161,7 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event) { QMenu menu; menu.addAction(QString("Close"), this, SLOT(slotCloseCase())); + menu.addAction(QString("New View"), this, SLOT(slotAddView())); menu.exec(event->globalPos()); } } @@ -510,12 +511,8 @@ void RimUiTreeView::slotAddView() RimUiTreeModelPdm* myModel = dynamic_cast(model()); caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex()); - RimReservoirView* rimView = dynamic_cast(uiItem->dataObject().p()); - if (rimView) - { - QModelIndex insertedIndex; - myModel->addReservoirView(index, insertedIndex); - } + QModelIndex insertedIndex; + myModel->addReservoirView(index, insertedIndex); } From e82aef5850eded693f192d8296beb7ab30eaf5c4 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 15 Feb 2013 10:01:41 +0100 Subject: [PATCH 031/242] Imroved lifespan handling for reservoirs p4#: 20526 --- .../ProjectDataModel/RimProject.cpp | 34 ++++++++++++++++++- ApplicationCode/ProjectDataModel/RimProject.h | 7 ++-- .../ProjectDataModel/RimReservoir.cpp | 3 +- .../ProjectDataModel/RimUiTreeModelPdm.cpp | 2 +- 4 files changed, 39 insertions(+), 7 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 81d5bff863..670ad8f481 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -132,7 +132,7 @@ QString RimProject::projectFileVersionString() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimProject::registerEclipseCase(RimReservoir* rimReservoir) +void RimProject::moveEclipseCaseIntoCaseGroup(RimReservoir* rimReservoir) { CVF_ASSERT(rimReservoir); @@ -184,4 +184,36 @@ void RimProject::registerEclipseCase(RimReservoir* rimReservoir) caseGroups().push_back(group); } + + // Remove reservoir from main container + reservoirs().removeChildObject(rimReservoir); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimProject::removeEclipseCaseFromAllGroups(RimReservoir* reservoir) +{ + m_gridCollection->removeCase(reservoir->reservoirData()); + + std::vector emptyCaseGroups; + for (size_t i = 0; i < caseGroups.size(); i++) + { + RimIdenticalGridCaseGroup* cg = caseGroups()[i]; + + cg->reservoirs().removeChildObject(reservoir); + + if (cg->reservoirs().size() == 0) + { + emptyCaseGroups.push_back(cg); + } + } + + for (size_t i = 0; i < emptyCaseGroups.size(); i++) + { + caseGroups().removeChildObject(emptyCaseGroups[i]); + delete emptyCaseGroups[i]; + } + + reservoirs().removeChildObject(reservoir); } diff --git a/ApplicationCode/ProjectDataModel/RimProject.h b/ApplicationCode/ProjectDataModel/RimProject.h index cf42fdf146..2fde1ce4bc 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.h +++ b/ApplicationCode/ProjectDataModel/RimProject.h @@ -48,7 +48,8 @@ public: void close(); - void registerEclipseCase(RimReservoir* rimReservoir); + void moveEclipseCaseIntoCaseGroup(RimReservoir* rimReservoir); + void removeEclipseCaseFromAllGroups(RimReservoir* rimReservoir); protected: // Overridden methods @@ -56,7 +57,7 @@ protected: virtual void setupBeforeSave(); private: - caf::PdmField m_projectFileVersionString; + caf::PdmField m_projectFileVersionString; - cvf::ref m_gridCollection; + cvf::ref m_gridCollection; }; diff --git a/ApplicationCode/ProjectDataModel/RimReservoir.cpp b/ApplicationCode/ProjectDataModel/RimReservoir.cpp index 28f0154b11..f6dcc9b5cb 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoir.cpp @@ -247,8 +247,7 @@ void RimReservoir::registerEclipseCase() CVF_ASSERT(proj); if (proj) { - - proj->registerEclipseCase(this); + proj->moveEclipseCaseIntoCaseGroup(this); } } diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index bfa5e39fe9..223a9417ab 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -219,7 +219,7 @@ void RimUiTreeModelPdm::deleteReservoir(const QModelIndex& itemIndex) removeRow(itemIndex.row(), itemIndex.parent()); RimProject* proj = RIApplication::instance()->project(); - proj->reservoirs().removeChildObject(reservoir); + proj->removeEclipseCaseFromAllGroups(reservoir); delete reservoir; } From 9ad5ec5449507b1bde56c6ed90a1d11f989a3743 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 21 Feb 2013 08:39:50 +0100 Subject: [PATCH 032/242] Add view from context menu of case p4#: 20589 --- ApplicationCode/ProjectDataModel/RimUiTreeView.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index f9c5b4d122..0630da0c1b 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -153,6 +153,7 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event) else if (dynamic_cast(uiItem->dataObject().p())) { QMenu menu; + menu.addAction(QString("New View"), this, SLOT(slotAddView())); menu.addAction(QString("Compute"), this, SLOT(slotComputeStatisticalCases())); menu.addAction(QString("Close"), this, SLOT(slotCloseCase())); menu.exec(event->globalPos()); From b6abc0c6ea227d8aba4b508a2efa84cfb6ae82bc Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 21 Feb 2013 08:46:09 +0100 Subject: [PATCH 033/242] Added CMakeLists_files.cmake in FileInterface folder p4#: 20590 --- ApplicationCode/CMakeLists.txt | 14 +------- .../FileInterface/CMakeLists_files.cmake | 33 +++++++++++++++++++ .../FileInterface_UnitTests/CMakeLists.txt | 10 ++---- 3 files changed, 36 insertions(+), 21 deletions(-) create mode 100644 ApplicationCode/FileInterface/CMakeLists_files.cmake diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index f17fe1ad1b..218e369791 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -49,17 +49,6 @@ list( APPEND CPP_SOURCES ModelVisualization/RivWellHeadPartMgr.cpp ) -list( APPEND CPP_SOURCES - FileInterface/RifEclipseInputFileTools.cpp - FileInterface/RifEclipseOutputFileTools.cpp - FileInterface/RifEclipseRestartFilesetAccess.cpp - FileInterface/RifEclipseRestartDataAccess.cpp - FileInterface/RifEclipseUnifiedRestartFileAccess.cpp - FileInterface/RifReaderEclipseInput.cpp - FileInterface/RifReaderEclipseOutput.cpp - FileInterface/RifReaderMockModel.cpp -) - list( APPEND CPP_SOURCES SocketInterface/RiaSocketServer.cpp ) @@ -97,12 +86,11 @@ list( APPEND CPP_SOURCES # Populate the filenames into variable lists include ("ReservoirDataModel/CMakeLists_files.cmake") +include ("FileInterface/CMakeLists_files.cmake") list( APPEND CPP_SOURCES ${CODE_SOURCE_FILES} ) -message(${CODE_SOURCE_FILES}) - list( APPEND CPP_SOURCES UserInterface/RICursors.cpp UserInterface/RIMainWindow.cpp diff --git a/ApplicationCode/FileInterface/CMakeLists_files.cmake b/ApplicationCode/FileInterface/CMakeLists_files.cmake new file mode 100644 index 0000000000..04b2938dc9 --- /dev/null +++ b/ApplicationCode/FileInterface/CMakeLists_files.cmake @@ -0,0 +1,33 @@ + +# Use this workaround until we're on 2.8.3 on all platforms and can use CMAKE_CURRENT_LIST_DIR directly +if (${CMAKE_VERSION} VERSION_GREATER "2.8.2") + set(CEE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR}/) +endif() + + +list(APPEND CODE_HEADER_FILES +${CEE_CURRENT_LIST_DIR}RifEclipseInputFileTools.h +${CEE_CURRENT_LIST_DIR}RifEclipseOutputFileTools.h +${CEE_CURRENT_LIST_DIR}RifEclipseRestartDataAccess.h +${CEE_CURRENT_LIST_DIR}RifEclipseRestartFilesetAccess.h +${CEE_CURRENT_LIST_DIR}RifEclipseUnifiedRestartFileAccess.h +${CEE_CURRENT_LIST_DIR}RifReaderEclipseInput.h +${CEE_CURRENT_LIST_DIR}RifReaderEclipseOutput.h +${CEE_CURRENT_LIST_DIR}RifReaderInterface.h +${CEE_CURRENT_LIST_DIR}RifReaderMockModel.h +${CEE_CURRENT_LIST_DIR}RifReaderStatisticalCalculation.h +) + +list(APPEND CODE_SOURCE_FILES +${CEE_CURRENT_LIST_DIR}RifEclipseInputFileTools.cpp +${CEE_CURRENT_LIST_DIR}RifEclipseOutputFileTools.cpp +${CEE_CURRENT_LIST_DIR}RifEclipseRestartDataAccess.cpp +${CEE_CURRENT_LIST_DIR}RifEclipseRestartFilesetAccess.cpp +${CEE_CURRENT_LIST_DIR}RifEclipseUnifiedRestartFileAccess.cpp +${CEE_CURRENT_LIST_DIR}RifReaderEclipseInput.cpp +${CEE_CURRENT_LIST_DIR}RifReaderEclipseOutput.cpp +${CEE_CURRENT_LIST_DIR}RifReaderMockModel.cpp +${CEE_CURRENT_LIST_DIR}RifReaderStatisticalCalculation.cpp +) + + diff --git a/ApplicationCode/FileInterface/FileInterface_UnitTests/CMakeLists.txt b/ApplicationCode/FileInterface/FileInterface_UnitTests/CMakeLists.txt index deb53d65b9..9c3864f00f 100644 --- a/ApplicationCode/FileInterface/FileInterface_UnitTests/CMakeLists.txt +++ b/ApplicationCode/FileInterface/FileInterface_UnitTests/CMakeLists.txt @@ -20,15 +20,9 @@ include_directories( ${ResInsight_SOURCE_DIR}/CommonCode ) +include ("${ResInsight_SOURCE_DIR}/ApplicationCode/FileInterface/CMakeLists_files.cmake") set( FILEINTERFACE_CPP_SOURCES - ../RifEclipseInputFileTools.cpp - ../RifEclipseOutputFileTools.cpp - ../RifEclipseRestartFilesetAccess.cpp - ../RifEclipseRestartDataAccess.cpp - ../RifEclipseUnifiedRestartFileAccess.cpp - ../RifReaderEclipseOutput.cpp - ../RifReaderEclipseInput.cpp - ../RifReaderMockModel.cpp + ${CODE_SOURCE_FILES} ) set( RESERVOIRDATAMODEL_CPP_SOURCES From a0b2be3dee4aeda18caf84ea167658e142b9908d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 21 Feb 2013 08:48:26 +0100 Subject: [PATCH 034/242] Added framework for statistical calculation reader p4#: 20591 --- .../RifReaderStatisticalCalculation.cpp | 121 ++++++++++++++++++ .../RifReaderStatisticalCalculation.h | 55 ++++++++ .../RimStatisticalCalculation.cpp | 16 +++ .../RimStatisticalCalculation.h | 4 + 4 files changed, 196 insertions(+) create mode 100644 ApplicationCode/FileInterface/RifReaderStatisticalCalculation.cpp create mode 100644 ApplicationCode/FileInterface/RifReaderStatisticalCalculation.h diff --git a/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.cpp b/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.cpp new file mode 100644 index 0000000000..e758d39e67 --- /dev/null +++ b/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.cpp @@ -0,0 +1,121 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 "cvfBase.h" + +#include "RigMainGrid.h" +#include "RigEclipseCase.h" +#include "RigReservoirCellResults.h" + +#include "RifReaderStatisticalCalculation.h" + + +//-------------------------------------------------------------------------------------------------- +/// Constructor +//-------------------------------------------------------------------------------------------------- +RifReaderStatisticalCalculation::RifReaderStatisticalCalculation() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// Destructor +//-------------------------------------------------------------------------------------------------- +RifReaderStatisticalCalculation::~RifReaderStatisticalCalculation() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// Open file and read geometry into given reservoir object +//-------------------------------------------------------------------------------------------------- +bool RifReaderStatisticalCalculation::open(const QString& fileName, RigEclipseCase* eclipseCase) +{ + m_matrixDynamicResultNames.push_back("SOIL"); + m_matrixDynamicResultNames.push_back("PRESSURE"); + + buildMetaData(eclipseCase); + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifReaderStatisticalCalculation::buildMetaData(RigEclipseCase* eclipseCase) +{ + RigReservoirCellResults* matrixModelResults = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS); + RigReservoirCellResults* fractureModelResults = eclipseCase->results(RifReaderInterface::FRACTURE_RESULTS); + + // Dynamic results + for (int i = 0; i < m_matrixDynamicResultNames.size(); ++i) + { + size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, m_matrixDynamicResultNames[i]); + matrixModelResults->setTimeStepDates(resIndex, m_timeSteps); + } + + for (int i = 0; i < m_fractureDynamicResultNames.size(); ++i) + { + size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, m_fractureDynamicResultNames[i]); + fractureModelResults->setTimeStepDates(resIndex, m_timeSteps); + } + + QList staticDate; + if (m_timeSteps.size() > 0) + { + staticDate.push_back(m_timeSteps.front()); + } + + // Static results + for (int i = 0; i < m_fractureStaticResultNames.size(); ++i) + { + size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, m_fractureStaticResultNames[i]); + fractureModelResults->setTimeStepDates(resIndex, staticDate); + } + + for (int i = 0; i < m_matrixStaticResultNames.size(); ++i) + { + size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, m_matrixStaticResultNames[i]); + matrixModelResults->setTimeStepDates(resIndex, staticDate); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifReaderStatisticalCalculation::setMatrixResultNames(const QStringList& staticResultNames, const QStringList& dynamicResultNames) +{ + m_matrixStaticResultNames = staticResultNames; + m_matrixDynamicResultNames = dynamicResultNames; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifReaderStatisticalCalculation::setFractureResultNames(const QStringList& staticResultNames, const QStringList& dynamicResultNames) +{ + m_fractureStaticResultNames = staticResultNames; + m_fractureDynamicResultNames = dynamicResultNames; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifReaderStatisticalCalculation::setTimeSteps(const QList& timesteps) +{ + m_timeSteps = timesteps; +} + diff --git a/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.h b/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.h new file mode 100644 index 0000000000..353051baef --- /dev/null +++ b/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.h @@ -0,0 +1,55 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 "RifReaderInterface.h" + + +class RifReaderStatisticalCalculation : public RifReaderInterface +{ +public: + RifReaderStatisticalCalculation(); + virtual ~RifReaderStatisticalCalculation(); + + // Virtual interface implementation + virtual bool open(const QString& fileName, RigEclipseCase* eclipseCase); + + virtual void close() {} + + virtual bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector* values ) { return false; } + virtual bool dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector* values ) { return false; } + + void setMatrixResultNames(const QStringList& staticResultNames, const QStringList& dynamicResultNames); + void setFractureResultNames(const QStringList& staticResultNames, const QStringList& dynamicResultNames); + + void setTimeSteps(const QList& timesteps); + +private: + void buildMetaData(RigEclipseCase* eclipseCase); + +private: + QList m_timeSteps; + + QStringList m_matrixDynamicResultNames; + QStringList m_fractureDynamicResultNames; + + QStringList m_matrixStaticResultNames; + QStringList m_fractureStaticResultNames; + +}; diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp index 946768af61..87f2aff1eb 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp @@ -22,6 +22,9 @@ #include "RimReservoirView.h" #include "cafPdmUiOrdering.h" #include "RimIdenticalGridCaseGroup.h" +#include "RigEclipseCase.h" +#include "RifReaderStatisticalCalculation.h" +#include "RigReservoirCellResults.h" CAF_PDM_SOURCE_INIT(RimStatisticalCalculation, "RimStatisticalCalculation"); @@ -37,6 +40,7 @@ RimStatisticalCalculation::RimStatisticalCalculation() CAF_PDM_InitField(&statisticsMean, "StatisticsMean", true, "Mean", "", "" ,""); CAF_PDM_InitField(&statisticsStdDev, "StatisticsStdDev", true, "Std dev", "", "" ,""); + m_readerInterface = new RifReaderStatisticalCalculation; } //-------------------------------------------------------------------------------------------------- @@ -52,6 +56,18 @@ RimStatisticalCalculation::~RimStatisticalCalculation() //-------------------------------------------------------------------------------------------------- bool RimStatisticalCalculation::openEclipseGridFile() { + cvf::ref eclipseCase = new RigEclipseCase; + + if (!m_readerInterface->open("dummy", eclipseCase.p())) + { + return false; + } + + m_rigEclipseCase = eclipseCase; + + m_rigEclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(m_readerInterface.p()); + m_rigEclipseCase->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(m_readerInterface.p()); + return true; } diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h index 01e3be7428..5990ca8165 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h @@ -27,6 +27,7 @@ class RimIdenticalGridCaseGroup; class RimResultDefinition; +class RifReaderStatisticalCalculation; //================================================================================================== @@ -60,4 +61,7 @@ private: void createAndComputeMean(); void createAndComputeStdDev(); +private: + cvf::ref m_readerInterface; + }; From f45c581dbcd9910f9ae9be3afb593d2f40850768 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 21 Feb 2013 10:38:28 +0100 Subject: [PATCH 035/242] Added name to group case p4#: 20595 --- .../ProjectDataModel/RimIdenticalGridCaseGroup.cpp | 10 ++++++++++ .../ProjectDataModel/RimIdenticalGridCaseGroup.h | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index cc892787c9..968afa016e 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -34,6 +34,8 @@ RimIdenticalGridCaseGroup::RimIdenticalGridCaseGroup() { CAF_PDM_InitObject("Identical Grids", "", "", ""); + CAF_PDM_InitField(&name, "UserDescription", QString("Identical Grid Case Group"), "Name", "", "", ""); + CAF_PDM_InitFieldNoDefault(&reservoirs, "Reservoirs", "", "", "", ""); CAF_PDM_InitFieldNoDefault(&statisticalReservoirs, "StatisticalReservoirs", "", "", "", ""); @@ -102,3 +104,11 @@ RimStatisticalCalculation* RimIdenticalGridCaseGroup::createAndAppendStatistical return newObject; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimIdenticalGridCaseGroup::userDescriptionField() +{ + return &name; +} + diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h index 871ac4c1c6..f652c4bf08 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h @@ -40,6 +40,8 @@ public: RimIdenticalGridCaseGroup(); virtual ~RimIdenticalGridCaseGroup(); + caf::PdmField name; + void addCase(RimReservoir* reservoir); caf::PdmPointersField reservoirs; @@ -48,6 +50,10 @@ public: RigMainGrid* mainGrid(); RimStatisticalCalculation* createAndAppendStatisticalCalculation(); + +protected: + virtual caf::PdmFieldHandle* userDescriptionField(); + private: cvf::ref m_mainGrid; From 4a3bde5baa3fc34f49eb7e30690f6f1f2909ba55 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 21 Feb 2013 12:00:49 +0100 Subject: [PATCH 036/242] Moved statistical cases into statistics case collection p4#: 20599 --- ApplicationCode/CMakeLists.txt | 1 + .../RimIdenticalGridCaseGroup.cpp | 23 ++----- .../RimIdenticalGridCaseGroup.h | 9 ++- .../RimStatisticalCalculation.cpp | 6 +- .../RimStatisticalCalculation.h | 3 +- .../RimStatisticalCollection.cpp | 61 +++++++++++++++++++ .../RimStatisticalCollection.h | 49 +++++++++++++++ .../ProjectDataModel/RimUiTreeModelPdm.cpp | 6 +- .../ProjectDataModel/RimUiTreeView.cpp | 2 +- 9 files changed, 129 insertions(+), 31 deletions(-) create mode 100644 ApplicationCode/ProjectDataModel/RimStatisticalCollection.cpp create mode 100644 ApplicationCode/ProjectDataModel/RimStatisticalCollection.h diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index 218e369791..8902977fa5 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -76,6 +76,7 @@ list( APPEND CPP_SOURCES ProjectDataModel/RimWellCollection.cpp ProjectDataModel/RimScriptCollection.cpp ProjectDataModel/RimStatisticalCalculation.cpp + ProjectDataModel/RimStatisticalCollection.cpp ProjectDataModel/RimCalcScript.cpp ProjectDataModel/RimExportInputPropertySettings.cpp ProjectDataModel/RimBinaryExportSettings.cpp diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index 968afa016e..1acf612561 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -22,7 +22,9 @@ #include "RimReservoir.h" #include "RimReservoirView.h" #include "RigEclipseCase.h" + #include "RimStatisticalCalculation.h" +#include "RimStatisticalCollection.h" CAF_PDM_SOURCE_INIT(RimIdenticalGridCaseGroup, "RimIdenticalGridCaseGroup"); @@ -37,12 +39,11 @@ RimIdenticalGridCaseGroup::RimIdenticalGridCaseGroup() CAF_PDM_InitField(&name, "UserDescription", QString("Identical Grid Case Group"), "Name", "", "", ""); CAF_PDM_InitFieldNoDefault(&reservoirs, "Reservoirs", "", "", "", ""); - CAF_PDM_InitFieldNoDefault(&statisticalReservoirs, "StatisticalReservoirs", "", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&statisticalReservoirCollection, "StatisticalReservoirCollection", "StatisticalReservoirCollection", "", "", ""); - RimStatisticalCalculation* dummyStat = new RimStatisticalCalculation; - dummyStat->caseName = "Statistics 1"; + statisticalReservoirCollection = new RimStatisticalCollection; - statisticalReservoirs.push_back(dummyStat); } //-------------------------------------------------------------------------------------------------- @@ -90,20 +91,6 @@ RigMainGrid* RimIdenticalGridCaseGroup::mainGrid() return NULL; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimStatisticalCalculation* RimIdenticalGridCaseGroup::createAndAppendStatisticalCalculation() -{ - RimStatisticalCalculation* newObject = new RimStatisticalCalculation; - - newObject->caseName = "Statistics 1"; - - statisticalReservoirs.push_back(newObject); - - return newObject; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h index f652c4bf08..a0db771b7b 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h @@ -23,9 +23,10 @@ #include "cafPdmField.h" #include "cafPdmObject.h" +#include "RimStatisticalCollection.h" + class RimReservoir; class RigMainGrid; -class RimStatisticalCalculation; //================================================================================================== // @@ -44,13 +45,11 @@ public: void addCase(RimReservoir* reservoir); - caf::PdmPointersField reservoirs; - caf::PdmPointersField statisticalReservoirs; + caf::PdmPointersField reservoirs; + caf::PdmField statisticalReservoirCollection; RigMainGrid* mainGrid(); - RimStatisticalCalculation* createAndAppendStatisticalCalculation(); - protected: virtual caf::PdmFieldHandle* userDescriptionField(); diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp index 87f2aff1eb..75fc55b738 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp @@ -91,18 +91,18 @@ void RimStatisticalCalculation::defineUiOrdering(QString uiConfigName, caf::PdmU //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimIdenticalGridCaseGroup* RimStatisticalCalculation::parent() +RimStatisticalCollection* RimStatisticalCalculation::parent() { std::vector parentObjects; this->parentObjects(parentObjects); - RimIdenticalGridCaseGroup* parentObject = NULL; + RimStatisticalCollection* parentObject = NULL; for (size_t i = 0; i < parentObjects.size(); i++) { if (parentObject) continue; caf::PdmObject* obj = parentObjects[i]; - parentObject = dynamic_cast(obj); + parentObject = dynamic_cast(obj); } CVF_ASSERT(parentObject); diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h index 5990ca8165..ffdedd6205 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h @@ -28,6 +28,7 @@ class RimIdenticalGridCaseGroup; class RimResultDefinition; class RifReaderStatisticalCalculation; +class RimStatisticalCollection; //================================================================================================== @@ -50,7 +51,7 @@ public: caf::PdmField statisticsMean; caf::PdmField statisticsStdDev; - RimIdenticalGridCaseGroup* parent(); + RimStatisticalCollection* parent(); virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) const; void computeStatistics(); diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCollection.cpp b/ApplicationCode/ProjectDataModel/RimStatisticalCollection.cpp new file mode 100644 index 0000000000..b67e4efdab --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCollection.cpp @@ -0,0 +1,61 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 "RIStdInclude.h" + +#include "RimReservoirView.h" + +#include "RimStatisticalCollection.h" + + +CAF_PDM_SOURCE_INIT(RimStatisticalCollection, "RimStatisticalCollection"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimStatisticalCollection::RimStatisticalCollection() + : PdmObject() +{ + CAF_PDM_InitObject("Derived Statistics", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&reservoirs, "Reservoirs", "", "", "", ""); + + createAndAppendStatisticalCalculation(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimStatisticalCollection::~RimStatisticalCollection() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimStatisticalCalculation* RimStatisticalCollection::createAndAppendStatisticalCalculation() +{ + RimStatisticalCalculation* newObject = new RimStatisticalCalculation; + + newObject->caseName = "Statistics 1"; + + reservoirs.push_back(newObject); + + return newObject; +} diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCollection.h b/ApplicationCode/ProjectDataModel/RimStatisticalCollection.h new file mode 100644 index 0000000000..728f467fbf --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCollection.h @@ -0,0 +1,49 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 "cvfBase.h" +#include "cvfObject.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" + +#include "RimStatisticalCalculation.h" + + + +//================================================================================================== +// +// +// +//================================================================================================== +class RimStatisticalCollection : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimStatisticalCollection(); + virtual ~RimStatisticalCollection(); + + caf::PdmPointersField reservoirs; + + RimStatisticalCalculation* createAndAppendStatisticalCalculation(); + +private: + +}; diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index 223a9417ab..bb776ca2b0 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -464,7 +464,7 @@ RimStatisticalCalculation* RimUiTreeModelPdm::addStatisticalCalculation(const QM caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex); QModelIndex collectionIndex; - RimIdenticalGridCaseGroup* caseGroup = NULL; + RimStatisticalCollection* caseGroup = NULL; caf::PdmUiTreeItem* parentCollectionItem = NULL; int position = 0; @@ -476,9 +476,9 @@ RimStatisticalCalculation* RimUiTreeModelPdm::addStatisticalCalculation(const QM position = itemIndex.row(); collectionIndex = itemIndex.parent(); } - else if (dynamic_cast(currentItem->dataObject().p())) + else if (dynamic_cast(currentItem->dataObject().p())) { - caseGroup = dynamic_cast(currentItem->dataObject().p()); + caseGroup = dynamic_cast(currentItem->dataObject().p()); parentCollectionItem = currentItem; position = parentCollectionItem->childCount(); collectionIndex = itemIndex; diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index 0630da0c1b..5037814912 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -144,7 +144,7 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event) menu.addAction(QString("Save Property To File"), this, SLOT(slotWriteBinaryResultAsInputProperty())); menu.exec(event->globalPos()); } - else if (dynamic_cast(uiItem->dataObject().p())) + else if (dynamic_cast(uiItem->dataObject().p())) { QMenu menu; menu.addAction(QString("New Statistical Case"), this, SLOT(slotNewStatisticalCase())); From 0dc492da751aa5defa707b89bb1f5095141c5beb Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 21 Feb 2013 15:37:51 +0100 Subject: [PATCH 037/242] Added casecollection in grid case group p4#: 20602 --- ApplicationCode/CMakeLists.txt | 1 + .../ProjectDataModel/RimCaseCollection.cpp | 44 +++++++++++++++++ .../ProjectDataModel/RimCaseCollection.h | 47 +++++++++++++++++++ .../RimIdenticalGridCaseGroup.cpp | 19 +++----- .../RimIdenticalGridCaseGroup.h | 3 +- .../ProjectDataModel/RimProject.cpp | 4 +- 6 files changed, 103 insertions(+), 15 deletions(-) create mode 100644 ApplicationCode/ProjectDataModel/RimCaseCollection.cpp create mode 100644 ApplicationCode/ProjectDataModel/RimCaseCollection.h diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index 8902977fa5..dedf4dd2ba 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -54,6 +54,7 @@ list( APPEND CPP_SOURCES ) list( APPEND CPP_SOURCES + ProjectDataModel/RimCaseCollection.cpp ProjectDataModel/RimCellFilter.cpp ProjectDataModel/RimCellPropertyFilter.cpp ProjectDataModel/RimCellPropertyFilterCollection.cpp diff --git a/ApplicationCode/ProjectDataModel/RimCaseCollection.cpp b/ApplicationCode/ProjectDataModel/RimCaseCollection.cpp new file mode 100644 index 0000000000..8001c8bffe --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimCaseCollection.cpp @@ -0,0 +1,44 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 "RIStdInclude.h" + + +#include "RimCaseCollection.h" + +#include "RimReservoirView.h" + +CAF_PDM_SOURCE_INIT(RimCaseCollection, "RimCaseCollection"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCaseCollection::RimCaseCollection() +{ + CAF_PDM_InitObject("Derived Statistics", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&reservoirs, "Reservoirs", "", "", "", ""); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCaseCollection::~RimCaseCollection() +{ + +} diff --git a/ApplicationCode/ProjectDataModel/RimCaseCollection.h b/ApplicationCode/ProjectDataModel/RimCaseCollection.h new file mode 100644 index 0000000000..137435fc32 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimCaseCollection.h @@ -0,0 +1,47 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 "cvfBase.h" +#include "cvfObject.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" + +#include "RimStatisticalCalculation.h" + + + +//================================================================================================== +// +// +// +//================================================================================================== +class RimCaseCollection : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimCaseCollection(); + virtual ~RimCaseCollection(); + + caf::PdmPointersField reservoirs; + +private: + +}; diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index 1acf612561..d206de060b 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -1,4 +1,5 @@ ///////////////////////////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2011-2012 Statoil ASA, Ceetron AS // @@ -38,10 +39,10 @@ RimIdenticalGridCaseGroup::RimIdenticalGridCaseGroup() CAF_PDM_InitField(&name, "UserDescription", QString("Identical Grid Case Group"), "Name", "", "", ""); - CAF_PDM_InitFieldNoDefault(&reservoirs, "Reservoirs", "", "", "", ""); - - CAF_PDM_InitFieldNoDefault(&statisticalReservoirCollection, "StatisticalReservoirCollection", "StatisticalReservoirCollection", "", "", ""); + CAF_PDM_InitFieldNoDefault(&caseCollection, "CaseCollection", "Cases", "", "", ""); + CAF_PDM_InitFieldNoDefault(&statisticalReservoirCollection, "StatisticalReservoirCollection", "Derived Statistics", "", "", ""); + caseCollection = new RimCaseCollection; statisticalReservoirCollection = new RimStatisticalCollection; } @@ -69,16 +70,10 @@ void RimIdenticalGridCaseGroup::addCase(RimReservoir* reservoir) { m_mainGrid = incomingMainGrid; } - else - { - if (m_mainGrid.p() != incomingMainGrid) - { - CVF_ASSERT(false); - return; - } - } - reservoirs.push_back(reservoir); + CVF_ASSERT(m_mainGrid.p() == incomingMainGrid); + + caseCollection()->reservoirs().push_back(reservoir); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h index a0db771b7b..909ad78283 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h @@ -24,6 +24,7 @@ #include "cafPdmObject.h" #include "RimStatisticalCollection.h" +#include "RimCaseCollection.h" class RimReservoir; class RigMainGrid; @@ -45,7 +46,7 @@ public: void addCase(RimReservoir* reservoir); - caf::PdmPointersField reservoirs; + caf::PdmField caseCollection; caf::PdmField statisticalReservoirCollection; RigMainGrid* mainGrid(); diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 670ad8f481..06747c47e8 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -201,9 +201,9 @@ void RimProject::removeEclipseCaseFromAllGroups(RimReservoir* reservoir) { RimIdenticalGridCaseGroup* cg = caseGroups()[i]; - cg->reservoirs().removeChildObject(reservoir); + cg->caseCollection()->reservoirs().removeChildObject(reservoir); - if (cg->reservoirs().size() == 0) + if (cg->caseCollection()->reservoirs().size() == 0) { emptyCaseGroups.push_back(cg); } From 49236839a388a2bd7b7fb93ff473a2fa37289446 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 21 Feb 2013 16:46:34 +0100 Subject: [PATCH 038/242] Added menu item for multiple case import Find EGRID files recursively in subfolders p4#: 20603 --- ApplicationCode/Application/RIApplication.cpp | 25 +++++++ ApplicationCode/Application/RIApplication.h | 1 + .../UserInterface/RIMainWindow.cpp | 70 +++++++++++++++++++ ApplicationCode/UserInterface/RIMainWindow.h | 2 + 4 files changed, 98 insertions(+) diff --git a/ApplicationCode/Application/RIApplication.cpp b/ApplicationCode/Application/RIApplication.cpp index 1423818f87..90e70ceaef 100644 --- a/ApplicationCode/Application/RIApplication.cpp +++ b/ApplicationCode/Application/RIApplication.cpp @@ -1291,3 +1291,28 @@ void RIApplication::updateRegressionTest(const QString& testRootPath) } } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RIApplication::addEclipseCase(const QString& fileName) +{ + QFileInfo gridFileName(fileName); + + QString caseName = gridFileName.completeBaseName(); + QString casePath = gridFileName.absolutePath(); + + RimResultReservoir* rimResultReservoir = new RimResultReservoir(); + rimResultReservoir->caseName = caseName; + rimResultReservoir->caseFileName = fileName; + rimResultReservoir->caseDirectory = casePath; + + m_project->reservoirs.push_back(rimResultReservoir); + + rimResultReservoir->openEclipseGridFile(); + + onProjectOpenedOrClosed(); + + return true; + +} diff --git a/ApplicationCode/Application/RIApplication.h b/ApplicationCode/Application/RIApplication.h index 06c5822593..6603b52380 100644 --- a/ApplicationCode/Application/RIApplication.h +++ b/ApplicationCode/Application/RIApplication.h @@ -80,6 +80,7 @@ public: bool openEclipseCaseFromFile(const QString& fileName); bool openEclipseCase(const QString& caseName, const QString& caseFileName); + bool addEclipseCase(const QString& fileName); bool openInputEclipseCase(const QString& caseName, const QStringList& caseFileNames); bool loadLastUsedProject(); diff --git a/ApplicationCode/UserInterface/RIMainWindow.cpp b/ApplicationCode/UserInterface/RIMainWindow.cpp index 625373fcf2..407ae81226 100644 --- a/ApplicationCode/UserInterface/RIMainWindow.cpp +++ b/ApplicationCode/UserInterface/RIMainWindow.cpp @@ -177,6 +177,8 @@ void RIMainWindow::createActions() // File actions m_openAction = new QAction(QIcon(":/AppLogo48x48.png"), "&Open Eclipse Case", this); m_openInputEclipseFileAction= new QAction(QIcon(":/EclipseInput48x48.png"), "&Open Input Eclipse Case", this); + m_openMultipleEclipseCasesAction = new QAction(QIcon(":/EclipseInput48x48.png"), "&Open Multiple Eclipse Folders", this); + m_openProjectAction = new QAction(style()->standardIcon(QStyle::SP_DirOpenIcon), "&Open Project", this); m_openLastUsedProjectAction = new QAction("Open &Last Used Project", this); @@ -197,6 +199,7 @@ void RIMainWindow::createActions() connect(m_openAction, SIGNAL(triggered()), SLOT(slotOpenBinaryGridFiles())); connect(m_openInputEclipseFileAction,SIGNAL(triggered()), SLOT(slotOpenInputFiles())); + connect(m_openMultipleEclipseCasesAction,SIGNAL(triggered()), SLOT(slotOpenMultipleCases())); connect(m_openProjectAction, SIGNAL(triggered()), SLOT(slotOpenProject())); connect(m_openLastUsedProjectAction,SIGNAL(triggered()), SLOT(slotOpenLastUsedProject())); @@ -264,6 +267,7 @@ void RIMainWindow::createMenus() QMenu* fileMenu = menuBar()->addMenu("&File"); fileMenu->addAction(m_openAction); fileMenu->addAction(m_openInputEclipseFileAction); + fileMenu->addAction(m_openMultipleEclipseCasesAction); fileMenu->addAction(m_openProjectAction); fileMenu->addAction(m_openLastUsedProjectAction); @@ -1249,3 +1253,69 @@ void RIMainWindow::hideAllDockWindows() dockWidgets[i]->close(); } } + + +void appendEGRIDFilesRecursively(const QString& folderName, QStringList& gridFileNames) +{ + { + QDir baseDir(folderName); + baseDir.setFilter(QDir::Files); + + QStringList nameFilters; + nameFilters << "*.egrid" << ".EGRID"; + baseDir.setNameFilters(nameFilters); + + QStringList fileNames = baseDir.entryList(); + + for (int i = 0; i < fileNames.size(); ++i) + { + QString fileName = fileNames[i]; + + QString absoluteFolderName = baseDir.absoluteFilePath(fileName); + + gridFileNames.append(absoluteFolderName); + } + } + + + { + QDir baseDir(folderName); + baseDir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); + + QStringList subFolders = baseDir.entryList(); + + for (int i = 0; i < subFolders.size(); ++i) + { + QString folderName = subFolders[i]; + + QString absoluteFolderName = baseDir.absoluteFilePath(folderName); + appendEGRIDFilesRecursively(absoluteFolderName, gridFileNames); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RIMainWindow::slotOpenMultipleCases() +{ + RIApplication* app = RIApplication::instance(); + + + QStringList folderNames; + QStringList gridFileNames; + + for (int i = 0; i < folderNames.size(); i++) + { + QString fileName = folderNames[i]; + + appendEGRIDFilesRecursively(fileName, gridFileNames); + } + + for (int i = 0; i < gridFileNames.size(); i++) + { + QString fileName = gridFileNames[i]; + + app->addEclipseCase(fileName); + } +} diff --git a/ApplicationCode/UserInterface/RIMainWindow.h b/ApplicationCode/UserInterface/RIMainWindow.h index 0f133900bd..284ab19bdd 100644 --- a/ApplicationCode/UserInterface/RIMainWindow.h +++ b/ApplicationCode/UserInterface/RIMainWindow.h @@ -106,6 +106,7 @@ private: // File actions QAction* m_openAction; QAction* m_openInputEclipseFileAction; + QAction* m_openMultipleEclipseCasesAction; QAction* m_openProjectAction; QAction* m_openLastUsedProjectAction; QAction* m_saveProjectAction; @@ -162,6 +163,7 @@ private slots: // File slots void slotOpenBinaryGridFiles(); void slotOpenInputFiles(); + void slotOpenMultipleCases(); void slotOpenProject(); void slotOpenLastUsedProject(); void slotSaveProject(); From f00152823fa6e5d69c85a07352e5ece1f7853d76 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 22 Feb 2013 10:12:06 +0100 Subject: [PATCH 039/242] Consolidated cache data computations Removed automatic insertion of grids into identical grid groups p4#: 20607 --- ApplicationCode/Application/RIApplication.cpp | 4 +++ .../ProjectDataModel/RimInputReservoir.cpp | 11 +++----- .../ProjectDataModel/RimReservoir.cpp | 27 +++++++++---------- .../ProjectDataModel/RimReservoir.h | 2 +- .../ProjectDataModel/RimResultReservoir.cpp | 7 +---- 5 files changed, 23 insertions(+), 28 deletions(-) diff --git a/ApplicationCode/Application/RIApplication.cpp b/ApplicationCode/Application/RIApplication.cpp index 90e70ceaef..3232e0f85c 100644 --- a/ApplicationCode/Application/RIApplication.cpp +++ b/ApplicationCode/Application/RIApplication.cpp @@ -1253,6 +1253,8 @@ void RIApplication::runRegressionTest(const QString& testRootPath) qDebug() << "Error comparing :" << imgComparator.errorMessage() << "\n" << imgComparator.errorDetails(); } } + + closeProject(false); } } } @@ -1311,6 +1313,8 @@ bool RIApplication::addEclipseCase(const QString& fileName) rimResultReservoir->openEclipseGridFile(); + m_project->moveEclipseCaseIntoCaseGroup(rimResultReservoir); + onProjectOpenedOrClosed(); return true; diff --git a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp index df7a33a8c7..f79fd5c6d2 100644 --- a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp @@ -94,9 +94,7 @@ void RimInputReservoir::openDataFileSet(const QStringList& filenames) { m_gridFileName = filenames[i]; - registerEclipseCase(); - - m_rigEclipseCase->computeCachedData(); + computeCachedData(); break; } @@ -176,9 +174,6 @@ bool RimInputReservoir::openEclipseGridFile() } m_rigEclipseCase = eclipseCase; - - registerEclipseCase(); - loadAndSyncronizeInputProperties(); } CVF_ASSERT(m_rigEclipseCase.notNull()); @@ -186,7 +181,9 @@ bool RimInputReservoir::openEclipseGridFile() m_rigEclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p()); m_rigEclipseCase->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p()); - m_rigEclipseCase->computeCachedData(); + + computeCachedData(); + loadAndSyncronizeInputProperties(); } diff --git a/ApplicationCode/ProjectDataModel/RimReservoir.cpp b/ApplicationCode/ProjectDataModel/RimReservoir.cpp index f6dcc9b5cb..d31bceba9c 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoir.cpp @@ -230,24 +230,23 @@ void RimReservoir::fieldChangedByUi(const caf::PdmFieldHandle* changedField, con //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoir::registerEclipseCase() +void RimReservoir::computeCachedData() { - std::vector parentObjects; - this->parentObjects(parentObjects); - - RimProject* proj = NULL; - for (size_t i = 0; i < parentObjects.size(); i++) + RigEclipseCase* rigEclipseCase = reservoirData(); + if (rigEclipseCase) { - if (proj) continue; + rigEclipseCase->computeCachedData(); - caf::PdmObject* obj = parentObjects[i]; - proj = dynamic_cast(obj); - } + rigEclipseCase->mainGrid()->computeCachedData(); - CVF_ASSERT(proj); - if (proj) - { - proj->moveEclipseCaseIntoCaseGroup(this); + std::vector grids; + rigEclipseCase->allGrids(&grids); + + size_t i; + for (i = 0; i < grids.size(); i++) + { + grids[i]->computeFaults(); + } } } diff --git a/ApplicationCode/ProjectDataModel/RimReservoir.h b/ApplicationCode/ProjectDataModel/RimReservoir.h index 5b4e99f3f8..a342e9e853 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoir.h +++ b/ApplicationCode/ProjectDataModel/RimReservoir.h @@ -70,7 +70,7 @@ protected: virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ); - void registerEclipseCase(); + void computeCachedData(); protected: cvf::ref m_rigEclipseCase; diff --git a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp index 30215beece..a312b79ceb 100644 --- a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp @@ -84,13 +84,8 @@ bool RimResultReservoir::openEclipseGridFile() CVF_ASSERT(m_rigEclipseCase.notNull()); CVF_ASSERT(readerInterface.notNull()); - - progInfo.setProgressDescription("Registering Case and Grid"); - registerEclipseCase(); - - progInfo.incrementProgress(); progInfo.setProgressDescription("Computing Case Cache"); - m_rigEclipseCase->computeCachedData(); + computeCachedData(); return true; } From 49f2c42c3e2c30004644b1b7886306b306ee95c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 25 Feb 2013 09:43:42 +0100 Subject: [PATCH 040/242] Renamed to Grid Case Group in the UI p4#: 20609 --- ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index d206de060b..eab45f8957 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -35,7 +35,7 @@ CAF_PDM_SOURCE_INIT(RimIdenticalGridCaseGroup, "RimIdenticalGridCaseGroup"); //-------------------------------------------------------------------------------------------------- RimIdenticalGridCaseGroup::RimIdenticalGridCaseGroup() { - CAF_PDM_InitObject("Identical Grids", "", "", ""); + CAF_PDM_InitObject("Grid Case Group", "", "", ""); CAF_PDM_InitField(&name, "UserDescription", QString("Identical Grid Case Group"), "Name", "", "", ""); From 7f01481393c94b52f300edcc351520e20a372835 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 25 Feb 2013 09:44:26 +0100 Subject: [PATCH 041/242] Refurbished the RimReservoirView header file, to make it more readable p4#: 20610 --- .../ProjectDataModel/RimReservoirView.h | 137 +++++++++--------- 1 file changed, 70 insertions(+), 67 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.h b/ApplicationCode/ProjectDataModel/RimReservoirView.h index 2dcb730882..4cbd6db5ad 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.h +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.h @@ -85,97 +85,100 @@ public: NO_SURFACE }; - // Public fields: + // Fields containing child objects : - caf::PdmField cellResult; - caf::PdmField cellEdgeResult; - caf::PdmField overlayInfoConfig; + caf::PdmField cellResult; + caf::PdmField cellEdgeResult; - caf::PdmField scaleZ; - caf::PdmField showWindow; - caf::PdmField name; + caf::PdmField rangeFilterCollection; + caf::PdmField propertyFilterCollection; - // Visibility - caf::PdmField showInvalidCells; - caf::PdmField showInactiveCells; - caf::PdmField showMainGrid; + caf::PdmField wellCollection; - caf::PdmField wellCollection; + caf::PdmField overlayInfoConfig; - caf::PdmField rangeFilterCollection; - caf::PdmField propertyFilterCollection; + // Visualization setup fields - caf::PdmField< caf::AppEnum< MeshModeType > > meshMode; - caf::PdmField< caf::AppEnum< SurfaceModeType > > surfaceMode; + caf::PdmField name; + caf::PdmField scaleZ; + caf::PdmField showWindow; + + caf::PdmField showInvalidCells; + caf::PdmField showInactiveCells; + caf::PdmField showMainGrid; + + caf::PdmField< caf::AppEnum< MeshModeType > > meshMode; + caf::PdmField< caf::AppEnum< SurfaceModeType > > surfaceMode; + + caf::PdmField cameraPosition; + + caf::PdmField maximumFrameRate; + caf::PdmField animationMode; + + // Access internal objects + RigReservoirCellResults* gridCellResults(); + + void setEclipseCase(RimReservoir* reservoir); + RimReservoir* eclipseCase(); // Animation - caf::PdmField maximumFrameRate; - caf::PdmField animationMode; - - int currentTimeStep() { return m_currentTimeStep;} - void setCurrentTimeStep(int frameIdx); - void updateCurrentTimeStepAndRedraw(); - void endAnimation(); + int currentTimeStep() { return m_currentTimeStep;} + void setCurrentTimeStep(int frameIdx); + void updateCurrentTimeStepAndRedraw(); + void endAnimation(); // 3D Viewer - // Cam pos should be a field, but is not yet supported bu caf::Pdm - caf::PdmField cameraPosition; - void setDefaultView(); - - RIViewer* viewer(); - void updateViewerWidget(); - void updateViewerWidgetWindowTitle(); + RIViewer* viewer(); + void updateViewerWidget(); + void updateViewerWidgetWindowTitle(); + void setDefaultView(); // Picking info - bool pickInfo(size_t gridIndex, size_t cellIndex, const cvf::Vec3d& point, QString* pickInfoText) const; - void appendCellResultInfo(size_t gridIndex, size_t cellIndex, QString* resultInfoText) const; - - RigReservoirCellResults* gridCellResults(); - - void setEclipseCase(RimReservoir* reservoir); - RimReservoir* eclipseCase(); - - void calculateVisibleWellCellsIncFence(cvf::UByteArray* visibleCells, RigGridBase * grid); + bool pickInfo(size_t gridIndex, size_t cellIndex, const cvf::Vec3d& point, QString* pickInfoText) const; + void appendCellResultInfo(size_t gridIndex, size_t cellIndex, QString* resultInfoText) const; + // Does this belong here, really ? + void calculateVisibleWellCellsIncFence(cvf::UByteArray* visibleCells, RigGridBase * grid); // Display model generation public: - void loadDataAndUpdate(); - void createDisplayModelAndRedraw(); - void scheduleGeometryRegen(unsigned short geometryType); - void schedulePipeGeometryRegen(); + void loadDataAndUpdate(); + void createDisplayModelAndRedraw(); + void scheduleGeometryRegen(unsigned short geometryType); + void schedulePipeGeometryRegen(); + + // Display model generation +private: + void createDisplayModel(); + void updateDisplayModelVisibility(); + void updateCurrentTimeStep(); + void indicesToVisibleGrids(std::vector* gridIndices); + void updateScaleTransform(); + void updateStaticCellColors(); + void updateStaticCellColors(unsigned short geometryType); + void updateLegends(); + + cvf::ref m_geometry; + cvf::ref m_pipesPartManager; // Overridden PDM methods: public: - virtual caf::PdmFieldHandle* userDescriptionField() { return &name;} - virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); + virtual caf::PdmFieldHandle* userDescriptionField() { return &name;} + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); protected: - virtual void initAfterRead(); - virtual void setupBeforeSave(); + virtual void initAfterRead(); + virtual void setupBeforeSave(); + // Really private +private: + void syncronizeWellsWithResults(); + void clampCurrentTimestep(); private: - void syncronizeWellsWithResults(); - void clampCurrentTimestep(); - -private: - caf::PdmField m_currentTimeStep; - QPointer m_viewer; - caf::PdmPointer m_reservoir; + caf::PdmField m_currentTimeStep; + QPointer m_viewer; + caf::PdmPointer m_reservoir; -// Display model generation -private: - void createDisplayModel(); - void updateDisplayModelVisibility(); - void updateCurrentTimeStep(); - void indicesToVisibleGrids(std::vector* gridIndices); - void updateScaleTransform(); - void updateStaticCellColors(); - void updateStaticCellColors(unsigned short geometryType); - void updateLegends(); - - cvf::ref m_geometry; - cvf::ref m_pipesPartManager; }; From 459f2a033be61b2d81f304dbebe2454a63036511 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 25 Feb 2013 11:52:28 +0100 Subject: [PATCH 042/242] Added background color setting to a view. Requested by Statoil at 19.02.2013 p4#: 20611 --- .../ProjectDataModel/RimReservoirView.cpp | 12 ++++++++++++ ApplicationCode/ProjectDataModel/RimReservoirView.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp index 7e7cbf39d2..21959e1251 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp @@ -137,6 +137,9 @@ RimReservoirView::RimReservoirView() CAF_PDM_InitField(&showInactiveCells, "ShowInactiveCells", false, "Show Inactive Cells", "", "", ""); CAF_PDM_InitField(&showInvalidCells, "ShowInvalidCells", false, "Show Invalid Cells", "", "", ""); + CAF_PDM_InitField(&backgroundColor, "ViewBackgroundColor", cvf::Color3f(0.69f, 0.77f, 0.87f), "Viewer Background", "", "", ""); + + CAF_PDM_InitField(&cameraPosition, "CameraPosition", cvf::Mat4d::IDENTITY, "", "", "", ""); @@ -220,6 +223,8 @@ void RimReservoirView::updateViewerWidget() RIMainWindow::instance()->setActiveViewer(m_viewer); if (isViewerCreated) m_viewer->mainCamera()->setViewMatrix(cameraPosition); + m_viewer->mainCamera()->viewport()->setClearColor(cvf::Color4f(backgroundColor())); + m_viewer->update(); } else @@ -358,6 +363,13 @@ void RimReservoirView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, createDisplayModelAndRedraw(); } } + else if (changedField == &backgroundColor ) + { + if (viewer() != NULL) + { + updateViewerWidget(); + } + } else if (changedField == &m_currentTimeStep) { if (m_viewer) diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.h b/ApplicationCode/ProjectDataModel/RimReservoirView.h index 4cbd6db5ad..bb2324534c 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.h +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.h @@ -110,6 +110,8 @@ public: caf::PdmField< caf::AppEnum< MeshModeType > > meshMode; caf::PdmField< caf::AppEnum< SurfaceModeType > > surfaceMode; + caf::PdmField< cvf::Color3f > backgroundColor; + caf::PdmField cameraPosition; caf::PdmField maximumFrameRate; From d8000be32a4ef37a4d28e68fba41cfba6eb99815 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 25 Feb 2013 13:27:38 +0100 Subject: [PATCH 043/242] Use isActiveInMatrixModel instead of activeInMatrixModel p4#: 20612 --- ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp | 8 ++++---- ApplicationCode/SocketInterface/RiaSocketServer.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp index 1f476b3f65..a192199546 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp @@ -266,12 +266,12 @@ void RigEclipseCase::computeActiveCellData() size_t i, j, k; m_mainGrid->ijkFromCellIndex(idx, &i, &j, &k); - if (m_activeCellInfo.activeIndexInMatrixModel(idx)) + if (m_activeCellInfo.isActiveInMatrixModel(idx)) { matrixModelActiveBB.add(i, j, k); } - if (m_activeCellInfo.activeIndexInFractureModel(idx)) + if (m_activeCellInfo.isActiveInFractureModel(idx)) { fractureModelActiveBB.add(i, j, k); } @@ -325,9 +325,9 @@ void RigEclipseCase::computeActiveCellsGeometryBoundingBox() } else { - for (size_t i = 0; i < m_mainGrid->cells().size(); i++) + for (size_t i = 0; i < m_mainGrid->cellCount(); i++) { - if (m_activeCellInfo.activeIndexInMatrixModel(i)) + if (m_activeCellInfo.isActiveInMatrixModel(i)) { const RigCell& c = m_mainGrid->cells()[i]; const caf::SizeTArray8& indices = c.cornerIndices(); diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.cpp b/ApplicationCode/SocketInterface/RiaSocketServer.cpp index c818ec1185..80308f3e8e 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.cpp +++ b/ApplicationCode/SocketInterface/RiaSocketServer.cpp @@ -650,7 +650,7 @@ void RiaSocketServer::calculateMatrixModelActiveCellInfo(std::vector& gr for (size_t cIdx = 0; cIdx < globalCells.size(); ++cIdx) { - if (actCellInfo->activeIndexInMatrixModel(cIdx)) + if (actCellInfo->isActiveInMatrixModel(cIdx)) { RigGridBase* grid = globalCells[cIdx].hostGrid(); CVF_ASSERT(grid != NULL); From edda92182b110054a795fd7d7fd9af9b95026e81 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 25 Feb 2013 14:01:40 +0100 Subject: [PATCH 044/242] Use active cell info struct instead of RigCell member function p4#: 20613 --- ApplicationCode/ProjectDataModel/RimReservoirView.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp index 21959e1251..51ed1acdb3 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp @@ -1185,6 +1185,13 @@ void RimReservoirView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibl // If all wells are forced off, return if (this->wellCollection()->wellCellVisibility() == RimWellCollection::FORCE_ALL_OFF) return; + RigActiveCellInfo* activeCellInfo = NULL; + if (eclipseCase() && eclipseCase()->reservoirData()) + { + activeCellInfo = eclipseCase()->reservoirData()->activeCellInfo(); + } + CVF_ASSERT(activeCellInfo); + // Loop over the wells and find their contribution for (size_t wIdx = 0; wIdx < this->wellCollection()->wells().size(); ++wIdx) { @@ -1249,7 +1256,9 @@ void RimReservoirView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibl for ( fIdx = 0; fIdx < cellCountFenceDirection; ++fIdx) { size_t fenceCellIndex = grid->cellIndexFromIJK(*pI,*pJ,*pK); - if (grid->cell(fenceCellIndex).isActiveInMatrixModel()) + size_t globalGridCellIndex = grid->globalGridCellIndex(fenceCellIndex); + + if (activeCellInfo && activeCellInfo->isActiveInMatrixModel(globalGridCellIndex)) { (*visibleCells)[fenceCellIndex] = true; } From 1a235529ac1c3fb9f57382dd1d83d9e114c02ccb Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 25 Feb 2013 14:07:59 +0100 Subject: [PATCH 045/242] Removed active cell info from RigCell Set all cells active for mock models p4#: 20614 --- .../FileInterface/RifReaderEclipseOutput.cpp | 5 --- .../ProjectDataModel/RimInputReservoir.cpp | 8 +++-- .../ProjectDataModel/RimResultReservoir.cpp | 8 +++-- .../ReservoirDataModel/RigCell.cpp | 1 - ApplicationCode/ReservoirDataModel/RigCell.h | 6 ---- .../RigReservoirBuilderMock.cpp | 34 ++++++++----------- 6 files changed, 26 insertions(+), 36 deletions(-) diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index 597da8587e..a405e20190 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -118,13 +118,8 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigActiveCellInfo* activeCellIn int matrixActiveIndex = ecl_grid_get_active_index1(localEclGrid, localCellIdx); if (matrixActiveIndex != -1) { - cell.setActiveIndexInMatrixModel(matrixActiveStartIndex + matrixActiveIndex); activeCellInfo->setActiveIndexInMatrixModel(cellStartIndex + localCellIdx, matrixActiveStartIndex + matrixActiveIndex); } - else - { - cell.setActiveIndexInMatrixModel(cvf::UNDEFINED_SIZE_T); - } int fractureActiveIndex = ecl_grid_get_active_fracture_index1(localEclGrid, localCellIdx); if (fractureActiveIndex != -1) diff --git a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp index f79fd5c6d2..27c50d2e63 100644 --- a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp @@ -383,12 +383,16 @@ cvf::ref RimInputReservoir::createMockModel(QString modelNam mockFileInterface->open("", reservoir.p()); { size_t idx = reservoir->mainGrid()->cellIndexFromIJK(1, 3, 4); - reservoir->mainGrid()->cell(idx).setActiveIndexInMatrixModel(cvf::UNDEFINED_SIZE_T); + + //TODO: Rewrite active cell info in mock models + //reservoir->mainGrid()->cell(idx).setActiveIndexInMatrixModel(cvf::UNDEFINED_SIZE_T); } { size_t idx = reservoir->mainGrid()->cellIndexFromIJK(2, 2, 3); - reservoir->mainGrid()->cell(idx).setActiveIndexInMatrixModel(cvf::UNDEFINED_SIZE_T); + + //TODO: Rewrite active cell info in mock models + //reservoir->mainGrid()->cell(idx).setActiveIndexInMatrixModel(cvf::UNDEFINED_SIZE_T); } // Add a property diff --git a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp index a312b79ceb..5461b8b8f2 100644 --- a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp @@ -109,12 +109,16 @@ cvf::ref RimResultReservoir::createMockModel(QString modelNa mockFileInterface->open("", reservoir.p()); { size_t idx = reservoir->mainGrid()->cellIndexFromIJK(1, 3, 4); - reservoir->mainGrid()->cell(idx).setActiveIndexInMatrixModel(cvf::UNDEFINED_SIZE_T); + + //TODO: Rewrite active cell info in mock models + //reservoir->mainGrid()->cell(idx).setActiveIndexInMatrixModel(cvf::UNDEFINED_SIZE_T); } { size_t idx = reservoir->mainGrid()->cellIndexFromIJK(2, 2, 3); - reservoir->mainGrid()->cell(idx).setActiveIndexInMatrixModel(cvf::UNDEFINED_SIZE_T); + + //TODO: Rewrite active cell info in mock models + //reservoir->mainGrid()->cell(idx).setActiveIndexInMatrixModel(cvf::UNDEFINED_SIZE_T); } } else if (modelName == "Result Mock Debug Model With Results") diff --git a/ApplicationCode/ReservoirDataModel/RigCell.cpp b/ApplicationCode/ReservoirDataModel/RigCell.cpp index 1228fa9860..84f16b9fdc 100644 --- a/ApplicationCode/ReservoirDataModel/RigCell.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCell.cpp @@ -42,7 +42,6 @@ RigCell::RigCell() : m_hostGrid(NULL), m_isInvalid(false), m_isWellCell(false), - m_activeIndexInMatrixModel(cvf::UNDEFINED_SIZE_T), m_cellIndex(cvf::UNDEFINED_SIZE_T), m_isInCoarseCell(false) { diff --git a/ApplicationCode/ReservoirDataModel/RigCell.h b/ApplicationCode/ReservoirDataModel/RigCell.h index a6ee7c6395..f328103f05 100644 --- a/ApplicationCode/ReservoirDataModel/RigCell.h +++ b/ApplicationCode/ReservoirDataModel/RigCell.h @@ -37,10 +37,6 @@ public: caf::SizeTArray8& cornerIndices() { return m_cornerIndices;} const caf::SizeTArray8& cornerIndices() const { return m_cornerIndices;} - bool isActiveInMatrixModel() const { return m_activeIndexInMatrixModel != cvf::UNDEFINED_SIZE_T; } - size_t activeIndexInMatrixModel() const { return m_activeIndexInMatrixModel; } - void setActiveIndexInMatrixModel(size_t val) { m_activeIndexInMatrixModel = val; } - bool isInvalid() const { return m_isInvalid; } void setInvalid( bool val ) { m_isInvalid = val; } @@ -89,6 +85,4 @@ private: // Result case specific data bool m_isWellCell; - - size_t m_activeIndexInMatrixModel; ///< This cell's running index of all the active calls (matrix) in the reservoir }; diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp index 3b6fc38cd0..00efac4260 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp @@ -152,6 +152,8 @@ void RigReservoirBuilderMock::appendCells(size_t nodeStartIndex, size_t cellCoun riCell.setParentCellIndex(0); + //TODO: Rewrite active cell info in mock models + /* if (!(i % 5)) { riCell.setActiveIndexInMatrixModel(cvf::UNDEFINED_SIZE_T); @@ -160,6 +162,7 @@ void RigReservoirBuilderMock::appendCells(size_t nodeStartIndex, size_t cellCoun { riCell.setActiveIndexInMatrixModel(activeCellIndex++); } + */ cells.push_back(riCell); } @@ -242,6 +245,14 @@ void RigReservoirBuilderMock::populateReservoir(RigEclipseCase* eclipseCase) eclipseCase->mainGrid()->setGridPointDimensions(m_gridPointDimensions); addWellData(eclipseCase, eclipseCase->mainGrid()); + + // Set all cells active + RigActiveCellInfo* activeCellInfo = eclipseCase->activeCellInfo(); + activeCellInfo->setGlobalCellCount(eclipseCase->mainGrid()->cells().size()); + for (size_t i = 0; i < eclipseCase->mainGrid()->cells().size(); i++) + { + activeCellInfo->setActiveIndexInMatrixModel(i, i); + } } @@ -293,17 +304,8 @@ bool RigReservoirBuilderMock::staticResult(RigEclipseCase* eclipseCase, const QS for (k = 0; k < eclipseCase->mainGrid()->cells().size(); k++) { - RigCell& cell = eclipseCase->mainGrid()->cells()[k]; - if (cell.isActiveInMatrixModel()) { - if (cell.hostGrid() == eclipseCase->mainGrid()) - { - values->push_back((k * 2) % eclipseCase->mainGrid()->cells().size()); - } - else - { - values->push_back(500); - } + values->push_back((k * 2) % eclipseCase->mainGrid()->cells().size()); } } @@ -331,17 +333,9 @@ bool RigReservoirBuilderMock::dynamicResult(RigEclipseCase* eclipseCase, const Q for (k = 0; k < eclipseCase->mainGrid()->cells().size(); k++) { RigCell& cell = eclipseCase->mainGrid()->cells()[k]; - if (cell.isActiveInMatrixModel()) { - if (cell.hostGrid() == eclipseCase->mainGrid()) - { - double val = offsetValue + scaleValue * ( (stepIndex * 1000 + k) % eclipseCase->mainGrid()->cells().size() ); - values->push_back(val); - } - else - { - values->push_back(500); - } + double val = offsetValue + scaleValue * ( (stepIndex * 1000 + k) % eclipseCase->mainGrid()->cells().size() ); + values->push_back(val); } } From 2b5bea7a4a2350f172c42ad25ef571f967f5cda9 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 26 Feb 2013 09:38:33 +0100 Subject: [PATCH 046/242] Cleaned up and improved how files are included from CMakeLists_files.cmake p4#: 20616 --- .../FileInterface_UnitTests/CMakeLists.txt | 65 +++++++------------ 1 file changed, 25 insertions(+), 40 deletions(-) diff --git a/ApplicationCode/FileInterface/FileInterface_UnitTests/CMakeLists.txt b/ApplicationCode/FileInterface/FileInterface_UnitTests/CMakeLists.txt index 9c3864f00f..33a34260a3 100644 --- a/ApplicationCode/FileInterface/FileInterface_UnitTests/CMakeLists.txt +++ b/ApplicationCode/FileInterface/FileInterface_UnitTests/CMakeLists.txt @@ -20,33 +20,34 @@ include_directories( ${ResInsight_SOURCE_DIR}/CommonCode ) + +# Populate variables from read from CMakeLists_files.cmake +set (CODE_SOURCE_FILES ) include ("${ResInsight_SOURCE_DIR}/ApplicationCode/FileInterface/CMakeLists_files.cmake") -set( FILEINTERFACE_CPP_SOURCES +set( CPP_SOURCES + ${CPP_SOURCES} ${CODE_SOURCE_FILES} ) +source_group( "FileInterface" FILES ${CODE_SOURCE_FILES} ) -set( RESERVOIRDATAMODEL_CPP_SOURCES - ${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigCell.cpp - ${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigGridBase.cpp - ${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigLocalGrid.cpp - ${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp - ${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp - ${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp - ${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp - ${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigWellResults.cpp - ${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp - ${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp + +# Populate variables from read from CMakeLists_files.cmake +set (CODE_SOURCE_FILES ) +include ("${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake") +set( CPP_SOURCES + ${CPP_SOURCES} + ${CODE_SOURCE_FILES} +) +source_group( "ReservoirDataModel" FILES ${CODE_SOURCE_FILES} ) + + +set( CPP_SOURCES + ${CPP_SOURCES} ${ResInsight_SOURCE_DIR}/cafUserInterface/cafProgressInfo.cpp ) -set( CPP_SOURCES - ${FILEINTERFACE_CPP_SOURCES} - ${RESERVOIRDATAMODEL_CPP_SOURCES} -) - -source_group( "FileInterface" FILES ${FILEINTERFACE_CPP_SOURCES} ) -source_group( "ReservoirDataModel" FILES ${RESERVOIRDATAMODEL_CPP_SOURCES} ) +source_group( "Headers" FILES ${CODE_HEADER_FILES} ) set( UNIT_TEST_CPP_SOURCES main.cpp @@ -54,7 +55,6 @@ set( UNIT_TEST_CPP_SOURCES Ert-Test.cpp ) - set( LINK_LIBRARIES CommonCode @@ -71,20 +71,22 @@ set( LINK_LIBRARIES ${QT_LIBRARIES} ) - - add_executable( ${ProjectName} + ${CODE_HEADER_FILES} + ${CPP_SOURCES} ${UNIT_TEST_CPP_SOURCES} ${ResInsight_SOURCE_DIR}/ThirdParty/gtest/gtest-all.cc + + ${ResInsight_SOURCE_DIR}/ApplicationCode/FileInterface/CMakeLists_files.cmake + ${ResInsight_SOURCE_DIR}/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake ) set( EXTERNAL_LINK_LIBRARIES ${ERT_LIBRARY_LIST} ) target_link_libraries( ${ProjectName} ${LINK_LIBRARIES} ${EXTERNAL_LINK_LIBRARIES}) - # Copy Dlls if (MSVC) @@ -97,21 +99,4 @@ if (MSVC) ${CMAKE_CURRENT_BINARY_DIR}/$) endforeach( qtlib ) - - # DLLs ERT depends on -# add_custom_command(TARGET ${ProjectName} POST_BUILD -# COMMAND ${CMAKE_COMMAND} -E copy_directory -# "${PROJECT_SOURCE_DIR}/../../../ThirdParty/Ert-windows/bin/" -# ${CMAKE_CURRENT_BINARY_DIR}/$) - - - # ERT DLLs - # set (ERT_MODULES ecl geometry util well) - # foreach (ert_module ${ERT_MODULES}) - # add_custom_command(TARGET ${ProjectName} POST_BUILD - # COMMAND ${CMAKE_COMMAND} -E copy_if_different - # "${CMAKE_CURRENT_SOURCE_DIR}/../../../ThirdParty/Ert-windows/${ert_module}/lib/lib${ert_module}.dll" - # ${CMAKE_CURRENT_BINARY_DIR}/$) - # endforeach() - endif(MSVC) From deae7520b9a3e7627b4daa9a7a5ee485fe9d9845 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 26 Feb 2013 11:48:41 +0100 Subject: [PATCH 047/242] Pipe generator: Added some asserts. p4#: 20624 --- .../LibRender/cvfOverlayScalarMapperLegend.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/VisualizationModules/LibRender/cvfOverlayScalarMapperLegend.cpp b/VisualizationModules/LibRender/cvfOverlayScalarMapperLegend.cpp index 93ea5c99a6..f5b649083e 100644 --- a/VisualizationModules/LibRender/cvfOverlayScalarMapperLegend.cpp +++ b/VisualizationModules/LibRender/cvfOverlayScalarMapperLegend.cpp @@ -686,7 +686,14 @@ void OverlayScalarMapperLegend::layoutInfo(OverlayColorLegendLayoutInfo* layout) if (m_scalarMapper.isNull()) t = 0; else t = m_scalarMapper->normalizedValue(m_tickValues[i]); t = Math::clamp(t, 0.0, 1.1); - layout->tickPixelPos->set(i, t*layout->legendRect.height()); + if (i != numTicks -1) + { + layout->tickPixelPos->set(i, t*layout->legendRect.height()); + } + else + { + layout->tickPixelPos->set(i, layout->legendRect.height()); // Make sure we get a value at the top even if the scalarmapper range is zero + } } } From 39ac12f2f3de6c1cab0ab6d75d18f651009c5b56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 26 Feb 2013 11:49:28 +0100 Subject: [PATCH 048/242] Pipe generator: Added some asserts. p4#: 20624 --- ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.cpp index e7562e8b05..c96ad5d33e 100644 --- a/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.cpp @@ -83,6 +83,7 @@ void RivPipeGeometryGenerator::setBendScalingFactor(double scaleFactor) //-------------------------------------------------------------------------------------------------- void RivPipeGeometryGenerator::setRadius(double radius) { + CVF_ASSERT(0 <= radius && radius < 1e100); m_radius = radius; clearComputedData(); @@ -93,6 +94,7 @@ void RivPipeGeometryGenerator::setRadius(double radius) //-------------------------------------------------------------------------------------------------- void RivPipeGeometryGenerator::setCrossSectionVertexCount(size_t nodeCount) { + CVF_ASSERT( 2 < nodeCount && nodeCount < 1000000); m_crossSectionNodeCount = nodeCount; clearComputedData(); From ab02afabcf8c2c52505b4500422f9e4cba2a2718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 26 Feb 2013 12:45:41 +0100 Subject: [PATCH 049/242] Legend config: Removed obsolete min value threshold p4#: 20626 --- .../ProjectDataModel/RimLegendConfig.cpp | 8 +- .../ProjectDataModel/RimLegendConfig.h | 2 +- .../cvfScalarMapperContinuousLog.cpp | 53 +++++++++---- .../LibRender/cvfScalarMapperContinuousLog.h | 9 +++ .../cvfScalarMapperDiscreteLinear.cpp | 12 +-- .../LibRender/cvfScalarMapperDiscreteLinear.h | 5 +- .../LibRender/cvfScalarMapperDiscreteLog.cpp | 74 +++++++++++++++---- .../LibRender/cvfScalarMapperDiscreteLog.h | 18 ++++- .../LibRender/cvfScalarMapperRangeBased.cpp | 14 ++-- .../LibRender/cvfScalarMapperRangeBased.h | 2 + 10 files changed, 148 insertions(+), 49 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp index 33fca47d93..625e8b0d48 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp @@ -405,13 +405,13 @@ void RimLegendConfig::recreateLegend() //-------------------------------------------------------------------------------------------------- double RimLegendConfig::adjust(double domainValue, double precision) { - double decadeValue = cvf::Math::abs(domainValue); - double threshold = 1e-6; - if (decadeValue < threshold) + double absDomainValue = cvf::Math::abs(domainValue); + if (absDomainValue == 0.0) { return 0.0; } - double logDecValue = log10(decadeValue); + + double logDecValue = log10(absDomainValue); logDecValue = cvf::Math::ceil(logDecValue); double factor = pow(10.0, precision - logDecValue); diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.h b/ApplicationCode/ProjectDataModel/RimLegendConfig.h index c2df1b93ff..540c0a63f2 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.h @@ -92,7 +92,7 @@ private: caf::PdmPointer m_reservoirView; cvf::ref m_linDiscreteScalarMapper; - cvf::ref m_logDiscreteScalarMapper; + cvf::ref m_logDiscreteScalarMapper; cvf::ref m_logSmoothScalarMapper; cvf::ref m_linSmoothScalarMapper; cvf::ref m_currentScalarMapper; diff --git a/VisualizationModules/LibRender/cvfScalarMapperContinuousLog.cpp b/VisualizationModules/LibRender/cvfScalarMapperContinuousLog.cpp index e3c8fd53a8..8cccdcae42 100644 --- a/VisualizationModules/LibRender/cvfScalarMapperContinuousLog.cpp +++ b/VisualizationModules/LibRender/cvfScalarMapperContinuousLog.cpp @@ -22,6 +22,7 @@ #include "cvfMath.h" #include "cvfTextureImage.h" #include +#include namespace cvf { @@ -34,6 +35,9 @@ namespace cvf { /// Configured by specifying a number of level colors and a min/max range. //================================================================================================== ScalarMapperContinuousLog::ScalarMapperContinuousLog() + : m_hasNegativeRange(false), + m_logRange(0.0), + m_logRangeMin(0.0) { } @@ -43,17 +47,16 @@ ScalarMapperContinuousLog::ScalarMapperContinuousLog() //-------------------------------------------------------------------------------------------------- double ScalarMapperContinuousLog::normalizedValue(double scalarValue) const { - double logRangeMax = log10(m_rangeMax); - double logRangeMin = log10(m_rangeMin); - double logRange = logRangeMax - logRangeMin; + if (m_hasNegativeRange) scalarValue = -1.0*scalarValue; + double logValue; - - if (scalarValue <= 0) logValue = logRangeMin; + + if (scalarValue <= 0) logValue = std::numeric_limits::min_exponent10; else logValue = log10(scalarValue); - if (logRange != 0) + if (m_logRange != 0) { - return cvf::Math::clamp((logValue - logRangeMin)/logRange, 0.0, 1.0); + return cvf::Math::clamp((logValue - m_logRangeMin)/m_logRange, 0.0, 1.0); } else { @@ -66,13 +69,37 @@ double ScalarMapperContinuousLog::normalizedValue(double scalarValue) const //-------------------------------------------------------------------------------------------------- double ScalarMapperContinuousLog::domainValue(double normalizedPosition) const { - double logRangeMax = log10(m_rangeMax); - double logRangeMin = log10(m_rangeMin); - double logRange = logRangeMax - logRangeMin; + double logValue = normalizedPosition*m_logRange + m_logRangeMin; + double domainVal = pow(10, logValue); - double logValue = normalizedPosition*logRange + logRangeMin; - - return pow(10, logValue); + if (m_hasNegativeRange) + domainVal *= -1.0; + + return domainVal; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void ScalarMapperContinuousLog::rangeUpdated() +{ + m_hasNegativeRange = false; + + double transformedRangeMax = m_rangeMax; + double transformedRangeMin = m_rangeMin; + + if ( m_rangeMax <= 0 && m_rangeMin <= 0) + { + m_hasNegativeRange = true; + + transformedRangeMax = -1.0*transformedRangeMax; + transformedRangeMin = -1.0*transformedRangeMin; + } + + double logRangeMax = (transformedRangeMax > 0) ? log10(transformedRangeMax): std::numeric_limits::min_exponent10; + m_logRangeMin = (transformedRangeMin > 0) ? log10(transformedRangeMin): std::numeric_limits::min_exponent10; + + m_logRange = logRangeMax - m_logRangeMin; } } // namespace cvf diff --git a/VisualizationModules/LibRender/cvfScalarMapperContinuousLog.h b/VisualizationModules/LibRender/cvfScalarMapperContinuousLog.h index 72a1b62d80..eda29b7339 100644 --- a/VisualizationModules/LibRender/cvfScalarMapperContinuousLog.h +++ b/VisualizationModules/LibRender/cvfScalarMapperContinuousLog.h @@ -38,6 +38,15 @@ public: virtual double normalizedValue( double domainValue ) const; virtual double domainValue( double normalizedPosition ) const; + + // +protected: + virtual void rangeUpdated(); + +private: + double m_logRange; + double m_logRangeMin; + bool m_hasNegativeRange; }; } diff --git a/VisualizationModules/LibRender/cvfScalarMapperDiscreteLinear.cpp b/VisualizationModules/LibRender/cvfScalarMapperDiscreteLinear.cpp index 6af6569e9e..febea0c299 100644 --- a/VisualizationModules/LibRender/cvfScalarMapperDiscreteLinear.cpp +++ b/VisualizationModules/LibRender/cvfScalarMapperDiscreteLinear.cpp @@ -41,7 +41,7 @@ ScalarMapperDiscreteLinear::ScalarMapperDiscreteLinear() //-------------------------------------------------------------------------------------------------- Vec2f ScalarMapperDiscreteLinear::mapToTextureCoord(double scalarValue) const { - double discVal = discretize(scalarValue); + double discVal = discretize(scalarValue, m_sortedLevels); return ScalarMapperRangeBased::mapToTextureCoord(discVal); } @@ -50,20 +50,20 @@ Vec2f ScalarMapperDiscreteLinear::mapToTextureCoord(double scalarValue) const //-------------------------------------------------------------------------------------------------- Color3ub ScalarMapperDiscreteLinear::mapToColor(double scalarValue) const { - double discVal = discretize(scalarValue); + double discVal = discretize(scalarValue, m_sortedLevels); return ScalarMapperRangeBased::mapToColor(discVal); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double ScalarMapperDiscreteLinear::discretize(double scalarValue) const +double ScalarMapperDiscreteLinear::discretize(double scalarValue, const std::set& sortedLevels) { std::set::iterator it; - it = m_sortedLevels.upper_bound(scalarValue); - if (it == m_sortedLevels.begin()) return (*it); - if (it == m_sortedLevels.end()) return (*m_sortedLevels.rbegin()); + it = sortedLevels.upper_bound(scalarValue); + if (it == sortedLevels.begin()) return (*it); + if (it == sortedLevels.end()) return (*sortedLevels.rbegin()); double upperValue = *it; it--; double lowerValue = *it; diff --git a/VisualizationModules/LibRender/cvfScalarMapperDiscreteLinear.h b/VisualizationModules/LibRender/cvfScalarMapperDiscreteLinear.h index 824fe00946..ec7a8baec1 100644 --- a/VisualizationModules/LibRender/cvfScalarMapperDiscreteLinear.h +++ b/VisualizationModules/LibRender/cvfScalarMapperDiscreteLinear.h @@ -23,6 +23,7 @@ namespace cvf { + class ScalarMapperDiscreteLog; //================================================================================================== // // Maps scalar values to texture coordinates/colors @@ -42,8 +43,8 @@ public: virtual double domainValue( double normalizedPosition ) const; private: - double discretize(double scalarValue) const; - + static double discretize(double scalarValue, const std::set& sortedLevels); + friend ScalarMapperDiscreteLog; }; } diff --git a/VisualizationModules/LibRender/cvfScalarMapperDiscreteLog.cpp b/VisualizationModules/LibRender/cvfScalarMapperDiscreteLog.cpp index 0ee3cbabd6..48e1adb274 100644 --- a/VisualizationModules/LibRender/cvfScalarMapperDiscreteLog.cpp +++ b/VisualizationModules/LibRender/cvfScalarMapperDiscreteLog.cpp @@ -18,6 +18,7 @@ //################################################################################################## #include "cvfScalarMapperDiscreteLog.h" +#include "cvfScalarMapperDiscreteLinear.h" #include #include "cvfMath.h" @@ -31,42 +32,87 @@ namespace cvf { /// Maps scalar values to texture coordinates/colors using discrete logarithmic mapping //================================================================================================== +ScalarMapperDiscreteLog::ScalarMapperDiscreteLog() +{ + m_decadeLevelCount = 2; +} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double ScalarMapperDiscreteLog::normalizedValue(double domainScalarValue) const +Vec2f ScalarMapperDiscreteLog::mapToTextureCoord(double scalarValue) const { - double logRangeMax = log10(m_rangeMax); - double logRangeMin = log10(m_rangeMin); - double logRange = logRangeMax - logRangeMin; + double discVal = ScalarMapperDiscreteLinear::discretize(scalarValue, m_sortedLevels); + return ScalarMapperRangeBased::mapToTextureCoord(discVal); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Color3ub ScalarMapperDiscreteLog::mapToColor(double scalarValue) const +{ + double discVal = ScalarMapperDiscreteLinear::discretize(scalarValue, m_sortedLevels); + return ScalarMapperRangeBased::mapToColor(discVal); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double ScalarMapperDiscreteLog::normalizedValue(double scalarValue) const +{ + if (m_hasNegativeRange) scalarValue = -1.0*scalarValue; + double logValue; - if (domainScalarValue <= 0) logValue = logRangeMin; - else logValue = log10(domainScalarValue); + if (scalarValue <= 0) logValue = std::numeric_limits::min_exponent10; + else logValue = log10(scalarValue); - if (logRange != 0) + if (m_logRange != 0) { - return cvf::Math::clamp((logValue - logRangeMin)/logRange, 0.0, 1.0); + return cvf::Math::clamp((logValue - m_logRangeMin)/m_logRange, 0.0, 1.0); } else { return 0; } -} +} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- double ScalarMapperDiscreteLog::domainValue(double normalizedPosition) const { - double logRangeMax = log10(m_rangeMax); - double logRangeMin = log10(m_rangeMin); - double logRange = logRangeMax - logRangeMin; + double logValue = normalizedPosition*m_logRange + m_logRangeMin; + double domainVal = pow(10, logValue); - double logValue = normalizedPosition*logRange + logRangeMin; + if (m_hasNegativeRange) + domainVal *= -1.0; - return pow(10, logValue); + return domainVal; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void ScalarMapperDiscreteLog::rangeUpdated() +{ + m_hasNegativeRange = false; + + double transformedRangeMax = m_rangeMax; + double transformedRangeMin = m_rangeMin; + + if ( m_rangeMax <= 0 && m_rangeMin <= 0) + { + m_hasNegativeRange = true; + + transformedRangeMax = -1.0*transformedRangeMax; + transformedRangeMin = -1.0*transformedRangeMin; + } + + double logRangeMax = (transformedRangeMax > 0) ? log10(transformedRangeMax): std::numeric_limits::min_exponent10; + m_logRangeMin = (transformedRangeMin > 0) ? log10(transformedRangeMin): std::numeric_limits::min_exponent10; + + m_logRange = logRangeMax - m_logRangeMin; } } // namespace cvf diff --git a/VisualizationModules/LibRender/cvfScalarMapperDiscreteLog.h b/VisualizationModules/LibRender/cvfScalarMapperDiscreteLog.h index b947b99bd8..bba36fbbea 100644 --- a/VisualizationModules/LibRender/cvfScalarMapperDiscreteLog.h +++ b/VisualizationModules/LibRender/cvfScalarMapperDiscreteLog.h @@ -19,7 +19,7 @@ #pragma once -#include "cvfScalarMapperDiscreteLinear.h" +#include "cvfScalarMapperRangeBased.h" namespace cvf { @@ -29,14 +29,24 @@ namespace cvf { // //================================================================================================== -class ScalarMapperDiscreteLog : public ScalarMapperDiscreteLinear +class ScalarMapperDiscreteLog : public ScalarMapperRangeBased { public: - ScalarMapperDiscreteLog() {m_decadeLevelCount = 2; } + ScalarMapperDiscreteLog(); // Implementing the Scalarmapper interface - + virtual Vec2f mapToTextureCoord(double scalarValue) const; + virtual Color3ub mapToColor(double scalarValue) const; virtual double normalizedValue( double domainValue ) const; virtual double domainValue( double normalizedPosition ) const; + + // +protected: + virtual void rangeUpdated(); + +private: + double m_logRange; + double m_logRangeMin; + bool m_hasNegativeRange; }; } diff --git a/VisualizationModules/LibRender/cvfScalarMapperRangeBased.cpp b/VisualizationModules/LibRender/cvfScalarMapperRangeBased.cpp index 5110300155..f2c41620e5 100644 --- a/VisualizationModules/LibRender/cvfScalarMapperRangeBased.cpp +++ b/VisualizationModules/LibRender/cvfScalarMapperRangeBased.cpp @@ -56,6 +56,7 @@ void ScalarMapperRangeBased::setRange(double min, double max) m_rangeMin = min; m_rangeMax = max; updateSortedLevels(); + rangeUpdated(); } @@ -160,7 +161,8 @@ bool ScalarMapperRangeBased::updateTexture(TextureImage* image) const // Then calculate a stepsize that is humanly understandable // basically rounded to whole or half of the decade in question - +// decadeParts - The number of steps wanted within a decade +// decadeValue - The value used to describe the current decade to round off within static double adjust(double domainValue, double decadeValue, unsigned int decadeParts = 2) { if (decadeValue == 0) return domainValue; // Conceptually correct @@ -200,7 +202,7 @@ void ScalarMapperRangeBased::majorTickValues( std::vector* domainValues) if (m_userDefinedLevelValues.empty()) { - domainValues->push_back(m_rangeMin); + domainValues->push_back(domainValue(0)); if (m_levelCount > 1) { double stepSizeNorm = 1.0/m_levelCount; @@ -213,17 +215,19 @@ void ScalarMapperRangeBased::majorTickValues( std::vector* domainValues) { double prevNormPos = normalizedValue(prevDomValue); double newNormPos = prevNormPos + stepSizeNorm; + double domValue = domainValue(newNormPos); double domStep = domValue - prevDomValue; double newLevel; - newLevel = prevDomValue + adjust(domStep, domStep, m_decadeLevelCount); + //newLevel = prevDomValue + adjust(domStep, domStep, m_decadeLevelCount); + newLevel = domValue; // Must handle first level specially to get a good absolute staring point // For log domain this must be done all the time, and it does not hamper linear, so.. do it always newLevel = adjust(newLevel, domStep, m_decadeLevelCount); - if (newLevel > m_rangeMax - domStep*0.4) break; + if (normalizedValue(newLevel) > 1.0 - stepSizeNorm*0.4) break; domainValues->push_back(newLevel); prevDomValue = newLevel; @@ -237,7 +241,7 @@ void ScalarMapperRangeBased::majorTickValues( std::vector* domainValues) } } } - domainValues->push_back(m_rangeMax); + domainValues->push_back(domainValue(1)); } else { diff --git a/VisualizationModules/LibRender/cvfScalarMapperRangeBased.h b/VisualizationModules/LibRender/cvfScalarMapperRangeBased.h index 93cbadcef1..2a818fb75f 100644 --- a/VisualizationModules/LibRender/cvfScalarMapperRangeBased.h +++ b/VisualizationModules/LibRender/cvfScalarMapperRangeBased.h @@ -48,6 +48,8 @@ public: virtual void majorTickValues(std::vector* domainValues ) const; protected: + virtual void rangeUpdated() {}; //< Called when the range is changed. Subclasses can reimplment to recalculate cached values + double m_rangeMin; double m_rangeMax; unsigned int m_decadeLevelCount; From dc02b1ae91e275ca2370176e6167b1a8d8ecb436 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 26 Feb 2013 14:07:30 +0100 Subject: [PATCH 050/242] Well pipe size now is based on min characteristic I, J cell size p4#: 20628 --- CommonCode/cvfStructGrid.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CommonCode/cvfStructGrid.cpp b/CommonCode/cvfStructGrid.cpp index 6b0e204e24..a268228b9a 100644 --- a/CommonCode/cvfStructGrid.cpp +++ b/CommonCode/cvfStructGrid.cpp @@ -236,19 +236,19 @@ void StructGridInterface::characteristicCellSizes(double* iSize, double* jSize, cellCornerVertices(cellIndex, cornerVerts); iSize += (cornerVerts[faceConnPosI[0]] - cornerVerts[faceConnNegI[0]]).lengthSquared(); - iSize += (cornerVerts[faceConnPosI[1]] - cornerVerts[faceConnNegI[1]]).lengthSquared(); + iSize += (cornerVerts[faceConnPosI[1]] - cornerVerts[faceConnNegI[3]]).lengthSquared(); iSize += (cornerVerts[faceConnPosI[2]] - cornerVerts[faceConnNegI[2]]).lengthSquared(); - iSize += (cornerVerts[faceConnPosI[3]] - cornerVerts[faceConnNegI[3]]).lengthSquared(); + iSize += (cornerVerts[faceConnPosI[3]] - cornerVerts[faceConnNegI[1]]).lengthSquared(); jSize += (cornerVerts[faceConnPosJ[0]] - cornerVerts[faceConnNegJ[0]]).lengthSquared(); - jSize += (cornerVerts[faceConnPosJ[1]] - cornerVerts[faceConnNegJ[1]]).lengthSquared(); + jSize += (cornerVerts[faceConnPosJ[1]] - cornerVerts[faceConnNegJ[3]]).lengthSquared(); jSize += (cornerVerts[faceConnPosJ[2]] - cornerVerts[faceConnNegJ[2]]).lengthSquared(); - jSize += (cornerVerts[faceConnPosJ[3]] - cornerVerts[faceConnNegJ[3]]).lengthSquared(); + jSize += (cornerVerts[faceConnPosJ[3]] - cornerVerts[faceConnNegJ[1]]).lengthSquared(); kSize += (cornerVerts[faceConnPosK[0]] - cornerVerts[faceConnNegK[0]]).lengthSquared(); - kSize += (cornerVerts[faceConnPosK[1]] - cornerVerts[faceConnNegK[1]]).lengthSquared(); + kSize += (cornerVerts[faceConnPosK[1]] - cornerVerts[faceConnNegK[3]]).lengthSquared(); kSize += (cornerVerts[faceConnPosK[2]] - cornerVerts[faceConnNegK[2]]).lengthSquared(); - kSize += (cornerVerts[faceConnPosK[3]] - cornerVerts[faceConnNegK[3]]).lengthSquared(); + kSize += (cornerVerts[faceConnPosK[3]] - cornerVerts[faceConnNegK[1]]).lengthSquared(); cellCount++; } From ad082254af3e04a5b8ff5cd3802aec265b3382f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 26 Feb 2013 14:08:30 +0100 Subject: [PATCH 051/242] Well pipe size now is based on min characteristic I, J cell size p4#: 20628 --- .../ModelVisualization/RivWellHeadPartMgr.cpp | 2 +- .../ModelVisualization/RivWellPipesPartMgr.cpp | 2 +- ApplicationCode/ReservoirDataModel/RigGridBase.cpp | 12 ++++++------ ApplicationCode/ReservoirDataModel/RigGridBase.h | 2 +- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp index 8012ff1172..a78833582f 100644 --- a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp @@ -90,7 +90,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex) const RigCell& whCell = rigReservoir->cellFromWellResultCell(wellResultFrame.m_wellHead); - double characteristicCellSize = rigReservoir->mainGrid()->characteristicCellSize(); + double characteristicCellSize = rigReservoir->mainGrid()->characteristicIJCellSize(); // Match this position with pipe start position in RivWellPipesPartMgr::calculateWellPipeCenterline() cvf::Vec3d whStartPos = whCell.faceCenter(cvf::StructGridInterface::NEG_K); diff --git a/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp index 183f952248..c091f1a4a2 100644 --- a/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp @@ -86,7 +86,7 @@ void RivWellPipesPartMgr::buildWellPipeParts() calculateWellPipeCenterline(pipeBranchesCLCoords, pipeBranchesCellIds); - double characteristicCellSize = m_rimReservoirView->eclipseCase()->reservoirData()->mainGrid()->characteristicCellSize(); + double characteristicCellSize = m_rimReservoirView->eclipseCase()->reservoirData()->mainGrid()->characteristicIJCellSize(); double pipeRadius = m_rimReservoirView->wellCollection()->pipeRadiusScaleFactor() *m_rimWell->pipeRadiusScaleFactor() * characteristicCellSize; for (size_t brIdx = 0; brIdx < pipeBranchesCellIds.size(); ++brIdx) diff --git a/ApplicationCode/ReservoirDataModel/RigGridBase.cpp b/ApplicationCode/ReservoirDataModel/RigGridBase.cpp index f00160f6c2..c4073bcd2c 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridBase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridBase.cpp @@ -435,18 +435,18 @@ cvf::Vec3d RigGridBase::displayModelOffset() const } //-------------------------------------------------------------------------------------------------- -/// Returns the max size of the charactristic cell sizes +/// Returns the min size of the I and J charactristic cell sizes //-------------------------------------------------------------------------------------------------- -double RigGridBase::characteristicCellSize() +double RigGridBase::characteristicIJCellSize() { - double characteristicCellSize = 0; + double characteristicCellSize = HUGE_VAL; double cellSizeI, cellSizeJ, cellSizeK; this->characteristicCellSizes(&cellSizeI, &cellSizeJ, &cellSizeK); - if (cellSizeI > characteristicCellSize) characteristicCellSize = cellSizeI; - if (cellSizeJ > characteristicCellSize) characteristicCellSize = cellSizeJ; - if (cellSizeK > characteristicCellSize) characteristicCellSize = cellSizeK; + if (cellSizeI < characteristicCellSize) characteristicCellSize = cellSizeI; + if (cellSizeJ < characteristicCellSize) characteristicCellSize = cellSizeJ; + return characteristicCellSize; } diff --git a/ApplicationCode/ReservoirDataModel/RigGridBase.h b/ApplicationCode/ReservoirDataModel/RigGridBase.h index 4a9bf35373..f447f49e48 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridBase.h +++ b/ApplicationCode/ReservoirDataModel/RigGridBase.h @@ -55,7 +55,7 @@ public: void setGridIndex(size_t index) { m_gridIndex = index; } size_t gridIndex() { return m_gridIndex; } - double characteristicCellSize(); + double characteristicIJCellSize(); std::string gridName() const; void setGridName(const std::string& gridName); From df281ccb2b210166bc2ec9f7fa32b737cb0b0bac Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 27 Feb 2013 11:27:02 +0100 Subject: [PATCH 052/242] Added reading of active cell data from EGRID file directly p4#: 20640 --- .../RifEclipseOutputFileTools.cpp | 22 +++ .../FileInterface/RifEclipseOutputFileTools.h | 1 + .../FileInterface/RifReaderEclipseOutput.cpp | 158 ++++++++++++++++-- .../FileInterface/RifReaderEclipseOutput.h | 2 + .../FileInterface/RifReaderInterface.h | 2 +- 5 files changed, 169 insertions(+), 16 deletions(-) diff --git a/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp b/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp index 2c77fd6355..de6f679d6d 100644 --- a/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp @@ -172,6 +172,28 @@ bool RifEclipseOutputFileTools::keywordData(ecl_file_type* ecl_file, const QStri return false; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifEclipseOutputFileTools::keywordData(ecl_file_type* ecl_file, const QString& keyword, size_t fileKeywordOccurrence, std::vector* values) +{ + ecl_kw_type* kwData = ecl_file_iget_named_kw(ecl_file, keyword.toAscii().data(), static_cast(fileKeywordOccurrence)); + if (kwData) + { + size_t numValues = ecl_kw_get_size(kwData); + + std::vector integerData; + integerData.resize(numValues); + + ecl_kw_get_memcpy_int_data(kwData, integerData.data()); + values->insert(values->end(), integerData.begin(), integerData.end()); + + return true; + } + + return false; +} + //-------------------------------------------------------------------------------------------------- /// Get first occurrence of file of given type in given list of filenames, as filename or NULL if not found diff --git a/ApplicationCode/FileInterface/RifEclipseOutputFileTools.h b/ApplicationCode/FileInterface/RifEclipseOutputFileTools.h index b4644289de..45b4b085d7 100644 --- a/ApplicationCode/FileInterface/RifEclipseOutputFileTools.h +++ b/ApplicationCode/FileInterface/RifEclipseOutputFileTools.h @@ -45,6 +45,7 @@ public: static void findKeywordsAndDataItemCounts(ecl_file_type* ecl_file, QStringList* keywords, std::vector* keywordDataItemCounts); static bool keywordData(ecl_file_type* ecl_file, const QString& keyword, size_t fileKeywordOccurrence, std::vector* values); + static bool keywordData(ecl_file_type* ecl_file, const QString& keyword, size_t fileKeywordOccurrence, std::vector* values); // static void timeStepsText(ecl_file_type* ecl_file, QStringList* timeSteps); static void timeSteps(ecl_file_type* ecl_file, QList* timeSteps, bool* detectedFractionOfDay = NULL); diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index a405e20190..c95632a904 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -32,6 +32,8 @@ #include "ecl_grid.h" #include "well_state.h" +#include "ecl_kw_magic.h" + #include "cafProgressInfo.h" //-------------------------------------------------------------------------------------------------- @@ -189,6 +191,8 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigActiveCellInfo* activeCellIn //-------------------------------------------------------------------------------------------------- RifReaderEclipseOutput::RifReaderEclipseOutput() { + m_ecl_file = NULL; + ground(); } @@ -216,8 +220,13 @@ void RifReaderEclipseOutput::ground() //-------------------------------------------------------------------------------------------------- void RifReaderEclipseOutput::close() { - m_ecl_file = NULL; - m_dynamicResultsAccess = NULL; + if (m_ecl_file) + { + ecl_file_close(m_ecl_file); + } + m_ecl_file = NULL; + + m_dynamicResultsAccess = NULL; ground(); } @@ -383,6 +392,116 @@ bool RifReaderEclipseOutput::open(const QString& fileName, RigEclipseCase* eclip return true; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifReaderEclipseOutput::openWithoutReadingData(const QString& fileName, RigEclipseCase* eclipseCase) +{ + CVF_ASSERT(eclipseCase); + caf::ProgressInfo progInfo(100, ""); + + close(); + + // Get set of files + QStringList fileSet; + if (!RifEclipseOutputFileTools::fileSet(fileName, &fileSet)) return false; + + // Keep the set of files of interest + m_fileSet = fileSet; + m_reservoir = eclipseCase; + + eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(this); + eclipseCase->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(this); + + progInfo.setNextProgressIncrement(50); + progInfo.setProgressDescription("Reading active cell information"); + + readActiveCellInfo(eclipseCase); + + progInfo.incrementProgress(); + + progInfo.setNextProgressIncrement(50); + progInfo.setProgressDescription("Reading meta data"); + + // Build results meta data + if (!buildMetaData(eclipseCase)) return false; + + return true; +} + + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifReaderEclipseOutput::readActiveCellInfo(RigEclipseCase* eclipseCase) +{ + CVF_ASSERT(eclipseCase); + + QString egridFileName = RifEclipseOutputFileTools::fileNameByType(m_fileSet, ECL_EGRID_FILE); + if (egridFileName.size() > 0) + { + ecl_file_type* ecl_file = ecl_file_open(egridFileName.toAscii().data()); + if (!ecl_file) return false; + + int actnumKeywordCount = ecl_file_get_num_named_kw(ecl_file, ACTNUM_KW); + if (actnumKeywordCount > 0) + { + std::vector > actnumValuesPerGrid; + actnumValuesPerGrid.resize(actnumKeywordCount); + + size_t globalCellCount = 0; + for (size_t gridIdx = 0; gridIdx < actnumKeywordCount; gridIdx++) + { + RifEclipseOutputFileTools::keywordData(ecl_file, ACTNUM_KW, gridIdx, &actnumValuesPerGrid[gridIdx]); + + globalCellCount += actnumValuesPerGrid[gridIdx].size(); + } + + RigActiveCellInfo* activeCellInfo = eclipseCase->activeCellInfo(); + + activeCellInfo->setGlobalCellCount(globalCellCount); + activeCellInfo->setGridCount(actnumKeywordCount); + + size_t cellIdx = 0; + for (size_t gridIdx = 0; gridIdx < actnumKeywordCount; gridIdx++) + { + size_t activeMatrixIndex = 0; + size_t activeFractureIndex = 0; + + std::vector& actnumValues = actnumValuesPerGrid[gridIdx]; + + for (size_t i = 0; i < actnumValues.size(); i++) + { + if (actnumValues[i] == 1 || actnumValues[i] == 3) + { + activeCellInfo->setActiveIndexInMatrixModel(cellIdx, activeMatrixIndex++); + } + + if (actnumValues[i] == 2 || actnumValues[i] == 3) + { + activeCellInfo->setActiveIndexInFractureModel(cellIdx, activeFractureIndex++); + } + + cellIdx++; + } + + activeCellInfo->setGridActiveCellCounts(gridIdx, activeMatrixIndex, activeFractureIndex); + } + + activeCellInfo->computeDerivedData(); + } + + ecl_file_close(ecl_file); + + return true; + } + + return false; +} + + //-------------------------------------------------------------------------------------------------- /// Build meta data - get states and results info //-------------------------------------------------------------------------------------------------- @@ -402,6 +521,7 @@ bool RifReaderEclipseOutput::buildMetaData(RigEclipseCase* eclipseCase) return false; } + progInfo.incrementProgress(); RigReservoirCellResults* matrixModelResults = m_reservoir->results(RifReaderInterface::MATRIX_RESULTS); @@ -778,17 +898,27 @@ QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringL QString keyword = keywords[i]; size_t keywordDataCount = keywordDataItemCounts[i]; - size_t timeStepsMatrix = keywordDataItemCounts[i] / activeCellInfo->globalMatrixModelActiveCellCount(); - size_t timeStepsMatrixRest = keywordDataItemCounts[i] % activeCellInfo->globalMatrixModelActiveCellCount(); - - size_t timeStepsMatrixAndFracture = keywordDataItemCounts[i] / (activeCellInfo->globalMatrixModelActiveCellCount() + activeCellInfo->globalFractureModelActiveCellCount()); - size_t timeStepsMatrixAndFractureRest = keywordDataItemCounts[i] % (activeCellInfo->globalMatrixModelActiveCellCount() + activeCellInfo->globalFractureModelActiveCellCount()); - - if (matrixOrFracture == RifReaderInterface::MATRIX_RESULTS) + if (activeCellInfo->globalMatrixModelActiveCellCount() > 0) { - if (timeStepsMatrixRest == 0 || timeStepsMatrixAndFractureRest == 0) + size_t timeStepsMatrix = keywordDataItemCounts[i] / activeCellInfo->globalMatrixModelActiveCellCount(); + size_t timeStepsMatrixRest = keywordDataItemCounts[i] % activeCellInfo->globalMatrixModelActiveCellCount(); + + size_t timeStepsMatrixAndFracture = keywordDataItemCounts[i] / (activeCellInfo->globalMatrixModelActiveCellCount() + activeCellInfo->globalFractureModelActiveCellCount()); + size_t timeStepsMatrixAndFractureRest = keywordDataItemCounts[i] % (activeCellInfo->globalMatrixModelActiveCellCount() + activeCellInfo->globalFractureModelActiveCellCount()); + + if (matrixOrFracture == RifReaderInterface::MATRIX_RESULTS) { - if (timeStepCount == timeStepsMatrix || timeStepCount == timeStepsMatrixAndFracture) + if (timeStepsMatrixRest == 0 || timeStepsMatrixAndFractureRest == 0) + { + if (timeStepCount == timeStepsMatrix || timeStepCount == timeStepsMatrixAndFracture) + { + keywordsWithCorrectNumberOfDataItems.push_back(keywords[i]); + } + } + } + else + { + if (timeStepsMatrixAndFractureRest == 0 && timeStepCount == timeStepsMatrixAndFracture) { keywordsWithCorrectNumberOfDataItems.push_back(keywords[i]); } @@ -796,16 +926,14 @@ QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringL } else { - if (timeStepsMatrixAndFractureRest == 0 && timeStepCount == timeStepsMatrixAndFracture) - { - keywordsWithCorrectNumberOfDataItems.push_back(keywords[i]); - } + keywordsWithCorrectNumberOfDataItems.push_back(keywords[i]); } } return keywordsWithCorrectNumberOfDataItems; } + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.h b/ApplicationCode/FileInterface/RifReaderEclipseOutput.h index 92f2eda1ba..817c458c6f 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.h +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.h @@ -44,6 +44,7 @@ public: virtual ~RifReaderEclipseOutput(); bool open(const QString& fileName, RigEclipseCase* eclipseCase); + virtual bool openWithoutReadingData(const QString& fileName, RigEclipseCase* eclipseCase); void close(); bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector* values); @@ -53,6 +54,7 @@ public: private: void ground(); + bool readActiveCellInfo(RigEclipseCase* eclipseCase); bool buildMetaData(RigEclipseCase* eclipseCase); void readWellCells(RigEclipseCase* eclipseCase); diff --git a/ApplicationCode/FileInterface/RifReaderInterface.h b/ApplicationCode/FileInterface/RifReaderInterface.h index 4de0ca8b34..db888335bb 100644 --- a/ApplicationCode/FileInterface/RifReaderInterface.h +++ b/ApplicationCode/FileInterface/RifReaderInterface.h @@ -47,9 +47,9 @@ public: virtual ~RifReaderInterface() {} virtual bool open(const QString& fileName, RigEclipseCase* eclipseCase) = 0; + virtual bool openWithoutReadingData(const QString& fileName, RigEclipseCase* eclipseCase) { return true; }; virtual void close() = 0; virtual bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector* values) = 0; virtual bool dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector* values) = 0; }; - From 092974a7fa8a2276a6b93abc971432897f063027 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 27 Feb 2013 11:54:32 +0100 Subject: [PATCH 053/242] Rename, reject update of active cell data if number of cells is not matching p4#: 20641 --- .../FileInterface/RifReaderEclipseOutput.cpp | 21 +++++++++++++++++-- .../FileInterface/RifReaderEclipseOutput.h | 2 +- .../FileInterface/RifReaderInterface.h | 2 +- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index c95632a904..4ba5ca018e 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -396,9 +396,16 @@ bool RifReaderEclipseOutput::open(const QString& fileName, RigEclipseCase* eclip //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifReaderEclipseOutput::openWithoutReadingData(const QString& fileName, RigEclipseCase* eclipseCase) +bool RifReaderEclipseOutput::openAndReadActiveCellData(const QString& fileName, RigEclipseCase* eclipseCase) { CVF_ASSERT(eclipseCase); + + // It is required to have a main grid before reading active cell data + if (!eclipseCase->mainGrid()) + { + return false; + } + caf::ProgressInfo progInfo(100, ""); close(); @@ -417,7 +424,10 @@ bool RifReaderEclipseOutput::openWithoutReadingData(const QString& fileName, Rig progInfo.setNextProgressIncrement(50); progInfo.setProgressDescription("Reading active cell information"); - readActiveCellInfo(eclipseCase); + if (!readActiveCellInfo(eclipseCase)) + { + return false; + } progInfo.incrementProgress(); @@ -438,6 +448,7 @@ bool RifReaderEclipseOutput::openWithoutReadingData(const QString& fileName, Rig bool RifReaderEclipseOutput::readActiveCellInfo(RigEclipseCase* eclipseCase) { CVF_ASSERT(eclipseCase); + CVF_ASSERT(eclipseCase->mainGrid()); QString egridFileName = RifEclipseOutputFileTools::fileNameByType(m_fileSet, ECL_EGRID_FILE); if (egridFileName.size() > 0) @@ -459,6 +470,12 @@ bool RifReaderEclipseOutput::readActiveCellInfo(RigEclipseCase* eclipseCase) globalCellCount += actnumValuesPerGrid[gridIdx].size(); } + // Check if number of cells is matching + if (eclipseCase->mainGrid()->cells().size() != globalCellCount) + { + return false; + } + RigActiveCellInfo* activeCellInfo = eclipseCase->activeCellInfo(); activeCellInfo->setGlobalCellCount(globalCellCount); diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.h b/ApplicationCode/FileInterface/RifReaderEclipseOutput.h index 817c458c6f..981c06ca7b 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.h +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.h @@ -44,7 +44,7 @@ public: virtual ~RifReaderEclipseOutput(); bool open(const QString& fileName, RigEclipseCase* eclipseCase); - virtual bool openWithoutReadingData(const QString& fileName, RigEclipseCase* eclipseCase); + virtual bool openAndReadActiveCellData(const QString& fileName, RigEclipseCase* eclipseCase); void close(); bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector* values); diff --git a/ApplicationCode/FileInterface/RifReaderInterface.h b/ApplicationCode/FileInterface/RifReaderInterface.h index db888335bb..66c18b1c45 100644 --- a/ApplicationCode/FileInterface/RifReaderInterface.h +++ b/ApplicationCode/FileInterface/RifReaderInterface.h @@ -47,7 +47,7 @@ public: virtual ~RifReaderInterface() {} virtual bool open(const QString& fileName, RigEclipseCase* eclipseCase) = 0; - virtual bool openWithoutReadingData(const QString& fileName, RigEclipseCase* eclipseCase) { return true; }; + virtual bool openAndReadActiveCellData(const QString& fileName, RigEclipseCase* eclipseCase) { return true; }; virtual void close() = 0; virtual bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector* values) = 0; From 7694c5d02d3814cb3afdbe9883a145a43bcd36ef Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 27 Feb 2013 14:01:36 +0100 Subject: [PATCH 054/242] Added support for lazy file parsing and improved closing of files p4#: 20644 --- .../RifEclipseRestartFilesetAccess.cpp | 78 +++++++++++++++---- .../RifEclipseRestartFilesetAccess.h | 7 +- .../RifEclipseUnifiedRestartFileAccess.cpp | 54 +++++++++---- .../RifEclipseUnifiedRestartFileAccess.h | 4 + 4 files changed, 113 insertions(+), 30 deletions(-) diff --git a/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp b/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp index 40b3e7a631..e194e245b8 100644 --- a/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp +++ b/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp @@ -42,7 +42,7 @@ RifEclipseRestartFilesetAccess::~RifEclipseRestartFilesetAccess() //-------------------------------------------------------------------------------------------------- bool RifEclipseRestartFilesetAccess::open(const QStringList& fileSet) { - close(); + setFileSet(fileSet); int numFiles = fileSet.size(); @@ -53,10 +53,7 @@ bool RifEclipseRestartFilesetAccess::open(const QStringList& fileSet) { progInfo.setProgressDescription(fileSet[i]); - ecl_file_type* ecl_file = ecl_file_open(fileSet[i].toAscii().data()); - if (!ecl_file) return false; - - m_ecl_files.push_back(ecl_file); + openTimeStep(i); progInfo.incrementProgress(); } @@ -64,6 +61,24 @@ bool RifEclipseRestartFilesetAccess::open(const QStringList& fileSet) return true; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifEclipseRestartFilesetAccess::setFileSet(const QStringList& fileSet) +{ + close(); + m_ecl_files.clear(); + + m_fileNames = fileSet; + + for (int i = 0; i < m_fileNames.size(); i++) + { + m_ecl_files.push_back(NULL); + } + + CVF_ASSERT(m_fileNames.size() == m_ecl_files.size()); +} + //-------------------------------------------------------------------------------------------------- /// Close files //-------------------------------------------------------------------------------------------------- @@ -71,10 +86,13 @@ void RifEclipseRestartFilesetAccess::close() { for (size_t i = 0; i < m_ecl_files.size(); i++) { - ecl_file_close(m_ecl_files[i]); - } - m_ecl_files.clear(); + if (m_ecl_files[i]) + { + ecl_file_close(m_ecl_files[i]); + } + m_ecl_files[i] = NULL; + } } //-------------------------------------------------------------------------------------------------- @@ -98,6 +116,8 @@ QList RifEclipseRestartFilesetAccess::timeSteps() { QList stepTime; + openTimeStep(i); + RifEclipseOutputFileTools::timeSteps(m_ecl_files[i], &stepTime); if (stepTime.size() == 1) @@ -120,6 +140,8 @@ void RifEclipseRestartFilesetAccess::resultNames(QStringList* resultNames, std:: { CVF_ASSERT(timeStepCount() > 0); + openTimeStep(0); + std::vector valueCountForOneFile; RifEclipseOutputFileTools::findKeywordsAndDataItemCounts(m_ecl_files[0], resultNames, &valueCountForOneFile); @@ -134,28 +156,35 @@ void RifEclipseRestartFilesetAccess::resultNames(QStringList* resultNames, std:: //-------------------------------------------------------------------------------------------------- bool RifEclipseRestartFilesetAccess::results(const QString& resultName, size_t timeStep, size_t gridCount, std::vector* values) { - size_t numOccurrences = ecl_file_get_num_named_kw(m_ecl_files[timeStep], resultName.toAscii().data()); + if (timeStep >= timeStepCount()) + { + return false; + } + + openTimeStep(timeStep); + + size_t fileGridCount = ecl_file_get_num_named_kw(m_ecl_files[timeStep], resultName.toAscii().data()); // No results for this result variable for current time step found - if (numOccurrences == 0) return true; + if (fileGridCount == 0) return true; // Result handling depends on presents of result values for all grids - if (gridCount != numOccurrences) + if (gridCount != fileGridCount) { return false; } size_t i; - for (i = 0; i < numOccurrences; i++) + for (i = 0; i < fileGridCount; i++) { - std::vector partValues; + std::vector gridValues; - if (!RifEclipseOutputFileTools::keywordData(m_ecl_files[timeStep], resultName, i, &partValues)) + if (!RifEclipseOutputFileTools::keywordData(m_ecl_files[timeStep], resultName, i, &gridValues)) { return false; } - values->insert(values->end(), partValues.begin(), partValues.end()); + values->insert(values->end(), gridValues.begin(), gridValues.end()); } return true; @@ -171,6 +200,8 @@ void RifEclipseRestartFilesetAccess::readWellData(well_info_type* well_info) for (size_t i = 0; i < m_ecl_files.size(); i++) { + openTimeStep(i); + const char* fileName = ecl_file_get_src_file(m_ecl_files[i]); int reportNumber = ecl_util_filename_report_nr(fileName); if(reportNumber != -1) @@ -179,3 +210,20 @@ void RifEclipseRestartFilesetAccess::readWellData(well_info_type* well_info) } } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifEclipseRestartFilesetAccess::openTimeStep(size_t timeStep) +{ + CVF_ASSERT(timeStep < m_ecl_files.size()); + + if (m_ecl_files[timeStep] == NULL) + { + int index = static_cast(timeStep); + ecl_file_type* ecl_file = ecl_file_open(m_fileNames[index].toAscii().data()); + + m_ecl_files[timeStep] = ecl_file; + } +} + diff --git a/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.h b/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.h index 7e0b181a44..44acf9e013 100644 --- a/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.h +++ b/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.h @@ -36,6 +36,7 @@ public: virtual ~RifEclipseRestartFilesetAccess(); bool open(const QStringList& fileSet); + void setFileSet(const QStringList& fileSet); void close(); size_t timeStepCount(); @@ -47,5 +48,9 @@ public: virtual void readWellData(well_info_type* well_info); private: - std::vector< ecl_file_type* > m_ecl_files; + void openTimeStep(size_t timeStep); + +private: + QStringList m_fileNames; + std::vector< ecl_file_type* > m_ecl_files; }; diff --git a/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp b/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp index 8fecb280e2..6a0641b8c1 100644 --- a/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp +++ b/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp @@ -38,12 +38,7 @@ RifEclipseUnifiedRestartFileAccess::RifEclipseUnifiedRestartFileAccess() //-------------------------------------------------------------------------------------------------- RifEclipseUnifiedRestartFileAccess::~RifEclipseUnifiedRestartFileAccess() { - if (m_ecl_file) - { - ecl_file_close(m_ecl_file); - } - - m_ecl_file = NULL; + close(); } //-------------------------------------------------------------------------------------------------- @@ -51,9 +46,17 @@ RifEclipseUnifiedRestartFileAccess::~RifEclipseUnifiedRestartFileAccess() //-------------------------------------------------------------------------------------------------- bool RifEclipseUnifiedRestartFileAccess::open(const QStringList& fileSet) { - QString fileName = fileSet[0]; + m_filename = fileSet[0]; - m_ecl_file = ecl_file_open(fileName.toAscii().data()); + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifEclipseUnifiedRestartFileAccess::openFile() +{ + m_ecl_file = ecl_file_open(m_filename.toAscii().data()); if (!m_ecl_file) return false; return true; @@ -64,6 +67,12 @@ bool RifEclipseUnifiedRestartFileAccess::open(const QStringList& fileSet) //-------------------------------------------------------------------------------------------------- void RifEclipseUnifiedRestartFileAccess::close() { + if (m_ecl_file) + { + ecl_file_close(m_ecl_file); + } + + m_ecl_file = NULL; } //-------------------------------------------------------------------------------------------------- @@ -71,6 +80,11 @@ void RifEclipseUnifiedRestartFileAccess::close() //-------------------------------------------------------------------------------------------------- size_t RifEclipseUnifiedRestartFileAccess::timeStepCount() { + if (!openFile()) + { + return 0; + } + return timeSteps().size(); } @@ -79,10 +93,12 @@ size_t RifEclipseUnifiedRestartFileAccess::timeStepCount() //-------------------------------------------------------------------------------------------------- QList RifEclipseUnifiedRestartFileAccess::timeSteps() { - CVF_ASSERT(m_ecl_file != NULL); - QList timeSteps; - RifEclipseOutputFileTools::timeSteps(m_ecl_file, &timeSteps); + + if (openFile()) + { + RifEclipseOutputFileTools::timeSteps(m_ecl_file, &timeSteps); + } return timeSteps; } @@ -92,7 +108,10 @@ QList RifEclipseUnifiedRestartFileAccess::timeSteps() //-------------------------------------------------------------------------------------------------- void RifEclipseUnifiedRestartFileAccess::resultNames(QStringList* resultNames, std::vector* resultDataItemCounts) { - RifEclipseOutputFileTools::findKeywordsAndDataItemCounts(m_ecl_file, resultNames, resultDataItemCounts); + if (openFile()) + { + RifEclipseOutputFileTools::findKeywordsAndDataItemCounts(m_ecl_file, resultNames, resultDataItemCounts); + } } //-------------------------------------------------------------------------------------------------- @@ -100,6 +119,11 @@ void RifEclipseUnifiedRestartFileAccess::resultNames(QStringList* resultNames, s //-------------------------------------------------------------------------------------------------- bool RifEclipseUnifiedRestartFileAccess::results(const QString& resultName, size_t timeStep, size_t gridCount, std::vector* values) { + if (!openFile()) + { + return false; + } + size_t numOccurrences = ecl_file_get_num_named_kw(m_ecl_file, resultName.toAscii().data()); size_t startIndex = timeStep * gridCount; @@ -124,8 +148,10 @@ bool RifEclipseUnifiedRestartFileAccess::results(const QString& resultName, size void RifEclipseUnifiedRestartFileAccess::readWellData(well_info_type* well_info) { if (!well_info) return; - CVF_ASSERT(m_ecl_file); - well_info_add_UNRST_wells(well_info, m_ecl_file); + if (openFile()) + { + well_info_add_UNRST_wells(well_info, m_ecl_file); + } } diff --git a/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.h b/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.h index f8188db60e..f85df6cce1 100644 --- a/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.h +++ b/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.h @@ -49,5 +49,9 @@ public: virtual void readWellData(well_info_type * well_info); private: + bool openFile(); + +private: + QString m_filename; ecl_file_type* m_ecl_file; }; From d628973f5605321e05314c0bedf17af21f7cc1b5 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 27 Feb 2013 14:13:37 +0100 Subject: [PATCH 055/242] Rename and improvements related to close p4#: 20645 --- .../FileInterface/RifReaderEclipseOutput.cpp | 166 ++++++++++-------- .../FileInterface/RifReaderEclipseOutput.h | 12 +- 2 files changed, 104 insertions(+), 74 deletions(-) diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index 4ba5ca018e..8691e5fa3b 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -191,7 +191,8 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigActiveCellInfo* activeCellIn //-------------------------------------------------------------------------------------------------- RifReaderEclipseOutput::RifReaderEclipseOutput() { - m_ecl_file = NULL; + m_ecl_init_file = NULL; + m_dynamicResultsAccess = NULL; ground(); } @@ -212,7 +213,7 @@ void RifReaderEclipseOutput::ground() m_fileSet.clear(); m_timeSteps.clear(); - m_reservoir = NULL; + m_eclipseCase = NULL; } //-------------------------------------------------------------------------------------------------- @@ -220,13 +221,16 @@ void RifReaderEclipseOutput::ground() //-------------------------------------------------------------------------------------------------- void RifReaderEclipseOutput::close() { - if (m_ecl_file) + if (m_ecl_init_file) { - ecl_file_close(m_ecl_file); + ecl_file_close(m_ecl_init_file); } - m_ecl_file = NULL; + m_ecl_init_file = NULL; - m_dynamicResultsAccess = NULL; + if (m_dynamicResultsAccess.notNull()) + { + m_dynamicResultsAccess->close(); + } ground(); } @@ -374,19 +378,19 @@ bool RifReaderEclipseOutput::open(const QString& fileName, RigEclipseCase* eclip progInfo.setProgressDescription("Reading Result index"); progInfo.setNextProgressIncrement(60); - m_reservoir = eclipseCase; + m_eclipseCase = eclipseCase; eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(this); eclipseCase->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(this); // Build results meta data - if (!buildMetaData(eclipseCase)) return false; + if (!buildMetaData()) return false; progInfo.incrementProgress(); progInfo.setNextProgressIncrement(8); progInfo.setProgressDescription("Reading Well information"); - readWellCells(eclipseCase); + readWellCells(); return true; @@ -416,7 +420,7 @@ bool RifReaderEclipseOutput::openAndReadActiveCellData(const QString& fileName, // Keep the set of files of interest m_fileSet = fileSet; - m_reservoir = eclipseCase; + m_eclipseCase = eclipseCase; eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(this); eclipseCase->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(this); @@ -424,7 +428,7 @@ bool RifReaderEclipseOutput::openAndReadActiveCellData(const QString& fileName, progInfo.setNextProgressIncrement(50); progInfo.setProgressDescription("Reading active cell information"); - if (!readActiveCellInfo(eclipseCase)) + if (!readActiveCellInfo()) { return false; } @@ -435,20 +439,19 @@ bool RifReaderEclipseOutput::openAndReadActiveCellData(const QString& fileName, progInfo.setProgressDescription("Reading meta data"); // Build results meta data - if (!buildMetaData(eclipseCase)) return false; + if (!buildMetaData()) return false; return true; } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifReaderEclipseOutput::readActiveCellInfo(RigEclipseCase* eclipseCase) +bool RifReaderEclipseOutput::readActiveCellInfo() { - CVF_ASSERT(eclipseCase); - CVF_ASSERT(eclipseCase->mainGrid()); + CVF_ASSERT(m_eclipseCase.notNull()); + CVF_ASSERT(m_eclipseCase->mainGrid()); QString egridFileName = RifEclipseOutputFileTools::fileNameByType(m_fileSet, ECL_EGRID_FILE); if (egridFileName.size() > 0) @@ -471,12 +474,12 @@ bool RifReaderEclipseOutput::readActiveCellInfo(RigEclipseCase* eclipseCase) } // Check if number of cells is matching - if (eclipseCase->mainGrid()->cells().size() != globalCellCount) + if (m_eclipseCase->mainGrid()->cells().size() != globalCellCount) { return false; } - RigActiveCellInfo* activeCellInfo = eclipseCase->activeCellInfo(); + RigActiveCellInfo* activeCellInfo = m_eclipseCase->activeCellInfo(); activeCellInfo->setGlobalCellCount(globalCellCount); activeCellInfo->setGridCount(actnumKeywordCount); @@ -522,9 +525,9 @@ bool RifReaderEclipseOutput::readActiveCellInfo(RigEclipseCase* eclipseCase) //-------------------------------------------------------------------------------------------------- /// Build meta data - get states and results info //-------------------------------------------------------------------------------------------------- -bool RifReaderEclipseOutput::buildMetaData(RigEclipseCase* eclipseCase) +bool RifReaderEclipseOutput::buildMetaData() { - CVF_ASSERT(m_reservoir.notNull()); + CVF_ASSERT(m_eclipseCase.notNull()); CVF_ASSERT(m_fileSet.size() > 0); caf::ProgressInfo progInfo(m_fileSet.size() + 3,""); @@ -541,8 +544,8 @@ bool RifReaderEclipseOutput::buildMetaData(RigEclipseCase* eclipseCase) progInfo.incrementProgress(); - RigReservoirCellResults* matrixModelResults = m_reservoir->results(RifReaderInterface::MATRIX_RESULTS); - RigReservoirCellResults* fractureModelResults = m_reservoir->results(RifReaderInterface::FRACTURE_RESULTS); + RigReservoirCellResults* matrixModelResults = m_eclipseCase->results(RifReaderInterface::MATRIX_RESULTS); + RigReservoirCellResults* fractureModelResults = m_eclipseCase->results(RifReaderInterface::FRACTURE_RESULTS); if (m_dynamicResultsAccess.notNull()) { @@ -554,7 +557,7 @@ bool RifReaderEclipseOutput::buildMetaData(RigEclipseCase* eclipseCase) m_dynamicResultsAccess->resultNames(&resultNames, &resultNamesDataItemCounts); { - QStringList matrixResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, m_reservoir->activeCellInfo(), RifReaderInterface::MATRIX_RESULTS, m_dynamicResultsAccess->timeStepCount()); + QStringList matrixResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, m_eclipseCase->activeCellInfo(), RifReaderInterface::MATRIX_RESULTS, m_dynamicResultsAccess->timeStepCount()); for (int i = 0; i < matrixResultNames.size(); ++i) { @@ -564,7 +567,7 @@ bool RifReaderEclipseOutput::buildMetaData(RigEclipseCase* eclipseCase) } { - QStringList fractureResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, m_reservoir->activeCellInfo(), RifReaderInterface::FRACTURE_RESULTS, m_dynamicResultsAccess->timeStepCount()); + QStringList fractureResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, m_eclipseCase->activeCellInfo(), RifReaderInterface::FRACTURE_RESULTS, m_dynamicResultsAccess->timeStepCount()); for (int i = 0; i < fractureResultNames.size(); ++i) { @@ -577,51 +580,47 @@ bool RifReaderEclipseOutput::buildMetaData(RigEclipseCase* eclipseCase) progInfo.incrementProgress(); - QString initFileName = RifEclipseOutputFileTools::fileNameByType(m_fileSet, ECL_INIT_FILE); - if (initFileName.size() > 0) + if (!openInitFile()) { - ecl_file_type* ecl_file = ecl_file_open(initFileName.toAscii().data()); - if (!ecl_file) return false; + return false; + } + + progInfo.incrementProgress(); - progInfo.incrementProgress(); + QStringList resultNames; + std::vector resultNamesDataItemCounts; + RifEclipseOutputFileTools::findKeywordsAndDataItemCounts(m_ecl_init_file, &resultNames, &resultNamesDataItemCounts); - QStringList resultNames; - std::vector resultNamesDataItemCounts; - RifEclipseOutputFileTools::findKeywordsAndDataItemCounts(ecl_file, &resultNames, &resultNamesDataItemCounts); + { + QStringList matrixResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, m_eclipseCase->activeCellInfo(), RifReaderInterface::MATRIX_RESULTS, 1); + QList staticDate; + if (m_timeSteps.size() > 0) { - QStringList matrixResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, m_reservoir->activeCellInfo(), RifReaderInterface::MATRIX_RESULTS, 1); - - QList staticDate; - if (m_timeSteps.size() > 0) - { - staticDate.push_back(m_timeSteps.front()); - } - - for (int i = 0; i < matrixResultNames.size(); ++i) - { - size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, matrixResultNames[i]); - matrixModelResults->setTimeStepDates(resIndex, staticDate); - } + staticDate.push_back(m_timeSteps.front()); } + for (int i = 0; i < matrixResultNames.size(); ++i) { - QStringList fractureResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, m_reservoir->activeCellInfo(), RifReaderInterface::FRACTURE_RESULTS, 1); + size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, matrixResultNames[i]); + matrixModelResults->setTimeStepDates(resIndex, staticDate); + } + } - QList staticDate; - if (m_timeSteps.size() > 0) - { - staticDate.push_back(m_timeSteps.front()); - } + { + QStringList fractureResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, m_eclipseCase->activeCellInfo(), RifReaderInterface::FRACTURE_RESULTS, 1); - for (int i = 0; i < fractureResultNames.size(); ++i) - { - size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, fractureResultNames[i]); - fractureModelResults->setTimeStepDates(resIndex, staticDate); - } + QList staticDate; + if (m_timeSteps.size() > 0) + { + staticDate.push_back(m_timeSteps.front()); } - m_ecl_file = ecl_file; + for (int i = 0; i < fractureResultNames.size(); ++i) + { + size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, fractureResultNames[i]); + fractureModelResults->setTimeStepDates(resIndex, staticDate); + } } return true; @@ -672,16 +671,22 @@ RifEclipseRestartDataAccess* RifReaderEclipseOutput::dynamicResultsAccess(const bool RifReaderEclipseOutput::staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector* values) { CVF_ASSERT(values); - CVF_ASSERT(m_ecl_file); + + if (!openInitFile()) + { + return false; + } + + CVF_ASSERT(m_ecl_init_file); std::vector fileValues; - size_t numOccurrences = ecl_file_get_num_named_kw(m_ecl_file, result.toAscii().data()); + size_t numOccurrences = ecl_file_get_num_named_kw(m_ecl_init_file, result.toAscii().data()); size_t i; for (i = 0; i < numOccurrences; i++) { std::vector partValues; - RifEclipseOutputFileTools::keywordData(m_ecl_file, result, i, &partValues); + RifEclipseOutputFileTools::keywordData(m_ecl_init_file, result, i, &partValues); fileValues.insert(fileValues.end(), partValues.begin(), partValues.end()); } @@ -698,7 +703,7 @@ bool RifReaderEclipseOutput::dynamicResult(const QString& result, PorosityModelR CVF_ASSERT(m_dynamicResultsAccess.notNull()); std::vector fileValues; - if (!m_dynamicResultsAccess->results(result, stepIndex, m_reservoir->mainGrid()->gridCount(), &fileValues)) + if (!m_dynamicResultsAccess->results(result, stepIndex, m_eclipseCase->mainGrid()->gridCount(), &fileValues)) { return false; } @@ -711,9 +716,9 @@ bool RifReaderEclipseOutput::dynamicResult(const QString& result, PorosityModelR //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RifReaderEclipseOutput::readWellCells(RigEclipseCase* eclipseCase) +void RifReaderEclipseOutput::readWellCells() { - CVF_ASSERT(eclipseCase); + CVF_ASSERT(m_eclipseCase.notNull()); if (m_dynamicResultsAccess.isNull()) return; @@ -722,9 +727,9 @@ void RifReaderEclipseOutput::readWellCells(RigEclipseCase* eclipseCase) m_dynamicResultsAccess->readWellData(ert_well_info); - RigMainGrid* mainGrid = eclipseCase->mainGrid(); + RigMainGrid* mainGrid = m_eclipseCase->mainGrid(); std::vector grids; - eclipseCase->allGrids(&grids); + m_eclipseCase->allGrids(&grids); cvf::Collection wells; caf::ProgressInfo progress(well_info_get_num_wells(ert_well_info), ""); @@ -884,7 +889,7 @@ void RifReaderEclipseOutput::readWellCells(RigEclipseCase* eclipseCase) well_info_free(ert_well_info); - eclipseCase->setWellResults(wells); + m_eclipseCase->setWellResults(wells); } @@ -956,7 +961,7 @@ QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringL //-------------------------------------------------------------------------------------------------- void RifReaderEclipseOutput::extractResultValuesBasedOnPorosityModel(PorosityModelResultType matrixOrFracture, std::vector* destinationResultValues, const std::vector& sourceResultValues) { - RigActiveCellInfo* actCellInfo = m_reservoir->activeCellInfo(); + RigActiveCellInfo* actCellInfo = m_eclipseCase->activeCellInfo(); if (matrixOrFracture == RifReaderInterface::MATRIX_RESULTS) { @@ -969,7 +974,7 @@ void RifReaderEclipseOutput::extractResultValuesBasedOnPorosityModel(PorosityMod size_t dataItemCount = 0; size_t sourceStartPosition = 0; - for (size_t i = 0; i < m_reservoir->mainGrid()->gridCount(); i++) + for (size_t i = 0; i < m_eclipseCase->mainGrid()->gridCount(); i++) { size_t matrixActiveCellCount = 0; size_t fractureActiveCellCount = 0; @@ -986,7 +991,7 @@ void RifReaderEclipseOutput::extractResultValuesBasedOnPorosityModel(PorosityMod size_t dataItemCount = 0; size_t sourceStartPosition = 0; - for (size_t i = 0; i < m_reservoir->mainGrid()->gridCount(); i++) + for (size_t i = 0; i < m_eclipseCase->mainGrid()->gridCount(); i++) { size_t matrixActiveCellCount = 0; size_t fractureActiveCellCount = 0; @@ -999,3 +1004,26 @@ void RifReaderEclipseOutput::extractResultValuesBasedOnPorosityModel(PorosityMod } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifReaderEclipseOutput::openInitFile() +{ + if (m_ecl_init_file) + { + return true; + } + + QString initFileName = RifEclipseOutputFileTools::fileNameByType(m_fileSet, ECL_INIT_FILE); + if (initFileName.size() > 0) + { + ecl_file_type* ecl_init_file = ecl_file_open(initFileName.toAscii().data()); + if (ecl_init_file) + { + return true; + } + } + + return false; +} + diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.h b/ApplicationCode/FileInterface/RifReaderEclipseOutput.h index 981c06ca7b..3970ef4132 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.h +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.h @@ -54,9 +54,11 @@ public: private: void ground(); - bool readActiveCellInfo(RigEclipseCase* eclipseCase); - bool buildMetaData(RigEclipseCase* eclipseCase); - void readWellCells(RigEclipseCase* eclipseCase); + bool readActiveCellInfo(); + bool buildMetaData(); + void readWellCells(); + + bool openInitFile(); void extractResultValuesBasedOnPorosityModel(PorosityModelResultType matrixOrFracture, std::vector* values, const std::vector& fileValues); @@ -69,10 +71,10 @@ private: QString m_fileName; // Name of file used to start accessing Eclipse output files QStringList m_fileSet; // Set of files in filename's path with same base name as filename - cvf::ref m_reservoir; + cvf::ref m_eclipseCase; QList m_timeSteps; - ecl_file_type* m_ecl_file; // File access to static results + ecl_file_type* m_ecl_init_file; // File access to static results cvf::ref m_dynamicResultsAccess; // File access to dynamic results }; From 3dc027e29e0360adbad9b30a095fb59be620c06c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 27 Feb 2013 14:30:32 +0100 Subject: [PATCH 056/242] Fixed issue related to reading data after close p4#: 20647 --- .../FileInterface/RifReaderEclipseOutput.cpp | 22 ++++++------------- .../FileInterface/RifReaderEclipseOutput.h | 1 - 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index 8691e5fa3b..4c97977ade 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -191,10 +191,15 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigActiveCellInfo* activeCellIn //-------------------------------------------------------------------------------------------------- RifReaderEclipseOutput::RifReaderEclipseOutput() { + m_fileName.clear(); + m_fileSet.clear(); + + m_timeSteps.clear(); + + m_eclipseCase = NULL; + m_ecl_init_file = NULL; m_dynamicResultsAccess = NULL; - - ground(); } //-------------------------------------------------------------------------------------------------- @@ -204,17 +209,6 @@ RifReaderEclipseOutput::~RifReaderEclipseOutput() { } -//-------------------------------------------------------------------------------------------------- -/// Ground members -//-------------------------------------------------------------------------------------------------- -void RifReaderEclipseOutput::ground() -{ - m_fileName.clear(); - m_fileSet.clear(); - - m_timeSteps.clear(); - m_eclipseCase = NULL; -} //-------------------------------------------------------------------------------------------------- /// Close interface (for now, no files are kept open after calling methods, so just clear members) @@ -231,8 +225,6 @@ void RifReaderEclipseOutput::close() { m_dynamicResultsAccess->close(); } - - ground(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.h b/ApplicationCode/FileInterface/RifReaderEclipseOutput.h index 3970ef4132..3b17858db8 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.h +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.h @@ -53,7 +53,6 @@ public: static bool transferGeometry(const ecl_grid_type* mainEclGrid, RigEclipseCase* eclipseCase); private: - void ground(); bool readActiveCellInfo(); bool buildMetaData(); void readWellCells(); From 3dbc8a9d57b58fd283631ba240b2736d42b6d4b9 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 27 Feb 2013 15:27:33 +0100 Subject: [PATCH 057/242] Improved multi case initial reading When creating a multi case group from multiple files, read grid from first file. The main grid from the first case is reused for the other cases. NOTE: Metadata and well information is not read for the other cases p4#: 20655 --- ApplicationCode/Application/RIApplication.cpp | 62 +++++++++++++++---- ApplicationCode/Application/RIApplication.h | 2 +- .../FileInterface/RifReaderEclipseOutput.cpp | 5 +- .../ProjectDataModel/RimResultReservoir.cpp | 45 ++++++++++++++ .../ProjectDataModel/RimResultReservoir.h | 4 +- .../UserInterface/RIMainWindow.cpp | 7 +-- 6 files changed, 103 insertions(+), 22 deletions(-) diff --git a/ApplicationCode/Application/RIApplication.cpp b/ApplicationCode/Application/RIApplication.cpp index 3232e0f85c..49ae37aba0 100644 --- a/ApplicationCode/Application/RIApplication.cpp +++ b/ApplicationCode/Application/RIApplication.cpp @@ -1297,26 +1297,64 @@ void RIApplication::updateRegressionTest(const QString& testRootPath) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RIApplication::addEclipseCase(const QString& fileName) +bool RIApplication::addEclipseCases(const QStringList& fileNames) { - QFileInfo gridFileName(fileName); + if (fileNames.size() == 0) return true; - QString caseName = gridFileName.completeBaseName(); - QString casePath = gridFileName.absolutePath(); - RimResultReservoir* rimResultReservoir = new RimResultReservoir(); - rimResultReservoir->caseName = caseName; - rimResultReservoir->caseFileName = fileName; - rimResultReservoir->caseDirectory = casePath; + // First file is read completely including grid. + // The main grid from the first case is reused directly in for the other cases. + // When reading active cell info, only the total cell count is tested for consistency + RigMainGrid* mainGrid = NULL; - m_project->reservoirs.push_back(rimResultReservoir); + { + QString firstFileName = fileNames[0]; + QFileInfo gridFileName(firstFileName); - rimResultReservoir->openEclipseGridFile(); + QString caseName = gridFileName.completeBaseName(); + QString casePath = gridFileName.absolutePath(); - m_project->moveEclipseCaseIntoCaseGroup(rimResultReservoir); + RimResultReservoir* rimResultReservoir = new RimResultReservoir(); + rimResultReservoir->caseName = caseName; + rimResultReservoir->caseFileName = firstFileName; + rimResultReservoir->caseDirectory = casePath; + + m_project->reservoirs.push_back(rimResultReservoir); + + if (!rimResultReservoir->openEclipseGridFile()) + { + return false; + } + + m_project->moveEclipseCaseIntoCaseGroup(rimResultReservoir); + + mainGrid = rimResultReservoir->reservoirData()->mainGrid(); + } + + for (int i = 1; i < fileNames.size(); i++) + { + QString fileName = fileNames[i]; + QFileInfo gridFileName(fileName); + + QString caseName = gridFileName.completeBaseName(); + QString casePath = gridFileName.absolutePath(); + + RimResultReservoir* rimResultReservoir = new RimResultReservoir(); + rimResultReservoir->caseName = caseName; + rimResultReservoir->caseFileName = fileName; + rimResultReservoir->caseDirectory = casePath; + + m_project->reservoirs.push_back(rimResultReservoir); + + if (!rimResultReservoir->openAndReadActiveCellData(mainGrid)) + { + return false; + } + + m_project->moveEclipseCaseIntoCaseGroup(rimResultReservoir); + } onProjectOpenedOrClosed(); return true; - } diff --git a/ApplicationCode/Application/RIApplication.h b/ApplicationCode/Application/RIApplication.h index 6603b52380..4073593ad7 100644 --- a/ApplicationCode/Application/RIApplication.h +++ b/ApplicationCode/Application/RIApplication.h @@ -80,7 +80,7 @@ public: bool openEclipseCaseFromFile(const QString& fileName); bool openEclipseCase(const QString& caseName, const QString& caseFileName); - bool addEclipseCase(const QString& fileName); + bool addEclipseCases(const QStringList& fileNames); bool openInputEclipseCase(const QString& caseName, const QStringList& caseFileNames); bool loadLastUsedProject(); diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index 4c97977ade..2c88903a4d 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -430,8 +430,9 @@ bool RifReaderEclipseOutput::openAndReadActiveCellData(const QString& fileName, progInfo.setNextProgressIncrement(50); progInfo.setProgressDescription("Reading meta data"); - // Build results meta data - if (!buildMetaData()) return false; + // Reading of metadata and well cells is not performed here + //if (!buildMetaData()) return false; + // readWellCells(); return true; } diff --git a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp index 5461b8b8f2..6bece89bf8 100644 --- a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp @@ -90,6 +90,51 @@ bool RimResultReservoir::openEclipseGridFile() return true; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimResultReservoir::openAndReadActiveCellData(RigMainGrid* mainGrid) +{ + cvf::ref readerInterface; + + if (caseName().contains("Result Mock Debug Model")) + { + readerInterface = this->createMockModel(this->caseName()); + + m_rigEclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p()); + m_rigEclipseCase->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p()); + } + else + { + QString fname = createAbsoluteFilenameFromCase(caseName); + if (fname.isEmpty()) + { + return false; + } + + cvf::ref eclipseCase = new RigEclipseCase; + eclipseCase->setMainGrid(mainGrid); + + readerInterface = new RifReaderEclipseOutput; + if (!readerInterface->openAndReadActiveCellData(fname, eclipseCase.p())) + { + return false; + } + + readerInterface->close(); + + m_rigEclipseCase = eclipseCase; + } + + CVF_ASSERT(m_rigEclipseCase.notNull()); + CVF_ASSERT(readerInterface.notNull()); + + m_rigEclipseCase->computeCachedData(); + + return true; +} + + //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/ProjectDataModel/RimResultReservoir.h b/ApplicationCode/ProjectDataModel/RimResultReservoir.h index cfbffd5abc..31d5f8fe26 100644 --- a/ApplicationCode/ProjectDataModel/RimResultReservoir.h +++ b/ApplicationCode/ProjectDataModel/RimResultReservoir.h @@ -24,7 +24,8 @@ #include "cafPdmObject.h" #include "RimReservoir.h" - class RifReaderInterface; +class RifReaderInterface; +class RigMainGrid; //================================================================================================== // @@ -45,6 +46,7 @@ public: caf::PdmField caseDirectory; virtual bool openEclipseGridFile(); + bool openAndReadActiveCellData(RigMainGrid* mainGrid); //virtual caf::PdmFieldHandle* userDescriptionField() { return &caseName;} diff --git a/ApplicationCode/UserInterface/RIMainWindow.cpp b/ApplicationCode/UserInterface/RIMainWindow.cpp index 407ae81226..9012fca5fc 100644 --- a/ApplicationCode/UserInterface/RIMainWindow.cpp +++ b/ApplicationCode/UserInterface/RIMainWindow.cpp @@ -1312,10 +1312,5 @@ void RIMainWindow::slotOpenMultipleCases() appendEGRIDFilesRecursively(fileName, gridFileNames); } - for (int i = 0; i < gridFileNames.size(); i++) - { - QString fileName = gridFileNames[i]; - - app->addEclipseCase(fileName); - } + app->addEclipseCases(gridFileNames); } From 0993a8984dd3e2eee1ef04647f2375604c36789f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 28 Feb 2013 08:04:43 +0100 Subject: [PATCH 058/242] Fixed unit tests p4#: 20659 --- .../RigReservoir-Test.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp index ad17a3348f..e02b08aa4d 100644 --- a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp +++ b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp @@ -33,15 +33,17 @@ TEST(RigGridCollection, BasicTest) cvf::ref mainGridA = new RigMainGrid; cvf::ref eclipseCase = new RigEclipseCase; + eclipseCase->setMainGrid(mainGridA.p()); + + int count = mainGridA->refCount(); + EXPECT_EQ(mainGridA->refCount(), 2); RigGridCollection gridCollection; gridCollection.addCase(eclipseCase.p()); - - int count = mainGridA->refCount(); - EXPECT_TRUE(mainGridA->refCount() == 2); + EXPECT_EQ(mainGridA->refCount(), 3); cvf::ref mainGridB = mainGridA; - EXPECT_TRUE(mainGridA->refCount() == 3); + EXPECT_EQ(mainGridA->refCount(), 4); cvf::ref existingGrid = gridCollection.findEqualGrid(mainGridB.p()); EXPECT_TRUE(existingGrid.notNull()); @@ -58,6 +60,8 @@ TEST(RigGridCollection, EqualTests) mainGridA->nodes().push_back(cvf::Vec3d(0, 0, 2)); cvf::ref eclipseCase = new RigEclipseCase; + eclipseCase->setMainGrid(mainGridA.p()); + RigGridCollection gridCollection; gridCollection.addCase(eclipseCase.p()); From c0a578678d11f74069578625ad19704b46aa4a84 Mon Sep 17 00:00:00 2001 From: CeetronResInsight Date: Thu, 28 Feb 2013 09:59:36 +0100 Subject: [PATCH 059/242] Linux compile fixes p4#: 20663 --- .../ReservoirDataModel_UnitTests/RigReservoir-Test.cpp | 2 +- ApplicationCode/ReservoirDataModel/RigGridCollection.h | 2 +- VisualizationModules/LibRender/cvfScalarMapperDiscreteLinear.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp index e02b08aa4d..d2467c7e23 100644 --- a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp +++ b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp @@ -129,4 +129,4 @@ TEST(RigReservoirTest, BasicTest) } -*/ \ No newline at end of file +*/ diff --git a/ApplicationCode/ReservoirDataModel/RigGridCollection.h b/ApplicationCode/ReservoirDataModel/RigGridCollection.h index 2a1df86574..29ca2c84e0 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridCollection.h +++ b/ApplicationCode/ReservoirDataModel/RigGridCollection.h @@ -52,4 +52,4 @@ private: private: cvf::Collection m_caseToGrid; -}; \ No newline at end of file +}; diff --git a/VisualizationModules/LibRender/cvfScalarMapperDiscreteLinear.h b/VisualizationModules/LibRender/cvfScalarMapperDiscreteLinear.h index ec7a8baec1..da8fcb5fd9 100644 --- a/VisualizationModules/LibRender/cvfScalarMapperDiscreteLinear.h +++ b/VisualizationModules/LibRender/cvfScalarMapperDiscreteLinear.h @@ -44,7 +44,7 @@ public: private: static double discretize(double scalarValue, const std::set& sortedLevels); - friend ScalarMapperDiscreteLog; + friend class ScalarMapperDiscreteLog; }; } From 839a617916b3a928e015faad4e454d51e2b18b57 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 28 Feb 2013 10:15:28 +0100 Subject: [PATCH 060/242] Do not store scripts in project file p4#: 20665 --- ApplicationCode/ProjectDataModel/RimCalcScript.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ApplicationCode/ProjectDataModel/RimCalcScript.cpp b/ApplicationCode/ProjectDataModel/RimCalcScript.cpp index b16fe12977..7794031863 100644 --- a/ApplicationCode/ProjectDataModel/RimCalcScript.cpp +++ b/ApplicationCode/ProjectDataModel/RimCalcScript.cpp @@ -35,6 +35,7 @@ RimCalcScript::RimCalcScript() CAF_PDM_InitField(&absolutePath, "AbsolutePath", QString(), "Location", "", "" ,""); CAF_PDM_InitField(&content, "Content", QString(), "Directory", "", "" ,""); content.setUiHidden(true); + content.setIOWritable(false); absolutePath.setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName()); } From 1a05676551d9deff3fc325eb13f71906d45530c5 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 28 Feb 2013 11:27:37 +0100 Subject: [PATCH 061/242] Fixed missing open of INIT file p4#: 20666 --- ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index 2c88903a4d..b7a98175ca 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -1010,8 +1010,8 @@ bool RifReaderEclipseOutput::openInitFile() QString initFileName = RifEclipseOutputFileTools::fileNameByType(m_fileSet, ECL_INIT_FILE); if (initFileName.size() > 0) { - ecl_file_type* ecl_init_file = ecl_file_open(initFileName.toAscii().data()); - if (ecl_init_file) + m_ecl_init_file = ecl_file_open(initFileName.toAscii().data()); + if (m_ecl_init_file) { return true; } From 5a84a12864c2a22d2e324a345638940c53f4a943 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 28 Feb 2013 11:37:32 +0100 Subject: [PATCH 062/242] Integrated new version of the Visualization modules: From change List number 20662. p4#: 20667 --- VisualizationModules/LibCore/CMakeLists.txt | 13 + .../LibCore/cvfCodeLocation.cpp | 163 +++ .../LibCore/cvfCodeLocation.h | 65 + .../LibCore/cvfLogDestination.h | 44 + .../LibCore/cvfLogDestinationConsole.cpp | 141 +++ .../LibCore/cvfLogDestinationConsole.h | 49 + .../LibCore/cvfLogDestinationFile.cpp | 169 +++ .../LibCore/cvfLogDestinationFile.h | 53 + VisualizationModules/LibCore/cvfLogEvent.cpp | 128 ++ VisualizationModules/LibCore/cvfLogEvent.h | 62 + .../LibCore/cvfLogManager.cpp | 236 ++++ VisualizationModules/LibCore/cvfLogManager.h | 74 ++ VisualizationModules/LibCore/cvfLogger.cpp | 145 ++- VisualizationModules/LibCore/cvfLogger.h | 56 +- VisualizationModules/LibCore/cvfMutex.cpp | 202 ++++ VisualizationModules/LibCore/cvfMutex.h | 60 + VisualizationModules/LibCore/cvfString.cpp | 9 + VisualizationModules/LibCore/cvfString.h | 1 + VisualizationModules/LibRender/CMakeLists.txt | 2 + VisualizationModules/LibRender/cvfCamera.cpp | 26 +- VisualizationModules/LibRender/cvfCamera.h | 2 + .../LibRender/cvfCameraAnimation.cpp | 109 ++ .../LibRender/cvfCameraAnimation.h | 56 + .../LibRender/cvfDrawableGeo.cpp | 26 +- .../LibRender/cvfDrawableText.cpp | 51 +- .../LibRender/cvfDrawableText.h | 4 + VisualizationModules/LibRender/cvfOpenGL.cpp | 8 +- VisualizationModules/LibRender/cvfOpenGL.h | 9 +- .../LibRender/cvfOpenGLContext.h | 4 +- .../LibRender/cvfOpenGLContextGroup.cpp | 4 +- .../LibRender/cvfOverlayImage.cpp | 48 +- .../LibRender/cvfOverlayImage.h | 4 +- .../LibRender/cvfOverlayNavigationCube.cpp | 1050 +++++++++++++++-- .../LibRender/cvfOverlayNavigationCube.h | 144 ++- .../LibRender/cvfTextDrawer.cpp | 85 +- .../LibRender/cvfTextDrawer.h | 7 + VisualizationModules/LibRender/cvfUniform.h | 6 +- .../LibViewing/cvfRendering.cpp | 19 +- .../LibViewing/cvfRendering.h | 1 + 39 files changed, 3071 insertions(+), 264 deletions(-) create mode 100644 VisualizationModules/LibCore/cvfCodeLocation.cpp create mode 100644 VisualizationModules/LibCore/cvfCodeLocation.h create mode 100644 VisualizationModules/LibCore/cvfLogDestination.h create mode 100644 VisualizationModules/LibCore/cvfLogDestinationConsole.cpp create mode 100644 VisualizationModules/LibCore/cvfLogDestinationConsole.h create mode 100644 VisualizationModules/LibCore/cvfLogDestinationFile.cpp create mode 100644 VisualizationModules/LibCore/cvfLogDestinationFile.h create mode 100644 VisualizationModules/LibCore/cvfLogEvent.cpp create mode 100644 VisualizationModules/LibCore/cvfLogEvent.h create mode 100644 VisualizationModules/LibCore/cvfLogManager.cpp create mode 100644 VisualizationModules/LibCore/cvfLogManager.h create mode 100644 VisualizationModules/LibCore/cvfMutex.cpp create mode 100644 VisualizationModules/LibCore/cvfMutex.h create mode 100644 VisualizationModules/LibRender/cvfCameraAnimation.cpp create mode 100644 VisualizationModules/LibRender/cvfCameraAnimation.h diff --git a/VisualizationModules/LibCore/CMakeLists.txt b/VisualizationModules/LibCore/CMakeLists.txt index 6acce2eec9..f3c0ab4c6e 100644 --- a/VisualizationModules/LibCore/CMakeLists.txt +++ b/VisualizationModules/LibCore/CMakeLists.txt @@ -14,6 +14,7 @@ cvfAssert.h cvfBase.h cvfBase64.h cvfCharArray.h +cvfCodeLocation.h cvfCollection.h cvfCollection.inl cvfColor3.h @@ -24,6 +25,11 @@ cvfFlags.h cvfFlags.inl cvfFunctorRange.h cvfLibCore.h +cvfLogDestination.h +cvfLogDestinationConsole.h +cvfLogDestinationFile.h +cvfLogEvent.h +cvfLogManager.h cvfLogger.h cvfMath.h cvfMath.inl @@ -31,6 +37,7 @@ cvfMatrix3.h cvfMatrix3.inl cvfMatrix4.h cvfMatrix4.inl +cvfMutex.h cvfObject.h cvfObject.inl cvfPlane.h @@ -60,11 +67,17 @@ set(CEE_SOURCE_FILES cvfAssert.cpp cvfBase64.cpp cvfCharArray.cpp +cvfCodeLocation.cpp cvfColor3.cpp cvfColor4.cpp cvfDebugTimer.cpp +cvfLogDestinationConsole.cpp +cvfLogDestinationFile.cpp +cvfLogEvent.cpp +cvfLogManager.cpp cvfLogger.cpp cvfMath.cpp +cvfMutex.cpp cvfObject.cpp cvfPlane.cpp cvfPropertySet.cpp diff --git a/VisualizationModules/LibCore/cvfCodeLocation.cpp b/VisualizationModules/LibCore/cvfCodeLocation.cpp new file mode 100644 index 0000000000..4716136be2 --- /dev/null +++ b/VisualizationModules/LibCore/cvfCodeLocation.cpp @@ -0,0 +1,163 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2012 Ceetron AS +// +// This library 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. +// +// This library 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 "cvfBase.h" +#include "cvfCodeLocation.h" + +#include +#include + +namespace cvf { + + +//================================================================================================== +/// +/// \class cvf::CodeLocation +/// \ingroup Core +/// +/// Represents a source code location. +/// +/// Typically used with logging, asserts etc. Typically initialized using built-in compiler macros +/// such as __FILE__ and __LINE__. +/// +/// Note that the strings parameters for file name and function must be a static strings with a +/// lifetime that's longer than the lifetime of the CodeLocation object +/// +//================================================================================================== + +static const char* const EMPTY_STRING = ""; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +CodeLocation::CodeLocation() +: m_fileName(EMPTY_STRING), + m_functionName(EMPTY_STRING), + m_lineNumber(-1) +{ +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +CodeLocation::CodeLocation(const char* fileName, const char* functionName, int lineNumber) +: m_fileName(fileName), + m_functionName(functionName), + m_lineNumber(lineNumber) +{ +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +CodeLocation::CodeLocation(const CodeLocation& other) +: m_fileName(other.m_fileName), + m_functionName(other.m_functionName), + m_lineNumber(other.m_lineNumber) +{ +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const CodeLocation& CodeLocation::operator=(CodeLocation rhs) +{ + // Copy-and-swap (copy already done since parameter is passed by value) + rhs.swap(*this); + + return *this; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const char* CodeLocation::fileName() const +{ + return m_fileName ? m_fileName : EMPTY_STRING; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const char* CodeLocation::shortFileName() const +{ + if (m_fileName) + { + const char* ptrToLastSlash = strrchr(m_fileName, '/'); + +#ifdef WIN32 + const char* ptrToLastBwdSlash = strrchr(m_fileName, '\\'); + if (ptrToLastBwdSlash > ptrToLastSlash) + { + ptrToLastSlash = ptrToLastBwdSlash; + } +#endif + + if (ptrToLastSlash) + { + return ptrToLastSlash + 1; + } + else + { + return m_fileName; + } + } + else + { + return EMPTY_STRING; + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const char* CodeLocation::functionName() const +{ + return m_functionName ? m_functionName : EMPTY_STRING; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int CodeLocation::lineNumber() const +{ + return m_lineNumber; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void CodeLocation::swap(CodeLocation& other) +{ + std::swap(m_fileName, other.m_fileName); + std::swap(m_functionName, other.m_functionName); + std::swap(m_lineNumber, other.m_lineNumber); +} + + +} // namespace cvf + diff --git a/VisualizationModules/LibCore/cvfCodeLocation.h b/VisualizationModules/LibCore/cvfCodeLocation.h new file mode 100644 index 0000000000..c8f5722a72 --- /dev/null +++ b/VisualizationModules/LibCore/cvfCodeLocation.h @@ -0,0 +1,65 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2012 Ceetron AS +// +// This library 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. +// +// This library 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 + +namespace cvf { + + +//================================================================================================== +// +// +// +//================================================================================================== +class CodeLocation +{ +public: + CodeLocation(); + CodeLocation(const char* fileName, const char* functionName, int lineNumber); + CodeLocation(const CodeLocation& other); + + const CodeLocation& operator=(CodeLocation rhs); + + const char* fileName() const; + const char* shortFileName() const; + const char* functionName() const; + int lineNumber() const; + void swap(CodeLocation& other); + +private: + const char* m_fileName; + const char* m_functionName; + int m_lineNumber; +}; + + +#if defined(_MSC_VER) +#define CVF_CODELOC_FUNCNAME __FUNCSIG__ +#elif defined(__GNUC__) +#define CVF_CODELOC_FUNCNAME __PRETTY_FUNCTION__ +#else +#define CVF_CODELOC_FUNCNAME "" +#endif + +#define CVF_CODE_LOCATION ::cvf::CodeLocation(__FILE__, CVF_CODELOC_FUNCNAME, __LINE__) + + +} // cvf + + diff --git a/VisualizationModules/LibCore/cvfLogDestination.h b/VisualizationModules/LibCore/cvfLogDestination.h new file mode 100644 index 0000000000..9fa8e12ae0 --- /dev/null +++ b/VisualizationModules/LibCore/cvfLogDestination.h @@ -0,0 +1,44 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2012 Ceetron AS +// +// This library 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. +// +// This library 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 "cvfObject.h" + +namespace cvf { + +class LogEvent; + + +//================================================================================================== +// +// Interface for log destinations +// +//================================================================================================== +class LogDestination : public Object +{ +public: + virtual void log(const LogEvent& logEvent) = 0; +}; + + + +} // cvf + + diff --git a/VisualizationModules/LibCore/cvfLogDestinationConsole.cpp b/VisualizationModules/LibCore/cvfLogDestinationConsole.cpp new file mode 100644 index 0000000000..3ec37d5d57 --- /dev/null +++ b/VisualizationModules/LibCore/cvfLogDestinationConsole.cpp @@ -0,0 +1,141 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2012 Ceetron AS +// +// This library 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. +// +// This library 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 "cvfBase.h" +#include "cvfLogDestinationConsole.h" +#include "cvfLogEvent.h" + +#ifdef WIN32 +#pragma warning (push) +#pragma warning (disable: 4668) +#include +#pragma warning (pop) +#else +#include +#include +#endif + +namespace cvf { + + + +//================================================================================================== +/// +/// \class cvf::LogDestinationConsole +/// \ingroup Core +/// +/// +/// +//================================================================================================== + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void LogDestinationConsole::log(const LogEvent& logEvent) +{ + String str; + bool addLocationInfo = false; + + Logger::Level logEventLevel = logEvent.level(); + if (logEventLevel == Logger::LL_ERROR) + { + str = "ERROR: " + logEvent.message(); + addLocationInfo = true; + } + else if (logEventLevel == Logger::LL_WARNING) + { + str = "warn: " + logEvent.message(); + } + else if (logEventLevel == Logger::LL_INFO) + { + str = "info: " + logEvent.message(); + } + else if (logEventLevel == Logger::LL_DEBUG) + { + str = "debug: " + logEvent.message(); + } + + if (addLocationInfo) + { + str += "\n"; + str += String(" -func: %1\n").arg(logEvent.location().functionName()); + str += String(" -file: %1(%2)").arg(logEvent.location().shortFileName()).arg(logEvent.location().lineNumber()); + } + + CharArray charArrMsg = str.toAscii(); + const char* szMsg = charArrMsg.ptr(); + + { + Mutex::ScopedLock lock(m_mutex); + +#ifdef WIN32 + writeToWindowsConsole(szMsg, true); +#else + writeToStderr(szMsg, true); +#endif + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void LogDestinationConsole::writeToWindowsConsole(const char* theString, bool addNewLine) +{ +#ifdef WIN32 + CVF_ASSERT(theString); + + AllocConsole(); + + HANDLE hStdOutputHandle = GetStdHandle(STD_OUTPUT_HANDLE); + if (hStdOutputHandle && theString) + { + DWORD stringLength = static_cast(System::strlen(theString)); + + unsigned long iDum = 0; + WriteConsoleA(hStdOutputHandle, theString, stringLength, &iDum, NULL); + if (addNewLine) WriteConsole(hStdOutputHandle, "\n", 1, &iDum, NULL); + } +#else + CVF_UNUSED(theString); + CVF_UNUSED(addNewLine); +#endif +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void LogDestinationConsole::writeToStderr(const char* theString, bool addNewLine) +{ + CVF_ASSERT(theString); + + if (theString) + { + fprintf(stderr, "%s", theString); + if (addNewLine) + { + fprintf(stderr, "\n"); + } + } +} + + +} // namespace cvf + diff --git a/VisualizationModules/LibCore/cvfLogDestinationConsole.h b/VisualizationModules/LibCore/cvfLogDestinationConsole.h new file mode 100644 index 0000000000..87f3bdd00a --- /dev/null +++ b/VisualizationModules/LibCore/cvfLogDestinationConsole.h @@ -0,0 +1,49 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2012 Ceetron AS +// +// This library 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. +// +// This library 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 "cvfLogDestination.h" +#include "cvfMutex.h" + +namespace cvf { + + +//================================================================================================== +// +// +// +//================================================================================================== +class LogDestinationConsole : public LogDestination +{ +public: + virtual void log(const LogEvent& logEvent); + +private: + static void writeToWindowsConsole(const char* theString, bool addNewLine); + static void writeToStderr(const char* theString, bool addNewLine); + +private: + Mutex m_mutex; +}; + + +} // cvf + + diff --git a/VisualizationModules/LibCore/cvfLogDestinationFile.cpp b/VisualizationModules/LibCore/cvfLogDestinationFile.cpp new file mode 100644 index 0000000000..67c65a1bcd --- /dev/null +++ b/VisualizationModules/LibCore/cvfLogDestinationFile.cpp @@ -0,0 +1,169 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2012 Ceetron AS +// +// This library 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. +// +// This library 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 "cvfBase.h" +#include "cvfLogDestinationFile.h" +#include "cvfLogEvent.h" + +#ifdef WIN32 +#pragma warning (push) +#pragma warning (disable: 4668) +#include +#pragma warning (pop) +#else +#include +#include +#endif + +namespace cvf { + +class FileWrapper +{ +public: + FileWrapper(const String& fileName) + : m_fileName(fileName), + m_filePtr(NULL) + { + } + + ~FileWrapper() + { + if (m_filePtr) + { + fclose(m_filePtr); + } + } + + bool open(const String& mode) + { + CVF_ASSERT(m_filePtr == NULL); + +#ifdef WIN32 + if (_wfopen_s(&m_filePtr, m_fileName.c_str(), mode.c_str()) != 0) + { + m_filePtr = NULL; + } +#else + m_filePtr = ::fopen(m_fileName.toUtf8().ptr(), mode.toUtf8().ptr()); +#endif + + return m_filePtr != NULL; + } + + FILE* filePtr() + { + return m_filePtr; + } + +private: + String m_fileName; + FILE* m_filePtr; +}; + + +//================================================================================================== +/// +/// \class cvf::LogDestinationFile +/// \ingroup Core +/// +/// +/// +//================================================================================================== + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void LogDestinationFile::log(const LogEvent& logEvent) +{ + String str; + bool addLocationInfo = false; + + Logger::Level logEventLevel = logEvent.level(); + if (logEventLevel == Logger::LL_ERROR) + { + str = "ERROR: " + logEvent.message(); + addLocationInfo = true; + } + else if (logEventLevel == Logger::LL_WARNING) + { + str = "warn: " + logEvent.message(); + } + else if (logEventLevel == Logger::LL_INFO) + { + str = "info: " + logEvent.message(); + } + else if (logEventLevel == Logger::LL_DEBUG) + { + str = "debug: " + logEvent.message(); + } + + if (addLocationInfo) + { + str += "\n"; + str += String(" -func: %1\n").arg(logEvent.location().functionName()); + str += String(" -file: %1(%2)").arg(logEvent.location().shortFileName()).arg(logEvent.location().lineNumber()); + } + + CharArray charArrMsg = str.toAscii(); + const char* szMsg = charArrMsg.ptr(); + + Mutex::ScopedLock lock(m_mutex); + writeToFile(szMsg, true); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void LogDestinationFile::writeToFile(const char* theString, bool addNewLine) +{ + FileWrapper file(m_fileName); + if (m_firstTimeOpen) + { + if (!file.open("wt")) + { + return; + } + + m_firstTimeOpen = false; + } + else + { + if (!file.open("at")) + { + return; + } + } + + if (file.filePtr() && theString) + { + if (addNewLine) + { + fprintf(file.filePtr(), "%s\n", theString); + } + else + { + fprintf(file.filePtr(), "%s", theString); + } + } +} + + +} // namespace cvf + diff --git a/VisualizationModules/LibCore/cvfLogDestinationFile.h b/VisualizationModules/LibCore/cvfLogDestinationFile.h new file mode 100644 index 0000000000..a01ddc344b --- /dev/null +++ b/VisualizationModules/LibCore/cvfLogDestinationFile.h @@ -0,0 +1,53 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2012 Ceetron AS +// +// This library 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. +// +// This library 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 "cvfLogDestination.h" +#include "cvfString.h" +#include "cvfMutex.h" + +namespace cvf { + + +//================================================================================================== +// +// +// +//================================================================================================== +class LogDestinationFile : public LogDestination +{ +public: + LogDestinationFile(const String& fileName); + + virtual void log(const LogEvent& logEvent); + +private: + void writeToFile(const char* theString, bool addNewLine); + +private: + String m_fileName; + bool m_firstTimeOpen; // Initialized to true, Will be set to false after first write operation + Mutex m_mutex; +}; + + +} // cvf + + diff --git a/VisualizationModules/LibCore/cvfLogEvent.cpp b/VisualizationModules/LibCore/cvfLogEvent.cpp new file mode 100644 index 0000000000..7d08ffe386 --- /dev/null +++ b/VisualizationModules/LibCore/cvfLogEvent.cpp @@ -0,0 +1,128 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2012 Ceetron AS +// +// This library 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. +// +// This library 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 "cvfBase.h" +#include "cvfLogEvent.h" + +namespace cvf { + + +//================================================================================================== +/// +/// \class cvf::LogEvent +/// \ingroup Core +/// +/// +/// +//================================================================================================== + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +LogEvent::LogEvent() +: m_level(Logger::LL_ERROR) +{ +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +LogEvent::LogEvent(const String& source, const String& message, Logger::Level level, const CodeLocation& codeLocation) +: m_source(source), + m_message(message), + m_level(level), + m_codeLocation(codeLocation) +{ +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +LogEvent::LogEvent(const LogEvent& other) +: m_source(other.m_source), + m_message(other.m_message), + m_level(other.m_level), + m_codeLocation(other.m_codeLocation) +{ +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const LogEvent& LogEvent::operator=(LogEvent rhs) +{ + // Copy-and-swap (copy already done since parameter is passed by value) + rhs.swap(*this); + + return *this; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const String& LogEvent::source() const +{ + return m_source; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Logger::Level LogEvent::level() const +{ + return m_level; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const String& LogEvent::message() const +{ + return m_message; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const CodeLocation& LogEvent::location() const +{ + return m_codeLocation; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void LogEvent::swap(LogEvent& other) +{ + m_source.swap(other.m_source); + m_message.swap(other.m_message); + std::swap(m_level, other.m_level); + m_codeLocation.swap(other.m_codeLocation); +} + +} // namespace cvf + diff --git a/VisualizationModules/LibCore/cvfLogEvent.h b/VisualizationModules/LibCore/cvfLogEvent.h new file mode 100644 index 0000000000..25c5c6592e --- /dev/null +++ b/VisualizationModules/LibCore/cvfLogEvent.h @@ -0,0 +1,62 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2012 Ceetron AS +// +// This library 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. +// +// This library 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 "cvfObject.h" +#include "cvfString.h" +#include "cvfLogger.h" + +namespace cvf { + + +//================================================================================================== +// +// +// +//================================================================================================== +class LogEvent +{ +public: + LogEvent(); + LogEvent(const String& source, const String& message, Logger::Level level, const CodeLocation& codeLocation); + LogEvent(const LogEvent& other); + + const LogEvent& operator=(LogEvent rhs); + + const String& source() const; + Logger::Level level() const; + const String& message() const; + const CodeLocation& location() const; + +private: + void swap(LogEvent& other); + +private: + String m_source; + String m_message; + Logger::Level m_level; + CodeLocation m_codeLocation; +}; + + + +} // cvf + + diff --git a/VisualizationModules/LibCore/cvfLogManager.cpp b/VisualizationModules/LibCore/cvfLogManager.cpp new file mode 100644 index 0000000000..1facf09548 --- /dev/null +++ b/VisualizationModules/LibCore/cvfLogManager.cpp @@ -0,0 +1,236 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2012 Ceetron AS +// +// This library 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. +// +// This library 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 "cvfBase.h" +#include "cvfLogManager.h" +#include "cvfLogger.h" +#include "cvfLogDestinationConsole.h" + +namespace cvf { + + + +//================================================================================================== +/// +/// \class cvf::LogManager +/// \ingroup Core +/// +/// +/// +//================================================================================================== + +cvf::ref LogManager::sm_logManagerInstance; +Mutex LogManager::sm_instanceMutex; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +LogManager::LogManager() +{ + // Create the root logger + ref rootLogger = new Logger("", Logger::LL_WARNING, new LogDestinationConsole); + m_loggerMap[""] = rootLogger; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +LogManager::~LogManager() +{ +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +LogManager* LogManager::instance() +{ + Mutex::ScopedLock mutexLock(sm_instanceMutex); + + if (sm_logManagerInstance.isNull()) + { + sm_logManagerInstance = new LogManager; + } + + return sm_logManagerInstance.p(); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void LogManager::setInstance(LogManager* logManagerInstance) +{ + Mutex::ScopedLock mutexLock(sm_instanceMutex); + + sm_logManagerInstance = logManagerInstance; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void LogManager::shutdownInstance() +{ + Mutex::ScopedLock mutexLock(sm_instanceMutex); + + sm_logManagerInstance = NULL; +} + + +//-------------------------------------------------------------------------------------------------- +/// Returns logger with the specified name +/// +/// Will create the logger if it doesn't already exist. In this case, the newly created logger will +/// be initialized with the same logging level and appender as its parent. +//-------------------------------------------------------------------------------------------------- +Logger* LogManager::logger(const String& loggerName) +{ + Mutex::ScopedLock mutexLock(m_mutex); + + ref theLogger = find(loggerName); + if (theLogger.isNull()) + { + // Must create a new logger + // Try and find parent (optionally we'll use the root logger) and use its settings to initialize level and appender + String parentLoggerName = LogManager::nameOfParentLogger(loggerName); + ref parentLogger = find(parentLoggerName); + if (parentLogger.isNull()) + { + parentLogger = rootLogger(); + } + + CVF_ASSERT(parentLogger.notNull()); + + theLogger = new Logger(loggerName, parentLogger->level(), parentLogger->destination()); + m_loggerMap[loggerName] = theLogger; + } + + return theLogger.p(); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Logger* LogManager::rootLogger() +{ + return logger(String()); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void LogManager::setLevelRecursive(const String& baseLoggerName, int logLevel) +{ + Mutex::ScopedLock mutexLock(m_mutex); + + const size_t baseNameLength = baseLoggerName.size(); + const bool baseNameIsRoot = (baseNameLength == 0); + + for (LoggerMap_T::iterator it = m_loggerMap.begin(); it != m_loggerMap.end(); ++it) + { + Logger* logger = it->second.p(); + if (baseNameIsRoot) + { + logger->setLevel(logLevel); + } + else + { + const String& loggerName = logger->name(); + if (loggerName.startsWith(baseLoggerName) && + ((loggerName.size() == baseNameLength) || (loggerName[baseNameLength] == '.')) ) + { + logger->setLevel(logLevel); + } + } + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void LogManager::setDestinationRecursive(const String& baseLoggerName, LogDestination* logDestination) +{ + Mutex::ScopedLock mutexLock(m_mutex); + + const size_t baseNameLength = baseLoggerName.size(); + const bool baseNameIsRoot = (baseNameLength == 0); + + for (LoggerMap_T::iterator it = m_loggerMap.begin(); it != m_loggerMap.end(); ++it) + { + Logger* logger = it->second.p(); + if (baseNameIsRoot) + { + logger->setDestination(logDestination); + } + else + { + const String& loggerName = logger->name(); + if (loggerName.startsWith(baseLoggerName) && + ((loggerName.size() == baseNameLength) || (loggerName[baseNameLength] == '.')) ) + { + logger->setDestination(logDestination); + } + } + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Logger* LogManager::find(const String& loggerName) +{ + LoggerMap_T::iterator it = m_loggerMap.find(loggerName); + if (it != m_loggerMap.end()) + { + return it->second.p(); + } + else + { + return NULL; + } +} + + +//-------------------------------------------------------------------------------------------------- +/// Determine name of the parent logger of \a childLoggerName +//-------------------------------------------------------------------------------------------------- +String LogManager::nameOfParentLogger(const String& childLoggerName) +{ + std::wstring childName = childLoggerName.toStdWString(); + std::wstring::size_type pos = childName.rfind('.'); + if (pos != std::wstring::npos) + { + std::wstring parentName = childName.substr(0, pos); + return parentName; + } + else + { + return String(); + } +} + + +} // namespace cvf + diff --git a/VisualizationModules/LibCore/cvfLogManager.h b/VisualizationModules/LibCore/cvfLogManager.h new file mode 100644 index 0000000000..b3dde9e597 --- /dev/null +++ b/VisualizationModules/LibCore/cvfLogManager.h @@ -0,0 +1,74 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2012 Ceetron AS +// +// This library 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. +// +// This library 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 "cvfObject.h" +#include "cvfString.h" +#include "cvfMutex.h" + +#include + +namespace cvf { + +class Logger; +class LogDestination; + + + +//================================================================================================== +// +// +// +//================================================================================================== +class LogManager : public Object +{ +public: + LogManager(); + ~LogManager(); + + static LogManager* instance(); + static void setInstance(LogManager* logManagerInstance); + static void shutdownInstance(); + + Logger* logger(const String& loggerName); + Logger* rootLogger(); + + void setLevelRecursive(const String& baseLoggerName, int logLevel); + void setDestinationRecursive(const String& baseLoggerName, LogDestination* logDestination); + +private: + Logger* find(const String& loggerName); + static String nameOfParentLogger(const String& childLoggerName); + +private: + typedef std::map > LoggerMap_T; + LoggerMap_T m_loggerMap; + Mutex m_mutex; + static cvf::ref sm_logManagerInstance; + static Mutex sm_instanceMutex; + + CVF_DISABLE_COPY_AND_ASSIGN(LogManager); +}; + + + +} // cvf + + diff --git a/VisualizationModules/LibCore/cvfLogger.cpp b/VisualizationModules/LibCore/cvfLogger.cpp index ad5ca091c3..d44feb8d65 100644 --- a/VisualizationModules/LibCore/cvfLogger.cpp +++ b/VisualizationModules/LibCore/cvfLogger.cpp @@ -19,7 +19,8 @@ #include "cvfBase.h" #include "cvfLogger.h" -#include "cvfTrace.h" +#include "cvfLogEvent.h" +#include "cvfLogDestination.h" namespace cvf { @@ -31,17 +32,20 @@ namespace cvf { /// \ingroup Core /// /// Logger class -/// -/// Currently, output is written using Trace, and special formatting of the string makes it possible -/// to navigate to source code using F4 in Visual Studio. See http://msdn.microsoft.com/en-us/library/yxkt8b26.aspx /// +/// Note that in itself, the Logger is not thread safe. This means that logger configuration, such +/// as setting the logging level and specifying the log destination, must be done in a single +/// threaded environment. +/// //================================================================================================== //-------------------------------------------------------------------------------------------------- /// Constructor //-------------------------------------------------------------------------------------------------- -Logger::Logger() -: m_debugLogging(false) +Logger::Logger(const String& loggerName, int logLevel, LogDestination* logDestination) +: m_name(loggerName), + m_logLevel(logLevel), + m_destination(logDestination) { } @@ -51,62 +55,145 @@ Logger::Logger() //-------------------------------------------------------------------------------------------------- Logger::~Logger() { - } //-------------------------------------------------------------------------------------------------- -/// Use file and line to create a specially formatted string for Visual Studio. /// -/// \param message The actual error message -/// \param fileName Use system macro __FILE__ for source code file name -/// \param line Use system macro __LINE__ for source code line number +//-------------------------------------------------------------------------------------------------- +const String& Logger::name() const +{ + return m_name; +} + + +//-------------------------------------------------------------------------------------------------- +/// Set the logging level of this logger /// -/// __FILE__ and __LINE__ are used to create the variables used to navigate to the line in the -/// source code file the error message was logged at. +/// Set a level of 0 to disable all logging for this logger. //-------------------------------------------------------------------------------------------------- -void Logger::error(const String& message, const char* fileName, int lineNumber) +void Logger::setLevel(int logLevel) { - String tmp; - tmp = String(fileName) + "(" + String(lineNumber) + "): error: " + message; - - Trace::show(tmp); + m_logLevel = logLevel; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Logger::enableDebug(bool enableDebugLogging) +int Logger::level() const { - m_debugLogging = enableDebugLogging; + return m_logLevel; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool Logger::isDebugEnabled() const +LogDestination* Logger::destination() { - return m_debugLogging; + return m_destination.p(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Logger::debug(const String& message, const char* /*fileName*/, int /*lineNumber*/) +void Logger::setDestination(LogDestination* logDestination) { - if (m_debugLogging) + m_destination = logDestination; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Logger::error(const String& message) +{ + error(message, CodeLocation()); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Logger::error(const String& message, const CodeLocation& location) +{ + if (m_logLevel >= LL_ERROR && m_destination.notNull()) { - // For now, don't report file and line - String tmp; - tmp = "debug: " + message; - - Trace::show(tmp); + log(message, LL_ERROR, location); } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Logger::warning(const String& message) +{ + warning(message, CodeLocation()); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Logger::warning(const String& message, const CodeLocation& location) +{ + if (m_logLevel >= LL_WARNING && m_destination.notNull()) + { + log(message, LL_WARNING, location); + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Logger::info(const String& message) +{ + info(message, CodeLocation()); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Logger::info(const String& message, const CodeLocation& location) +{ + if (m_logLevel >= LL_INFO && m_destination.notNull()) + { + log(message, LL_INFO, location); + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Logger::debug(const String& message, const CodeLocation& location) +{ + if (m_logLevel >= LL_DEBUG && m_destination.notNull()) + { + log(message, LL_DEBUG, location); + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Logger::log(const String& message, Logger::Level messageLevel, const CodeLocation& location) +{ + if (m_logLevel >= messageLevel && m_destination.notNull()) + { + m_destination->log(LogEvent(m_name, message, messageLevel, location)); + } +} + + + + + } // namespace cvf diff --git a/VisualizationModules/LibCore/cvfLogger.h b/VisualizationModules/LibCore/cvfLogger.h index 8c29a9c8eb..d48e4363a6 100644 --- a/VisualizationModules/LibCore/cvfLogger.h +++ b/VisualizationModules/LibCore/cvfLogger.h @@ -21,9 +21,14 @@ #include "cvfObject.h" #include "cvfString.h" +#include "cvfCodeLocation.h" namespace cvf { - + +class LogEvent; +class LogDestination; + + //================================================================================================== // @@ -33,20 +38,57 @@ namespace cvf { class Logger : public Object { public: - Logger(); + enum Level + { + LL_ERROR = 1, + LL_WARNING, + LL_INFO, + LL_DEBUG + }; + +public: + Logger(const String& loggerName, int logLevel, LogDestination* logDestination); ~Logger(); - void error(const String& message, const char* fileName, int lineNumber); + const String& name() const; + int level() const; + void setLevel(int logLevel); + LogDestination* destination(); + void setDestination(LogDestination* logDestination); - void enableDebug(bool enableDebugLogging); - bool isDebugEnabled() const; - void debug(const String& message, const char* fileName, int lineNumber); + void error(const String& message); + void error(const String& message, const CodeLocation& location); + void warning(const String& message); + void warning(const String& message, const CodeLocation& location); + void info(const String& message); + void info(const String& message, const CodeLocation& location); + void debug(const String& message, const CodeLocation& location); + + bool isErrorEnabled() const { return m_logLevel >= LL_ERROR; } + bool isWarningEnabled() const { return m_logLevel >= LL_WARNING; } + bool isInfoEnabled() const { return m_logLevel >= LL_INFO; } + bool isDebugEnabled() const { return m_logLevel >= LL_DEBUG; } private: - bool m_debugLogging; // Whether debug messages get logged or not + void log(const String& message, Logger::Level messageLevel, const CodeLocation& location); + +private: + String m_name; // Logger name + int m_logLevel; // Logging level, all messages with a level less than or equal to this level will be logged + ref m_destination; + + CVF_DISABLE_COPY_AND_ASSIGN(Logger); }; +// Helper macros for writing log messages to a logger +#define CVF_LOG_ERROR(theLogger, theMessage) if ((theLogger)->isErrorEnabled()) { (theLogger)->error((theMessage), CVF_CODE_LOCATION); } +#define CVF_LOG_WARNING(theLogger, theMessage) if ((theLogger)->isWarningEnabled()) { (theLogger)->warning((theMessage), CVF_CODE_LOCATION); } +#define CVF_LOG_INFO(theLogger, theMessage) if ((theLogger)->isInfoEnabled()) { (theLogger)->info((theMessage), CVF_CODE_LOCATION); } +#define CVF_LOG_DEBUG(theLogger, theMessage) if ((theLogger)->isDebugEnabled()) { (theLogger)->debug((theMessage), CVF_CODE_LOCATION); } + + + } // cvf diff --git a/VisualizationModules/LibCore/cvfMutex.cpp b/VisualizationModules/LibCore/cvfMutex.cpp new file mode 100644 index 0000000000..532005c7a1 --- /dev/null +++ b/VisualizationModules/LibCore/cvfMutex.cpp @@ -0,0 +1,202 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2012 Ceetron AS +// +// This library 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. +// +// This library 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 "cvfBase.h" +#include "cvfMutex.h" + +#ifdef WIN32 +#pragma warning (push) +#pragma warning (disable: 4668) +#include +#pragma warning (pop) +#endif + +#ifdef CVF_LINUX +#include +#endif + +namespace cvf { + + +//================================================================================================== +// +// Win32 implementation using critical section +// +//================================================================================================== +#ifdef WIN32 +class MutexImpl +{ +public: + MutexImpl() + { + ::InitializeCriticalSection(&m_critSection); + } + + ~MutexImpl() + { + ::DeleteCriticalSection(&m_critSection); + } + + void lock() + { + ::EnterCriticalSection(&m_critSection); + } + + void unlock() + { + ::LeaveCriticalSection(&m_critSection); + } + +private: + CRITICAL_SECTION m_critSection; +}; +#endif + + +//================================================================================================== +// +// Linux implementation using POSIX/Pthreads +// +//================================================================================================== +#ifdef CVF_LINUX +class MutexImpl +{ +public: + MutexImpl() + { + pthread_mutexattr_t mutexAttribs; + + int errCode = 0; + CVF_UNUSED(errCode); + errCode = pthread_mutexattr_init(&mutexAttribs); + CVF_ASSERT(errCode == 0); + + // Use a recursive mutex to be aligned with Win32 implementation + errCode = pthread_mutexattr_settype(&mutexAttribs, PTHREAD_MUTEX_RECURSIVE); + CVF_ASSERT(errCode == 0); + + errCode = pthread_mutex_init(&m_mutex, &mutexAttribs); + CVF_ASSERT(errCode == 0); + + // We're done with the attribs object + errCode = pthread_mutexattr_destroy(&mutexAttribs); + CVF_ASSERT(errCode == 0); + } + + ~MutexImpl() + { + int errCode = pthread_mutex_destroy(&m_mutex); + CVF_UNUSED(errCode); + CVF_TIGHT_ASSERT(errCode == 0); + } + + void lock() + { + int errCode = pthread_mutex_lock(&m_mutex); + CVF_UNUSED(errCode); + CVF_TIGHT_ASSERT(errCode == 0); + } + + void unlock() + { + int errCode = pthread_mutex_unlock(&m_mutex); + CVF_UNUSED(errCode); + CVF_TIGHT_ASSERT(errCode == 0); + } + +private: + pthread_mutex_t m_mutex; +}; +#endif + + + +//================================================================================================== +/// +/// \class cvf::Mutex +/// \ingroup Core +/// +/// Implements a recursive mutex where the same thread can acquire the lock multiple times. +/// +/// The mutex is implemented as an recursive mutex since on Windows platforms its implementation +/// is based critical sections. Win32 critical sections are always recursive, and therefore we also +/// make the other platform implementations recursive for consistency. +/// +//================================================================================================== + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Mutex::Mutex() +: m_pimpl(new MutexImpl) +{ +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Mutex::~Mutex() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Mutex::lock() +{ + m_pimpl->lock(); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Mutex::unlock() +{ + m_pimpl->unlock(); +} + + +//================================================================================================== +/// +/// \class cvf::Mutex::ScopedLock +/// \ingroup Core +/// +/// +/// +//================================================================================================== +Mutex::ScopedLock::ScopedLock(Mutex& mutex) +: m_theMutex(mutex) +{ + m_theMutex.lock(); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Mutex::ScopedLock::~ScopedLock() +{ + m_theMutex.unlock(); +} + + +} // namespace cvf + diff --git a/VisualizationModules/LibCore/cvfMutex.h b/VisualizationModules/LibCore/cvfMutex.h new file mode 100644 index 0000000000..5571a9717c --- /dev/null +++ b/VisualizationModules/LibCore/cvfMutex.h @@ -0,0 +1,60 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2012 Ceetron AS +// +// This library 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. +// +// This library 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 + +namespace cvf { + + +//================================================================================================== +// +// +// +//================================================================================================== +class Mutex +{ +public: + Mutex(); + ~Mutex(); + + void lock(); + void unlock(); + + class ScopedLock + { + public: + ScopedLock(Mutex& mutex); + ~ScopedLock(); + + private: + Mutex& m_theMutex; + }; + +private: + std::auto_ptr m_pimpl; + + CVF_DISABLE_COPY_AND_ASSIGN(Mutex); +}; + + +} // cvf + + diff --git a/VisualizationModules/LibCore/cvfString.cpp b/VisualizationModules/LibCore/cvfString.cpp index 9e9b6754b8..b042a5daf0 100644 --- a/VisualizationModules/LibCore/cvfString.cpp +++ b/VisualizationModules/LibCore/cvfString.cpp @@ -1063,6 +1063,15 @@ size_t String::find(const String& str, size_t start) const } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool String::startsWith(const String& str) const +{ + return (find(str) == 0); +} + + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/VisualizationModules/LibCore/cvfString.h b/VisualizationModules/LibCore/cvfString.h index 7a0d45e0b0..35c820e867 100644 --- a/VisualizationModules/LibCore/cvfString.h +++ b/VisualizationModules/LibCore/cvfString.h @@ -69,6 +69,7 @@ public: std::vector split(const String& delimiters = " ") const; size_t find(const String& str, size_t start = 0) const; + bool startsWith(const String& str) const; String subString(size_t start, size_t length = npos) const; void replace(const String& before, const String& after); diff --git a/VisualizationModules/LibRender/CMakeLists.txt b/VisualizationModules/LibRender/CMakeLists.txt index f2005f4d69..d4ea84debf 100644 --- a/VisualizationModules/LibRender/CMakeLists.txt +++ b/VisualizationModules/LibRender/CMakeLists.txt @@ -20,6 +20,7 @@ include_directories(glew) set(CEE_HEADER_FILES cvfBufferObjectManaged.h cvfCamera.h +cvfCameraAnimation.h cvfDrawable.h cvfDrawableGeo.h cvfDrawableText.h @@ -98,6 +99,7 @@ cvfViewport.h set(CEE_SOURCE_FILES cvfBufferObjectManaged.cpp cvfCamera.cpp +cvfCameraAnimation.cpp cvfDrawable.cpp cvfDrawableGeo.cpp cvfDrawableVectors.cpp diff --git a/VisualizationModules/LibRender/cvfCamera.cpp b/VisualizationModules/LibRender/cvfCamera.cpp index 6ea6a8ebc7..0aea6f4b47 100644 --- a/VisualizationModules/LibRender/cvfCamera.cpp +++ b/VisualizationModules/LibRender/cvfCamera.cpp @@ -268,13 +268,23 @@ void Camera::setProjectionAsPixelExact2D() /// the view to. The relativeDistance parameter specifies the distance from the camera to the /// center of the bounding box //-------------------------------------------------------------------------------------------------- -void Camera::fitView(const BoundingBox& boundingBox, const Vec3d& dir, const Vec3d& up, double distanceScaleFactor) +void Camera::fitView(const BoundingBox& boundingBox, const Vec3d& dir, const Vec3d& up, double coverageFactor) +{ + // Use old view direction, but look towards model center + Vec3d eye = fitViewEyePosition(boundingBox, dir, up, coverageFactor); + + // Will update cached values + setFromLookAt(eye, boundingBox.center(), up); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Vec3d Camera::fitViewEyePosition(const BoundingBox& boundingBox, const Vec3d& dir, const Vec3d& up, double coverageFactor) const { CVF_ASSERT(projection() == PERSPECTIVE); - // TODO! !!! !! !! - CVF_UNUSED(distanceScaleFactor); - cvf::Vec3d corners[8]; boundingBox.cornerVertices(corners); @@ -312,8 +322,8 @@ void Camera::fitView(const BoundingBox& boundingBox, const Vec3d& dir, const Vec distUp += (centerToCornerSide*boxEyeNorm); // Adjust for the distance scale factor - distRight /= distanceScaleFactor; - distUp /= distanceScaleFactor; + distRight /= coverageFactor; + distUp /= coverageFactor; dist = CVF_MAX(dist, distRight); dist = CVF_MAX(dist, distUp); @@ -328,8 +338,7 @@ void Camera::fitView(const BoundingBox& boundingBox, const Vec3d& dir, const Vec // Use old view direction, but look towards model center Vec3d eye = boundingBox.center()- dir.getNormalized()*dist; - // Will update cached values - setFromLookAt(eye, boundingBox.center(), up); + return eye; } @@ -1023,6 +1032,5 @@ void Camera::applyOpenGL() const #endif } - } // namespace cvf diff --git a/VisualizationModules/LibRender/cvfCamera.h b/VisualizationModules/LibRender/cvfCamera.h index d00e364cf4..c247c47fe0 100644 --- a/VisualizationModules/LibRender/cvfCamera.h +++ b/VisualizationModules/LibRender/cvfCamera.h @@ -66,6 +66,8 @@ public: void fitView(const BoundingBox& boundingBox, const Vec3d& dir, const Vec3d& up, double coverageFactor = 0.9); void fitViewOrtho(const BoundingBox& boundingBox, double eyeDist, const Vec3d& dir, const Vec3d& up, double coverageFactor = 0.9); + Vec3d fitViewEyePosition(const BoundingBox& boundingBox, const Vec3d& dir, const Vec3d& up, double coverageFactor = 0.9) const; + void setClipPlanesFromBoundingBox(const BoundingBox& boundingBox, double minNearPlaneDistance = 0.01); const Mat4d& viewMatrix() const; diff --git a/VisualizationModules/LibRender/cvfCameraAnimation.cpp b/VisualizationModules/LibRender/cvfCameraAnimation.cpp new file mode 100644 index 0000000000..f18144f184 --- /dev/null +++ b/VisualizationModules/LibRender/cvfCameraAnimation.cpp @@ -0,0 +1,109 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2012 Ceetron AS +// +// This library 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. +// +// This library 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 "cvfBase.h" +#include "cvfCameraAnimation.h" +#include "cvfCamera.h" +#include "cvfTimer.h" + +namespace cvf { + + +//================================================================================================== +/// +/// \class cvf::CameraAnimation +/// \ingroup Render +/// +/// Support class for creating a camera path animation from one camera configuration to another. +/// +//================================================================================================== + + +//-------------------------------------------------------------------------------------------------- +/// Configures the animation with start and end point +//-------------------------------------------------------------------------------------------------- +CameraAnimation::CameraAnimation(const Vec3d& currentPos, const Vec3d& currentDir, const Vec3d& currentUp, const Vec3d& newPos, const Vec3d& newDir, const Vec3d& newUp) +: m_currentPos(currentPos), + m_currentDir(currentDir), + m_currentUp(currentUp), + m_newPos(newPos), + m_newDir(newDir), + m_newUp(newUp), + m_animDuration(0.75), + m_animDone(false) +{ +} + + +//-------------------------------------------------------------------------------------------------- +/// Returns the next position in the animation. After the duration of the animation is used up, +/// the method returns the end point and after that always returns false. +/// +/// So usage would be: +/// \code +/// cvf::Vec3d pos, dir, up; +/// while(anim.newPosition(&pos, &dir, &up)) +/// { +/// m_camera->setFromLookAt(pos, pos + dir, up); +/// repaint(); +/// } +/// \endcode +//-------------------------------------------------------------------------------------------------- +bool CameraAnimation::newPosition(Vec3d* pos, Vec3d* dir, Vec3d* up) +{ + if (m_animDone) + { + return false; + } + + if (m_timer.isNull()) + { + m_timer = new Timer; + } + + double timeNow = m_timer->time(); + + if (timeNow > m_animDuration) + { + *pos = m_newPos; + *dir = m_newDir; + *up = m_newUp; + + m_animDone = true; + + return true; + } + + *pos = m_currentPos + (m_newPos - m_currentPos)*(timeNow/m_animDuration); + *dir = m_currentDir + (m_newDir - m_currentDir)*(timeNow/m_animDuration); + *up = m_currentUp + (m_newUp - m_currentUp )*(timeNow/m_animDuration); + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// Sets the duration of the animation +//-------------------------------------------------------------------------------------------------- +void CameraAnimation::setDuration(double seconds) +{ + m_animDuration = seconds; +} + +} // namespace cvf + diff --git a/VisualizationModules/LibRender/cvfCameraAnimation.h b/VisualizationModules/LibRender/cvfCameraAnimation.h new file mode 100644 index 0000000000..70e166f8bf --- /dev/null +++ b/VisualizationModules/LibRender/cvfCameraAnimation.h @@ -0,0 +1,56 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2012 Ceetron AS +// +// This library 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. +// +// This library 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 "cvfObject.h" +#include "cvfVector3.h" + +namespace cvf { + +class Timer; + +//================================================================================================== +// +// Camera animation class +// +//================================================================================================== +class CameraAnimation : public Object +{ +public: + CameraAnimation(const Vec3d& currentPos, const Vec3d& currentDir, const Vec3d& currentUp, const Vec3d& newPos, const Vec3d& newDir, const Vec3d& newUp); + + void setDuration(double seconds); + + bool newPosition(Vec3d* pos, Vec3d* dir, Vec3d* up); + +private: + Vec3d m_currentPos; + Vec3d m_currentDir; + Vec3d m_currentUp; + Vec3d m_newPos; + Vec3d m_newDir; + Vec3d m_newUp; + + ref m_timer; + double m_animDuration; + bool m_animDone; +}; + +} diff --git a/VisualizationModules/LibRender/cvfDrawableGeo.cpp b/VisualizationModules/LibRender/cvfDrawableGeo.cpp index 447496332e..28ee7bba9c 100644 --- a/VisualizationModules/LibRender/cvfDrawableGeo.cpp +++ b/VisualizationModules/LibRender/cvfDrawableGeo.cpp @@ -1273,8 +1273,6 @@ BoundingBox DrawableGeo::boundingBox() const //-------------------------------------------------------------------------------------------------- bool DrawableGeo::rayIntersect(const Ray& ray, Vec3d* intersectionPoint, uint* faceHit) const { - CVF_ASSERT(intersectionPoint); - bool anyHits = false; double minDistSquared = 1.0e300; @@ -1314,19 +1312,23 @@ bool DrawableGeo::rayIntersect(const Ray& ray, Vec3d* intersectionPoint, uint* f double distSquared = (ray.origin() - localIntersect).lengthSquared(); #pragma omp critical { - if (distSquared < minDistSquared) + if (distSquared < minDistSquared) + { + if (intersectionPoint) { - *intersectionPoint = localIntersect; - minDistSquared = distSquared; - - if (faceHit) - { - *faceHit = i + accumulatedFaceCount; - } + *intersectionPoint = localIntersect; } - anyHits = true; - } + + minDistSquared = distSquared; + + if (faceHit) + { + *faceHit = i + accumulatedFaceCount; + } + } + anyHits = true; } + } } // End omp parallel for accumulatedFaceCount += numPrimFaces; } diff --git a/VisualizationModules/LibRender/cvfDrawableText.cpp b/VisualizationModules/LibRender/cvfDrawableText.cpp index 1948122fdf..11ac32b535 100644 --- a/VisualizationModules/LibRender/cvfDrawableText.cpp +++ b/VisualizationModules/LibRender/cvfDrawableText.cpp @@ -64,7 +64,8 @@ DrawableText::DrawableText() m_borderColor(Color3::BLACK), m_drawBackground(true), m_drawBorder(true), - m_checkPosVisible(true) + m_checkPosVisible(true), + m_useDepthBuffer(false) { } @@ -158,6 +159,15 @@ void DrawableText::setCheckPosVisible(bool checkpos) } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void DrawableText::setUseDepthBuffer(bool useDepthBuffer) +{ + m_useDepthBuffer = useDepthBuffer; +} + + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -323,7 +333,7 @@ void DrawableText::renderText(OpenGLContext* oglContext, ShaderProgram* shaderPr if (!m_checkPosVisible || labelAnchorVisible(oglContext, proj, m_positions[pos], shaderProgram == NULL)) { // Note: Need to adjust for the current viewport, as the coords returned from project are in global windows coordinates - projCoords.push_back(Vec3f(static_cast(proj.x() - matrixState.viewportPosition().x()), static_cast(proj.y() - matrixState.viewportPosition().y()), 0.0f)); + projCoords.push_back(Vec3f(static_cast(proj.x() - matrixState.viewportPosition().x()), static_cast(proj.y() - matrixState.viewportPosition().y()), static_cast(1.0 - 2.0*proj.z()))); // Map z into 1 .. -1 textsToDraw.push_back(m_texts[pos]); } } @@ -355,12 +365,13 @@ void DrawableText::renderText(OpenGLContext* oglContext, ShaderProgram* shaderPr drawer.setBorderColor(m_borderColor); drawer.setDrawBorder(m_drawBorder); drawer.setDrawBackground(m_drawBackground); + drawer.setUseDepthBuffer(m_useDepthBuffer); size_t i; for (i = 0; i < textsToDraw.size(); i++) { Vec3f pos = projCoords[i]; - drawer.addText(textsToDraw[i], Vec2f(pos)); + drawer.addText(textsToDraw[i], pos); } if (shaderProgram) @@ -423,4 +434,38 @@ bool DrawableText::labelAnchorVisible(OpenGLContext* oglContext, const Vec3d win } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool DrawableText::rayIntersect(const Ray& ray, const Camera& camera, Vec3d* intersectionPoint) +{ + Vec3d pickCoord2d; + camera.project(ray.origin(), &pickCoord2d); + + size_t i; + for (i = 0; i < m_positions.size(); i++) + { + Vec3d proj; + camera.project(Vec3d(m_positions[i]), &proj); + + Vec3f posTextDrawer = Vec3f(static_cast(proj.x() - camera.viewport()->x()), static_cast(proj.y() - camera.viewport()->y()), static_cast(1.0 - 2.0*proj.z())); // Map z into 1 .. -1 + + if (TextDrawer::pickText(Vec3f(pickCoord2d), m_texts[i], posTextDrawer, m_font.p())) + { + if (m_useDepthBuffer) + { + *intersectionPoint = Vec3d(m_positions[i]); + } + else + { + *intersectionPoint = ray.origin(); + } + + return true; + } + } + + return false; +} + } // namespace cvf diff --git a/VisualizationModules/LibRender/cvfDrawableText.h b/VisualizationModules/LibRender/cvfDrawableText.h index 9299ecd699..f9a6bdacfc 100644 --- a/VisualizationModules/LibRender/cvfDrawableText.h +++ b/VisualizationModules/LibRender/cvfDrawableText.h @@ -30,6 +30,7 @@ class Font; class DrawableGeo; class ShaderProgram; class BufferObjectManaged; +class Camera; //================================================================================================== @@ -55,6 +56,7 @@ public: void setDrawBackground(bool drawBackground); void setDrawBorder(bool drawBorder); void setCheckPosVisible(bool checkpos); + void setUseDepthBuffer(bool useDepthBuffer); virtual void createUploadBufferObjectsGPU(OpenGLContext* /*oglContext*/) {} virtual void releaseBufferObjectsGPU() {} @@ -69,6 +71,7 @@ public: virtual BoundingBox boundingBox() const; virtual bool rayIntersectCreateDetail(const Ray& ray, Vec3d* intersectionPoint, ref* hitDetail) const; + bool rayIntersect(const Ray& ray, const Camera& camera, Vec3d* intersectionPoint); // TO BE REMOVED! virtual void renderFixedFunction(OpenGLContext* oglContext, const MatrixState& matrixState) { renderSoftware(oglContext, matrixState); } @@ -92,6 +95,7 @@ private: bool m_drawBackground; bool m_drawBorder; bool m_checkPosVisible; + bool m_useDepthBuffer; BoundingBox m_boundingBox; // }; diff --git a/VisualizationModules/LibRender/cvfOpenGL.cpp b/VisualizationModules/LibRender/cvfOpenGL.cpp index 3d76136ca0..b021de0ae9 100644 --- a/VisualizationModules/LibRender/cvfOpenGL.cpp +++ b/VisualizationModules/LibRender/cvfOpenGL.cpp @@ -136,7 +136,7 @@ String OpenGL::mapOpenGLErrorToString(cvfGLenum errorCode) //-------------------------------------------------------------------------------------------------- /// Returns false if no error. //-------------------------------------------------------------------------------------------------- -bool OpenGL::testAndReportOpenGLError(OpenGLContext* oglContext, const char* operation, const char* fileName, int line) +bool OpenGL::testAndReportOpenGLError(OpenGLContext* oglContext, const char* operation, const CodeLocation& codeLocation) { // glGetError will end up in an endless loop if no context is current CVF_ASSERT(oglContext); @@ -157,7 +157,7 @@ bool OpenGL::testAndReportOpenGLError(OpenGLContext* oglContext, const char* ope String errCodeStr = mapOpenGLErrorToString(err); String msg = String("Operation: ") + operation; msg += "OGL(" + errCodeStr + "): "; - logger->error(msg, fileName, line); + logger->error(msg, codeLocation); } err = glGetError(); @@ -170,7 +170,7 @@ bool OpenGL::testAndReportOpenGLError(OpenGLContext* oglContext, const char* ope //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void OpenGL::cvf_check_ogl(OpenGLContext* oglContext, const char* fileName, int line) +void OpenGL::cvf_check_ogl(OpenGLContext* oglContext, const CodeLocation& codeLocation) { if (OpenGL::m_enableCheckOgl) { @@ -186,7 +186,7 @@ void OpenGL::cvf_check_ogl(OpenGLContext* oglContext, const char* fileName, int { String errCodeStr = mapOpenGLErrorToString(err); String msg = "OGL(" + errCodeStr + "): "; - logger->error(msg, fileName, line); + logger->error(msg, codeLocation); } err = glGetError(); diff --git a/VisualizationModules/LibRender/cvfOpenGL.h b/VisualizationModules/LibRender/cvfOpenGL.h index a08b3dbd0f..691563dc73 100644 --- a/VisualizationModules/LibRender/cvfOpenGL.h +++ b/VisualizationModules/LibRender/cvfOpenGL.h @@ -84,6 +84,7 @@ #include "cvfOpenGLTypes.h" #include "cvfString.h" +#include "cvfCodeLocation.h" // As long as we're using GLEW we will almost always need the context and context group when doing OpenGL calls #include "cvfOpenGLContext.h" @@ -105,9 +106,9 @@ public: static void clearOpenGLError(OpenGLContext* oglContext); static String mapOpenGLErrorToString(cvfGLenum errorCode); - static bool testAndReportOpenGLError(OpenGLContext* oglContext, const char* operation, const char* fileName, int line); + static bool testAndReportOpenGLError(OpenGLContext* oglContext, const char* operation, const CodeLocation& codeLocation); - static void cvf_check_ogl(OpenGLContext* oglContext, const char* fileName, int line); + static void cvf_check_ogl(OpenGLContext* oglContext, const CodeLocation& codeLocation); static void enableCheckOgl(bool enable); static bool isCheckOglEnabled(); @@ -123,8 +124,8 @@ private: #define CVF_OGL_BUFFER_OFFSET(BYTE_OFFSET) ((char*)NULL + (BYTE_OFFSET)) // Define used to log error messages with file and line -#define CVF_CHECK_OGL(OGL_CTX_PTR) cvf::OpenGL::cvf_check_ogl(OGL_CTX_PTR, __FILE__, __LINE__) +#define CVF_CHECK_OGL(OGL_CTX_PTR) cvf::OpenGL::cvf_check_ogl(OGL_CTX_PTR, CVF_CODE_LOCATION) #define CVF_CLEAR_OGL_ERROR(OGL_CTX_PTR) cvf::OpenGL::clearOpenGLError(OGL_CTX_PTR) -#define CVF_TEST_AND_REPORT_OPENGL_ERROR(OGL_CTX_PTR, OPERATION) cvf::OpenGL::testAndReportOpenGLError(OGL_CTX_PTR, OPERATION, __FILE__, __LINE__) +#define CVF_TEST_AND_REPORT_OPENGL_ERROR(OGL_CTX_PTR, OPERATION) cvf::OpenGL::testAndReportOpenGLError(OGL_CTX_PTR, OPERATION, CVF_CODE_LOCATION) diff --git a/VisualizationModules/LibRender/cvfOpenGLContext.h b/VisualizationModules/LibRender/cvfOpenGLContext.h index 32f0520207..2ae21727d9 100644 --- a/VisualizationModules/LibRender/cvfOpenGLContext.h +++ b/VisualizationModules/LibRender/cvfOpenGLContext.h @@ -58,9 +58,9 @@ private: friend class OpenGLContextGroup; }; -#define CVF_LOG_RENDER_ERROR(OGL_CTX_PTR, THE_MESSAGE) OGL_CTX_PTR->group()->logger()->error((THE_MESSAGE), __FILE__, __LINE__ ) +#define CVF_LOG_RENDER_ERROR(OGL_CTX_PTR, THE_MESSAGE) OGL_CTX_PTR->group()->logger()->error((THE_MESSAGE), CVF_CODE_LOCATION) -#define CVF_LOG_RENDER_DEBUG(OGL_CTX_PTR, THE_MESSAGE) OGL_CTX_PTR->group()->logger()->debug((THE_MESSAGE), __FILE__, __LINE__ ) +#define CVF_LOG_RENDER_DEBUG(OGL_CTX_PTR, THE_MESSAGE) OGL_CTX_PTR->group()->logger()->debug((THE_MESSAGE), CVF_CODE_LOCATION) #define CVF_SHOULD_LOG_RENDER_DEBUG(OGL_CTX_PTR) OGL_CTX_PTR->group()->logger()->isDebugEnabled() diff --git a/VisualizationModules/LibRender/cvfOpenGLContextGroup.cpp b/VisualizationModules/LibRender/cvfOpenGLContextGroup.cpp index ad6e99c802..abf299e7b2 100644 --- a/VisualizationModules/LibRender/cvfOpenGLContextGroup.cpp +++ b/VisualizationModules/LibRender/cvfOpenGLContextGroup.cpp @@ -23,7 +23,7 @@ #include "cvfOpenGLContext.h" #include "cvfOpenGLResourceManager.h" #include "cvfOpenGLCapabilities.h" -#include "cvfTrace.h" +#include "cvfLogDestinationConsole.h" #include @@ -58,7 +58,7 @@ OpenGLContextGroup::OpenGLContextGroup() m_wglewContextStruct(NULL) { m_resourceManager = new OpenGLResourceManager; - m_logger = new Logger; + m_logger = new Logger("cvf.OpenGL", Logger::LL_WARNING, new LogDestinationConsole); m_capabilities = new OpenGLCapabilities; } diff --git a/VisualizationModules/LibRender/cvfOverlayImage.cpp b/VisualizationModules/LibRender/cvfOverlayImage.cpp index 0bb7443fc8..bd2b578c52 100644 --- a/VisualizationModules/LibRender/cvfOverlayImage.cpp +++ b/VisualizationModules/LibRender/cvfOverlayImage.cpp @@ -40,6 +40,7 @@ #ifndef CVF_OPENGL_ES #include "cvfRenderState_FF.h" #endif +#include "cvfTexture2D_FF.h" namespace cvf { @@ -164,6 +165,19 @@ void OverlayImage::render(OpenGLContext* oglContext, const Vec2i& position, cons RenderStateLighting_FF light(false); light.applyOpenGL(oglContext); + + // Use fixed function texture setup + ref texture = new Texture2D_FF(m_image.p()); + texture->setWrapMode(Texture2D_FF::CLAMP); + texture->setMinFilter(Texture2D_FF::NEAREST); + texture->setMagFilter(Texture2D_FF::NEAREST); + texture->setupTexture(oglContext); + texture->setupTextureParams(oglContext); + + ref textureMapping = new RenderStateTextureMapping_FF(texture.p()); + textureMapping->setTextureFunction(m_blendMode == TEXTURE_ALPHA ? RenderStateTextureMapping_FF::MODULATE : RenderStateTextureMapping_FF::DECAL); + + m_textureBindings = textureMapping; #endif projCam.applyOpenGL(); } @@ -200,6 +214,18 @@ void OverlayImage::render(OpenGLContext* oglContext, const Vec2i& position, cons m_shaderProgram->clearUniformApplyTracking(); m_shaderProgram->applyFixedUniforms(oglContext, projMatrixState); } + + if (m_texture->textureOglId() == 0) + { + m_texture->setupTexture(oglContext); + } + + if (m_textureBindings.isNull()) + { + cvf::RenderStateTextureBindings* textureBindings = new cvf::RenderStateTextureBindings; + textureBindings->addBinding(m_texture.p(), m_sampler.p(), "u_texture2D"); + m_textureBindings = textureBindings; + } } Vec3f min(1.0f, 1.0f, 0.0f); @@ -214,12 +240,6 @@ void OverlayImage::render(OpenGLContext* oglContext, const Vec2i& position, cons v2[0] = max.x(); v2[1] = min.y(); v2[2] = 0.0f; v3[0] = max.x(); v3[1] = max.y(); v3[2] = 0.0f; v4[0] = min.x(); v4[1] = max.y(); v4[2] = 0.0f; - - - if (m_texture->textureOglId() == 0) - { - m_texture->setupTexture(oglContext); - } if (m_blendMode != NO_BLENDING) { @@ -233,7 +253,7 @@ void OverlayImage::render(OpenGLContext* oglContext, const Vec2i& position, cons if (software) { #ifndef CVF_OPENGL_ES - glColor4f(1.0f, 1.0f, 1.0f, m_alpha); + glColor4f(1.0f, 1.0f, 1.0f, m_blendMode == GLOBAL_ALPHA ? m_alpha : 1.0f); glBegin(GL_TRIANGLE_FAN); glTexCoord2f(textureCoords[0], textureCoords[1]); glVertex3fv(v1); @@ -263,6 +283,17 @@ void OverlayImage::render(OpenGLContext* oglContext, const Vec2i& position, cons blend.applyOpenGL(oglContext); } + RenderStateDepth resetDepth; + resetDepth.applyOpenGL(oglContext); + + if (software) + { +#ifndef CVF_OPENGL_ES + RenderStateTextureMapping_FF resetTextureMapping; + resetTextureMapping.applyOpenGL(oglContext); +#endif + } + if (!software) { glDisableVertexAttribArray(ShaderProgram::VERTEX); @@ -280,8 +311,7 @@ void OverlayImage::setImage(TextureImage* image) m_texture = new Texture(image); - m_textureBindings = new cvf::RenderStateTextureBindings; - m_textureBindings->addBinding(m_texture.p(), m_sampler.p(), "u_texture2D"); + m_textureBindings = NULL; } diff --git a/VisualizationModules/LibRender/cvfOverlayImage.h b/VisualizationModules/LibRender/cvfOverlayImage.h index 8a68e5274f..76d96c9dab 100644 --- a/VisualizationModules/LibRender/cvfOverlayImage.h +++ b/VisualizationModules/LibRender/cvfOverlayImage.h @@ -25,7 +25,7 @@ namespace cvf { class TextureImage; class Sampler; -class RenderStateTextureBindings; +class RenderState; class Texture; class ShaderProgram; @@ -69,7 +69,7 @@ private: Vec2ui m_size; ref m_image; ref m_sampler; - ref m_textureBindings; + ref m_textureBindings; ref m_texture; ref m_shaderProgram; diff --git a/VisualizationModules/LibRender/cvfOverlayNavigationCube.cpp b/VisualizationModules/LibRender/cvfOverlayNavigationCube.cpp index 8a0c6d9d2a..5a75015354 100644 --- a/VisualizationModules/LibRender/cvfOverlayNavigationCube.cpp +++ b/VisualizationModules/LibRender/cvfOverlayNavigationCube.cpp @@ -40,9 +40,15 @@ #include "cvfPrimitiveSetIndexedUShort.h" #include "cvfShaderProgramGenerator.h" #include "cvfShaderSourceProvider.h" +#include "cvfRay.h" +#include "cvfRenderStateDepth.h" +#include "cvfTexture.h" +#include "cvfSampler.h" +#include "cvfRenderStateTextureBindings.h" #ifndef CVF_OPENGL_ES #include "cvfRenderState_FF.h" +#include "cvfTexture2D_FF.h" #endif @@ -63,12 +69,22 @@ namespace cvf { //-------------------------------------------------------------------------------------------------- OverlayNavigationCube::OverlayNavigationCube(Camera* camera, Font* font) : m_camera(camera), - m_xLabel("ax"), - m_yLabel("by"), - m_zLabel("cz"), - m_textColor(Color3::BLACK), m_font(font), - m_size(120, 120) + m_xLabel("x"), + m_yLabel("y"), + m_zLabel("z"), + m_textColor(Color3::BLACK), + m_size(120, 120), + m_homeViewDirection(-Vec3f::Z_AXIS), + m_homeUp(Vec3f::Y_AXIS), + m_hightlightItem(NCI_NONE), + m_upVector(Vec3d::Z_AXIS), + m_frontVector(-Vec3d::Y_AXIS), + m_xFaceColor(Color3::RED), + m_yFaceColor(Color3::GREEN), + m_zFaceColor(Color3::BLUE), + m_itemHighlightColor(Color3::GRAY), + m_2dItemsColor(Color3::WHITE) { } @@ -78,14 +94,13 @@ OverlayNavigationCube::OverlayNavigationCube(Camera* camera, Font* font) //-------------------------------------------------------------------------------------------------- OverlayNavigationCube::~OverlayNavigationCube() { - // Empty destructor to avoid errors with undefined types when cvf::ref's destructor gets called } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void OverlayNavigationCube::setAxisLabels( const String& xLabel, const String& yLabel, const String& zLabel ) +void OverlayNavigationCube::setAxisLabels(const String& xLabel, const String& yLabel, const String& zLabel) { // Clipping of axis label text is depends on m_size and // z-part of axisMatrix.setTranslation(Vec3d(0, 0, -4.4)) defined in OverlayNavigationCube::render() @@ -147,8 +162,7 @@ void OverlayNavigationCube::setSize(const Vec2ui& size) //-------------------------------------------------------------------------------------------------- void OverlayNavigationCube::render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) { - Mat4d viewMatrix = m_camera->viewMatrix(); - render(oglContext, position, size, false, viewMatrix); + render(oglContext, position, size, false); } @@ -157,21 +171,25 @@ void OverlayNavigationCube::render(OpenGLContext* oglContext, const Vec2i& posit //-------------------------------------------------------------------------------------------------- void OverlayNavigationCube::renderSoftware(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) { - Mat4d viewMatrix = m_camera->viewMatrix(); - render(oglContext, position, size, true, viewMatrix); + render(oglContext, position, size, true); } //-------------------------------------------------------------------------------------------------- /// Set up camera/viewport and render //-------------------------------------------------------------------------------------------------- -void OverlayNavigationCube::render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size, bool software, const Mat4d& viewMatrix) +void OverlayNavigationCube::render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size, bool software) { if (size.x() <= 0 || size.y() <= 0) { return; } + if (software && ShaderProgram::supportedOpenGL(oglContext)) + { + ShaderProgram::useNoProgram(oglContext); + } + if (m_axis.isNull()) { createAxisGeometry(software); @@ -181,22 +199,42 @@ void OverlayNavigationCube::render(OpenGLContext* oglContext, const Vec2i& posit { createCubeGeos(); - // Create the shader for the cube geometry - ShaderProgramGenerator gen("CubeGeoShader", ShaderSourceProvider::instance()); - gen.configureStandardHeadlightColor(); - m_cubeGeoShader = gen.generate(); - m_cubeGeoShader->linkProgram(oglContext); + if (!software) + { + // Create the shader for the cube geometry + ShaderProgramGenerator gen("CubeGeoShader", ShaderSourceProvider::instance()); + gen.configureStandardHeadlightColor(); + m_cubeGeoShader = gen.generate(); + m_cubeGeoShader->linkProgram(oglContext); + + { + ShaderProgramGenerator gen("CubeGeoTextureShader", ShaderSourceProvider::instance()); + + gen.addVertexCode(cvf::ShaderSourceRepository::vs_Standard); + gen.addFragmentCode(cvf::ShaderSourceRepository::src_Texture); + gen.addFragmentCode(cvf::ShaderSourceRepository::light_Headlight); + gen.addFragmentCode(cvf::ShaderSourceRepository::fs_Standard); + + m_cubeGeoTextureShader = gen.generate(); + + m_cubeGeoTextureShader->setDefaultUniform(new cvf::UniformFloat("u_specularIntensity", 0.1f)); + m_cubeGeoTextureShader->setDefaultUniform(new cvf::UniformFloat("u_ambientIntensity", 0.2f)); + m_cubeGeoTextureShader->setDefaultUniform(new cvf::UniformFloat("u_emissiveColor", cvf::Vec3f(0.0f, 0.0f, 0.0f))); + m_cubeGeoTextureShader->setDefaultUniform(new cvf::UniformFloat("u_ecLightPosition", cvf::Vec3f(0.5f, 5.0f, 7.0f))); + + m_cubeGeoTextureShader->linkProgram(oglContext); + } + } } - // Position the camera far enough away to make the axis and the text fit within the viewport - Mat4d axisMatrix = viewMatrix; - axisMatrix.setTranslation(Vec3d(0, 0, -2.0)); + if (m_2dGeos.size() == 0) + { + create2dGeos(); + } // Setup camera Camera cam; - cam.setProjectionAsPerspective(40.0, 0.05, 100.0); - cam.setViewMatrix(axisMatrix); - cam.setViewport(position.x(), position.y(), size.x(), size.y()); + configureLocalCamera(&cam, position, size); // Setup viewport cam.viewport()->applyOpenGL(oglContext, Viewport::CLEAR_DEPTH); @@ -204,7 +242,6 @@ void OverlayNavigationCube::render(OpenGLContext* oglContext, const Vec2i& posit // Do the actual rendering - // ----------------------------------------------- MatrixState matrixState(cam); if (software) { @@ -216,8 +253,9 @@ void OverlayNavigationCube::render(OpenGLContext* oglContext, const Vec2i& posit } renderCubeGeos(oglContext, software, matrixState); - renderAxisLabels(oglContext, software, matrixState); + + render2dItems(oglContext, position, size, software); } @@ -275,23 +313,25 @@ void OverlayNavigationCube::createAxisGeometry(bool software) ref vertexArray = new Vec3fArray; vertexArray->resize(3); - vertexArray->set(0, cp[0]); // X axis - vertexArray->set(1, cp[0]); // Y axis - vertexArray->set(2, cp[0]); // Z axis + vertexArray->set(0, cp[0]); // X axis + vertexArray->set(1, cp[0]); // Y axis + vertexArray->set(2, cp[0]); // Z axis // Direction & magnitude of the vectors + float arrowLength = 0.8f; + ref vectorArray = new Vec3fArray; vectorArray->resize(3); - vectorArray->set(0, Vec3f::X_AXIS); // X axis - vectorArray->set(1, Vec3f::Y_AXIS); // Y axis - vectorArray->set(2, Vec3f::Z_AXIS); // Z axis + vectorArray->set(0, arrowLength*Vec3f::X_AXIS); + vectorArray->set(1, arrowLength*Vec3f::Y_AXIS); + vectorArray->set(2, arrowLength*Vec3f::Z_AXIS); // Create the arrow glyph for the vector drawer GeometryBuilderTriangles arrowBuilder; ArrowGenerator gen; - gen.setShaftRelativeRadius(0.045f); - gen.setHeadRelativeRadius(0.12f); - gen.setHeadRelativeLength(0.2f); + gen.setShaftRelativeRadius(0.020f); + gen.setHeadRelativeRadius(0.05f); + gen.setHeadRelativeLength(0.1f); gen.setNumSlices(30); gen.generate(&arrowBuilder); @@ -310,6 +350,61 @@ void OverlayNavigationCube::createAxisGeometry(bool software) } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void OverlayNavigationCube::updateTextureBindings(OpenGLContext* oglContext, bool software) +{ + m_faceTextureBindings.clear(); + + for (size_t i = 0; i < 6; i++) + { + NavCubeFace face = static_cast(i); + std::map >::iterator it = m_faceTextures.find(face); + + if (it != m_faceTextures.end()) + { + if (software) + { +#ifndef CVF_OPENGL_ES + // Use fixed function texture setup + ref texture = new Texture2D_FF(it->second.p()); + texture->setWrapMode(Texture2D_FF::CLAMP); + texture->setMinFilter(Texture2D_FF::NEAREST); + texture->setMagFilter(Texture2D_FF::NEAREST); + texture->setupTexture(oglContext); + texture->setupTextureParams(oglContext); + + ref textureMapping = new RenderStateTextureMapping_FF(texture.p()); + textureMapping->setTextureFunction(RenderStateTextureMapping_FF::MODULATE); + + m_faceTextureBindings[face] = textureMapping; +#else + CVF_FAIL_MSG("Not supported on OpenGL ES"); +#endif + + } + else + { + ref texture = new cvf::Texture(it->second.p()); + ref sampler = new cvf::Sampler; + texture->enableMipmapGeneration(true); + sampler->setWrapMode(Sampler::CLAMP_TO_EDGE); + sampler->setMinFilter(Sampler::LINEAR_MIPMAP_LINEAR); + sampler->setMagFilter(Sampler::NEAREST); + + ref texBind = new cvf::RenderStateTextureBindings; + texBind->addBinding(texture.p(), sampler.p(), "u_texture2D"); + + texBind->setupTextures(oglContext); + + m_faceTextureBindings[face] = texBind; + } + } + } +} + + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -317,10 +412,312 @@ void OverlayNavigationCube::renderCubeGeos(OpenGLContext* oglContext, bool softw { CVF_UNUSED(software); - for (size_t i = 0; i < m_cubeGeos.size(); ++i) + if (m_faceTextureBindings.size() != m_faceTextures.size()) { - m_cubeGeos[i]->render(oglContext, m_cubeGeoShader.p(), matrixState); + updateTextureBindings(oglContext, software); } + + if (software) + { +#ifndef CVF_OPENGL_ES + RenderStateMaterial_FF mat; + mat.enableColorMaterial(true); + mat.applyOpenGL(oglContext); + + RenderStateLighting_FF light; + light.applyOpenGL(oglContext); +#endif + } + + for (size_t i = 0; i < 6; i++) + { + NavCubeFace face = static_cast(i); + + std::map >::iterator it = m_faceTextures.find(m_cubeGeoFace[i]); + ShaderProgram* shader = NULL; + bool hasTexture = it != m_faceTextures.end(); + + if (hasTexture) + { + RenderState* textureBinding = m_faceTextureBindings[face].p(); + CVF_ASSERT(textureBinding); + textureBinding->applyOpenGL(oglContext); + } + + if (!software) + { + shader = hasTexture ? m_cubeGeoTextureShader.p() : m_cubeGeoShader.p(); + + if (shader->useProgram(oglContext)) + { + shader->applyFixedUniforms(oglContext, matrixState); + } + } + + Color3f faceColor; + switch (face) + { + case NCF_X_POS: + case NCF_X_NEG: faceColor = m_xFaceColor; break; + case NCF_Y_POS: + case NCF_Y_NEG: faceColor = m_yFaceColor; break; + case NCF_Z_POS: + case NCF_Z_NEG: faceColor = m_zFaceColor; break; + } + + for (size_t i = 0; i < m_cubeGeos.size(); ++i) + { + if (m_cubeGeoFace[i] == face) + { + Color3f renderFaceColor = faceColor; + cvf::Vec3f emissiveColor = cvf::Vec3f(0.0f, 0.0f, 0.0f); + + if (m_cubeItemType[i] == m_hightlightItem) + { + renderFaceColor = m_itemHighlightColor; + emissiveColor = cvf::Vec3f(-0.25f, -0.25f, -0.25f); + } + + if (software) + { + if (hasTexture) + { + glColor3f(1.0f, 1.0f, 1.0f); + } + else + { + glColor3fv(renderFaceColor.ptr()); + } + + m_cubeGeos[i]->renderImmediateMode(oglContext, matrixState); + } + else + { + if (hasTexture) + { + UniformFloat uniform("u_emissiveColor", emissiveColor); + shader->applyUniform(oglContext, uniform); + } + else + { + UniformFloat uniform("u_color", Color4f(renderFaceColor)); + shader->applyUniform(oglContext, uniform); + } + + m_cubeGeos[i]->render(oglContext, m_cubeGeoShader.p(), matrixState); + } + } + } + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void OverlayNavigationCube::render2dItems(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size, bool software) +{ + Camera cam; + cam.setViewport(position.x(), position.y(), size.x(), size.y()); + cam.setProjectionAsUnitOrtho(); + + // Setup viewport + cam.viewport()->applyOpenGL(oglContext, Viewport::CLEAR_DEPTH); + cam.applyOpenGL(); + + RenderStateDepth depth(false); + depth.applyOpenGL(oglContext); + + MatrixState matrixState(cam); + + if (software) + { +#ifdef CVF_OPENGL_ES + CVF_FAIL_MSG("Not supported on OpenGL ES"); +#else + RenderStateLighting_FF light(false); + light.applyOpenGL(oglContext); + glColor3fv(m_hightlightItem == NCI_HOME ? m_itemHighlightColor.ptr() : m_2dItemsColor.ptr()); + + m_homeGeo->renderImmediateMode(oglContext, matrixState); +#endif + } + else + { + if (m_cubeGeoShader->useProgram(oglContext)) + { + m_cubeGeoShader->applyFixedUniforms(oglContext, matrixState); + } + + UniformFloat colorUniform("u_color", Color4f(m_hightlightItem == NCI_HOME ? m_itemHighlightColor : m_2dItemsColor)); + m_cubeGeoShader->applyUniform(oglContext, colorUniform); + m_homeGeo->render(oglContext, m_cubeGeoShader.p(), matrixState); + } + + if (isFaceAlignedViewPoint()) + { + for (size_t i = 0; i < m_2dGeos.size(); ++i) + { + Color3f renderFaceColor = Color3f(1,1,1); + + if (m_2dItemType[i] == m_hightlightItem) + { + renderFaceColor = m_itemHighlightColor; + } + + if (software) + { + glColor3fv(renderFaceColor.ptr()); + m_2dGeos[i]->renderImmediateMode(oglContext, matrixState); + } + else + { + UniformFloat colorUniform("u_color", Color4f(renderFaceColor)); + m_cubeGeoShader->applyUniform(oglContext, colorUniform); + + m_2dGeos[i]->render(oglContext, m_cubeGeoShader.p(), matrixState); + } + } + } + + RenderStateDepth resetDepth; + resetDepth.applyOpenGL(oglContext); + + if (software) + { +#ifdef CVF_OPENGL_ES + CVF_FAIL_MSG("Not supported on OpenGL ES"); +#else + RenderStateLighting_FF resetLight; + resetLight.applyOpenGL(oglContext); +#endif + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void OverlayNavigationCube::create2dGeos() +{ + // "Home" aka. House geometry + { + m_homeGeo = new DrawableGeo; + + ref vertexArray = new Vec3fArray(12); + vertexArray->set(0, Vec3f(-0.97f, 0.86f, 0.0f)); + vertexArray->set(1, Vec3f(-0.68f, 0.86f, 0.0f)); + vertexArray->set(2, Vec3f(-0.825f, 1.0f, 0.0f)); + vertexArray->set(3, Vec3f(-0.825f, 1.0f, 0.0f)); + + vertexArray->set(4, Vec3f(-0.9f, 0.76f, 0.0f)); + vertexArray->set(5, Vec3f(-0.75f, 0.76f, 0.0f)); + vertexArray->set(6, Vec3f(-0.75f, 0.86f, 0.0f)); + vertexArray->set(7, Vec3f(-0.9f, 0.86f, 0.0f)); + + vertexArray->set(8, Vec3f(-0.77f, 0.86f, 0.0f)); + vertexArray->set(9, Vec3f(-0.75f, 0.86f, 0.0f)); + vertexArray->set(10, Vec3f(-0.75f, 1.0f, 0.0f)); + vertexArray->set(11, Vec3f(-0.77f, 1.0f, 0.0f)); + + for (size_t i = 0; i < vertexArray->size(); ++i) + { + Vec3f v = vertexArray->get(i); + v.x() = 0.5f + v.x()/2.0f; + v.y() = 0.5f + v.y()/2.0f; + vertexArray->set(i, v); + } + + m_homeGeo->setVertexArray(vertexArray.p()); + + ref indices = new cvf::UShortArray(18); + indices->set(0, 0); indices->set(1, 1); indices->set(2, 2); + indices->set(3, 0); indices->set(4, 2); indices->set(5, 3); + + indices->set(6, 4); indices->set(7, 5); indices->set(8, 6); + indices->set(9, 4); indices->set(10, 6); indices->set(11, 7); + + indices->set(12, 8); indices->set(13, 9); indices->set(14, 10); + indices->set(15, 8); indices->set(16, 10); indices->set(17, 11); + + ref primSet = new cvf::PrimitiveSetIndexedUShort(cvf::PT_TRIANGLES); + primSet->setIndices(indices.p()); + m_homeGeo->addPrimitiveSet(primSet.p()); + m_homeGeo->computeNormals(); + } + + m_2dGeos.push_back(create2dArrow(Vec3f(-0.7f, 0,0), Vec3f(-0.9f, 0,0)).p()); m_2dItemType.push_back(NCI_ARROW_LEFT); + m_2dGeos.push_back(create2dArrow(Vec3f(0.7f, 0,0), Vec3f(0.9f, 0,0)).p()); m_2dItemType.push_back(NCI_ARROW_RIGHT); + m_2dGeos.push_back(create2dArrow(Vec3f(0, -0.7f,0), Vec3f(0, -0.9f,0)).p()); m_2dItemType.push_back(NCI_ARROW_BOTTOM); + m_2dGeos.push_back(create2dArrow(Vec3f(0, 0.7f,0), Vec3f(0, 0.9f,0)).p()); m_2dItemType.push_back(NCI_ARROW_TOP); + + // Rotate arrows + m_2dGeos.push_back(create2dArrow(Vec3f(0.75f, 0.65f, 0.0f), Vec3f(0.87f,0.49f, 0.0f)).p()); m_2dItemType.push_back(NCI_ROTATE_CW); + m_2dGeos.push_back(create2dArrow(Vec3f(0.71f, 0.70f, 0.0f), Vec3f(0.59f,0.86f, 0.0f)).p()); m_2dItemType.push_back(NCI_ROTATE_CCW); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +ref OverlayNavigationCube::create2dArrow(const Vec3f& start, const Vec3f& end) +{ + float fWidth = 0.042f; + float fArrowWidth = 0.12f; + float fBaseRelLength = 0.50f; + float fLength = (end - start).length(); + + Vec3f vUp = Vec3f(0,0,1); + Vec3f vDir = (end - start); + Vec3f vRight = vUp^vDir; + vDir.normalize(); + vRight.normalize(); + + Vec3f vBaseBL = start + vDir*fLength*fBaseRelLength + vRight*fWidth; + Vec3f vBaseBR = start + vRight*fWidth; + Vec3f vBaseTL = start + vDir*fLength*fBaseRelLength - vRight*fWidth; + Vec3f vBaseTR = start - vRight*fWidth; + + Vec3f vArrowB = start + vDir*fLength*fBaseRelLength + vRight*fArrowWidth; + Vec3f vArrowT = start + vDir*fLength*fBaseRelLength - vRight*fArrowWidth; + + ref geo = new DrawableGeo; + + ref vertexArray = new Vec3fArray(7); + + vertexArray->set(0, vBaseBL); + vertexArray->set(1, vBaseBR); + vertexArray->set(2, vBaseTR); + vertexArray->set(3, vBaseTL); + + vertexArray->set(4, vArrowT); + vertexArray->set(5, end); + vertexArray->set(6, vArrowB); + + for (size_t i = 0; i < vertexArray->size(); ++i) + { + Vec3f v = vertexArray->get(i); + v.x() = 0.5f + v.x()/2.0f; + v.y() = 0.5f + v.y()/2.0f; + vertexArray->set(i, v); + } + + geo->setVertexArray(vertexArray.p()); + + ref indices = new cvf::UShortArray(9); + indices->set(0, 0); indices->set(1, 1); indices->set(2, 2); + indices->set(3, 0); indices->set(4, 2); indices->set(5, 3); + indices->set(6, 4); indices->set(7, 5); indices->set(8, 6); + + ref primSet = new cvf::PrimitiveSetIndexedUShort(cvf::PT_TRIANGLES); + primSet->setIndices(indices.p()); + geo->addPrimitiveSet(primSet.p()); + geo->computeNormals(); + + m_2dGeos.push_back(geo.p()); + m_2dItemType.push_back(NCI_HOME); + + return geo; } @@ -329,14 +726,22 @@ void OverlayNavigationCube::renderCubeGeos(OpenGLContext* oglContext, bool softw //-------------------------------------------------------------------------------------------------- void OverlayNavigationCube::renderAxisLabels(OpenGLContext* oglContext, bool software, const MatrixState& matrixState) { + if (m_xLabel.isEmpty() && m_yLabel.isEmpty() && m_zLabel.isEmpty()) + { + return; + } + + float fBoxLength = 0.65f; + // Multiply with 1.08 will slightly pull the labels away from the corresponding arrow head - Vec3f xPos(1.08f, 0, 0); - Vec3f yPos(0, 1.08f, 0); - Vec3f zPos(0, 0, 1.08f); + Vec3f xPos(0.5f, -fBoxLength/2.0f, -fBoxLength/2.0f); + Vec3f yPos(-fBoxLength/2.0f, 0.5f, -fBoxLength/2.0f); + Vec3f zPos(-fBoxLength/2.0f, -fBoxLength/2.0f, 0.5f); DrawableText drawableText; drawableText.setFont(m_font.p()); drawableText.setCheckPosVisible(false); + drawableText.setUseDepthBuffer(true); drawableText.setDrawBorder(false); drawableText.setDrawBackground(false); drawableText.setVerticalAlignment(TextDrawer::CENTER); @@ -346,7 +751,6 @@ void OverlayNavigationCube::renderAxisLabels(OpenGLContext* oglContext, bool sof if (!m_yLabel.isEmpty()) drawableText.addText(m_yLabel, yPos); if (!m_zLabel.isEmpty()) drawableText.addText(m_zLabel, zPos); - // Do the actual rendering // ----------------------------------------------- if (software) @@ -415,14 +819,14 @@ void OverlayNavigationCube::createCubeGeos() m_cubeGeos.clear(); - createCubeFaceGeos(NCF_Y_NEG, cp[0], cp[1], cp[5], cp[4]);//, m_yNegAxisName, m_yFaceColor, m_textureNegYAxis.p()); // Front - createCubeFaceGeos(NCF_Y_POS, cp[2], cp[3], cp[7], cp[6]);//, m_yPosAxisName, m_yFaceColor, m_texturePosYAxis.p()); // Back + createCubeFaceGeos(NCF_Y_NEG, cp[0], cp[1], cp[5], cp[4]); + createCubeFaceGeos(NCF_Y_POS, cp[2], cp[3], cp[7], cp[6]); - createCubeFaceGeos(NCF_Z_POS, cp[4], cp[5], cp[6], cp[7]);//, m_zPosAxisName, m_zFaceColor, m_texturePosZAxis.p()); // Top - createCubeFaceGeos(NCF_Z_NEG, cp[3], cp[2], cp[1], cp[0]);//, m_zNegAxisName, m_zFaceColor, m_textureNegZAxis.p()); // Bottom + createCubeFaceGeos(NCF_Z_POS, cp[4], cp[5], cp[6], cp[7]); + createCubeFaceGeos(NCF_Z_NEG, cp[3], cp[2], cp[1], cp[0]); - createCubeFaceGeos(NCF_X_NEG, cp[3], cp[0], cp[4], cp[7]);//, m_xNegAxisName, m_xFaceColor, m_textureNegXAxis.p()); // left - createCubeFaceGeos(NCF_X_POS, cp[1], cp[2], cp[6], cp[5]);//, m_xPosAxisName, m_xFaceColor, m_texturePosXAxis.p()); // Right + createCubeFaceGeos(NCF_X_NEG, cp[3], cp[0], cp[4], cp[7]); + createCubeFaceGeos(NCF_X_POS, cp[1], cp[2], cp[6], cp[5]); } @@ -440,71 +844,82 @@ void OverlayNavigationCube::createCubeGeos() /// |---|----------|---| /// 1 2 //-------------------------------------------------------------------------------------------------- -void OverlayNavigationCube::createCubeFaceGeos(NavCubeFace face, Vec3f p1, Vec3f p2, Vec3f p3, Vec3f p4)//, const String& name, const Color3f& baseColor, TextureImage* texture) +void OverlayNavigationCube::createCubeFaceGeos(NavCubeFace face, Vec3f p1, Vec3f p2, Vec3f p3, Vec3f p4) { - // Get the orientation vectors for the face -// Vec3f vNormal, vUp, vRight; -// faceOrientation(face, &vNormal, &vUp, &vRight); + Vec2f t1(0,0); + Vec2f t2(1,0); + Vec2f t3(1,1); + Vec2f t4(0,1); float fCornerFactor = 0.175f; - Vec3f p12 = p1 + (p2 - p1)*fCornerFactor; - Vec3f p14 = p1 + (p4 - p1)*fCornerFactor; - Vec3f pi1 = p1 + (p12 - p1) + (p14 - p1); + float fOneMinusCF = 1.0f - fCornerFactor; + Vec3f p12 = p1 + (p2 - p1)*fCornerFactor; Vec2f t12(fCornerFactor, 0); + Vec3f p14 = p1 + (p4 - p1)*fCornerFactor; Vec2f t14(0, fCornerFactor); + Vec3f pi1 = p1 + (p12 - p1) + (p14 - p1); Vec2f ti1(fCornerFactor, fCornerFactor); - Vec3f p21 = p2 + (p1 - p2)*fCornerFactor; - Vec3f p23 = p2 + (p3 - p2)*fCornerFactor; - Vec3f pi2 = p2 + (p21 - p2) + (p23 - p2); + Vec3f p21 = p2 + (p1 - p2)*fCornerFactor; Vec2f t21(fOneMinusCF, 0); + Vec3f p23 = p2 + (p3 - p2)*fCornerFactor; Vec2f t23(1.0, fCornerFactor); + Vec3f pi2 = p2 + (p21 - p2) + (p23 - p2); Vec2f ti2(fOneMinusCF, fCornerFactor); - Vec3f p32 = p3 + (p2 - p3)*fCornerFactor; - Vec3f p34 = p3 + (p4 - p3)*fCornerFactor; - Vec3f pi3 = p3 + (p32 - p3) + (p34 - p3); + Vec3f p32 = p3 + (p2 - p3)*fCornerFactor; Vec2f t32(1.0, fOneMinusCF); + Vec3f p34 = p3 + (p4 - p3)*fCornerFactor; Vec2f t34(fOneMinusCF, 1.0); + Vec3f pi3 = p3 + (p32 - p3) + (p34 - p3); Vec2f ti3(fOneMinusCF, fOneMinusCF); - Vec3f p41 = p4 + (p1 - p4)*fCornerFactor; - Vec3f p43 = p4 + (p3 - p4)*fCornerFactor; - Vec3f pi4 = p4 + (p41 - p4) + (p43 - p4); + Vec3f p41 = p4 + (p1 - p4)*fCornerFactor; Vec2f t41(0, fOneMinusCF); + Vec3f p43 = p4 + (p3 - p4)*fCornerFactor; Vec2f t43(fCornerFactor, 1.0); + Vec3f pi4 = p4 + (p41 - p4) + (p43 - p4); Vec2f ti4(fCornerFactor, fOneMinusCF); // Bottom left m_cubeItemType.push_back(navCubeItem(face, NCFI_BOTTOM_LEFT)); - m_cubeGeos.push_back(createQuadGeo(p1, p12, pi1, p14).p()); + m_cubeGeoFace.push_back(face); + m_cubeGeos.push_back(createQuadGeo(p1, p12, pi1, p14, t1, t12, ti1, t14).p()); // Bottom right m_cubeItemType.push_back(navCubeItem(face, NCFI_BOTTOM_RIGHT)); - m_cubeGeos.push_back(createQuadGeo(p2, p23, pi2, p21).p()); + m_cubeGeoFace.push_back(face); + m_cubeGeos.push_back(createQuadGeo(p2, p23, pi2, p21, t2, t23, ti2, t21).p()); // Top right m_cubeItemType.push_back(navCubeItem(face, NCFI_TOP_RIGHT)); - m_cubeGeos.push_back(createQuadGeo(p3, p34, pi3, p32).p()); + m_cubeGeoFace.push_back(face); + m_cubeGeos.push_back(createQuadGeo(p3, p34, pi3, p32, t3, t34, ti3, t32).p()); // Top left m_cubeItemType.push_back(navCubeItem(face, NCFI_TOP_LEFT)); - m_cubeGeos.push_back(createQuadGeo(p4, p41, pi4, p43).p()); + m_cubeGeoFace.push_back(face); + m_cubeGeos.push_back(createQuadGeo(p4, p41, pi4, p43, t4, t41, ti4, t43).p()); // Bottom m_cubeItemType.push_back(navCubeItem(face, NCFI_BOTTOM)); - m_cubeGeos.push_back(createQuadGeo(p12, p21, pi2, pi1).p()); + m_cubeGeoFace.push_back(face); + m_cubeGeos.push_back(createQuadGeo(p12, p21, pi2, pi1, t12, t21, ti2, ti1).p()); // Top m_cubeItemType.push_back(navCubeItem(face, NCFI_TOP)); - m_cubeGeos.push_back(createQuadGeo(p34, p43, pi4, pi3).p()); + m_cubeGeoFace.push_back(face); + m_cubeGeos.push_back(createQuadGeo(p34, p43, pi4, pi3, t34, t43, ti4, ti3).p()); // Right m_cubeItemType.push_back(navCubeItem(face, NCFI_RIGHT)); - m_cubeGeos.push_back(createQuadGeo(p23, p32, pi3, pi2).p()); + m_cubeGeoFace.push_back(face); + m_cubeGeos.push_back(createQuadGeo(p23, p32, pi3, pi2, t23, t32, ti3, ti2).p()); // Left m_cubeItemType.push_back(navCubeItem(face, NCFI_LEFT)); - m_cubeGeos.push_back(createQuadGeo(p41, p14, pi1, pi4).p()); + m_cubeGeoFace.push_back(face); + m_cubeGeos.push_back(createQuadGeo(p41, p14, pi1, pi4, t41, t14, ti1, ti4).p()); // Inner part m_cubeItemType.push_back(navCubeItem(face, NCFI_CENTER)); - m_cubeGeos.push_back(createQuadGeo(pi1, pi2, pi3, pi4).p()); + m_cubeGeoFace.push_back(face); + m_cubeGeos.push_back(createQuadGeo(pi1, pi2, pi3, pi4, ti1, ti2, ti3, ti4).p()); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -ref OverlayNavigationCube::createQuadGeo(const Vec3f& v1, const Vec3f& v2, const Vec3f& v3, const Vec3f& v4) +ref OverlayNavigationCube::createQuadGeo(const Vec3f& v1, const Vec3f& v2, const Vec3f& v3, const Vec3f& v4, const Vec2f& t1, const Vec2f& t2, const Vec2f& t3, const Vec2f& t4) { ref geo = new DrawableGeo; @@ -514,7 +929,14 @@ ref OverlayNavigationCube::createQuadGeo(const Vec3f& v1, const Vec vertexArray->set(2, v3); vertexArray->set(3, v4); + ref textureCoordArray = new Vec2fArray(4); + textureCoordArray->set(0, t1); + textureCoordArray->set(1, t2); + textureCoordArray->set(2, t3); + textureCoordArray->set(3, t4); + geo->setVertexArray(vertexArray.p()); + geo->setTextureCoordArray(textureCoordArray.p()); ref indices = new cvf::UShortArray(6); indices->set(0, 0); @@ -527,6 +949,7 @@ ref OverlayNavigationCube::createQuadGeo(const Vec3f& v1, const Vec ref primSet = new cvf::PrimitiveSetIndexedUShort(cvf::PT_TRIANGLES); primSet->setIndices(indices.p()); geo->addPrimitiveSet(primSet.p()); + geo->computeNormals(); return geo; } @@ -560,11 +983,9 @@ void OverlayNavigationCube::navCubeCornerPoints(Vec3f points[8]) } -/************************************************************************************************* - *//** - * Convert face + faceItem to VTNavCubeItem - * - *************************************************************************************************/ +//-------------------------------------------------------------------------------------------------- +/// Convert face + faceItem to NavCubeItem +//-------------------------------------------------------------------------------------------------- OverlayNavigationCube::NavCubeItem OverlayNavigationCube::navCubeItem(NavCubeFace face, NavCubeFaceItem faceItem) const { NavCubeItem item = NCI_NONE; @@ -673,12 +1094,6 @@ OverlayNavigationCube::NavCubeItem OverlayNavigationCube::navCubeItem(NavCubeFac } break; } - - case NCF_NONE: - { - CVF_FAIL_MSG("Illegal nav cube face specified"); - break; - } } return item; @@ -688,38 +1103,449 @@ OverlayNavigationCube::NavCubeItem OverlayNavigationCube::navCubeItem(NavCubeFac //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void OverlayNavigationCube::faceOrientation(NavCubeFace face, Vec3f* normal, Vec3f* upVector, Vec3f* rightVector) const +bool OverlayNavigationCube::pick(int winCoordX, int winCoordY, const Vec2i& position, const Vec2ui& size) { - CVF_ASSERT(normal && upVector && rightVector); - - switch (face) - { - case NCF_X_POS: *normal = Vec3f::X_AXIS; break; - case NCF_X_NEG: *normal = -Vec3f::X_AXIS; break; - case NCF_Y_POS: *normal = Vec3f::Y_AXIS; break; - case NCF_Y_NEG: *normal = -Vec3f::Y_AXIS; break; - case NCF_Z_POS: *normal = Vec3f::Z_AXIS; break; - case NCF_Z_NEG: *normal = -Vec3f::Z_AXIS; break; - case NCF_NONE: CVF_FAIL_MSG("Illegal nav cube face"); break; - } - - if ((*normal)*m_upVector == 0.0) - { - if (*normal == m_upVector) *upVector = -m_frontVector; - else *upVector = m_frontVector; - } - else - { - *upVector = m_upVector; - } - - *rightVector = *upVector^*normal; - - normal->normalize(); - upVector->normalize(); - rightVector->normalize(); + return pickItem(winCoordX, winCoordY, position, size) != cvf::UNDEFINED_UINT; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool OverlayNavigationCube::updateHighlight(int winCoordX, int winCoordY, const Vec2i& position, const Vec2ui& size) +{ + // Early out + if (winCoordX < position.x() || winCoordY > (position.x() + static_cast(size.x())) || + winCoordY < position.y() || winCoordY > (position.y() + static_cast(size.y()))) + { + bool redraw = m_hightlightItem != NCI_NONE; + m_hightlightItem = NCI_NONE; + return redraw; + } + + NavCubeItem item2d = pick2dItem(winCoordX, winCoordY, position, size); + if (item2d != NCI_NONE) + { + bool redraw = m_hightlightItem != item2d; + m_hightlightItem = item2d; + return redraw; + } + + size_t itemIndex = pickItem(winCoordX, winCoordY, position, size); + + bool redraw = false; + + if (itemIndex == cvf::UNDEFINED_SIZE_T) + { + if (m_hightlightItem != NCI_NONE) + { + m_hightlightItem = NCI_NONE; + redraw = true; + } + } + else + { + if (m_hightlightItem != m_cubeItemType[itemIndex]) + { + m_hightlightItem = m_cubeItemType[itemIndex]; + redraw = true; + } + } + + return redraw; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool OverlayNavigationCube::processSelection(int winCoordX, int winCoordY, const Vec2i& position, const Vec2ui& size, Vec3d* viewDir, Vec3d* up) +{ + *viewDir = Vec3d::UNDEFINED; + *up = Vec3d::UNDEFINED; + + NavCubeItem faceItem = pick2dItem(winCoordX, winCoordY, position, size); + + if (faceItem == NCI_NONE) + { + size_t minIndex = pickItem(winCoordX, winCoordY, position, size); + + if (minIndex == cvf::UNDEFINED_SIZE_T) + { + return false; + } + + faceItem = m_cubeItemType[minIndex]; + } + + if (faceItem == NCI_NONE) + { + return false; + } + + viewConfigurationFromNavCubeItem(faceItem, viewDir, up); + + return true; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t OverlayNavigationCube::pickItem(int winCoordX, int winCoordY, const Vec2i& position, const Vec2ui& size) +{ + Camera cam; + configureLocalCamera(&cam, position, size); + + ref ray = cam.rayFromWindowCoordinates(winCoordX, winCoordY); + + double minDistSq = cvf::UNDEFINED_DOUBLE_THRESHOLD; + size_t minIndex = cvf::UNDEFINED_SIZE_T; + + for (size_t i = 0; i < m_cubeGeos.size(); ++i) + { + Vec3d intersectionPoint; + ref detail; + if (m_cubeGeos[i]->rayIntersectCreateDetail(*ray, &intersectionPoint, &detail)) + { + double distSq = ray->origin().pointDistanceSquared(intersectionPoint); + + if (distSq < minDistSq) + { + minDistSq = distSq; + minIndex = i; + } + } + } + + return minIndex; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +OverlayNavigationCube::NavCubeItem OverlayNavigationCube::pick2dItem(int winCoordX, int winCoordY, const Vec2i& position, const Vec2ui& size) +{ + Vec2f vpOrigin; + vpOrigin.x() = static_cast(position.x()) + static_cast(size.x())*0.5f; + vpOrigin.y() = static_cast(position.y()) + static_cast(size.y())*0.5f; + + Vec2f relCoord; + relCoord.x() = (static_cast(winCoordX) - vpOrigin.x())/(static_cast(size.x())*0.5f); + relCoord.y() = (static_cast(winCoordY) - vpOrigin.y())/(static_cast(size.y())*0.5f); + + // Check for home + Rectf home(-0.97f, 0.76f, 0.21f, 0.24f); + if (home.contains(relCoord)) return NCI_HOME; + + if (isFaceAlignedViewPoint()) + { + float fEnd = 0.9f; + float fStart = 0.7f; + float fWidth = 0.12f; + + Rectf leftArrow(-fEnd, -fWidth, 0.2f, 2*fWidth); + Rectf rightArrow(fStart, -fWidth, 0.2f, 2*fWidth); + Rectf topArrow(-fWidth, fStart, 2*fWidth, 0.2f); + Rectf bottomArrow(-fWidth, -fEnd, 2*fWidth, 0.2f); + Rectf rotateCW(0.75f, 0.49f, 0.12f, 0.16f); + Rectf rotateCCW(0.59f, 0.70f, 0.12f, 0.16f); + + if (leftArrow.contains(relCoord)) return NCI_ARROW_LEFT; + else if (rightArrow.contains(relCoord)) return NCI_ARROW_RIGHT; + else if (topArrow.contains(relCoord)) return NCI_ARROW_TOP; + else if (bottomArrow.contains(relCoord)) return NCI_ARROW_BOTTOM; + else if (rotateCW.contains(relCoord)) return NCI_ROTATE_CW; + else if (rotateCCW.contains(relCoord)) return NCI_ROTATE_CCW; + } + + return NCI_NONE; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void OverlayNavigationCube::configureLocalCamera(Camera* camera, const Vec2i& position, const Vec2ui& size) +{ + // Position the camera far enough away to make the axis and the text fit within the viewport + Mat4d axisMatrix = m_camera->viewMatrix(); + axisMatrix.setTranslation(Vec3d(0, 0, -2.0)); + + // Setup camera + camera->setProjectionAsPerspective(40.0, 0.05, 100.0); + camera->setViewMatrix(axisMatrix); + camera->setViewport(position.x(), position.y(), size.x(), size.y()); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void OverlayNavigationCube::viewConfigurationFromNavCubeItem(NavCubeItem item, Vec3d* viewDir, Vec3d* up) +{ + // Handle Home and Rotate specially, as they do not fall into the simple "view from" category + if (item == NCI_HOME) + { + *viewDir = m_homeViewDirection; + *up = m_homeUp; + return; + } + else if ((item == NCI_ROTATE_CW) || (item == NCI_ROTATE_CCW)) + { + *viewDir = m_camera->direction(); + *up = m_camera->up(); + + Mat4d mat = Mat4d::fromRotation(*viewDir, Math::toRadians(item == NCI_ROTATE_CW ? -90.0 : 90.0)); + up->transformVector(mat); + + return; + } + + // Determine the view from point based on the VTNavCubeItem + Vec3d viewFrom; + + switch(item) + { + case NCI_ARROW_LEFT: + case NCI_ARROW_RIGHT: + case NCI_ARROW_TOP: + case NCI_ARROW_BOTTOM: + { + Vec3d currentViewDir = m_camera->direction(); + Vec3d currentUp = m_camera->up(); + Vec3d rightVec = currentViewDir^currentUp; + + if (item == NCI_ARROW_LEFT) viewFrom = -rightVec; + else if (item == NCI_ARROW_RIGHT) viewFrom = rightVec; + else if (item == NCI_ARROW_TOP) viewFrom = currentUp; + else if (item == NCI_ARROW_BOTTOM) viewFrom = -currentUp; + break; + } + case NCI_CORNER_XN_YN_ZN: viewFrom = Vec3d(-1, -1, -1); break; + case NCI_CORNER_XP_YN_ZN: viewFrom = Vec3d( 1, -1, -1); break; + case NCI_CORNER_XP_YP_ZN: viewFrom = Vec3d( 1, 1, -1); break; + case NCI_CORNER_XN_YP_ZN: viewFrom = Vec3d(-1, 1, -1); break; + case NCI_CORNER_XN_YN_ZP: viewFrom = Vec3d(-1, -1, 1); break; + case NCI_CORNER_XP_YN_ZP: viewFrom = Vec3d( 1, -1, 1); break; + case NCI_CORNER_XP_YP_ZP: viewFrom = Vec3d( 1, 1, 1); break; + case NCI_CORNER_XN_YP_ZP: viewFrom = Vec3d(-1, 1, 1); break; + case NCI_EDGE_YN_ZN: viewFrom = Vec3d( 0, -1, -1); break; + case NCI_EDGE_XP_ZN: viewFrom = Vec3d( 1, 0, -1); break; + case NCI_EDGE_YP_ZN: viewFrom = Vec3d( 0, 1, -1); break; + case NCI_EDGE_XN_ZN: viewFrom = Vec3d(-1, 0, -1); break; + case NCI_EDGE_YN_ZP: viewFrom = Vec3d( 0, -1, 1); break; + case NCI_EDGE_XP_ZP: viewFrom = Vec3d( 1, 0, 1); break; + case NCI_EDGE_YP_ZP: viewFrom = Vec3d( 0, 1, 1); break; + case NCI_EDGE_XN_ZP: viewFrom = Vec3d(-1, 0, 1); break; + case NCI_EDGE_XN_YN: viewFrom = Vec3d(-1, -1, 0); break; + case NCI_EDGE_XP_YN: viewFrom = Vec3d( 1, -1, 0); break; + case NCI_EDGE_XP_YP: viewFrom = Vec3d( 1, 1, 0); break; + case NCI_EDGE_XN_YP: viewFrom = Vec3d(-1, 1, 0); break; + case NCI_FACE_X_POS: viewFrom = Vec3d( 1, 0, 0); break; + case NCI_FACE_X_NEG: viewFrom = Vec3d(-1, 0, 0); break; + case NCI_FACE_Y_POS: viewFrom = Vec3d( 0, 1, 0); break; + case NCI_FACE_Y_NEG: viewFrom = Vec3d( 0, -1, 0); break; + case NCI_FACE_Z_POS: viewFrom = Vec3d( 0, 0, 1); break; + case NCI_FACE_Z_NEG: viewFrom = Vec3d( 0, 0, -1); break; + case NCI_NONE: + case NCI_HOME: + case NCI_ROTATE_CW: + case NCI_ROTATE_CCW: + default: CVF_ASSERT(0); break; + } + + *viewDir = Vec3d::ZERO - viewFrom; + + // Find the new up vector + *up = computeNewUpVector(viewFrom, m_camera->up()); +} + + +//-------------------------------------------------------------------------------------------------- +/// Find the new up vector +//-------------------------------------------------------------------------------------------------- +Vec3d OverlayNavigationCube::computeNewUpVector(const Vec3d& viewFrom, const Vec3d currentUp) const +{ + Vec3d upVector = currentUp; + upVector.normalize(); + + // Snap to axis before rotate, give priority to Z axis if equal + upVector = snapToAxis(upVector, &Vec3d::Z_AXIS); + + Vec3d currentUpVectorSnapped = upVector; + Vec3d viewDir = -viewFrom; + + // New approach: + Vec3d currentViewDir = m_camera->direction(); + Vec3d rotAxis; + + if (vectorsParallelFuzzy(currentViewDir, viewDir)) + { + // The current and new dirs are parallel, just use the up vector as it is perpendicular to the view dir + rotAxis = currentUp; + } + else + { + rotAxis = currentViewDir^viewDir; + } + + rotAxis.normalize(); + + // Guard acos against out-of-domain input + const double dotProduct = Math::clamp(currentViewDir*viewDir, -1.0, 1.0); + const double angle = Math::acos(dotProduct); + Mat4d rotMat = Mat4d::fromRotation(rotAxis, angle); + upVector.transformVector(rotMat); + + // Snap to closest axis + if (cvf::Math::abs(upVector*currentUpVectorSnapped) > 0.01) + { + upVector = currentUpVectorSnapped; + } + else + { + upVector = snapToAxis(upVector, ¤tUpVectorSnapped); + } + + if (vectorsParallelFuzzy(upVector, viewDir)) + { + // The found up vector and view dir are parallel, select another axis based on the current up vector + if (vectorsParallelFuzzy(Vec3d::Z_AXIS, viewDir)) + { + if (cvf::Math::abs(currentUp.y()) >= cvf::Math::abs(currentUp.x())) upVector = (currentUp.y() >= 0.0f) ? Vec3d::Y_AXIS : -Vec3d::Y_AXIS; + else upVector = (currentUp.x() >= 0.0f) ? Vec3d::X_AXIS : -Vec3d::X_AXIS; + } + else if (vectorsParallelFuzzy(Vec3d::Y_AXIS, viewDir)) + { + if (cvf::Math::abs(currentUp.x()) >= cvf::Math::abs(currentUp.z())) upVector = (currentUp.x() >= 0.0f) ? Vec3d::X_AXIS : -Vec3d::X_AXIS; + else upVector = (currentUp.z() >= 0.0f) ? Vec3d::Z_AXIS : -Vec3d::Z_AXIS; + } + else + { + if (cvf::Math::abs(currentUp.y()) >= cvf::Math::abs(currentUp.z())) upVector = (currentUp.y() >= 0.0f) ? Vec3d::Y_AXIS : -Vec3d::Y_AXIS; + else upVector = (currentUp.z() >= 0.0f) ? Vec3d::Z_AXIS : -Vec3d::Z_AXIS; + } + } + + return upVector; +} + + +//-------------------------------------------------------------------------------------------------- +/// Static +//-------------------------------------------------------------------------------------------------- +Vec3d OverlayNavigationCube::snapToAxis(const Vec3d& vector, const Vec3d* pPreferIfEqual) +{ + // Snap to closest axis + int closestAxis = findClosestAxis(vector); + + if (pPreferIfEqual) + { + int closestPreferAxis = findClosestAxis(*pPreferIfEqual); + + if (closestAxis != closestPreferAxis) + { + if (cvf::Math::abs(cvf::Math::abs(vector[closestAxis]) - cvf::Math::abs(vector[closestPreferAxis])) < 0.01) + { + closestAxis = closestPreferAxis; + } + } + } + + Vec3d snapVector = vector; + + if (closestAxis == 0) snapVector = vector.x() >= 0.0f ? Vec3d::X_AXIS : -Vec3d::X_AXIS; + if (closestAxis == 1) snapVector = vector.y() >= 0.0f ? Vec3d::Y_AXIS : -Vec3d::Y_AXIS; + if (closestAxis == 2) snapVector = vector.z() >= 0.0f ? Vec3d::Z_AXIS : -Vec3d::Z_AXIS; + + return snapVector; +} + + +//-------------------------------------------------------------------------------------------------- +/// Static +//-------------------------------------------------------------------------------------------------- +bool OverlayNavigationCube::vectorsParallelFuzzy(Vec3d v1, Vec3d v2) +{ + v1.normalize(); + v2.normalize(); + if (cvf::Math::abs(v1*v2) < 0.999f) return false; + + return true; +} + + +//-------------------------------------------------------------------------------------------------- +/// Static +//-------------------------------------------------------------------------------------------------- +int OverlayNavigationCube::findClosestAxis(const Vec3d& vector) +{ + int retAxis = 0; + double largest = cvf::Math::abs(vector.x()); + + if (cvf::Math::abs(vector.y()) > largest) + { + largest = cvf::Math::abs(vector.y()); + retAxis = 1; + } + + if (cvf::Math::abs(vector.z()) > largest) + { + retAxis = 2; + } + + return retAxis; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void OverlayNavigationCube::setFaceTexture(NavCubeFace face, TextureImage* texture) +{ + m_faceTextures[face] = texture; + m_faceTextureBindings.clear(); +} + + +//-------------------------------------------------------------------------------------------------- +/// Check if the current view dir is aligned with a face (principal axis) +//-------------------------------------------------------------------------------------------------- +bool OverlayNavigationCube::isFaceAlignedViewPoint() const +{ + Vec3d viewDir = m_camera->direction().getNormalized(); + Vec3d upVector = m_camera->up().getNormalized(); + + // First check up vector + float fThreshold = 0.999f; + if ((Math::abs(upVector*Vec3d::X_AXIS) < fThreshold) && + (Math::abs(upVector*Vec3d::Y_AXIS) < fThreshold) && + (Math::abs(upVector*Vec3d::Z_AXIS) < fThreshold)) + { + return false; + } + + if (viewDir*Vec3d::X_AXIS > fThreshold) return true; + else if (viewDir*Vec3d::X_AXIS < -fThreshold) return true; + else if (viewDir*Vec3d::Y_AXIS > fThreshold) return true; + else if (viewDir*Vec3d::Y_AXIS < -fThreshold) return true; + else if (viewDir*Vec3d::Z_AXIS > fThreshold) return true; + else if (viewDir*Vec3d::Z_AXIS < -fThreshold) return true; + + return false; +} + + +//-------------------------------------------------------------------------------------------------- +/// Set the "home" camera angle, which is used when the user presses the house 2d item +//-------------------------------------------------------------------------------------------------- +void OverlayNavigationCube::setHome(const Vec3d& viewDirection, const Vec3d& up) +{ + m_homeViewDirection = viewDirection; + m_homeUp = up; +} + } // namespace cvf diff --git a/VisualizationModules/LibRender/cvfOverlayNavigationCube.h b/VisualizationModules/LibRender/cvfOverlayNavigationCube.h index e878ecf9ce..1a5750f47d 100644 --- a/VisualizationModules/LibRender/cvfOverlayNavigationCube.h +++ b/VisualizationModules/LibRender/cvfOverlayNavigationCube.h @@ -26,6 +26,8 @@ #include "cvfBoundingBox.h" #include "cvfCollection.h" +#include + namespace cvf { class Camera; @@ -35,7 +37,7 @@ class Font; class ShaderProgram; class MatrixState; class TextureImage; - +class RenderState; //================================================================================================== // @@ -45,8 +47,8 @@ class TextureImage; class OverlayNavigationCube: public OverlayItem { public: - enum NavCubeFace { - NCF_NONE, + enum NavCubeFace + { NCF_X_POS, NCF_X_NEG, NCF_Y_POS, @@ -55,8 +57,31 @@ public: NCF_Z_NEG }; - // Note that the order of the items starting at the VT_NCFI_BOTTOM_LEFT is important (in a CCW order) - enum NavCubeFaceItem { +public: + OverlayNavigationCube(Camera* camera, Font* font); + ~OverlayNavigationCube(); + + virtual Vec2ui sizeHint(); + virtual Vec2ui maximumSize(); + virtual Vec2ui minimumSize(); + + virtual void render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size); + virtual void renderSoftware(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size); + virtual bool pick(int winCoordX, int winCoordY, const Vec2i& position, const Vec2ui& size); + + bool updateHighlight(int winCoordX, int winCoordY, const Vec2i& position, const Vec2ui& size); + bool processSelection(int winCoordX, int winCoordY, const Vec2i& position, const Vec2ui& size, Vec3d* viewDir, Vec3d* up); + + void setSize(const Vec2ui& size); + void setHome(const Vec3d& viewDirection, const Vec3d& up); + void setAxisLabels(const String& xLabel, const String& yLabel, const String& zlabel); + void setAxisLabelsColor(const Color3f& color); + void setFaceTexture(NavCubeFace face, TextureImage* texture); + +private: + // Note that the order of the items starting at the NCFI_BOTTOM_LEFT is important (in a CCW order) + enum NavCubeFaceItem + { NCFI_NONE, NCFI_CENTER, NCFI_BOTTOM_LEFT, @@ -111,77 +136,76 @@ public: NCI_ROTATE_CCW }; -public: - OverlayNavigationCube(Camera* camera, Font* font); - ~OverlayNavigationCube(); +private: + void render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size, bool software); + void createAxisGeometry(bool software); + void renderAxis(OpenGLContext* oglContext, const MatrixState& matrixState); + void renderAxisImmediateMode(OpenGLContext* oglContext, const MatrixState& matrixState); + void renderAxisLabels(OpenGLContext* oglContext, bool software, const MatrixState& matrixState); + void renderCubeGeos(OpenGLContext* oglContext, bool software, const MatrixState& matrixState); + void render2dItems(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size, bool software); - virtual Vec2ui sizeHint(); - virtual Vec2ui maximumSize(); - virtual Vec2ui minimumSize(); + void createCubeGeos(); + void createCubeFaceGeos(NavCubeFace face, Vec3f p1, Vec3f p2, Vec3f p3, Vec3f p4); + ref createQuadGeo(const Vec3f& v1, const Vec3f& v2, const Vec3f& v3, const Vec3f& v4, const Vec2f& t1, const Vec2f& t2, const Vec2f& t3, const Vec2f& t4); + void navCubeCornerPoints(Vec3f points[8]); + void create2dGeos(); + ref create2dArrow(const Vec3f& start, const Vec3f& end); - virtual void render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size); - virtual void renderSoftware(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size); + NavCubeItem navCubeItem(NavCubeFace face, NavCubeFaceItem item) const; - void setSize(const Vec2ui& size); - void updateHighlight(int winCoordX, int winCoordY); - void processSelection(int winCoordX, int winCoordY, const BoundingBox& boundingBox, Vec3d* eye, Vec3d* viewDirection); + void configureLocalCamera(Camera* camera, const Vec2i& position, const Vec2ui& size); - void setAxisLabels(const String& xLabel, const String& yLabel, const String& zlabel); - void setAxisLabelsColor(const Color3f& color); + void viewConfigurationFromNavCubeItem(NavCubeItem item, Vec3d* viewDir, Vec3d* up); + Vec3d computeNewUpVector(const Vec3d& viewFrom, const Vec3d currentUp) const; + + size_t pickItem(int winCoordX, int winCoordY, const Vec2i& position, const Vec2ui& size); + NavCubeItem pick2dItem(int winCoordX, int winCoordY, const Vec2i& position, const Vec2ui& size); + + void updateTextureBindings(OpenGLContext* oglContext, bool software); + bool isFaceAlignedViewPoint() const; + + static Vec3d snapToAxis(const Vec3d& vector, const Vec3d* pPreferIfEqual = NULL); + static bool vectorsParallelFuzzy(Vec3d v1, Vec3d v2); + static int findClosestAxis(const Vec3d& vector); private: - void render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size, bool software, const Mat4d& viewMatrix); - void createAxisGeometry(bool software); - void renderAxis(OpenGLContext* oglContext, const MatrixState& matrixState); - void renderAxisImmediateMode(OpenGLContext* oglContext, const MatrixState& matrixState); - void renderAxisLabels(OpenGLContext* oglContext, bool software, const MatrixState& matrixState); - void renderCubeGeos(OpenGLContext* oglContext, bool software, const MatrixState& matrixState); + ref m_camera; // This camera's view matrix will be used to orient the axis cross + ref m_font; + String m_xLabel; // Label to display on x axis, default 'x' + String m_yLabel; + String m_zLabel; + Color3f m_textColor; // Text color - void createCubeGeos(); - void createCubeFaceGeos(NavCubeFace face, Vec3f p1, Vec3f p2, Vec3f p3, Vec3f p4);//, const String& name, const Color3f& baseColor, TextureImage* texture); - void navCubeCornerPoints(Vec3f points[8]); - ref createQuadGeo(const Vec3f& v1, const Vec3f& v2, const Vec3f& v3, const Vec3f& v4); + Vec2ui m_size; // Pixel size of the nav cube area - NavCubeItem navCubeItem(NavCubeFace face, NavCubeFaceItem item) const; - void faceOrientation(NavCubeFace face, Vec3f* normal, Vec3f* upVector, Vec3f* rightVector) const; + Vec3d m_homeViewDirection; + Vec3d m_homeUp; -private: - ref m_camera; // This camera's view matrix will be used to orient the axis cross - String m_xLabel; // Label to display on x axis, default 'x' - String m_yLabel; - String m_zLabel; - Color3f m_textColor; // Text color - ref m_font; + Collection m_cubeGeos; // These arrays have the same length + std::vector m_cubeItemType; // These arrays have the same length + std::vector m_cubeGeoFace; // These arrays have the same length - Vec2ui m_size; // Pixel size of the axis area + ref m_homeGeo; // These arrays have the same length + Collection m_2dGeos; // These arrays have the same length + std::vector m_2dItemType; - Collection m_cubeGeos; - std::vector m_cubeItemType; ref m_cubeGeoShader; + ref m_cubeGeoTextureShader; ref m_axis; - NavCubeItem m_hightlightItem; ///< The currently highlighted cube item (face, corner, edge, buttons) - Vec3f m_upVector; ///< Specify the up vector, which is used for the orientation of the text and textures on the faces - Vec3f m_frontVector; ///< Specify the front vector, which is used for the orientation of the top and bottom faces + NavCubeItem m_hightlightItem; ///< The currently highlighted cube item (face, corner, edge, buttons) + Vec3f m_upVector; ///< Specify the up vector, which is used for the orientation of the text and textures on the faces + Vec3f m_frontVector; ///< Specify the front vector, which is used for the orientation of the top and bottom faces - String m_xPosAxisName; ///< The name of the X_POS face - String m_xNegAxisName; ///< The name of the X_NEG face - String m_yPosAxisName; ///< The name of the Y_POS face - String m_yNegAxisName; ///< The name of the Y_NEG face - String m_zPosAxisName; ///< The name of the Z_POS face - String m_zNegAxisName; ///< The name of the Z_NEG face + Color3f m_xFaceColor; ///< The color of the X_POS and X_NEG faces + Color3f m_yFaceColor; ///< The color of the Y_POS and Y_NEG faces + Color3f m_zFaceColor; ///< The color of the Z_POS and Z_NEG faces + Color3f m_itemHighlightColor; + Color3f m_2dItemsColor; - ref m_texturePosXAxis; ///< The texture to draw on the X_POS face. If NULL, the specified text will be drawn. - ref m_textureNegXAxis; ///< The texture to draw on the X_NEG face. If NULL, the specified text will be drawn. - ref m_texturePosYAxis; ///< The texture to draw on the Y_POS face. If NULL, the specified text will be drawn. - ref m_textureNegYAxis; ///< The texture to draw on the Y_NEG face. If NULL, the specified text will be drawn. - ref m_texturePosZAxis; ///< The texture to draw on the Z_POS face. If NULL, the specified text will be drawn. - ref m_textureNegZAxis; ///< The texture to draw on the Z_NEG face. If NULL, the specified text will be drawn. - - Color3f m_xFaceColor; ///< The color of the X_POS and X_NEG faces - Color3f m_yFaceColor; ///< The color of the Y_POS and Y_NEG faces - Color3f m_zFaceColor; ///< The color of the Z_POS and Z_NEG faces + std::map > m_faceTextures; + std::map > m_faceTextureBindings; }; } - diff --git a/VisualizationModules/LibRender/cvfTextDrawer.cpp b/VisualizationModules/LibRender/cvfTextDrawer.cpp index ad3f7ed460..86a635d9a0 100644 --- a/VisualizationModules/LibRender/cvfTextDrawer.cpp +++ b/VisualizationModules/LibRender/cvfTextDrawer.cpp @@ -34,6 +34,7 @@ #include "cvfMatrixState.h" #include "cvfRenderStateDepth.h" #include "cvfRenderStateBlending.h" +#include "cvfRenderStatePolygonOffset.h" #ifndef CVF_OPENGL_ES #include "cvfRenderState_FF.h" @@ -60,7 +61,8 @@ TextDrawer::TextDrawer(Font* font) m_textColor(Color3::GRAY), m_backgroundColor(1.0f, 1.0f, 0.8f), m_borderColor(Color3::DARK_GRAY), - m_verticalAlignment(0) // BASELINE + m_useDepthBuffer(false), + m_verticalAlignment(0) // BASELINE { CVF_ASSERT(font); CVF_ASSERT(!font->isEmpty()); @@ -88,6 +90,22 @@ void TextDrawer::addText(const String& text, const Vec2f& pos) } +//-------------------------------------------------------------------------------------------------- +/// Add text to be drawn +/// +/// Note: The Z coordinate needs to correspond with the orthographic projection that is setup +/// to render the text. So the range should be <1..-1> with 1 being closest to the near plane. +//-------------------------------------------------------------------------------------------------- +void TextDrawer::addText(const String& text, const Vec3f& pos) +{ + CVF_ASSERT(!text.isEmpty()); + CVF_ASSERT(!pos.isUndefined()); + + m_texts.push_back(text); + m_positions.push_back(pos); +} + + //-------------------------------------------------------------------------------------------------- /// Remove all texts in the drawer //-------------------------------------------------------------------------------------------------- @@ -192,6 +210,15 @@ void TextDrawer::setDrawBorder(bool drawBorder) } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void TextDrawer::setUseDepthBuffer(bool useDepthBuffer) +{ + m_useDepthBuffer = useDepthBuffer; +} + + //-------------------------------------------------------------------------------------------------- /// Returns the color used to draw the text //-------------------------------------------------------------------------------------------------- @@ -284,7 +311,7 @@ void TextDrawer::doRender2d(OpenGLContext* oglContext, const MatrixState& matrix MatrixState projMatrixState(projCam); // Turn off depth test - RenderStateDepth depth(false, RenderStateDepth::LESS, false); + RenderStateDepth depth(m_useDepthBuffer, RenderStateDepth::LESS, m_useDepthBuffer); depth.applyOpenGL(oglContext); // Setup viewport @@ -322,6 +349,13 @@ void TextDrawer::doRender2d(OpenGLContext* oglContext, const MatrixState& matrix // ------------------------------------------------------------------------- if (m_drawBackground || m_drawBorder) { + if (m_useDepthBuffer) + { + RenderStatePolygonOffset polygonOffset; + polygonOffset.configurePolygonPositiveOffset(); + polygonOffset.applyOpenGL(oglContext); + } + ref backgroundShader; if (!softwareRendering) @@ -353,10 +387,10 @@ void TextDrawer::doRender2d(OpenGLContext* oglContext, const MatrixState& matrix Vec3f max = Vec3f(min.x() + static_cast(textExtent.x()) + offset.x()*2.0f, min.y() + static_cast(textExtent.y()) + offset.y()*2.0f, 0.0f); // Draw the background triangle - v1[0] = min.x(); v1[1] = min.y(); - v2[0] = max.x(); v2[1] = min.y(); - v3[0] = max.x(); v3[1] = max.y(); - v4[0] = min.x(); v4[1] = max.y(); + v1[0] = min.x(); v1[1] = min.y(); v1[2] = pos.z(); + v2[0] = max.x(); v2[1] = min.y(); v2[2] = pos.z(); + v3[0] = max.x(); v3[1] = max.y(); v3[2] = pos.z(); + v4[0] = min.x(); v4[1] = max.y(); v4[2] = pos.z(); if (m_drawBackground) { @@ -408,6 +442,12 @@ void TextDrawer::doRender2d(OpenGLContext* oglContext, const MatrixState& matrix } } } + + if (m_useDepthBuffer) + { + RenderStatePolygonOffset resetPolygonOffset; + resetPolygonOffset.applyOpenGL(oglContext); + } } // Render texts @@ -459,7 +499,6 @@ void TextDrawer::doRender2d(OpenGLContext* oglContext, const MatrixState& matrix // Need to round off to integer positions to avoid buggy text drawing on iPad2 pos.x() = cvf::Math::floor(pos.x()); pos.y() = cvf::Math::floor(pos.y()); - pos.z() = cvf::Math::floor(pos.z()); // Cursor incrementor Vec2f cursor(pos); @@ -484,18 +523,22 @@ void TextDrawer::doRender2d(OpenGLContext* oglContext, const MatrixState& matrix // Lower left corner v1[0] = cursor.x() + static_cast(glyph->horizontalBearingX()); v1[1] = cursor.y() + static_cast(glyph->horizontalBearingY()) - textureHeight + static_cast(m_verticalAlignment); + v1[2] = pos.z(); // Lower right corner v2[0] = v1[0] + textureWidth; v2[1] = v1[1]; + v2[2] = pos.z(); // Upper right corner v3[0] = v2[0]; v3[1] = v1[1] + textureHeight; + v3[2] = pos.z(); // Upper left corner v4[0] = v1[0]; v4[1] = v3[1]; + v4[2] = pos.z(); glyph->setupAndBindTexture(oglContext, softwareRendering); @@ -591,4 +634,32 @@ void TextDrawer::doRender2d(OpenGLContext* oglContext, const MatrixState& matrix CVF_CHECK_OGL(oglContext); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool TextDrawer::pickText(const Vec3f& pickCoord2d, const String& text, const Vec3f& pos, Font* font) +{ + // Figure out margin + ref glyph = font->getGlyph(L'A'); + float charHeight = static_cast(glyph->height()); + float charWidth = static_cast(glyph->width()); + + float offsetX = cvf::Math::floor(charWidth/2.0f); + float offsetY = cvf::Math::floor(charHeight/2.0f); + + Vec2ui textExtent = font->textExtent(text); + + Vec3f min = pos; + Vec3f max = Vec3f(min.x() + static_cast(textExtent.x()) + offsetX*2.0f, min.y() + static_cast(textExtent.y()) + offsetY*2.0f, 0.0f); + + if (pickCoord2d.x() > min.x() && pickCoord2d.x() < max.x() && + pickCoord2d.y() > min.y() && pickCoord2d.y() < max.y()) + { + return true; + } + + return false; +} + } // namespace cvf diff --git a/VisualizationModules/LibRender/cvfTextDrawer.h b/VisualizationModules/LibRender/cvfTextDrawer.h index 1e00354671..208bf507b2 100644 --- a/VisualizationModules/LibRender/cvfTextDrawer.h +++ b/VisualizationModules/LibRender/cvfTextDrawer.h @@ -55,6 +55,7 @@ public: virtual ~TextDrawer(); void addText(const String& text, const Vec2f& pos); + void addText(const String& text, const Vec3f& pos); void removeAllTexts(); void setVerticalAlignment(Alignment alignment); @@ -63,16 +64,21 @@ public: void setBorderColor(const Color3f& color); void setDrawBackground(bool drawBackground); void setDrawBorder(bool drawBorder); + void setUseDepthBuffer(bool useDepthBuffer); Color3f textColor() const; Color3f backgroundColor() const; Color3f borderColor() const; bool drawBackground() const; bool drawBorder() const; + bool useDepthBuffer() const; + void render(OpenGLContext* oglContext, const MatrixState& matrixState); void renderSoftware(OpenGLContext* oglContext, const MatrixState& matrixState); + static bool pickText(const Vec3f& pickCoord2d, const String& text, const Vec3f& pos, Font* font); + private: void doRender2d(OpenGLContext* oglContext, const MatrixState& matrixState, bool softwareRendering); @@ -87,6 +93,7 @@ private: Color3f m_textColor; Color3f m_backgroundColor; Color3f m_borderColor; + bool m_useDepthBuffer; short m_verticalAlignment;// Vertical alignment for horizontal text }; diff --git a/VisualizationModules/LibRender/cvfUniform.h b/VisualizationModules/LibRender/cvfUniform.h index 17687287ad..7c7345cf8d 100644 --- a/VisualizationModules/LibRender/cvfUniform.h +++ b/VisualizationModules/LibRender/cvfUniform.h @@ -62,6 +62,7 @@ protected: private: CharArray m_name; + CVF_DISABLE_COPY_AND_ASSIGN(Uniform); }; @@ -85,6 +86,7 @@ public: private: IntArray m_data; + CVF_DISABLE_COPY_AND_ASSIGN(UniformInt); }; @@ -120,6 +122,7 @@ public: private: FloatArray m_data; + CVF_DISABLE_COPY_AND_ASSIGN(UniformFloat); }; @@ -129,7 +132,7 @@ private: // // //================================================================================================== -class UniformMatrixf: public Uniform +class UniformMatrixf : public Uniform { public: UniformMatrixf(const char* name); @@ -142,6 +145,7 @@ public: private: FloatArray m_data; + CVF_DISABLE_COPY_AND_ASSIGN(UniformMatrixf); }; diff --git a/VisualizationModules/LibViewing/cvfRendering.cpp b/VisualizationModules/LibViewing/cvfRendering.cpp index b29e6cc711..a250346712 100644 --- a/VisualizationModules/LibViewing/cvfRendering.cpp +++ b/VisualizationModules/LibViewing/cvfRendering.cpp @@ -904,6 +904,24 @@ OverlayItem* Rendering::overlayItemFromWindowCoordinates(int x, int y) } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Recti Rendering::overlayItemRect(OverlayItem* item) +{ + OverlayItemRectMap itemRectMap; + calculateOverlayItemLayout(&itemRectMap); + + OverlayItemRectMap::iterator it = itemRectMap.find(item); + if (it != itemRectMap.end()) + { + return it->second; + } + + return cvf::Recti(); +} + + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -963,6 +981,5 @@ String Rendering::debugString() const return str; } - } // namespace cvf diff --git a/VisualizationModules/LibViewing/cvfRendering.h b/VisualizationModules/LibViewing/cvfRendering.h index 7061de66b8..1875538b80 100644 --- a/VisualizationModules/LibViewing/cvfRendering.h +++ b/VisualizationModules/LibViewing/cvfRendering.h @@ -113,6 +113,7 @@ public: OverlayItem* overlayItem(size_t index, OverlayItem::LayoutCorner* corner, OverlayItem::LayoutDirection* direction); const OverlayItem* overlayItem(size_t index, OverlayItem::LayoutCorner* corner, OverlayItem::LayoutDirection* direction) const; OverlayItem* overlayItemFromWindowCoordinates(int x, int y); + Recti overlayItemRect(OverlayItem* item); void removeOverlayItem(const OverlayItem* overlayItem); void removeAllOverlayItems(); From cd0b40ef208b24c57074ec91fdcf4608acf29b5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 28 Feb 2013 11:58:31 +0100 Subject: [PATCH 063/242] 3D info is now using a different rendereing method more compatible with software rendering p4#: 20669 --- ApplicationCode/UserInterface/RIViewer.cpp | 13 +- ApplicationCode/UserInterface/RIViewer.h | 1 + .../LibRender/cvfOverlayItem.h | 10 +- .../LibViewing/cvfRendering.cpp | 19 +++ cafViewer/cafViewer.cpp | 117 ++++++++++++++++-- cafViewer/cafViewer.h | 53 ++++---- 6 files changed, 171 insertions(+), 42 deletions(-) diff --git a/ApplicationCode/UserInterface/RIViewer.cpp b/ApplicationCode/UserInterface/RIViewer.cpp index 204a2a66d6..6187c278f7 100644 --- a/ApplicationCode/UserInterface/RIViewer.cpp +++ b/ApplicationCode/UserInterface/RIViewer.cpp @@ -62,11 +62,12 @@ RIViewer::RIViewer(const QGLFormat& format, QWidget* parent) axisCross->setAxisLabels("E", "N", "Z"); m_mainRendering->addOverlayItem(axisCross, cvf::OverlayItem::BOTTOM_LEFT, cvf::OverlayItem::VERTICAL); - setReleaseOGLResourcesEachFrame(true); + this->enableOverlyPainting(true); + this->setReleaseOGLResourcesEachFrame(true); QColor c; QPalette p = QApplication::palette(); - QColor frameAndTextColor(255, 255, 255, 200); + QColor frameAndTextColor(255, 255, 255, 255); p.setColor(QPalette::Window, QColor(144, 173, 208, 180)); p.setColor(QPalette::WindowText, frameAndTextColor); @@ -427,10 +428,10 @@ cvf::Part* RIViewer::pickPointAndFace(int winPosX, int winPosY, uint* faceHit, c void RIViewer::paintOverlayItems(QPainter* painter) { // No support for overlay items using SW rendering yet. - if (!isShadersSupported()) - { - return; - } + //if (!isShadersSupported()) + //{ + // return; + //} int columnWidth = 200; int margin = 5; diff --git a/ApplicationCode/UserInterface/RIViewer.h b/ApplicationCode/UserInterface/RIViewer.h index b09ce90448..349f415783 100644 --- a/ApplicationCode/UserInterface/RIViewer.h +++ b/ApplicationCode/UserInterface/RIViewer.h @@ -95,6 +95,7 @@ private: cvf::ref m_legend1; cvf::ref m_legend2; + caf::PdmPointer m_reservoirView; }; diff --git a/VisualizationModules/LibRender/cvfOverlayItem.h b/VisualizationModules/LibRender/cvfOverlayItem.h index d196c29e16..a419c93015 100644 --- a/VisualizationModules/LibRender/cvfOverlayItem.h +++ b/VisualizationModules/LibRender/cvfOverlayItem.h @@ -43,7 +43,8 @@ public: TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, - BOTTOM_RIGHT + BOTTOM_RIGHT, + UNMANAGED }; enum LayoutDirection @@ -56,10 +57,17 @@ public: virtual Vec2ui sizeHint() = 0; // In Pixels virtual Vec2ui maximumSize() = 0; // In Pixels virtual Vec2ui minimumSize() = 0; // In Pixels + + cvf::Vec2i unmanagedPosition() const { return m_unmanagedPosition; } + void setUnmanagedPosition(cvf::Vec2i val) { m_unmanagedPosition = val; } virtual void render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) = 0; virtual void renderSoftware(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) = 0; virtual bool pick(int oglXCoord, int oglYCoord, const Vec2i& position, const Vec2ui& size); + +private: + Vec2i m_unmanagedPosition; + }; } diff --git a/VisualizationModules/LibViewing/cvfRendering.cpp b/VisualizationModules/LibViewing/cvfRendering.cpp index a250346712..e5664f7397 100644 --- a/VisualizationModules/LibViewing/cvfRendering.cpp +++ b/VisualizationModules/LibViewing/cvfRendering.cpp @@ -308,6 +308,25 @@ void Rendering::renderOverlayItems(OpenGLContext* oglContext, bool useSoftwareRe item->render(oglContext, rect.min(), Vec2ui(static_cast(rect.width()), static_cast(rect.height()))); } } + + for (size_t i = 0; i < m_overlayItems.size(); i++) + { + OverlayItemLayout item = m_overlayItems.at(i); + if ((item.corner == OverlayItem::UNMANAGED) ) + { + Vec2ui size = item.overlayItem->sizeHint(); + Vec2i pos = item.overlayItem->unmanagedPosition(); + + if (useSoftwareRendering) + { + item.overlayItem->renderSoftware(oglContext, pos, size); + } + else + { + item.overlayItem->render(oglContext, pos, size); + } + } + } } diff --git a/cafViewer/cafViewer.cpp b/cafViewer/cafViewer.cpp index 97ac316856..ccc4e257db 100644 --- a/cafViewer/cafViewer.cpp +++ b/cafViewer/cafViewer.cpp @@ -26,6 +26,8 @@ #include "cvfRenderQueueSorter.h" #include "cvfScene.h" #include "cvfModel.h" +#include "cvfTextureImage.h" +#include "cvfOverlayImage.h" #include "cvfqtOpenGLContext.h" @@ -62,7 +64,8 @@ caf::Viewer::Viewer(const QGLFormat& format, QWidget* parent) m_maxFarPlaneDistance(cvf::UNDEFINED_DOUBLE), m_releaseOGLResourcesEachFrame(false), m_paintCounter(0), - m_navigationPolicyEnabled(true) + m_navigationPolicyEnabled(true), + m_isOverlyPaintingEnabled(true) { m_layoutWidget = parentWidget(); @@ -89,6 +92,11 @@ caf::Viewer::Viewer(const QGLFormat& format, QWidget* parent) this->setNavigationPolicy(new caf::CadNavigation); + m_overlayTextureImage = new cvf::TextureImage; + m_overlayImage = new cvf::OverlayImage(m_overlayTextureImage.p()); + m_overlayImage->setBlending(cvf::OverlayImage::TEXTURE_ALPHA); + m_overlayImage->setUnmanagedPosition(cvf::Vec2i(0,0)); + setupMainRendering(); setupRenderingSequence(); @@ -121,6 +129,8 @@ void caf::Viewer::setupMainRendering() { m_mainRendering->renderEngine()->enableForcedImmediateMode(true); } + + updateOverlayImagePresence(); } //-------------------------------------------------------------------------------------------------- @@ -358,6 +368,7 @@ void caf::Viewer::resizeGL(int width, int height) void caf::Viewer::enablePerfInfoHud(bool enable) { m_showPerfInfoHud = enable; + updateOverlayImagePresence(); } @@ -391,6 +402,66 @@ void caf::Viewer::paintEvent(QPaintEvent* event) return; } + // If Qt overlay painting is enabled, paint to an QImage, and set it to the cvf::OverlayImage + + if (m_isOverlyPaintingEnabled || m_showPerfInfoHud) + { + // Set up image to draw to, and painter + if (m_overlayPaintingQImage.size() != this->size()) + { + m_overlayPaintingQImage = QImage(this->size(), QImage::Format_ARGB32); + } + + m_overlayPaintingQImage.fill(Qt::transparent); + QPainter overlyPainter(&m_overlayPaintingQImage); + + // Call virtual method to allow subclasses to paint on the OpenGlCanvas + + if (m_isOverlyPaintingEnabled) + { + this->paintOverlayItems(&overlyPainter); + } + + // Draw performance overlay + + if (m_showPerfInfoHud ) + { + cvfqt::PerformanceInfoHud hud; + hud.addStrings(m_renderingSequence->performanceInfo()); + hud.addStrings(*m_mainCamera); + hud.addString(QString("PaintCount: %1").arg(m_paintCounter++)); + hud.draw(&overlyPainter, width(), height()); + } + + // Convert the QImage into the cvf::TextureImage, + // handling vertical mirroring and (possible) byteswapping + + if (m_overlayTextureImage->height() != this->height() || m_overlayTextureImage->width() != this->width()) + { + m_overlayTextureImage->allocate(this->width(), this->height()); + } + + int height = m_overlayTextureImage->height(); + int width = m_overlayTextureImage->width(); + +#pragma omp parallel for + for (int y = 0 ; y < height; ++y) + { + int negy = height - 1 - y; + for (int x = 0 ; x < width; ++x) + { + // Should probably do direct conversion on byte level. Would be faster + // QImage.bits() and cvf::TextureImage.ptr() (casting away const) + QRgb qtRgbaVal = m_overlayPaintingQImage.pixel(x, negy); + cvf::Color4ub cvfRgbVal(qRed(qtRgbaVal), qGreen(qtRgbaVal), qBlue(qtRgbaVal), qAlpha(qtRgbaVal)); + m_overlayTextureImage->setPixel(x, y, cvfRgbVal); + } + } + + m_overlayImage->setImage(m_overlayTextureImage.p()); + m_overlayImage->setPixelSize(cvf::Vec2ui(this->width(), this->height())); + } + #if QT_VERSION >= 0x040600 // Qt 4.6 painter.beginNativePainting(); @@ -417,17 +488,7 @@ void caf::Viewer::paintEvent(QPaintEvent* event) painter.endNativePainting(); #endif - // Call virtual method to allow subclasses to paint on the OpenGlCanvas - this->paintOverlayItems(&painter); - - if (m_showPerfInfoHud && isShadersSupported()) - { - cvfqt::PerformanceInfoHud hud; - hud.addStrings(m_renderingSequence->performanceInfo()); - hud.addStrings(*m_mainCamera); - hud.addString(QString("PaintCount: %1").arg(m_paintCounter++)); - hud.draw(&painter, width(), height()); - } + } //-------------------------------------------------------------------------------------------------- @@ -696,3 +757,35 @@ int caf::Viewer::currentFrameIndex() else return 0; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool caf::Viewer::isOverlyPaintingEnabled() const +{ + return m_isOverlyPaintingEnabled; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void caf::Viewer::enableOverlyPainting(bool val) +{ + m_isOverlyPaintingEnabled = val; + updateOverlayImagePresence(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void caf::Viewer::updateOverlayImagePresence() +{ + if (m_isOverlyPaintingEnabled || m_showPerfInfoHud) + { + m_mainRendering->addOverlayItem(m_overlayImage.p(), cvf::OverlayItem::UNMANAGED, cvf::OverlayItem::VERTICAL); + } + else + { + m_mainRendering->removeOverlayItem(m_overlayImage.p()); + } +} + diff --git a/cafViewer/cafViewer.h b/cafViewer/cafViewer.h index d3708ba00c..e9ad4bf13e 100644 --- a/cafViewer/cafViewer.h +++ b/cafViewer/cafViewer.h @@ -26,9 +26,6 @@ #include "cvfVector3.h" #include "cvfOpenGL.h" - -//#include "cvfManipulatorTrackball.h" - #include "cafOpenGLWidget.h" @@ -39,6 +36,8 @@ namespace cvf { class RenderSequence; class OverlayScalarMapperLegend; class HitItemCollection; + class OverlayImage; + class TextureImage; } namespace caf { @@ -100,6 +99,11 @@ public: bool rayPick(int winPosX, int winPosY, cvf::HitItemCollection* pickedPoints) ; + // QPainter based drawing on top of the OpenGL graphics + + bool isOverlyPaintingEnabled() const; + void enableOverlyPainting(bool val); + // Performance information for debugging etc. void enablePerfInfoHud(bool enable); bool isPerfInfoHudEnabled(); @@ -131,10 +135,9 @@ protected: virtual void paintEvent(QPaintEvent* event); // Support the navigation policy concept - virtual bool event( QEvent* e ); - cvf::ref - m_navigationPolicy; - bool m_navigationPolicyEnabled; + virtual bool event( QEvent* e ); + cvf::ref m_navigationPolicy; + bool m_navigationPolicyEnabled; // Actual rendering objects cvf::ref m_renderingSequence; @@ -142,31 +145,35 @@ protected: cvf::ref m_mainCamera; cvf::ref m_mainRendering; - double m_minNearPlaneDistance; - double m_maxFarPlaneDistance; + double m_minNearPlaneDistance; + double m_maxFarPlaneDistance; private: - void updateCamera(int width, int height); + void updateCamera(int width, int height); - void releaseOGlResourcesForCurrentFrame(); - void debugShowRenderingSequencePartNames(); + void releaseOGlResourcesForCurrentFrame(); + void debugShowRenderingSequencePartNames(); - bool m_showPerfInfoHud; - size_t m_paintCounter; - bool m_releaseOGLResourcesEachFrame; - QPointer m_layoutWidget; + bool m_showPerfInfoHud; + size_t m_paintCounter; + bool m_releaseOGLResourcesEachFrame; + QPointer m_layoutWidget; + bool m_isOverlyPaintingEnabled; + cvf::ref m_overlayTextureImage; + cvf::ref m_overlayImage; + QImage m_overlayPaintingQImage; + void updateOverlayImagePresence(); // System to make sure we share OpenGL resources - static Viewer* sharedWidget(); - static cvf::OpenGLContextGroup* contextGroup(); - static std::list - sm_viewers; + static Viewer* sharedWidget(); + static cvf::OpenGLContextGroup* contextGroup(); + static std::list sm_viewers; static cvf::ref - sm_openGLContextGroup; + sm_openGLContextGroup; - caf::FrameAnimationControl* m_animationControl; - cvf::Collection m_frameScenes; + caf::FrameAnimationControl* m_animationControl; + cvf::Collection m_frameScenes; }; } // End namespace caf From 1181d62b7542755b88ecf63b7dffb0e40cbd050f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 1 Mar 2013 16:00:34 +0100 Subject: [PATCH 064/242] Reviewed and simplified DataAccess classes. Includes some const changes and some renaming p4#: 20687 --- .../RifEclipseInputFileTools.cpp | 2 +- .../ProjectDataModel/RimReservoirView.cpp | 8 +- .../ProjectDataModel/RimReservoirView.h | 2 +- .../ReservoirDataModel/RigActiveCellInfo.cpp | 12 +- .../ReservoirDataModel/RigEclipseCase.cpp | 26 ++- .../ReservoirDataModel/RigEclipseCase.h | 13 +- .../ReservoirDataModel/RigGridBase.h | 2 +- .../RigGridScalarDataAccess.cpp | 185 ++++++++---------- .../RigGridScalarDataAccess.h | 11 +- .../RigReservoirCellResults.cpp | 2 +- .../RigReservoirCellResults.h | 2 +- CommonCode/cvfStructGridScalarDataAccess.h | 12 +- 12 files changed, 138 insertions(+), 139 deletions(-) diff --git a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp index 59db59045f..13182d8852 100644 --- a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp @@ -432,7 +432,7 @@ bool RifEclipseInputFileTools::writeBinaryResultToTextFile(const QString& fileNa { for (i = 0; i < eclipseCase->mainGrid()->cellCountI(); i++) { - double resultValue = dataAccessObject->cellScalar(i, j, k); + double resultValue = dataAccessObject->cellScalar(eclipseCase->mainGrid()->cellIndexFromIJK(i, j, k)); if (resultValue == HUGE_VAL) { resultValue = undefinedValue; diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp index 51ed1acdb3..47fd6876ce 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp @@ -874,15 +874,15 @@ bool RimReservoirView::pickInfo(size_t gridIndex, size_t cellIndex, const cvf::V //-------------------------------------------------------------------------------------------------- /// Get the current scalar value for the display face at the given index //-------------------------------------------------------------------------------------------------- -void RimReservoirView::appendCellResultInfo(size_t gridIndex, size_t cellIndex, QString* resultInfoText) const +void RimReservoirView::appendCellResultInfo(size_t gridIndex, size_t cellIndex, QString* resultInfoText) { CVF_ASSERT(resultInfoText); if (m_reservoir && m_reservoir->reservoirData()) { - const RigEclipseCase* eclipseCase = m_reservoir->reservoirData(); - const RigGridBase* grid = eclipseCase->grid(gridIndex); - const RigActiveCellInfo* activeCellInfo = eclipseCase->activeCellInfo(); + RigEclipseCase* eclipseCase = m_reservoir->reservoirData(); + RigGridBase* grid = eclipseCase->grid(gridIndex); + RigActiveCellInfo* activeCellInfo = eclipseCase->activeCellInfo(); if (this->cellResult()->hasResult()) { diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.h b/ApplicationCode/ProjectDataModel/RimReservoirView.h index bb2324534c..7eb628e114 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.h +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.h @@ -137,7 +137,7 @@ public: // Picking info bool pickInfo(size_t gridIndex, size_t cellIndex, const cvf::Vec3d& point, QString* pickInfoText) const; - void appendCellResultInfo(size_t gridIndex, size_t cellIndex, QString* resultInfoText) const; + void appendCellResultInfo(size_t gridIndex, size_t cellIndex, QString* resultInfoText) ; // Does this belong here, really ? void calculateVisibleWellCellsIncFence(cvf::UByteArray* visibleCells, RigGridBase * grid); diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp index 81766f472a..b26df3d7b1 100644 --- a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp @@ -45,7 +45,7 @@ void RigActiveCellInfo::setGlobalCellCount(size_t globalCellCount) //-------------------------------------------------------------------------------------------------- bool RigActiveCellInfo::isActiveInMatrixModel(size_t globalCellIndex) const { - if (globalCellIndex >= m_activeInMatrixModel.size()) return false; + CVF_TIGHT_ASSERT(globalCellIndex < m_activeInMatrixModel.size()); return m_activeInMatrixModel[globalCellIndex] != cvf::UNDEFINED_SIZE_T; } @@ -55,7 +55,7 @@ bool RigActiveCellInfo::isActiveInMatrixModel(size_t globalCellIndex) const //-------------------------------------------------------------------------------------------------- size_t RigActiveCellInfo::activeIndexInMatrixModel(size_t globalCellIndex) const { - if (globalCellIndex >= m_activeInMatrixModel.size()) return cvf::UNDEFINED_SIZE_T; + CVF_TIGHT_ASSERT(globalCellIndex < m_activeInMatrixModel.size()); return m_activeInMatrixModel[globalCellIndex]; } @@ -75,7 +75,7 @@ void RigActiveCellInfo::setActiveIndexInMatrixModel(size_t globalCellIndex, size //-------------------------------------------------------------------------------------------------- bool RigActiveCellInfo::isActiveInFractureModel(size_t globalCellIndex) const { - if (globalCellIndex >= m_activeInFractureModel.size()) return false; + CVF_TIGHT_ASSERT(globalCellIndex < m_activeInFractureModel.size()); return m_activeInFractureModel[globalCellIndex] != cvf::UNDEFINED_SIZE_T; } @@ -85,7 +85,7 @@ bool RigActiveCellInfo::isActiveInFractureModel(size_t globalCellIndex) const //-------------------------------------------------------------------------------------------------- size_t RigActiveCellInfo::activeIndexInFractureModel(size_t globalCellIndex) const { - if (globalCellIndex >= m_activeInFractureModel.size()) return cvf::UNDEFINED_SIZE_T; + CVF_TIGHT_ASSERT(globalCellIndex < m_activeInFractureModel.size()); return m_activeInFractureModel[globalCellIndex]; } @@ -133,10 +133,6 @@ void RigActiveCellInfo::computeDerivedData() m_globalFractureModelActiveCellCount += m_perGridActiveCellInfo[i].fractureModelActiveCellCount(); } - if (m_globalFractureModelActiveCellCount == 0) - { - m_activeInFractureModel.resize(0); - } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp index a192199546..30d7322de1 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp @@ -83,6 +83,24 @@ const RigGridBase* RigEclipseCase::grid(size_t index) const return m_mainGrid->gridByIndex(index); } + +//-------------------------------------------------------------------------------------------------- +/// Get grid by index. The main grid has index 0, so the first lgr has index 1 +//-------------------------------------------------------------------------------------------------- +RigGridBase* RigEclipseCase::grid(size_t index) +{ + return m_mainGrid->gridByIndex(index); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigEclipseCase::gridCount() const +{ + return m_mainGrid->gridCount(); +} + + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -375,16 +393,18 @@ const RigReservoirCellResults* RigEclipseCase::results(RifReaderInterface::Poros //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RigEclipseCase::dataAccessObject(const RigGridBase* grid, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStepIndex, size_t scalarSetIndex) const +cvf::ref RigEclipseCase::dataAccessObject(const RigGridBase* grid, + RifReaderInterface::PorosityModelResultType porosityModel, + size_t timeStepIndex, + size_t scalarSetIndex) { if (timeStepIndex != cvf::UNDEFINED_SIZE_T && scalarSetIndex != cvf::UNDEFINED_SIZE_T) { - cvf::ref dataAccess = RigGridScalarDataAccessFactory::createDataAccessObject(grid, this, porosityModel, timeStepIndex, scalarSetIndex); + cvf::ref dataAccess = RigGridScalarDataAccessFactory::createPerGridDataAccessObject( this, grid->gridIndex(), porosityModel, timeStepIndex, scalarSetIndex); return dataAccess; } return NULL; } - diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCase.h b/ApplicationCode/ReservoirDataModel/RigEclipseCase.h index 4dd62bd912..73836cdbf1 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCase.h +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCase.h @@ -40,16 +40,19 @@ public: const RigMainGrid* mainGrid() const { return m_mainGrid.p(); } void setMainGrid(RigMainGrid* mainGrid); - void allGrids(std::vector* grids); - void allGrids(std::vector* grids) const; + void allGrids(std::vector* grids); // To be removed + void allGrids(std::vector* grids) const;// To be removed const RigGridBase* grid(size_t index) const; - + RigGridBase* grid(size_t index); + size_t gridCount() const; RigReservoirCellResults* results(RifReaderInterface::PorosityModelResultType porosityModel); const RigReservoirCellResults* results(RifReaderInterface::PorosityModelResultType porosityModel) const; - cvf::ref dataAccessObject(const RigGridBase* grid, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStepIndex, size_t scalarSetIndex) const; - + cvf::ref dataAccessObject(const RigGridBase* grid, + RifReaderInterface::PorosityModelResultType porosityModel, + size_t timeStepIndex, + size_t scalarSetIndex); void computeCachedData(); diff --git a/ApplicationCode/ReservoirDataModel/RigGridBase.h b/ApplicationCode/ReservoirDataModel/RigGridBase.h index f447f49e48..59a492450d 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridBase.h +++ b/ApplicationCode/ReservoirDataModel/RigGridBase.h @@ -53,7 +53,7 @@ public: void setIndexToStartOfCells(size_t indexToStartOfCells) { m_indexToStartOfCells = indexToStartOfCells; } void setGridIndex(size_t index) { m_gridIndex = index; } - size_t gridIndex() { return m_gridIndex; } + size_t gridIndex() const { return m_gridIndex; } double characteristicIJCellSize(); diff --git a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp index f7f492d06c..d4d3aeba05 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp @@ -31,132 +31,100 @@ #include "RigEclipseCase.h" #include - - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- class RigGridAllCellsScalarDataAccess : public cvf::StructGridScalarDataAccess { public: - RigGridAllCellsScalarDataAccess(const RigGridBase* grid, const std::vector* resultValues); + RigGridAllCellsScalarDataAccess(const RigGridBase* grid, std::vector* reservoirResultValues); - 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 double cellScalar(size_t gridLocalCellIndex) const; + virtual void setCellScalar(size_t cellIndex, double value); - virtual const cvf::Vec3d* cellVector(size_t i, size_t j, size_t k) const; - -protected: +private: cvf::cref m_grid; - const std::vector* m_resultValues; + std::vector* m_reservoirResultValues; }; - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigGridAllCellsScalarDataAccess::RigGridAllCellsScalarDataAccess(const RigGridBase* grid, const std::vector* resultValues) : -m_grid(grid), - m_resultValues(resultValues) +RigGridAllCellsScalarDataAccess::RigGridAllCellsScalarDataAccess(const RigGridBase* grid, std::vector* reservoirResultValues) + : m_grid(grid), + m_reservoirResultValues(reservoirResultValues) { -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -double RigGridAllCellsScalarDataAccess::cellScalar(size_t i, size_t j, size_t k) const -{ - size_t cellIndex = m_grid->cellIndexFromIJK(i, j, k); - - return cellScalar(cellIndex); + CVF_ASSERT(reservoirResultValues != NULL); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double RigGridAllCellsScalarDataAccess::cellScalar(size_t cellIndex) const +double RigGridAllCellsScalarDataAccess::cellScalar(size_t gridLocalCellIndex) const { - if (m_resultValues->size() == 0 ) return HUGE_VAL; + if (m_reservoirResultValues->size() == 0 ) return HUGE_VAL; - if (m_resultValues->size() <= cellIndex) return HUGE_VAL; + size_t globalGridCellIndex = m_grid->globalGridCellIndex(gridLocalCellIndex); + CVF_TIGHT_ASSERT(globalGridCellIndex < m_reservoirResultValues->size() ); - return m_resultValues->at(cellIndex); + return m_reservoirResultValues->at(globalGridCellIndex); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double RigGridAllCellsScalarDataAccess::gridPointScalar(size_t i, size_t j, size_t k) const +void RigGridAllCellsScalarDataAccess::setCellScalar(size_t gridLocalCellIndex, double scalarValue) { - CVF_ASSERT(false); - return 0.0; + size_t globalGridCellIndex = m_grid->globalGridCellIndex(gridLocalCellIndex); + CVF_TIGHT_ASSERT(globalGridCellIndex < m_reservoirResultValues->size() ); + + (*m_reservoirResultValues)[globalGridCellIndex] = scalarValue; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigGridAllCellsScalarDataAccess::cellCornerScalars(size_t i, size_t j, size_t k, double scalars[8]) const -{ - CVF_ASSERT(false); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RigGridAllCellsScalarDataAccess::pointScalar(const cvf::Vec3d& p, double* scalarValue) const -{ - CVF_ASSERT(false); - return false; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -const cvf::Vec3d* RigGridAllCellsScalarDataAccess::cellVector(size_t i, size_t j, size_t k) const -{ - CVF_ASSERT(false); - return new cvf::Vec3d(); -} - - - - - - - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -class RigGridMatrixActiveCellsScalarDataAccess : public RigGridAllCellsScalarDataAccess +class RigGridMatrixActiveCellsScalarDataAccess : public cvf::StructGridScalarDataAccess { public: - RigGridMatrixActiveCellsScalarDataAccess(const RigGridBase* grid, const std::vector* resultValues, const RigActiveCellInfo* activeCellInfo) : - RigGridAllCellsScalarDataAccess(grid, resultValues), + RigGridMatrixActiveCellsScalarDataAccess(const RigGridBase* grid, std::vector* reservoirResultValues, const RigActiveCellInfo* activeCellInfo) + : m_grid(grid), + m_reservoirResultValues(reservoirResultValues), m_activeCellInfo(activeCellInfo) { } - virtual double cellScalar(size_t cellIndex) const - { - if (m_resultValues->size() == 0 ) return HUGE_VAL; + virtual double cellScalar(size_t gridLocalCellIndex) const + { + if (m_reservoirResultValues->size() == 0 ) return HUGE_VAL; - size_t globalGridCellIndex = m_grid->globalGridCellIndex(cellIndex); - size_t resultValueIndex = m_activeCellInfo->activeIndexInMatrixModel(globalGridCellIndex); - if (resultValueIndex == cvf::UNDEFINED_SIZE_T) return HUGE_VAL; + size_t globalGridCellIndex = m_grid->globalGridCellIndex(gridLocalCellIndex); + size_t resultValueIndex = m_activeCellInfo->activeIndexInMatrixModel(globalGridCellIndex); + if (resultValueIndex == cvf::UNDEFINED_SIZE_T) return HUGE_VAL; - if (m_resultValues->size() <= resultValueIndex) return HUGE_VAL; + CVF_TIGHT_ASSERT (resultValueIndex < m_reservoirResultValues->size()); - return m_resultValues->at(resultValueIndex); - } + return m_reservoirResultValues->at(resultValueIndex); + } -protected: + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + virtual void setCellScalar(size_t gridLocalCellIndex, double scalarValue) + { + size_t globalGridCellIndex = m_grid->globalGridCellIndex(gridLocalCellIndex); + size_t resultValueIndex = m_activeCellInfo->activeIndexInMatrixModel(globalGridCellIndex); + + CVF_TIGHT_ASSERT (resultValueIndex < m_reservoirResultValues->size()); + + (*m_reservoirResultValues)[resultValueIndex] = scalarValue; + } + +private: const RigActiveCellInfo* m_activeCellInfo; + cvf::cref m_grid; + std::vector* m_reservoirResultValues; }; @@ -167,30 +135,46 @@ protected: //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -class RigGridFractureActiveCellsScalarDataAccess : public RigGridAllCellsScalarDataAccess +class RigGridFractureActiveCellsScalarDataAccess : public cvf::StructGridScalarDataAccess { public: - RigGridFractureActiveCellsScalarDataAccess(const RigGridBase* grid, const std::vector* resultValues, const RigActiveCellInfo* activeCellInfo) : - RigGridAllCellsScalarDataAccess(grid, resultValues), - m_activeCellInfo(activeCellInfo) + RigGridFractureActiveCellsScalarDataAccess(const RigGridBase* grid, std::vector* reservoirResultValues, const RigActiveCellInfo* activeCellInfo) + : m_grid(grid), + m_reservoirResultValues(reservoirResultValues), + m_activeCellInfo(activeCellInfo) { } - virtual double cellScalar(size_t cellIndex) const + virtual double cellScalar(size_t gridLocalCellIndex) const { - if (m_resultValues->size() == 0 ) return HUGE_VAL; + if (m_reservoirResultValues->size() == 0 ) return HUGE_VAL; - size_t globalGridCellIndex = m_grid->globalGridCellIndex(cellIndex); + size_t globalGridCellIndex = m_grid->globalGridCellIndex(gridLocalCellIndex); size_t resultValueIndex = m_activeCellInfo->activeIndexInFractureModel(globalGridCellIndex); if (resultValueIndex == cvf::UNDEFINED_SIZE_T) return HUGE_VAL; - if (m_resultValues->size() <= resultValueIndex) return HUGE_VAL; + CVF_TIGHT_ASSERT (resultValueIndex < m_reservoirResultValues->size()); - return m_resultValues->at(resultValueIndex); + return m_reservoirResultValues->at(resultValueIndex); } -protected: + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + virtual void setCellScalar(size_t gridLocalCellIndex, double scalarValue) + { + size_t globalGridCellIndex = m_grid->globalGridCellIndex(gridLocalCellIndex); + size_t resultValueIndex = m_activeCellInfo->activeIndexInFractureModel(globalGridCellIndex); + + CVF_TIGHT_ASSERT (resultValueIndex < m_reservoirResultValues->size()); + + (*m_reservoirResultValues)[resultValueIndex] = scalarValue; + } + +private: const RigActiveCellInfo* m_activeCellInfo; + cvf::cref m_grid; + std::vector* m_reservoirResultValues; }; @@ -200,29 +184,32 @@ protected: //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RigGridScalarDataAccessFactory::createDataAccessObject(const RigGridBase* grid, - const RigEclipseCase* eclipseCase, - RifReaderInterface::PorosityModelResultType porosityModel, - size_t timeStepIndex, - size_t scalarSetIndex) +cvf::ref RigGridScalarDataAccessFactory::createPerGridDataAccessObject(RigEclipseCase* eclipseCase, + size_t gridIndex, + RifReaderInterface::PorosityModelResultType porosityModel, + size_t timeStepIndex, + size_t scalarSetIndex) { - CVF_ASSERT(grid); + + CVF_ASSERT(gridIndex < eclipseCase->gridCount()); CVF_ASSERT(eclipseCase); CVF_ASSERT(eclipseCase->results(porosityModel)); CVF_ASSERT(eclipseCase->activeCellInfo()); - if (!grid || !eclipseCase || !eclipseCase->results(porosityModel) || !eclipseCase->activeCellInfo()) + RigGridBase *grid = eclipseCase->grid(gridIndex); + + if ( !eclipseCase || !eclipseCase->results(porosityModel) || !eclipseCase->activeCellInfo()) { return NULL; } - const std::vector< std::vector > & scalarSetResults = eclipseCase->results(porosityModel)->cellScalarResults(scalarSetIndex); + std::vector< std::vector > & scalarSetResults = eclipseCase->results(porosityModel)->cellScalarResults(scalarSetIndex); if (timeStepIndex >= scalarSetResults.size()) { return NULL; } - const std::vector* resultValues = &(scalarSetResults[timeStepIndex]); + std::vector* resultValues = &(scalarSetResults[timeStepIndex]); bool useGlobalActiveIndex = eclipseCase->results(porosityModel)->isUsingGlobalActiveIndex(scalarSetIndex); diff --git a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.h b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.h index 520750bf12..ce0bd96b0b 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.h +++ b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.h @@ -29,11 +29,12 @@ class RigGridBase; class RigGridScalarDataAccessFactory { public: - static cvf::ref createDataAccessObject(const RigGridBase* grid, - const RigEclipseCase* eclipseCase, - RifReaderInterface::PorosityModelResultType porosityModel, - size_t timeStepIndex, - size_t scalarSetIndex); + static cvf::ref + createPerGridDataAccessObject(RigEclipseCase* eclipseCase, + size_t gridIndex, + RifReaderInterface::PorosityModelResultType porosityModel, + size_t timeStepIndex, + size_t scalarSetIndex); }; diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp index 10d3916be0..cba54355e6 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp @@ -253,7 +253,7 @@ std::vector< std::vector > & RigReservoirCellResults::cellScalarResults( //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double RigReservoirCellResults::cellScalarResult(size_t timeStepIndex, size_t scalarResultIndex, size_t resultValueIndex) +double RigReservoirCellResults::cellScalarResult( size_t scalarResultIndex, size_t timeStepIndex, size_t resultValueIndex) { if (scalarResultIndex < resultCount() && timeStepIndex < m_cellScalarResults[scalarResultIndex].size() && diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h index d4065cfeb2..bdf2b8d223 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h +++ b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h @@ -73,7 +73,7 @@ public: // Access the results data const std::vector< std::vector > & cellScalarResults(size_t scalarResultIndex) const; std::vector< std::vector > & cellScalarResults(size_t scalarResultIndex); - double cellScalarResult(size_t timeStepIndex, size_t scalarResultIndex, size_t resultValueIndex); + double cellScalarResult(size_t scalarResultIndex, size_t timeStepIndex, size_t resultValueIndex); static RifReaderInterface::PorosityModelResultType convertFromProjectModelPorosityModel(RimDefines::PorosityModelType porosityModel); diff --git a/CommonCode/cvfStructGridScalarDataAccess.h b/CommonCode/cvfStructGridScalarDataAccess.h index 226a821357..cbdac5ee4e 100644 --- a/CommonCode/cvfStructGridScalarDataAccess.h +++ b/CommonCode/cvfStructGridScalarDataAccess.h @@ -30,16 +30,8 @@ namespace cvf { class StructGridScalarDataAccess : public Object { public: - virtual double cellScalar(size_t i, size_t j, size_t k) const = 0; - virtual double cellScalar(size_t cellIndex) const = 0; - virtual void cellCornerScalars(size_t i, size_t j, size_t k, double scalars[8]) const = 0; - - // Trenger vi denne? Kan erstattes av cellCornerScalars for kuttplan - virtual double gridPointScalar(size_t i, size_t j, size_t k) const = 0; - virtual bool pointScalar(const cvf::Vec3d& p, double* scalarValue) const = 0; - - // Vector results - virtual const cvf::Vec3d* cellVector(size_t i, size_t j, size_t k) const = 0; + virtual double cellScalar(size_t cellIndex) const = 0; + virtual void setCellScalar(size_t cellIndex, double value) = 0; }; From 27a8088421e08de1d9659383433cd3aaf4e61631 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 1 Mar 2013 16:13:37 +0100 Subject: [PATCH 065/242] Compute global count based on active cell vectors p4#: 20688 --- ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp index b26df3d7b1..0176a45bc9 100644 --- a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp @@ -127,12 +127,11 @@ void RigActiveCellInfo::computeDerivedData() m_globalMatrixModelActiveCellCount = 0; m_globalFractureModelActiveCellCount = 0; - for (size_t i = 0; i < m_perGridActiveCellInfo.size(); i++) + for (size_t i = 0; i < m_activeInFractureModel.size(); i++) { - m_globalMatrixModelActiveCellCount += m_perGridActiveCellInfo[i].matrixModelActiveCellCount(); - m_globalFractureModelActiveCellCount += m_perGridActiveCellInfo[i].fractureModelActiveCellCount(); + if (activeIndexInMatrixModel(i)) m_globalMatrixModelActiveCellCount++; + if (activeIndexInFractureModel(i)) m_globalFractureModelActiveCellCount++; } - } //-------------------------------------------------------------------------------------------------- From 5ed0e5a725f897c2e5bc294835588ceec3e04227 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sat, 2 Mar 2013 10:18:27 +0100 Subject: [PATCH 066/242] Linux fixes p4#: 20691 --- .../FileInterface/RifEclipseRestartFilesetAccess.cpp | 2 +- .../FileInterface/RifReaderEclipseOutput.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp b/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp index e194e245b8..c8254c63a6 100644 --- a/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp +++ b/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp @@ -76,7 +76,7 @@ void RifEclipseRestartFilesetAccess::setFileSet(const QStringList& fileSet) m_ecl_files.push_back(NULL); } - CVF_ASSERT(m_fileNames.size() == m_ecl_files.size()); + CVF_ASSERT(m_fileNames.size() == static_cast(m_ecl_files.size())); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index b7a98175ca..3a703fb8e6 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -459,7 +459,7 @@ bool RifReaderEclipseOutput::readActiveCellInfo() actnumValuesPerGrid.resize(actnumKeywordCount); size_t globalCellCount = 0; - for (size_t gridIdx = 0; gridIdx < actnumKeywordCount; gridIdx++) + for (size_t gridIdx = 0; gridIdx < static_cast(actnumKeywordCount); gridIdx++) { RifEclipseOutputFileTools::keywordData(ecl_file, ACTNUM_KW, gridIdx, &actnumValuesPerGrid[gridIdx]); @@ -478,7 +478,7 @@ bool RifReaderEclipseOutput::readActiveCellInfo() activeCellInfo->setGridCount(actnumKeywordCount); size_t cellIdx = 0; - for (size_t gridIdx = 0; gridIdx < actnumKeywordCount; gridIdx++) + for (size_t gridIdx = 0; gridIdx < static_cast(actnumKeywordCount); gridIdx++) { size_t activeMatrixIndex = 0; size_t activeFractureIndex = 0; @@ -810,7 +810,7 @@ void RifReaderEclipseOutput::readWellCells() // If a well is defined in fracture region, the K-value is from (cellCountK - 1) -> cellCountK*2 - 1 // Adjust K so index is always in valid grid region - if (cellK >= grids[gridNr]->cellCountK()) + if (cellK >= static_cast(grids[gridNr]->cellCountK())) { cellK -= static_cast(grids[gridNr]->cellCountK()); } @@ -855,7 +855,7 @@ void RifReaderEclipseOutput::readWellCells() // If a well is defined in fracture region, the K-value is from (cellCountK - 1) -> cellCountK*2 - 1 // Adjust K so index is always in valid grid region - if (cellK >= grids[gridNr]->cellCountK()) + if (cellK >= static_cast(grids[gridNr]->cellCountK())) { cellK -= static_cast(grids[gridNr]->cellCountK()); } @@ -893,7 +893,7 @@ QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringL { CVF_ASSERT(activeCellInfo); - if (keywords.size() != keywordDataItemCounts.size()) + if (keywords.size() != static_cast(keywordDataItemCounts.size())) { return QStringList(); } From 42f3f0b2d268689282a72c98971ba82833f13b16 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sat, 2 Mar 2013 15:10:10 +0100 Subject: [PATCH 067/242] Fixed invalid check p4#: 20692 --- ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp index 0176a45bc9..a261b60ddf 100644 --- a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp @@ -129,8 +129,8 @@ void RigActiveCellInfo::computeDerivedData() for (size_t i = 0; i < m_activeInFractureModel.size(); i++) { - if (activeIndexInMatrixModel(i)) m_globalMatrixModelActiveCellCount++; - if (activeIndexInFractureModel(i)) m_globalFractureModelActiveCellCount++; + if (isActiveInMatrixModel(i)) m_globalMatrixModelActiveCellCount++; + if (isActiveInFractureModel(i)) m_globalFractureModelActiveCellCount++; } } From 4c955ece4a1ac9788b37e9282544a62d92d545ff Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sat, 2 Mar 2013 15:32:38 +0100 Subject: [PATCH 068/242] Improved statistical data infrastructure p4#: 20694 --- .../RifReaderStatisticalCalculation.cpp | 19 +++- .../RifReaderStatisticalCalculation.h | 4 +- .../ProjectDataModel/RimReservoirView.cpp | 2 +- .../RimStatisticalCalculation.cpp | 98 ++++++++++++++++--- .../RimStatisticalCalculation.h | 10 ++ .../RimStatisticalCollection.cpp | 31 +++++- .../RimStatisticalCollection.h | 2 + 7 files changed, 145 insertions(+), 21 deletions(-) diff --git a/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.cpp b/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.cpp index e758d39e67..c109a1cded 100644 --- a/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.cpp +++ b/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.cpp @@ -44,9 +44,6 @@ RifReaderStatisticalCalculation::~RifReaderStatisticalCalculation() //-------------------------------------------------------------------------------------------------- bool RifReaderStatisticalCalculation::open(const QString& fileName, RigEclipseCase* eclipseCase) { - m_matrixDynamicResultNames.push_back("SOIL"); - m_matrixDynamicResultNames.push_back("PRESSURE"); - buildMetaData(eclipseCase); return true; @@ -119,3 +116,19 @@ void RifReaderStatisticalCalculation::setTimeSteps(const QList& times m_timeSteps = timesteps; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifReaderStatisticalCalculation::staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector* values) +{ + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifReaderStatisticalCalculation::dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector* values) +{ + return false; +} + diff --git a/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.h b/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.h index 353051baef..70814ae583 100644 --- a/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.h +++ b/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.h @@ -32,8 +32,8 @@ public: virtual void close() {} - virtual bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector* values ) { return false; } - virtual bool dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector* values ) { return false; } + virtual bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector* values ); + virtual bool dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector* values ); void setMatrixResultNames(const QStringList& staticResultNames, const QStringList& dynamicResultNames); void setFractureResultNames(const QStringList& staticResultNames, const QStringList& dynamicResultNames); diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp index 47fd6876ce..d5d574908b 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp @@ -274,7 +274,7 @@ void RimReservoirView::clampCurrentTimestep() // Clamp the current timestep to actual possibilities if (this->gridCellResults()) { - if (m_currentTimeStep() > this->gridCellResults()->maxTimeStepCount()) + if (m_currentTimeStep() > static_cast(this->gridCellResults()->maxTimeStepCount())) { m_currentTimeStep = static_cast(this->gridCellResults()->maxTimeStepCount()) -1; } diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp index 75fc55b738..bd9c8d43fd 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp @@ -25,6 +25,8 @@ #include "RigEclipseCase.h" #include "RifReaderStatisticalCalculation.h" #include "RigReservoirCellResults.h" +#include "RigStatistics.h" +#include "RigMainGrid.h" CAF_PDM_SOURCE_INIT(RimStatisticalCalculation, "RimStatisticalCalculation"); @@ -35,12 +37,16 @@ CAF_PDM_SOURCE_INIT(RimStatisticalCalculation, "RimStatisticalCalculation"); RimStatisticalCalculation::RimStatisticalCalculation() : RimReservoir() { + CAF_PDM_InitField(&m_resultName, "ResultName", QString("PRESSURE"), "ResultName", "", "", ""); + CAF_PDM_InitField(&statisticsMin, "StatisticsMin", true, "Minimum", "", "" ,""); CAF_PDM_InitField(&statisticsMax, "StatisticsMax", true, "Maximum", "", "" ,""); CAF_PDM_InitField(&statisticsMean, "StatisticsMean", true, "Mean", "", "" ,""); CAF_PDM_InitField(&statisticsStdDev, "StatisticsStdDev", true, "Std dev", "", "" ,""); m_readerInterface = new RifReaderStatisticalCalculation; + + openEclipseGridFile(); } //-------------------------------------------------------------------------------------------------- @@ -51,11 +57,25 @@ RimStatisticalCalculation::~RimStatisticalCalculation() } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimStatisticalCalculation::setMainGrid(RigMainGrid* mainGrid) +{ + CVF_ASSERT(mainGrid); + CVF_ASSERT(m_rigEclipseCase.notNull()); + + m_rigEclipseCase->setMainGrid(mainGrid); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- bool RimStatisticalCalculation::openEclipseGridFile() { + if (m_rigEclipseCase.notNull()) return true; + cvf::ref eclipseCase = new RigEclipseCase; if (!m_readerInterface->open("dummy", eclipseCase.p())) @@ -115,25 +135,30 @@ RimStatisticalCollection* RimStatisticalCalculation::parent() //-------------------------------------------------------------------------------------------------- void RimStatisticalCalculation::computeStatistics() { - if (statisticsMin) + if (m_rigEclipseCase.isNull()) { - createAndComputeMin(); - } - - if (statisticsMax) - { - createAndComputeMax(); + openEclipseGridFile(); } - if (statisticsMean) + cvf::Collection sourceCases; + + getSourceCases(sourceCases); + + if (sourceCases.size() == 0) { - createAndComputeMean(); + return; } - if (statisticsStdDev) - { - createAndComputeStdDev(); - } + RigStatisticsConfig statisticsConfig; + + std::vector timeStepIndices; + timeStepIndices.push_back(0); + timeStepIndices.push_back(1); + + RigEclipseCase* resultCase = reservoirData(); + + RigStatistics stat(sourceCases, timeStepIndices, statisticsConfig, resultCase); + stat.evaluateStatistics(RimDefines::DYNAMIC_NATIVE, m_resultName); } //-------------------------------------------------------------------------------------------------- @@ -167,3 +192,50 @@ void RimStatisticalCalculation::createAndComputeStdDev() { } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimStatisticalCalculation::getSourceCases(cvf::Collection& sourceCases) +{ + RimIdenticalGridCaseGroup* gridCaseGroup = caseGroup(); + if (gridCaseGroup) + { + size_t caseCount = gridCaseGroup->caseCollection->reservoirs.size(); + for (size_t i = 0; i < caseCount; i++) + { + CVF_ASSERT(gridCaseGroup->caseCollection); + CVF_ASSERT(gridCaseGroup->caseCollection->reservoirs[i]); + CVF_ASSERT(gridCaseGroup->caseCollection->reservoirs[i]->reservoirData()); + + RigEclipseCase* sourceCase = gridCaseGroup->caseCollection->reservoirs[i]->reservoirData(); + sourceCases.push_back(sourceCase); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimIdenticalGridCaseGroup* RimStatisticalCalculation::caseGroup() +{ + RimStatisticalCollection* statColl = parent(); + if (statColl) + { + std::vector parentObjects; + statColl->parentObjects(parentObjects); + + RimIdenticalGridCaseGroup* gridCaseGroup = NULL; + for (size_t i = 0; i < parentObjects.size(); i++) + { + if (gridCaseGroup) continue; + + caf::PdmObject* obj = parentObjects[i]; + gridCaseGroup = dynamic_cast(obj); + } + + return gridCaseGroup; + } + + return NULL; +} diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h index ffdedd6205..84aec72d1d 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h @@ -29,6 +29,7 @@ class RimIdenticalGridCaseGroup; class RimResultDefinition; class RifReaderStatisticalCalculation; class RimStatisticalCollection; +class RigMainGrid; //================================================================================================== @@ -44,8 +45,12 @@ public: RimStatisticalCalculation(); virtual ~RimStatisticalCalculation(); + void setMainGrid(RigMainGrid* mainGrid); + virtual bool openEclipseGridFile(); + caf::PdmField m_resultName; + caf::PdmField statisticsMin; caf::PdmField statisticsMax; caf::PdmField statisticsMean; @@ -57,11 +62,16 @@ public: void computeStatistics(); private: + RimIdenticalGridCaseGroup* caseGroup(); + void createAndComputeMin(); void createAndComputeMax(); void createAndComputeMean(); void createAndComputeStdDev(); + void getSourceCases(cvf::Collection& sourceCases); + + private: cvf::ref m_readerInterface; diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCollection.cpp b/ApplicationCode/ProjectDataModel/RimStatisticalCollection.cpp index b67e4efdab..da22bc2b29 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCollection.cpp @@ -21,6 +21,7 @@ #include "RimReservoirView.h" #include "RimStatisticalCollection.h" +#include "RimIdenticalGridCaseGroup.h" CAF_PDM_SOURCE_INIT(RimStatisticalCollection, "RimStatisticalCollection"); @@ -34,8 +35,6 @@ RimStatisticalCollection::RimStatisticalCollection() CAF_PDM_InitObject("Derived Statistics", "", "", ""); CAF_PDM_InitFieldNoDefault(&reservoirs, "Reservoirs", "", "", "", ""); - - createAndAppendStatisticalCalculation(); } //-------------------------------------------------------------------------------------------------- @@ -52,6 +51,12 @@ RimStatisticalCollection::~RimStatisticalCollection() RimStatisticalCalculation* RimStatisticalCollection::createAndAppendStatisticalCalculation() { RimStatisticalCalculation* newObject = new RimStatisticalCalculation; + RimIdenticalGridCaseGroup* gridCaseGroup = parent(); + + CVF_ASSERT(gridCaseGroup); + CVF_ASSERT(gridCaseGroup->mainGrid()); + + newObject->setMainGrid(gridCaseGroup->mainGrid()); newObject->caseName = "Statistics 1"; @@ -59,3 +64,25 @@ RimStatisticalCalculation* RimStatisticalCollection::createAndAppendStatisticalC return newObject; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimIdenticalGridCaseGroup* RimStatisticalCollection::parent() +{ + std::vector parentObjects; + this->parentObjects(parentObjects); + + RimIdenticalGridCaseGroup* gridCaseGroup = NULL; + for (size_t i = 0; i < parentObjects.size(); i++) + { + if (gridCaseGroup) continue; + + caf::PdmObject* obj = parentObjects[i]; + gridCaseGroup = dynamic_cast(obj); + } + + return gridCaseGroup; + +} + diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCollection.h b/ApplicationCode/ProjectDataModel/RimStatisticalCollection.h index 728f467fbf..8b8d7c5eec 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCollection.h +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCollection.h @@ -44,6 +44,8 @@ public: RimStatisticalCalculation* createAndAppendStatisticalCalculation(); + RimIdenticalGridCaseGroup* parent(); + private: }; From a63c656a48a1def68662a1c9981cf6f25bff4638 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sat, 2 Mar 2013 15:33:27 +0100 Subject: [PATCH 069/242] Added RigStatistics p4#: 20695 --- .../ReservoirDataModel/CMakeLists_files.cmake | 2 + .../ReservoirDataModel/RigStatistics.cpp | 260 ++++++++++++++++++ .../ReservoirDataModel/RigStatistics.h | 147 ++++++++++ 3 files changed, 409 insertions(+) create mode 100644 ApplicationCode/ReservoirDataModel/RigStatistics.cpp create mode 100644 ApplicationCode/ReservoirDataModel/RigStatistics.h diff --git a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake index 5239d1e831..84b7d966db 100644 --- a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake @@ -16,6 +16,7 @@ ${CEE_CURRENT_LIST_DIR}RigLocalGrid.h ${CEE_CURRENT_LIST_DIR}RigMainGrid.h ${CEE_CURRENT_LIST_DIR}RigReservoirBuilderMock.h ${CEE_CURRENT_LIST_DIR}RigReservoirCellResults.h +${CEE_CURRENT_LIST_DIR}RigStatistics.h ${CEE_CURRENT_LIST_DIR}RigWellResults.h ) @@ -30,6 +31,7 @@ ${CEE_CURRENT_LIST_DIR}RigLocalGrid.cpp ${CEE_CURRENT_LIST_DIR}RigMainGrid.cpp ${CEE_CURRENT_LIST_DIR}RigReservoirBuilderMock.cpp ${CEE_CURRENT_LIST_DIR}RigReservoirCellResults.cpp +${CEE_CURRENT_LIST_DIR}RigStatistics.cpp ${CEE_CURRENT_LIST_DIR}RigWellResults.cpp ) diff --git a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp new file mode 100644 index 0000000000..68d58b36d6 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp @@ -0,0 +1,260 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 "RigStatistics.h" +#include "RigReservoirCellResults.h" + +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigStatistics::addNamedResult(RigReservoirCellResults* cellResults, RimDefines::ResultCatType resultType, const QString& resultName, size_t activeCellCount) +{ + size_t resultIndexMin = cellResults->addEmptyScalarResult(resultType, resultName); + std::vector< std::vector >& dataValues = cellResults->cellScalarResults(resultIndexMin); + dataValues.resize(m_timeStepIndices.size()); + + for (size_t i = 0; i < m_timeStepIndices.size(); i++) + { + dataValues[i].resize(activeCellCount, HUGE_VAL); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigStatistics::computeActiveCellUnion() +{ + // Early exit if active cell union is already computed + if (m_destinationCase->activeCellInfo()->globalFractureModelActiveCellCount() + + m_destinationCase->activeCellInfo()->globalFractureModelActiveCellCount() > 0) + { + return; + } + + std::vector activeM(m_globalCellCount, 0); + std::vector activeF(m_globalCellCount, 0); + + for (size_t cellIdx = 0; cellIdx < m_globalCellCount; cellIdx++) + { + for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++) + { + if (activeM[cellIdx] == 0) + { + if (m_sourceCases[caseIdx]->activeCellInfo()->isActiveInMatrixModel(cellIdx)) + { + activeM[cellIdx] = 1; + } + } + + if (activeF[cellIdx] == 0) + { + if (m_sourceCases[caseIdx]->activeCellInfo()->isActiveInFractureModel(cellIdx)) + { + activeF[cellIdx] = 1; + } + } + } + } + + m_destinationCase->activeCellInfo()->setGlobalCellCount(m_globalCellCount); + + size_t activeMIndex = 0; + size_t activeFIndex = 0; + + for (size_t cellIdx = 0; cellIdx < m_globalCellCount; cellIdx++) + { + if (activeM[cellIdx] != 0) + { + m_destinationCase->activeCellInfo()->setActiveIndexInMatrixModel(cellIdx, activeMIndex++); + } + + if (activeF[cellIdx] != 0) + { + m_destinationCase->activeCellInfo()->setActiveIndexInFractureModel(cellIdx, activeFIndex++); + } + } + + m_destinationCase->activeCellInfo()->computeDerivedData(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, const QString& resultName) +{ + CVF_ASSERT(m_destinationCase.notNull()); + + computeActiveCellUnion(); + + QString minResultName = resultName + "_MIN"; + QString maxResultName = resultName + "_MAX"; + QString meanResultName = resultName + "_MEAN"; + QString devResultName = resultName + "_DEV"; + + RigReservoirCellResults* matrixResults = m_destinationCase->results(RifReaderInterface::MATRIX_RESULTS); + + size_t activeMatrixCellCount = m_destinationCase->activeCellInfo()->globalMatrixModelActiveCellCount(); + if (activeMatrixCellCount > 0) + { + addNamedResult(matrixResults, resultType, minResultName, activeMatrixCellCount); + addNamedResult(matrixResults, resultType, maxResultName, activeMatrixCellCount); + addNamedResult(matrixResults, resultType, meanResultName, activeMatrixCellCount); + addNamedResult(matrixResults, resultType, devResultName, activeMatrixCellCount); + } + + if (activeMatrixCellCount > 0) + { + for (size_t timeIndicesIdx = 0; timeIndicesIdx < m_timeStepIndices.size(); timeIndicesIdx++) + { + size_t timeStepIdx = m_timeStepIndices[timeIndicesIdx]; + + size_t gridCount = 0; + for (size_t gridIdx = 0; gridIdx < m_destinationCase->gridCount(); gridIdx++) + { + RigGridBase* grid = m_destinationCase->grid(gridIdx); + + // Build data access objects for source scalar results + cvf::Collection dataAccesObjectList; + for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++) + { + RigEclipseCase* eclipseCase = m_sourceCases.at(caseIdx); + + size_t scalarResultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->findOrLoadScalarResult(resultName); + + cvf::ref dataAccessObject = eclipseCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); + if (dataAccessObject.notNull()) + { + dataAccesObjectList.push_back(dataAccessObject.p()); + } + } + + // Build data access objects form destination scalar results + cvf::ref dataAccessObjectMin = NULL; + cvf::ref dataAccessObjectMax = NULL; + cvf::ref dataAccessObjectMean = NULL; + cvf::ref dataAccessObjectDev = NULL; + + { + size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, minResultName); + if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) + { + dataAccessObjectMin = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); + } + } + + { + size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, maxResultName); + if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) + { + dataAccessObjectMax = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); + } + } + + { + size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, meanResultName); + if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) + { + dataAccessObjectMean = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); + } + } + + { + size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, devResultName); + if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) + { + dataAccessObjectDev = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); + } + } + + double min, max, mean, dev; + std::vector values(dataAccesObjectList.size(), HUGE_VAL); + for (size_t cellIdx = 0; cellIdx < grid->cellCount(); cellIdx++) + { + size_t globalGridCellIdx = grid->globalGridCellIndex(cellIdx); + if (m_destinationCase->activeCellInfo()->isActiveInMatrixModel(globalGridCellIdx)) + { + for (size_t caseIdx = 0; caseIdx < dataAccesObjectList.size(); caseIdx++) + { + double val = dataAccesObjectList.at(caseIdx)->cellScalar(cellIdx); + values[caseIdx] = val; + } + + RigStatisticsEvaluator stat(values); + stat.getStatistics(min, max, mean, dev); + + if (dataAccessObjectMin.notNull()) + { + dataAccessObjectMin->setCellScalar(cellIdx, min); + } + + if (dataAccessObjectMax.notNull()) + { + dataAccessObjectMax->setCellScalar(cellIdx, max); + } + + if (dataAccessObjectMean.notNull()) + { + dataAccessObjectMean->setCellScalar(cellIdx, mean); + } + + if (dataAccessObjectDev.notNull()) + { + dataAccessObjectDev->setCellScalar(cellIdx, dev); + } + } + } + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigStatistics::debugOutput(RimDefines::ResultCatType resultType, const QString& resultName, size_t timeStepIdx) +{ + qDebug() << resultName << "timeIdx : " << timeStepIdx; + + RigReservoirCellResults* matrixResults = m_destinationCase->results(RifReaderInterface::MATRIX_RESULTS); + size_t scalarResultIndex = m_destinationCase->results(RifReaderInterface::MATRIX_RESULTS)->findOrLoadScalarResult(resultName); + + cvf::ref dataAccessObject = m_destinationCase->dataAccessObject(m_destinationCase->mainGrid(), RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); + if (dataAccessObject.isNull()) return; + + for (size_t cellIdx = 0; cellIdx < m_globalCellCount; cellIdx++) + { + qDebug() << dataAccessObject->cellScalar(cellIdx); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigStatistics::RigStatistics(cvf::Collection& sourceCases, const std::vector& timeStepIndices, const RigStatisticsConfig& statisticsConfig, RigEclipseCase* destinationCase) : m_sourceCases(sourceCases), + m_statisticsConfig(statisticsConfig), + m_destinationCase(destinationCase), + m_globalCellCount(0), + m_timeStepIndices(timeStepIndices) +{ + if (sourceCases.size() > 0) + { + m_globalCellCount = sourceCases[0]->mainGrid()->cells().size(); + } +} diff --git a/ApplicationCode/ReservoirDataModel/RigStatistics.h b/ApplicationCode/ReservoirDataModel/RigStatistics.h new file mode 100644 index 0000000000..9ee3379694 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigStatistics.h @@ -0,0 +1,147 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 "cvfBase.h" +#include "cvfObject.h" +#include "cvfCollection.h" + +#include +#include "RigEclipseCase.h" + +class RigStatisticsEvaluator +{ +public: + RigStatisticsEvaluator(const std::vector& values) + : m_values(values), + m_min(HUGE_VAL), + m_max(-HUGE_VAL), + m_mean(cvf::UNDEFINED_DOUBLE), + m_dev(0.0) + { + } + + + void getStatistics(double& min, double& max, double& mean, double& dev) + { + evaluate(); + + min = m_min; + max = m_max; + mean = m_mean; + dev = m_dev; + } + +private: + void evaluate() + { + double sum = 0.0; + double sumSquared = 0.0; + + size_t validValueCount = 0; + + for (size_t i = 0; i < m_values.size(); i++) + { + double val = m_values[i]; + if (val == HUGE_VAL) continue; + + validValueCount++; + + if (val < m_min) m_min = val; + if (val > m_max) m_max = val; + + sum += val; + sumSquared += (val * val); + } + + if (validValueCount > 0) + { + m_mean = sum / validValueCount; + + + // http://en.wikipedia.org/wiki/Standard_deviation#Rapid_calculation_methods + // Running standard deviation + + double s0 = validValueCount; + double s1 = sum; + double s2 = sumSquared; + + m_dev = cvf::Math::sqrt( (s0 * s2) - (s1 * s1) ) / s0; + } + } + + +private: + const std::vector& m_values; + + double m_min; + double m_max; + double m_mean; + double m_dev; +}; + + + +class RigStatisticsConfig +{ +public: + RigStatisticsConfig() + : m_min(true), + m_max(true), + m_mean(true), + m_stdDev(true) + { + } + +public: + bool m_min; + bool m_max; + bool m_mean; + bool m_stdDev; +}; + + +class RigStatistics +{ +public: + RigStatistics(cvf::Collection& sourceCases, + const std::vector& timeStepIndices, + const RigStatisticsConfig& statisticsConfig, + RigEclipseCase* destinationCase); + + + void evaluateStatistics(RimDefines::ResultCatType resultType, const QString& resultName); + + void debugOutput(RimDefines::ResultCatType resultType, const QString& resultName, size_t timeStepIdx); + +private: + void computeActiveCellUnion(); + void addNamedResult(RigReservoirCellResults* cellResults, RimDefines::ResultCatType resultType, const QString& resultName, size_t activeCellCount); + +private: + cvf::Collection m_sourceCases; + std::vector m_timeStepIndices; + + size_t m_globalCellCount; + + RigStatisticsConfig m_statisticsConfig; + + cvf::ref m_destinationCase; +}; + From a6c9d9d0f025a173c2ce2e3c38a2762f944033a6 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sat, 2 Mar 2013 15:39:33 +0100 Subject: [PATCH 070/242] Linux fix p4#: 20696 --- ApplicationCode/ReservoirDataModel/RigStatistics.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ReservoirDataModel/RigStatistics.h b/ApplicationCode/ReservoirDataModel/RigStatistics.h index 9ee3379694..716bc36098 100644 --- a/ApplicationCode/ReservoirDataModel/RigStatistics.h +++ b/ApplicationCode/ReservoirDataModel/RigStatistics.h @@ -22,9 +22,11 @@ #include "cvfObject.h" #include "cvfCollection.h" -#include #include "RigEclipseCase.h" +#include +#include + class RigStatisticsEvaluator { public: From 7174049aed6971bc43d641b9f3a7aa5f0c1141ab Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 5 Mar 2013 08:34:45 +0100 Subject: [PATCH 071/242] Use time step dates from first source case when creating a statistical result p4#: 20713 --- .../ReservoirDataModel/RigStatistics.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp index 68d58b36d6..85901115e7 100644 --- a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp +++ b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp @@ -26,11 +26,17 @@ //-------------------------------------------------------------------------------------------------- void RigStatistics::addNamedResult(RigReservoirCellResults* cellResults, RimDefines::ResultCatType resultType, const QString& resultName, size_t activeCellCount) { - size_t resultIndexMin = cellResults->addEmptyScalarResult(resultType, resultName); - std::vector< std::vector >& dataValues = cellResults->cellScalarResults(resultIndexMin); - dataValues.resize(m_timeStepIndices.size()); + // Use time step dates from first result in first source case + CVF_ASSERT(m_sourceCases.size() > 0); + QList timeStepDates = m_sourceCases[0]->results(RifReaderInterface::PorosityModelResultType::MATRIX_RESULTS)->timeStepDates(0); - for (size_t i = 0; i < m_timeStepIndices.size(); i++) + size_t resultIndexMin = cellResults->addEmptyScalarResult(resultType, resultName); + cellResults->setTimeStepDates(resultIndexMin, timeStepDates); + + std::vector< std::vector >& dataValues = cellResults->cellScalarResults(resultIndexMin); + dataValues.resize(timeStepDates.size()); + + for (size_t i = 0; i < timeStepDates.size(); i++) { dataValues[i].resize(activeCellCount, HUGE_VAL); } From debb8e132f4c014c166ad9eac443c75a4d15cc26 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 5 Mar 2013 08:39:50 +0100 Subject: [PATCH 072/242] Linux fix p4#: 20715 --- ApplicationCode/ReservoirDataModel/RigStatistics.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp index 85901115e7..d0f375aa5d 100644 --- a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp +++ b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp @@ -28,7 +28,7 @@ void RigStatistics::addNamedResult(RigReservoirCellResults* cellResults, RimDefi { // Use time step dates from first result in first source case CVF_ASSERT(m_sourceCases.size() > 0); - QList timeStepDates = m_sourceCases[0]->results(RifReaderInterface::PorosityModelResultType::MATRIX_RESULTS)->timeStepDates(0); + QList timeStepDates = m_sourceCases[0]->results(RifReaderInterface::MATRIX_RESULTS)->timeStepDates(0); size_t resultIndexMin = cellResults->addEmptyScalarResult(resultType, resultName); cellResults->setTimeStepDates(resultIndexMin, timeStepDates); From 452b08db3a413da8c837c86637f35980821f6a38 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 5 Mar 2013 13:03:52 +0100 Subject: [PATCH 073/242] Added progress info p4#: 20755 --- .../ReservoirDataModel_UnitTests/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/CMakeLists.txt b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/CMakeLists.txt index b78efa2a45..d21c6599a9 100644 --- a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/CMakeLists.txt +++ b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/CMakeLists.txt @@ -29,6 +29,9 @@ include ("${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists_files.cmake") set( UNIT_TEST_CPP_SOURCES + + ${ResInsight_SOURCE_DIR}/cafUserInterface/cafProgressInfo.cpp + main.cpp RigActiveCellInfo-Test.cpp RigReservoir-Test.cpp From e94264a39f120158af821b31941eb1feed39d65e Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 5 Mar 2013 13:10:26 +0100 Subject: [PATCH 074/242] Added support for building of metadata from existing time steps Improved statistics calculation for opening single time step files Close all dynamic access files when a time step statistics is complete p4#: 20756 --- ApplicationCode/Application/RIApplication.cpp | 11 +- .../RifEclipseRestartDataAccess.h | 2 + .../RifEclipseRestartFilesetAccess.cpp | 66 +++++----- .../RifEclipseRestartFilesetAccess.h | 3 + .../FileInterface/RifReaderEclipseOutput.cpp | 114 +++++++++--------- .../FileInterface/RifReaderEclipseOutput.h | 7 +- .../FileInterface/RifReaderInterface.h | 5 +- .../ProjectDataModel/RimResultReservoir.cpp | 8 +- .../ProjectDataModel/RimResultReservoir.h | 2 +- .../RimStatisticalCalculation.cpp | 8 +- .../ReservoirDataModel/RigEclipseCase.cpp | 13 ++ .../ReservoirDataModel/RigEclipseCase.h | 3 +- .../RigReservoirCellResults.cpp | 77 +++++++++++- .../RigReservoirCellResults.h | 2 + .../ReservoirDataModel/RigStatistics.cpp | 46 ++++++- .../ReservoirDataModel/RigStatistics.h | 2 +- 16 files changed, 264 insertions(+), 105 deletions(-) diff --git a/ApplicationCode/Application/RIApplication.cpp b/ApplicationCode/Application/RIApplication.cpp index 49ae37aba0..19cfe414e4 100644 --- a/ApplicationCode/Application/RIApplication.cpp +++ b/ApplicationCode/Application/RIApplication.cpp @@ -55,6 +55,7 @@ #include "RimUiTreeModelPdm.h" #include "RiaImageCompareReporter.h" #include "RiaImageFileCompare.h" +#include "cafProgressInfo.h" namespace caf { @@ -1305,7 +1306,7 @@ bool RIApplication::addEclipseCases(const QStringList& fileNames) // First file is read completely including grid. // The main grid from the first case is reused directly in for the other cases. // When reading active cell info, only the total cell count is tested for consistency - RigMainGrid* mainGrid = NULL; + RigEclipseCase* mainEclipseCase = NULL; { QString firstFileName = fileNames[0]; @@ -1328,9 +1329,11 @@ bool RIApplication::addEclipseCases(const QStringList& fileNames) m_project->moveEclipseCaseIntoCaseGroup(rimResultReservoir); - mainGrid = rimResultReservoir->reservoirData()->mainGrid(); + mainEclipseCase = rimResultReservoir->reservoirData(); } + caf::ProgressInfo info(fileNames.size(), "Reading Active Cell data"); + for (int i = 1; i < fileNames.size(); i++) { QString fileName = fileNames[i]; @@ -1346,12 +1349,14 @@ bool RIApplication::addEclipseCases(const QStringList& fileNames) m_project->reservoirs.push_back(rimResultReservoir); - if (!rimResultReservoir->openAndReadActiveCellData(mainGrid)) + if (!rimResultReservoir->openAndReadActiveCellData(mainEclipseCase)) { return false; } m_project->moveEclipseCaseIntoCaseGroup(rimResultReservoir); + + info.setProgress(i); } onProjectOpenedOrClosed(); diff --git a/ApplicationCode/FileInterface/RifEclipseRestartDataAccess.h b/ApplicationCode/FileInterface/RifEclipseRestartDataAccess.h index 25cf515ee0..44779337b9 100644 --- a/ApplicationCode/FileInterface/RifEclipseRestartDataAccess.h +++ b/ApplicationCode/FileInterface/RifEclipseRestartDataAccess.h @@ -43,8 +43,10 @@ public: virtual ~RifEclipseRestartDataAccess(); virtual bool open(const QStringList& fileSet) = 0; + virtual void setFileSet(const QStringList& fileSet) {}; virtual void close() = 0; + virtual void setTimeSteps(const QList& timeSteps) {}; virtual size_t timeStepCount() = 0; virtual QList timeSteps() = 0; diff --git a/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp b/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp index c8254c63a6..c3074443ce 100644 --- a/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp +++ b/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp @@ -42,20 +42,19 @@ RifEclipseRestartFilesetAccess::~RifEclipseRestartFilesetAccess() //-------------------------------------------------------------------------------------------------- bool RifEclipseRestartFilesetAccess::open(const QStringList& fileSet) { - setFileSet(fileSet); - - int numFiles = fileSet.size(); - - caf::ProgressInfo progInfo(numFiles,""); - - int i; - for (i = 0; i < numFiles; i++) + if (m_fileNames.size() > 0) { - progInfo.setProgressDescription(fileSet[i]); + caf::ProgressInfo progInfo(m_fileNames.size(), ""); - openTimeStep(i); + int i; + for (i = 0; i < m_fileNames.size(); i++) + { + progInfo.setProgressDescription(m_fileNames[i]); - progInfo.incrementProgress(); + openTimeStep(i); + + progInfo.incrementProgress(); + } } return true; @@ -95,12 +94,21 @@ void RifEclipseRestartFilesetAccess::close() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifEclipseRestartFilesetAccess::setTimeSteps(const QList& timeSteps) +{ + CVF_ASSERT(m_fileNames.size() == timeSteps.size()); + m_timeSteps = timeSteps; +} + //-------------------------------------------------------------------------------------------------- /// Get the number of time steps //-------------------------------------------------------------------------------------------------- size_t RifEclipseRestartFilesetAccess::timeStepCount() { - return m_ecl_files.size(); + return m_timeSteps.size(); } //-------------------------------------------------------------------------------------------------- @@ -108,29 +116,31 @@ size_t RifEclipseRestartFilesetAccess::timeStepCount() //-------------------------------------------------------------------------------------------------- QList RifEclipseRestartFilesetAccess::timeSteps() { - QList timeSteps; - - size_t numSteps = timeStepCount(); - size_t i; - for (i = 0; i < numSteps; i++) + if (m_timeSteps.size() == 0) { - QList stepTime; + size_t numSteps = m_fileNames.size(); + size_t i; + for (i = 0; i < numSteps; i++) + { + QList stepTime; - openTimeStep(i); + openTimeStep(i); - RifEclipseOutputFileTools::timeSteps(m_ecl_files[i], &stepTime); + RifEclipseOutputFileTools::timeSteps(m_ecl_files[i], &stepTime); - if (stepTime.size() == 1) - { - timeSteps.push_back(stepTime[0]); - } - else - { - timeSteps.push_back(QDateTime()); + if (stepTime.size() == 1) + { + m_timeSteps.push_back(stepTime[0]); + } + else + { + m_timeSteps.push_back(QDateTime()); + } } + } - return timeSteps; + return m_timeSteps; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.h b/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.h index 44acf9e013..d332cea65c 100644 --- a/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.h +++ b/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.h @@ -39,6 +39,7 @@ public: void setFileSet(const QStringList& fileSet); void close(); + void setTimeSteps(const QList& timeSteps); size_t timeStepCount(); QList timeSteps(); @@ -52,5 +53,7 @@ private: private: QStringList m_fileNames; + QList m_timeSteps; + std::vector< ecl_file_type* > m_ecl_files; }; diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index 3a703fb8e6..59bdc86b87 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -392,7 +392,7 @@ bool RifReaderEclipseOutput::open(const QString& fileName, RigEclipseCase* eclip //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifReaderEclipseOutput::openAndReadActiveCellData(const QString& fileName, RigEclipseCase* eclipseCase) +bool RifReaderEclipseOutput::openAndReadActiveCellData(const QString& fileName, RigEclipseCase* mainEclipseCase, RigEclipseCase* eclipseCase) { CVF_ASSERT(eclipseCase); @@ -402,8 +402,6 @@ bool RifReaderEclipseOutput::openAndReadActiveCellData(const QString& fileName, return false; } - caf::ProgressInfo progInfo(100, ""); - close(); // Get set of files @@ -417,23 +415,21 @@ bool RifReaderEclipseOutput::openAndReadActiveCellData(const QString& fileName, eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(this); eclipseCase->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(this); - progInfo.setNextProgressIncrement(50); - progInfo.setProgressDescription("Reading active cell information"); - if (!readActiveCellInfo()) { return false; } - progInfo.incrementProgress(); - - progInfo.setNextProgressIncrement(50); - progInfo.setProgressDescription("Reading meta data"); // Reading of metadata and well cells is not performed here //if (!buildMetaData()) return false; // readWellCells(); + m_dynamicResultsAccess = createDynamicResultsAccess(m_fileSet); + + QList mainCaseTimeSteps = mainEclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->readerInterface()->timeSteps(); + m_dynamicResultsAccess->setTimeSteps(mainCaseTimeSteps); + return true; } @@ -528,12 +524,14 @@ bool RifReaderEclipseOutput::buildMetaData() progInfo.setNextProgressIncrement(m_fileSet.size()); // Create access object for dynamic results - m_dynamicResultsAccess = dynamicResultsAccess(m_fileSet); + m_dynamicResultsAccess = createDynamicResultsAccess(m_fileSet); if (m_dynamicResultsAccess.isNull()) { return false; } + m_dynamicResultsAccess->open(m_fileSet); + progInfo.incrementProgress(); @@ -573,46 +571,46 @@ bool RifReaderEclipseOutput::buildMetaData() progInfo.incrementProgress(); - if (!openInitFile()) - { - return false; - } + openInitFile(); progInfo.incrementProgress(); - QStringList resultNames; - std::vector resultNamesDataItemCounts; - RifEclipseOutputFileTools::findKeywordsAndDataItemCounts(m_ecl_init_file, &resultNames, &resultNamesDataItemCounts); - + if (m_ecl_init_file) { - QStringList matrixResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, m_eclipseCase->activeCellInfo(), RifReaderInterface::MATRIX_RESULTS, 1); + QStringList resultNames; + std::vector resultNamesDataItemCounts; + RifEclipseOutputFileTools::findKeywordsAndDataItemCounts(m_ecl_init_file, &resultNames, &resultNamesDataItemCounts); - QList staticDate; - if (m_timeSteps.size() > 0) { - staticDate.push_back(m_timeSteps.front()); + QStringList matrixResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, m_eclipseCase->activeCellInfo(), RifReaderInterface::MATRIX_RESULTS, 1); + + QList staticDate; + if (m_timeSteps.size() > 0) + { + staticDate.push_back(m_timeSteps.front()); + } + + for (int i = 0; i < matrixResultNames.size(); ++i) + { + size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, matrixResultNames[i]); + matrixModelResults->setTimeStepDates(resIndex, staticDate); + } } - for (int i = 0; i < matrixResultNames.size(); ++i) { - size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, matrixResultNames[i]); - matrixModelResults->setTimeStepDates(resIndex, staticDate); - } - } + QStringList fractureResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, m_eclipseCase->activeCellInfo(), RifReaderInterface::FRACTURE_RESULTS, 1); - { - QStringList fractureResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, m_eclipseCase->activeCellInfo(), RifReaderInterface::FRACTURE_RESULTS, 1); + QList staticDate; + if (m_timeSteps.size() > 0) + { + staticDate.push_back(m_timeSteps.front()); + } - QList staticDate; - if (m_timeSteps.size() > 0) - { - staticDate.push_back(m_timeSteps.front()); - } - - for (int i = 0; i < fractureResultNames.size(); ++i) - { - size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, fractureResultNames[i]); - fractureModelResults->setTimeStepDates(resIndex, staticDate); + for (int i = 0; i < fractureResultNames.size(); ++i) + { + size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, fractureResultNames[i]); + fractureModelResults->setTimeStepDates(resIndex, staticDate); + } } } @@ -622,7 +620,7 @@ bool RifReaderEclipseOutput::buildMetaData() //-------------------------------------------------------------------------------------------------- /// Create results access object (.UNRST or .X0001 ... .XNNNN) //-------------------------------------------------------------------------------------------------- -RifEclipseRestartDataAccess* RifReaderEclipseOutput::dynamicResultsAccess(const QStringList& fileSet) +RifEclipseRestartDataAccess* RifReaderEclipseOutput::createDynamicResultsAccess(const QStringList& fileSet) { RifEclipseRestartDataAccess* resultsAccess = NULL; @@ -631,11 +629,7 @@ RifEclipseRestartDataAccess* RifReaderEclipseOutput::dynamicResultsAccess(const if (unrstFileName.size() > 0) { resultsAccess = new RifEclipseUnifiedRestartFileAccess(); - if (!resultsAccess->open(QStringList(unrstFileName))) - { - delete resultsAccess; - return NULL; - } + resultsAccess->setFileSet(QStringList(unrstFileName)); } else { @@ -644,17 +638,10 @@ RifEclipseRestartDataAccess* RifReaderEclipseOutput::dynamicResultsAccess(const if (restartFiles.size() > 0) { resultsAccess = new RifEclipseRestartFilesetAccess(); - if (!resultsAccess->open(restartFiles)) - { - delete resultsAccess; - return NULL; - } + resultsAccess->setFileSet(restartFiles); } } - // !! could add support for formatted result files - // !! consider priorities in case multiple types exist (.UNRST, .XNNNN, ...) - return resultsAccess; } @@ -693,7 +680,16 @@ bool RifReaderEclipseOutput::staticResult(const QString& result, PorosityModelRe //-------------------------------------------------------------------------------------------------- bool RifReaderEclipseOutput::dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector* values) { - CVF_ASSERT(m_dynamicResultsAccess.notNull()); + if (m_dynamicResultsAccess.isNull()) + { + m_dynamicResultsAccess = createDynamicResultsAccess(m_fileSet); + } + + if (m_dynamicResultsAccess.isNull()) + { + CVF_ASSERT(false); + return false; + } std::vector fileValues; if (!m_dynamicResultsAccess->results(result, stepIndex, m_eclipseCase->mainGrid()->gridCount(), &fileValues)) @@ -1020,3 +1016,11 @@ bool RifReaderEclipseOutput::openInitFile() return false; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RifReaderEclipseOutput::timeSteps() +{ + return m_timeSteps; +} + diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.h b/ApplicationCode/FileInterface/RifReaderEclipseOutput.h index 3b17858db8..e69781b20f 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.h +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.h @@ -44,7 +44,7 @@ public: virtual ~RifReaderEclipseOutput(); bool open(const QString& fileName, RigEclipseCase* eclipseCase); - virtual bool openAndReadActiveCellData(const QString& fileName, RigEclipseCase* eclipseCase); + virtual bool openAndReadActiveCellData(const QString& fileName, RigEclipseCase* mainEclipseCase, RigEclipseCase* eclipseCase); void close(); bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector* values); @@ -58,14 +58,15 @@ private: void readWellCells(); bool openInitFile(); + bool openDynamicAccess(); void extractResultValuesBasedOnPorosityModel(PorosityModelResultType matrixOrFracture, std::vector* values, const std::vector& fileValues); - static RifEclipseRestartDataAccess* staticResultsAccess(const QStringList& fileSet); - static RifEclipseRestartDataAccess* dynamicResultsAccess(const QStringList& fileSet); + static RifEclipseRestartDataAccess* createDynamicResultsAccess(const QStringList& fileSet); QStringList validKeywordsForPorosityModel(const QStringList& keywords, const std::vector& keywordDataItemCounts, const RigActiveCellInfo* activeCellInfo, PorosityModelResultType matrixOrFracture, size_t timeStepCount) const; + virtual QList timeSteps(); private: QString m_fileName; // Name of file used to start accessing Eclipse output files QStringList m_fileSet; // Set of files in filename's path with same base name as filename diff --git a/ApplicationCode/FileInterface/RifReaderInterface.h b/ApplicationCode/FileInterface/RifReaderInterface.h index 66c18b1c45..2848aa363d 100644 --- a/ApplicationCode/FileInterface/RifReaderInterface.h +++ b/ApplicationCode/FileInterface/RifReaderInterface.h @@ -24,6 +24,7 @@ #include #include +#include class RigEclipseCase; @@ -47,9 +48,11 @@ public: virtual ~RifReaderInterface() {} virtual bool open(const QString& fileName, RigEclipseCase* eclipseCase) = 0; - virtual bool openAndReadActiveCellData(const QString& fileName, RigEclipseCase* eclipseCase) { return true; }; + virtual bool openAndReadActiveCellData(const QString& fileName, RigEclipseCase* mainEclipseCase, RigEclipseCase* eclipseCase) { return true; }; virtual void close() = 0; virtual bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector* values) = 0; virtual bool dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector* values) = 0; + + virtual QList timeSteps() { QList timeSteps; return timeSteps; } }; diff --git a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp index 6bece89bf8..69d1d04d6c 100644 --- a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp @@ -93,7 +93,7 @@ bool RimResultReservoir::openEclipseGridFile() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimResultReservoir::openAndReadActiveCellData(RigMainGrid* mainGrid) +bool RimResultReservoir::openAndReadActiveCellData(RigEclipseCase* mainEclipseCase) { cvf::ref readerInterface; @@ -113,10 +113,12 @@ bool RimResultReservoir::openAndReadActiveCellData(RigMainGrid* mainGrid) } cvf::ref eclipseCase = new RigEclipseCase; - eclipseCase->setMainGrid(mainGrid); + + CVF_ASSERT(mainEclipseCase && mainEclipseCase->mainGrid()); + eclipseCase->setMainGrid(mainEclipseCase->mainGrid()); readerInterface = new RifReaderEclipseOutput; - if (!readerInterface->openAndReadActiveCellData(fname, eclipseCase.p())) + if (!readerInterface->openAndReadActiveCellData(fname, mainEclipseCase, eclipseCase.p())) { return false; } diff --git a/ApplicationCode/ProjectDataModel/RimResultReservoir.h b/ApplicationCode/ProjectDataModel/RimResultReservoir.h index 31d5f8fe26..a97f141e11 100644 --- a/ApplicationCode/ProjectDataModel/RimResultReservoir.h +++ b/ApplicationCode/ProjectDataModel/RimResultReservoir.h @@ -46,7 +46,7 @@ public: caf::PdmField caseDirectory; virtual bool openEclipseGridFile(); - bool openAndReadActiveCellData(RigMainGrid* mainGrid); + bool openAndReadActiveCellData(RigEclipseCase* mainEclipseCase); //virtual caf::PdmFieldHandle* userDescriptionField() { return &caseName;} diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp index bd9c8d43fd..7045832b0f 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp @@ -152,8 +152,12 @@ void RimStatisticalCalculation::computeStatistics() RigStatisticsConfig statisticsConfig; std::vector timeStepIndices; - timeStepIndices.push_back(0); - timeStepIndices.push_back(1); + + size_t timeStepCount = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->maxTimeStepCount(); + for (size_t i = 0; i < timeStepCount; i++) + { + timeStepIndices.push_back(i); + } RigEclipseCase* resultCase = reservoirData(); diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp index 30d7322de1..474c5d0cc4 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp @@ -408,3 +408,16 @@ cvf::ref RigEclipseCase::dataAccessObject(const return NULL; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigEclipseCase::closeReaderInterface() +{ + RifReaderInterface* readerInterface = m_matrixModelResults->readerInterface(); + + if (readerInterface) + { + readerInterface->close(); + } +} diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCase.h b/ApplicationCode/ReservoirDataModel/RigEclipseCase.h index 73836cdbf1..c188179e68 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCase.h +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCase.h @@ -48,6 +48,8 @@ public: RigReservoirCellResults* results(RifReaderInterface::PorosityModelResultType porosityModel); const RigReservoirCellResults* results(RifReaderInterface::PorosityModelResultType porosityModel) const; + + void closeReaderInterface(); cvf::ref dataAccessObject(const RigGridBase* grid, RifReaderInterface::PorosityModelResultType porosityModel, @@ -74,7 +76,6 @@ private: void computeWellCellsPrGrid(); void computeActiveCellsGeometryBoundingBox(); - private: RigActiveCellInfo m_activeCellInfo; diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp index cba54355e6..185f4ca982 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp @@ -268,6 +268,61 @@ double RigReservoirCellResults::cellScalarResult( size_t scalarResultIndex, size } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigReservoirCellResults::findOrLoadScalarResultForTimeStep(RimDefines::ResultCatType type, const QString& resultName, size_t timeStepIndex) +{ + size_t resultGridIndex = cvf::UNDEFINED_SIZE_T; + + resultGridIndex = findScalarResultIndex(type, resultName); + + if (resultGridIndex == cvf::UNDEFINED_SIZE_T) return cvf::UNDEFINED_SIZE_T; + + if (type == RimDefines::GENERATED) + { + return cvf::UNDEFINED_SIZE_T; + } + + if (m_readerInterface.notNull()) + { + // Add one more result to result container + size_t timeStepCount = m_resultInfos[resultGridIndex].m_timeStepDates.size(); + + bool resultLoadingSucess = true; + + if (type == RimDefines::DYNAMIC_NATIVE && timeStepCount > 0) + { + std::vector& values = m_cellScalarResults[resultGridIndex][timeStepIndex]; + if (values.size() == 0) + { + if (!m_readerInterface->dynamicResult(resultName, RifReaderInterface::MATRIX_RESULTS, timeStepIndex, &values)) + { + resultLoadingSucess = false; + } + } + } + else if (type == RimDefines::STATIC_NATIVE) + { + std::vector& values = m_cellScalarResults[resultGridIndex][0]; + if (!m_readerInterface->staticResult(resultName, RifReaderInterface::MATRIX_RESULTS, &values)) + { + resultLoadingSucess = false; + } + } + + if (!resultLoadingSucess) + { + // Error logging + CVF_ASSERT(false); + } + } + + return resultGridIndex; + +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -336,6 +391,15 @@ void RigReservoirCellResults::setReaderInterface(RifReaderInterface* readerInter m_readerInterface = readerInterface; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifReaderInterface* RigReservoirCellResults::readerInterface() +{ + return m_readerInterface.p(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -697,12 +761,15 @@ void RigReservoirCellResults::setTimeStepDates(size_t scalarResultIndex, const Q //-------------------------------------------------------------------------------------------------- size_t RigReservoirCellResults::maxTimeStepCount() const { - size_t maxTsCount = 0; - for (size_t i = 0; i < m_cellScalarResults.size(); ++i) + int maxTsCount = 0; + + std::vector::const_iterator it; + for (it = m_resultInfos.begin(); it != m_resultInfos.end(); it++) { - maxTsCount = m_cellScalarResults[i].size() > maxTsCount ? m_cellScalarResults[i].size() : maxTsCount; - } - return maxTsCount; + maxTsCount = it->m_timeStepDates.size() > maxTsCount ? it->m_timeStepDates.size() : maxTsCount; + } + + return static_cast(maxTsCount); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h index bdf2b8d223..2673a5fb05 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h +++ b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h @@ -36,6 +36,7 @@ public: RigReservoirCellResults(RigMainGrid* ownerGrid); void setReaderInterface(RifReaderInterface* readerInterface); + RifReaderInterface* readerInterface(); // Max and min values of the results void recalculateMinMax(size_t scalarResultIndex); @@ -57,6 +58,7 @@ public: void setTimeStepDates(size_t scalarResultIndex, const QList& dates); // Find or create a slot for the results + size_t findOrLoadScalarResultForTimeStep(RimDefines::ResultCatType type, const QString& resultName, size_t timeStepIndex); size_t findOrLoadScalarResult(RimDefines::ResultCatType type, const QString& resultName); size_t findOrLoadScalarResult(const QString& resultName); ///< Simplified search. Assumes unique names across types. size_t findScalarResultIndex(RimDefines::ResultCatType type, const QString& resultName) const; diff --git a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp index d0f375aa5d..21455ce8c3 100644 --- a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp +++ b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp @@ -20,6 +20,7 @@ #include "RigReservoirCellResults.h" #include +#include "cafProgressInfo.h" //-------------------------------------------------------------------------------------------------- /// @@ -36,7 +37,7 @@ void RigStatistics::addNamedResult(RigReservoirCellResults* cellResults, RimDefi std::vector< std::vector >& dataValues = cellResults->cellScalarResults(resultIndexMin); dataValues.resize(timeStepDates.size()); - for (size_t i = 0; i < timeStepDates.size(); i++) + for (int i = 0; i < timeStepDates.size(); i++) { dataValues[i].resize(activeCellCount, HUGE_VAL); } @@ -109,6 +110,8 @@ void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, con computeActiveCellUnion(); + buildSourceMetaData(resultType, resultName); + QString minResultName = resultName + "_MIN"; QString maxResultName = resultName + "_MAX"; QString meanResultName = resultName + "_MEAN"; @@ -127,6 +130,8 @@ void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, con if (activeMatrixCellCount > 0) { + caf::ProgressInfo info(m_timeStepIndices.size(), "Computing Statistics"); + for (size_t timeIndicesIdx = 0; timeIndicesIdx < m_timeStepIndices.size(); timeIndicesIdx++) { size_t timeStepIdx = m_timeStepIndices[timeIndicesIdx]; @@ -142,7 +147,7 @@ void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, con { RigEclipseCase* eclipseCase = m_sourceCases.at(caseIdx); - size_t scalarResultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->findOrLoadScalarResult(resultName); + size_t scalarResultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->findOrLoadScalarResultForTimeStep(resultType, resultName, timeStepIdx); cvf::ref dataAccessObject = eclipseCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); if (dataAccessObject.notNull()) @@ -227,6 +232,19 @@ void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, con } } } + + for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++) + { + RigEclipseCase* eclipseCase = m_sourceCases.at(caseIdx); + + // When one time step is completed, close all result files. + // Microsoft note: On Windows, the maximum number of files open at the same time is 512 + // http://msdn.microsoft.com/en-us/library/kdfaxaay%28vs.71%29.aspx + // + eclipseCase->closeReaderInterface(); + } + + info.setProgress(timeIndicesIdx); } } } @@ -264,3 +282,27 @@ RigStatistics::RigStatistics(cvf::Collection& sourceCases, const m_globalCellCount = sourceCases[0]->mainGrid()->cells().size(); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigStatistics::buildSourceMetaData(RimDefines::ResultCatType resultType, const QString& resultName) +{ + for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++) + { + RigEclipseCase* eclipseCase = m_sourceCases.at(caseIdx); + + RigReservoirCellResults* matrixResults = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS); + size_t scalarResultIndex = matrixResults->findOrLoadScalarResult(resultType, resultName); + if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) + { + QList timeStepDates = m_sourceCases[0]->results(RifReaderInterface::MATRIX_RESULTS)->timeStepDates(0); + + size_t scalarResultIndex = matrixResults->addEmptyScalarResult(resultType, resultName); + matrixResults->setTimeStepDates(scalarResultIndex, timeStepDates); + + std::vector< std::vector >& dataValues = matrixResults->cellScalarResults(scalarResultIndex); + dataValues.resize(timeStepDates.size()); + } + } +} diff --git a/ApplicationCode/ReservoirDataModel/RigStatistics.h b/ApplicationCode/ReservoirDataModel/RigStatistics.h index 716bc36098..b3fb935d06 100644 --- a/ApplicationCode/ReservoirDataModel/RigStatistics.h +++ b/ApplicationCode/ReservoirDataModel/RigStatistics.h @@ -135,7 +135,7 @@ public: private: void computeActiveCellUnion(); void addNamedResult(RigReservoirCellResults* cellResults, RimDefines::ResultCatType resultType, const QString& resultName, size_t activeCellCount); - + void buildSourceMetaData( RimDefines::ResultCatType resultType, const QString& resultName ); private: cvf::Collection m_sourceCases; std::vector m_timeStepIndices; From e0688008ca0e3cdeb9b13218006cd7f3e2793428 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 5 Mar 2013 13:26:28 +0100 Subject: [PATCH 075/242] Added a multi case import dialog p4#: 20758 --- ApplicationCode/CMakeLists.txt | 13 +- .../UserInterface/RIMainWindow.cpp | 55 +---- .../RiuMultiCaseImportDialog.cpp | 202 ++++++++++++++++++ .../UserInterface/RiuMultiCaseImportDialog.h | 56 +++++ .../UserInterface/RiuMultiCaseImportDialog.ui | 186 ++++++++++++++++ 5 files changed, 462 insertions(+), 50 deletions(-) create mode 100644 ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp create mode 100644 ApplicationCode/UserInterface/RiuMultiCaseImportDialog.h create mode 100644 ApplicationCode/UserInterface/RiuMultiCaseImportDialog.ui diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index dedf4dd2ba..10e2d226ce 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -20,6 +20,7 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel ${CMAKE_CURRENT_SOURCE_DIR}/ReservoirDataModel ${CMAKE_BINARY_DIR}/Generated + ${CMAKE_CURRENT_BINARY_DIR} ) @@ -100,7 +101,7 @@ list( APPEND CPP_SOURCES UserInterface/RIResultInfoPanel.cpp UserInterface/RIViewer.cpp UserInterface/RiuSimpleHistogramWidget.cpp - + UserInterface/RiuMultiCaseImportDialog.cpp UserInterface/RIProcessMonitor.cpp ) @@ -118,10 +119,18 @@ set ( QT_MOC_HEADERS UserInterface/RIViewer.h UserInterface/RIProcessMonitor.h SocketInterface/RiaSocketServer.h + UserInterface/RiuMultiCaseImportDialog.h ) qt4_wrap_cpp( MOC_FILES_CPP ${QT_MOC_HEADERS} ) +# Define files for the uic compiler +set ( QT_UI_FILES + UserInterface/RiuMultiCaseImportDialog.ui +) + +qt4_wrap_ui( FORM_FILES_CPP ${QT_UI_FILES} ) + # NOTE! Resources in subfolders must append to QRC_FILES using the following statement # set( QRC_FILES # ${QRC_FILES} @@ -165,6 +174,7 @@ list( REMOVE_ITEM RAW_SOURCES FileInterface/RifReaderEclipseInput.cpp FileInterface/RifReaderEclipseOutput.cpp UserInterface/RiuSimpleHistogramWidget.cpp + UserInterface/RiuMultiCaseImportDialog.cpp ) @@ -194,6 +204,7 @@ precompiled_header( RAW_SOURCES ALL_INCLUDES ${GCC_PCH_TARGET} ${PCH_NAME} ${PCH add_executable(ResInsight ${CPP_SOURCES} ${MOC_FILES_CPP} + ${FORM_FILES_CPP} ${QRC_FILES_CPP} ${HEADER_FILES} ) diff --git a/ApplicationCode/UserInterface/RIMainWindow.cpp b/ApplicationCode/UserInterface/RIMainWindow.cpp index 9012fca5fc..354f8dce7a 100644 --- a/ApplicationCode/UserInterface/RIMainWindow.cpp +++ b/ApplicationCode/UserInterface/RIMainWindow.cpp @@ -40,6 +40,7 @@ #include "cafPdmUiPropertyView.h" #include "RimUiTreeView.h" +#include "RiuMultiCaseImportDialog.h" @@ -1255,45 +1256,6 @@ void RIMainWindow::hideAllDockWindows() } -void appendEGRIDFilesRecursively(const QString& folderName, QStringList& gridFileNames) -{ - { - QDir baseDir(folderName); - baseDir.setFilter(QDir::Files); - - QStringList nameFilters; - nameFilters << "*.egrid" << ".EGRID"; - baseDir.setNameFilters(nameFilters); - - QStringList fileNames = baseDir.entryList(); - - for (int i = 0; i < fileNames.size(); ++i) - { - QString fileName = fileNames[i]; - - QString absoluteFolderName = baseDir.absoluteFilePath(fileName); - - gridFileNames.append(absoluteFolderName); - } - } - - - { - QDir baseDir(folderName); - baseDir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); - - QStringList subFolders = baseDir.entryList(); - - for (int i = 0; i < subFolders.size(); ++i) - { - QString folderName = subFolders[i]; - - QString absoluteFolderName = baseDir.absoluteFilePath(folderName); - appendEGRIDFilesRecursively(absoluteFolderName, gridFileNames); - } - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1301,16 +1263,11 @@ void RIMainWindow::slotOpenMultipleCases() { RIApplication* app = RIApplication::instance(); - - QStringList folderNames; - QStringList gridFileNames; - - for (int i = 0; i < folderNames.size(); i++) + RiuMultiCaseImportDialog dialog; + int action = dialog.exec(); + if (action == QDialog::Accepted) { - QString fileName = folderNames[i]; - - appendEGRIDFilesRecursively(fileName, gridFileNames); + QStringList gridFileNames = dialog.eclipseCaseFileNames(); + app->addEclipseCases(gridFileNames); } - - app->addEclipseCases(gridFileNames); } diff --git a/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp b/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp new file mode 100644 index 0000000000..283b1bf56c --- /dev/null +++ b/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp @@ -0,0 +1,202 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 "RiuMultiCaseImportDialog.h" +#include "ui_RiuMultiCaseImportDialog.h" +#include +#include +#include +#include + +class FileListModel: public QStringListModel +{ +public: + FileListModel(QObject *parent = 0) : m_isItemsEditable(false), QStringListModel(parent) + { + } + + virtual Qt::ItemFlags flags (const QModelIndex& index) const + { + if (m_isItemsEditable) + return Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsEditable; + else + return Qt::ItemIsSelectable | Qt::ItemIsEnabled; + } + + virtual QVariant data ( const QModelIndex & index, int role ) const + { + if (role == Qt::DecorationRole) + { + QFileInfo fileInfo(stringList()[index.row()]); + QFileIconProvider iconProv; + return QVariant(iconProv.icon(fileInfo)); + } + else + { + return QStringListModel::data(index, role); + } + } + + + void setItemsEditable(bool isEditable) + { + m_isItemsEditable = isEditable; + } + +private: + bool m_isItemsEditable; +}; + + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuMultiCaseImportDialog::RiuMultiCaseImportDialog(QWidget *parent /*= 0*/) + : QDialog(parent) +{ + ui = new Ui::RiuMultiCaseImportDialog; + ui->setupUi(this); + + m_searchFolders = new FileListModel(this); + ui->m_searchFolderList->setModel(m_searchFolders); + + m_eclipseGridFiles = new FileListModel(this); + ui->m_eclipseCasesList->setModel(m_eclipseGridFiles); + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuMultiCaseImportDialog::~RiuMultiCaseImportDialog() +{ + delete ui; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMultiCaseImportDialog::on_m_addSearchFolderButton_clicked() +{ + QString selectedFolder = QFileDialog::getExistingDirectory(this, "Select an Eclipse case search folder" ); + QStringList folderNames = m_searchFolders->stringList(); + if (!folderNames.contains(selectedFolder)) + { + folderNames.push_back(selectedFolder); + m_searchFolders->setStringList(folderNames); + updateGridFileList(); + } + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMultiCaseImportDialog::on_m_removeSearchFolderButton_clicked() +{ + QModelIndexList selection = ui->m_searchFolderList->selectionModel()->selectedIndexes(); + for (int i = 0; i < selection.size(); ++i) + { + ui->m_searchFolderList->model()->removeRow(selection[i].row(), selection[i].parent()); + } + + if (selection.size()) + { + updateGridFileList(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMultiCaseImportDialog::updateGridFileList() +{ + + QStringList folderNames = m_searchFolders->stringList(); + QStringList gridFileNames; + + for (int i = 0; i < folderNames.size(); i++) + { + QString folderName = folderNames[i]; + + appendEGRIDFilesRecursively(folderName, gridFileNames); + } + + m_eclipseGridFiles->setStringList(gridFileNames); +} + + +void RiuMultiCaseImportDialog::appendEGRIDFilesRecursively(const QString& folderName, QStringList& gridFileNames) +{ + { + QDir baseDir(folderName); + baseDir.setFilter(QDir::Files); + + QStringList nameFilters; + nameFilters << "*.egrid" << ".EGRID"; + baseDir.setNameFilters(nameFilters); + + QStringList fileNames = baseDir.entryList(); + + for (int i = 0; i < fileNames.size(); ++i) + { + QString fileName = fileNames[i]; + + QString absoluteFolderName = baseDir.absoluteFilePath(fileName); + + gridFileNames.append(absoluteFolderName); + } + } + + + { + QDir baseDir(folderName); + baseDir.setFilter(QDir::Dirs | QDir::NoDotAndDotDot); + + QStringList subFolders = baseDir.entryList(); + + for (int i = 0; i < subFolders.size(); ++i) + { + QString folderName = subFolders[i]; + + QString absoluteFolderName = baseDir.absoluteFilePath(folderName); + appendEGRIDFilesRecursively(absoluteFolderName, gridFileNames); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RiuMultiCaseImportDialog::eclipseCaseFileNames() const +{ + return m_eclipseGridFiles->stringList(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMultiCaseImportDialog::on_m_removeEclipseCaseButton_clicked() +{ + QModelIndexList selection = ui->m_eclipseCasesList->selectionModel()->selectedIndexes(); + for (int i = 0; i < selection.size(); ++i) + { + ui->m_eclipseCasesList->model()->removeRow(selection[i].row(), selection[i].parent()); + } +} diff --git a/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.h b/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.h new file mode 100644 index 0000000000..815628d147 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.h @@ -0,0 +1,56 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 + +namespace Ui { + class RiuMultiCaseImportDialog; +}; + +class FileListModel; + +//================================================================================================== +// +// +// +//================================================================================================== + +class RiuMultiCaseImportDialog: public QDialog +{ + Q_OBJECT + +public: + RiuMultiCaseImportDialog(QWidget *parent = 0); + virtual ~RiuMultiCaseImportDialog(); + + QStringList eclipseCaseFileNames() const; + +protected slots: + void on_m_addSearchFolderButton_clicked(); + void on_m_removeSearchFolderButton_clicked(); + void on_m_removeEclipseCaseButton_clicked(); +private: + void updateGridFileList(); + static void appendEGRIDFilesRecursively(const QString& folderName, QStringList& gridFileNames); + Ui::RiuMultiCaseImportDialog* ui; + + FileListModel *m_searchFolders; + FileListModel *m_eclipseGridFiles; +}; diff --git a/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.ui b/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.ui new file mode 100644 index 0000000000..101bf899e7 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.ui @@ -0,0 +1,186 @@ + + + RiuMultiCaseImportDialog + + + + 0 + 0 + 755 + 736 + + + + Import multiple cases + + + true + + + + + + Qt::Horizontal + + + + + + + QAbstractItemView::ExtendedSelection + + + + + + + Remove + + + + + + + Add + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Search Folders + + + + + + + Qt::Vertical + + + + 20 + 222 + + + + + + + + + + + + + 0 + 0 + + + + QAbstractItemView::ExtendedSelection + + + + + + + Selected Eclipse Cases + + + + + + + Remove + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 400 + 20 + + + + + + + + + + + + Qt::Horizontal + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + m_dialogButtons + accepted() + RiuMultiCaseImportDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + m_dialogButtons + rejected() + RiuMultiCaseImportDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + From 02c7cc2b065beefcf96a9d3d23fefa12dbd2b737 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 5 Mar 2013 13:49:34 +0100 Subject: [PATCH 076/242] Fixed filenames for dynamic result access p4#: 20762 --- .../FileInterface/RifEclipseRestartDataAccess.h | 4 ++-- .../RifEclipseRestartFilesetAccess.cpp | 2 +- .../FileInterface/RifEclipseRestartFilesetAccess.h | 2 +- .../RifEclipseUnifiedRestartFileAccess.cpp | 13 ++++++++++--- .../RifEclipseUnifiedRestartFileAccess.h | 3 ++- .../FileInterface/RifReaderEclipseOutput.cpp | 2 +- 6 files changed, 17 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/FileInterface/RifEclipseRestartDataAccess.h b/ApplicationCode/FileInterface/RifEclipseRestartDataAccess.h index 44779337b9..a7d61d27ce 100644 --- a/ApplicationCode/FileInterface/RifEclipseRestartDataAccess.h +++ b/ApplicationCode/FileInterface/RifEclipseRestartDataAccess.h @@ -42,8 +42,8 @@ public: RifEclipseRestartDataAccess(); virtual ~RifEclipseRestartDataAccess(); - virtual bool open(const QStringList& fileSet) = 0; - virtual void setFileSet(const QStringList& fileSet) {}; + virtual bool open() = 0; + virtual void setFileSet(const QStringList& fileSet) = 0; virtual void close() = 0; virtual void setTimeSteps(const QList& timeSteps) {}; diff --git a/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp b/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp index c3074443ce..dd8b4ffa07 100644 --- a/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp +++ b/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp @@ -40,7 +40,7 @@ RifEclipseRestartFilesetAccess::~RifEclipseRestartFilesetAccess() //-------------------------------------------------------------------------------------------------- /// Open files //-------------------------------------------------------------------------------------------------- -bool RifEclipseRestartFilesetAccess::open(const QStringList& fileSet) +bool RifEclipseRestartFilesetAccess::open() { if (m_fileNames.size() > 0) { diff --git a/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.h b/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.h index d332cea65c..8fe26540d3 100644 --- a/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.h +++ b/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.h @@ -35,7 +35,7 @@ public: RifEclipseRestartFilesetAccess(); virtual ~RifEclipseRestartFilesetAccess(); - bool open(const QStringList& fileSet); + bool open(); void setFileSet(const QStringList& fileSet); void close(); diff --git a/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp b/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp index 6a0641b8c1..b5e79ea6bb 100644 --- a/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp +++ b/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp @@ -44,10 +44,8 @@ RifEclipseUnifiedRestartFileAccess::~RifEclipseUnifiedRestartFileAccess() //-------------------------------------------------------------------------------------------------- /// Open file //-------------------------------------------------------------------------------------------------- -bool RifEclipseUnifiedRestartFileAccess::open(const QStringList& fileSet) +bool RifEclipseUnifiedRestartFileAccess::open() { - m_filename = fileSet[0]; - return true; } @@ -155,3 +153,12 @@ void RifEclipseUnifiedRestartFileAccess::readWellData(well_info_type* well_info) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifEclipseUnifiedRestartFileAccess::setFileSet(const QStringList& fileSet) +{ + m_filename = fileSet[0]; + +} + diff --git a/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.h b/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.h index f85df6cce1..95e3d4858f 100644 --- a/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.h +++ b/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.h @@ -37,7 +37,8 @@ public: RifEclipseUnifiedRestartFileAccess(); virtual ~RifEclipseUnifiedRestartFileAccess(); - bool open(const QStringList& fileSet); + void setFileSet(const QStringList& fileSet); + bool open(); void close(); size_t timeStepCount(); diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index 59bdc86b87..a410e56d20 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -530,7 +530,7 @@ bool RifReaderEclipseOutput::buildMetaData() return false; } - m_dynamicResultsAccess->open(m_fileSet); + m_dynamicResultsAccess->open(); progInfo.incrementProgress(); From 2c19c8010c79e75f39ad8595ca2f938a23d74672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 5 Mar 2013 14:45:29 +0100 Subject: [PATCH 077/242] MultiCase import dialog: Fixed errors in remove search folders and cases p4#: 20765 --- .../RiuMultiCaseImportDialog.cpp | 64 ++++++++++++++++++- 1 file changed, 61 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp b/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp index 283b1bf56c..353f059ba9 100644 --- a/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp +++ b/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp @@ -96,6 +96,7 @@ void RiuMultiCaseImportDialog::on_m_addSearchFolderButton_clicked() { QString selectedFolder = QFileDialog::getExistingDirectory(this, "Select an Eclipse case search folder" ); QStringList folderNames = m_searchFolders->stringList(); + if (!folderNames.contains(selectedFolder)) { folderNames.push_back(selectedFolder); @@ -111,11 +112,22 @@ void RiuMultiCaseImportDialog::on_m_addSearchFolderButton_clicked() void RiuMultiCaseImportDialog::on_m_removeSearchFolderButton_clicked() { QModelIndexList selection = ui->m_searchFolderList->selectionModel()->selectedIndexes(); + QStringList folderNames = m_searchFolders->stringList(); + + QStringList searchFoldersToRemove; + for (int i = 0; i < selection.size(); ++i) { - ui->m_searchFolderList->model()->removeRow(selection[i].row(), selection[i].parent()); + searchFoldersToRemove.push_back(folderNames[selection[i].row()]); } + for (int i = 0; i < searchFoldersToRemove.size(); ++i) + { + folderNames.removeOne(searchFoldersToRemove[i]); + } + + m_searchFolders->setStringList(folderNames); + if (selection.size()) { updateGridFileList(); @@ -131,6 +143,32 @@ void RiuMultiCaseImportDialog::updateGridFileList() QStringList folderNames = m_searchFolders->stringList(); QStringList gridFileNames; + + // Filter the search folders to remove subfolders of existing roots' + + bool okToAdd = true; + QStringList searchFoldersToRemove; + + for (int i = 0; i < folderNames.size(); ++i) + for (int j = 0; j < folderNames.size(); ++j) + { + if ( i != j) + { + if (folderNames[i].startsWith(folderNames[j])) + { + // Remove folderNames[i] + searchFoldersToRemove.push_back(folderNames[i]); + } + } + } + + // Remove the subfolders when adding a root + + for (int i = 0; i < searchFoldersToRemove.size(); ++i) + { + folderNames.removeOne(searchFoldersToRemove[i]); + } + for (int i = 0; i < folderNames.size(); i++) { QString folderName = folderNames[i]; @@ -195,8 +233,28 @@ QStringList RiuMultiCaseImportDialog::eclipseCaseFileNames() const void RiuMultiCaseImportDialog::on_m_removeEclipseCaseButton_clicked() { QModelIndexList selection = ui->m_eclipseCasesList->selectionModel()->selectedIndexes(); - for (int i = 0; i < selection.size(); ++i) + if (selection.size()) { - ui->m_eclipseCasesList->model()->removeRow(selection[i].row(), selection[i].parent()); + for (int i = 0; i < selection.size(); ++i) + { + ui->m_eclipseCasesList->model()->removeRow(selection[i].row(), selection[i].parent()); + } + + QModelIndexList selection = ui->m_eclipseCasesList->selectionModel()->selectedIndexes(); + QStringList fileNames = m_eclipseGridFiles->stringList(); + + QStringList filenamesToRemove; + + for (int i = 0; i < selection.size(); ++i) + { + filenamesToRemove.push_back(fileNames[selection[i].row()]); + } + + for (int i = 0; i < filenamesToRemove.size(); ++i) + { + fileNames.removeOne(filenamesToRemove[i]); + } + + m_eclipseGridFiles->setStringList(fileNames); } } From 466eb906aa63aeb1337577518ef53b091282a749 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 5 Mar 2013 15:22:19 +0100 Subject: [PATCH 078/242] Multi Case Dialog now remebers the Add Search Folder path p4#: 20770 --- ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp b/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp index 353f059ba9..dd2e77ebc9 100644 --- a/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp +++ b/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp @@ -22,6 +22,7 @@ #include #include #include +#include "RIApplication.h" class FileListModel: public QStringListModel { @@ -94,7 +95,7 @@ RiuMultiCaseImportDialog::~RiuMultiCaseImportDialog() //-------------------------------------------------------------------------------------------------- void RiuMultiCaseImportDialog::on_m_addSearchFolderButton_clicked() { - QString selectedFolder = QFileDialog::getExistingDirectory(this, "Select an Eclipse case search folder" ); + QString selectedFolder = QFileDialog::getExistingDirectory(this, "Select an Eclipse case search folder", RIApplication::instance()->defaultFileDialogDirectory("MULTICASEIMPORT")); QStringList folderNames = m_searchFolders->stringList(); if (!folderNames.contains(selectedFolder)) @@ -104,6 +105,7 @@ void RiuMultiCaseImportDialog::on_m_addSearchFolderButton_clicked() updateGridFileList(); } + RIApplication::instance()->setDefaultFileDialogDirectory("MULTICASEIMPORT", selectedFolder); } //-------------------------------------------------------------------------------------------------- From 5247d6687d33c9ecd848d95e70736e0502acf960 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 6 Mar 2013 09:25:33 +0100 Subject: [PATCH 079/242] Integrating Visualization Modules from ChangeList 20718 Due to updates in the overlay image p4#: 20781 --- .../LibRender/cvfOverlayImage.cpp | 57 +++++++++++++++---- .../LibRender/cvfOverlayImage.h | 1 + .../LibRender/cvfOverlayNavigationCube.cpp | 2 +- 3 files changed, 47 insertions(+), 13 deletions(-) diff --git a/VisualizationModules/LibRender/cvfOverlayImage.cpp b/VisualizationModules/LibRender/cvfOverlayImage.cpp index bd2b578c52..1c42403920 100644 --- a/VisualizationModules/LibRender/cvfOverlayImage.cpp +++ b/VisualizationModules/LibRender/cvfOverlayImage.cpp @@ -153,6 +153,23 @@ void OverlayImage::render(OpenGLContext* oglContext, const Vec2i& position, cons if (software) { + // Create a POW2 texture for software rendering if needed + if (m_image.notNull() && m_pow2Image.isNull() && (!Math::isPow2(m_image->width()) || !Math::isPow2(m_image->height()))) + { + m_pow2Image = new TextureImage; + m_pow2Image->allocate(Math::roundUpPow2(m_image->width()), Math::roundUpPow2(m_image->height())); + m_pow2Image->fill(Color4ub(Color3::BLACK)); + + for (uint y = 0; y < m_image->height(); ++y) + { + for (uint x = 0; x < m_image->width(); ++x) + { + m_pow2Image->setPixel(x, y, m_image->pixel(x, y)); + } + } + } + + if (ShaderProgram::supportedOpenGL(oglContext)) { ShaderProgram::useNoProgram(oglContext); @@ -166,19 +183,33 @@ void OverlayImage::render(OpenGLContext* oglContext, const Vec2i& position, cons RenderStateLighting_FF light(false); light.applyOpenGL(oglContext); - // Use fixed function texture setup - ref texture = new Texture2D_FF(m_image.p()); - texture->setWrapMode(Texture2D_FF::CLAMP); - texture->setMinFilter(Texture2D_FF::NEAREST); - texture->setMagFilter(Texture2D_FF::NEAREST); - texture->setupTexture(oglContext); - texture->setupTextureParams(oglContext); + if (m_textureBindings.isNull()) + { + // Use fixed function texture setup + ref texture = new Texture2D_FF(m_pow2Image.notNull() ? m_pow2Image.p() : m_image.p()); + texture->setWrapMode(Texture2D_FF::CLAMP); + texture->setMinFilter(Texture2D_FF::NEAREST); + texture->setMagFilter(Texture2D_FF::NEAREST); + texture->setupTexture(oglContext); + texture->setupTextureParams(oglContext); - ref textureMapping = new RenderStateTextureMapping_FF(texture.p()); - textureMapping->setTextureFunction(m_blendMode == TEXTURE_ALPHA ? RenderStateTextureMapping_FF::MODULATE : RenderStateTextureMapping_FF::DECAL); + ref textureMapping = new RenderStateTextureMapping_FF(texture.p()); + textureMapping->setTextureFunction(m_blendMode == TEXTURE_ALPHA ? RenderStateTextureMapping_FF::MODULATE : RenderStateTextureMapping_FF::DECAL); - m_textureBindings = textureMapping; + m_textureBindings = textureMapping; + } #endif + // Adjust texture coordinates + if (m_pow2Image.notNull()) + { + float xMax = static_cast(m_image->width())/static_cast(m_pow2Image->width()); + float yMax = static_cast(m_image->height())/static_cast(m_pow2Image->height()); + textureCoords[2] = xMax; + textureCoords[4] = xMax; + textureCoords[5] = yMax; + textureCoords[7] = yMax; + } + projCam.applyOpenGL(); } else @@ -228,8 +259,9 @@ void OverlayImage::render(OpenGLContext* oglContext, const Vec2i& position, cons } } - Vec3f min(1.0f, 1.0f, 0.0f); - Vec3f max(static_cast(size.x() - 1), static_cast(size.y() - 1), 0.0f); + float offset = 0.0f; + Vec3f min(offset, offset, 0.0f); + Vec3f max(static_cast(size.x()) + offset, static_cast(size.y()) + offset, 0.0f); // Setup the vertex array float* v1 = &vertexArray[0]; @@ -308,6 +340,7 @@ void OverlayImage::render(OpenGLContext* oglContext, const Vec2i& position, cons void OverlayImage::setImage(TextureImage* image) { m_image = image; + m_pow2Image = NULL; m_texture = new Texture(image); diff --git a/VisualizationModules/LibRender/cvfOverlayImage.h b/VisualizationModules/LibRender/cvfOverlayImage.h index 76d96c9dab..854f491475 100644 --- a/VisualizationModules/LibRender/cvfOverlayImage.h +++ b/VisualizationModules/LibRender/cvfOverlayImage.h @@ -68,6 +68,7 @@ private: private: Vec2ui m_size; ref m_image; + ref m_pow2Image; ref m_sampler; ref m_textureBindings; ref m_texture; diff --git a/VisualizationModules/LibRender/cvfOverlayNavigationCube.cpp b/VisualizationModules/LibRender/cvfOverlayNavigationCube.cpp index 5a75015354..a28fb8bf08 100644 --- a/VisualizationModules/LibRender/cvfOverlayNavigationCube.cpp +++ b/VisualizationModules/LibRender/cvfOverlayNavigationCube.cpp @@ -1115,7 +1115,7 @@ bool OverlayNavigationCube::pick(int winCoordX, int winCoordY, const Vec2i& posi bool OverlayNavigationCube::updateHighlight(int winCoordX, int winCoordY, const Vec2i& position, const Vec2ui& size) { // Early out - if (winCoordX < position.x() || winCoordY > (position.x() + static_cast(size.x())) || + if (winCoordX < position.x() || winCoordX > (position.x() + static_cast(size.x())) || winCoordY < position.y() || winCoordY > (position.y() + static_cast(size.y()))) { bool redraw = m_hightlightItem != NCI_NONE; From 77d5b810ca8c40d3533819dce6819fc6147fbdba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 6 Mar 2013 15:13:37 +0100 Subject: [PATCH 080/242] Fixed errror regarding LGC and missing results p4#: 20794 --- ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp index a261b60ddf..07d93fd055 100644 --- a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp @@ -127,10 +127,10 @@ void RigActiveCellInfo::computeDerivedData() m_globalMatrixModelActiveCellCount = 0; m_globalFractureModelActiveCellCount = 0; - for (size_t i = 0; i < m_activeInFractureModel.size(); i++) + for (size_t i = 0; i < m_perGridActiveCellInfo.size(); i++) { - if (isActiveInMatrixModel(i)) m_globalMatrixModelActiveCellCount++; - if (isActiveInFractureModel(i)) m_globalFractureModelActiveCellCount++; + m_globalMatrixModelActiveCellCount += m_perGridActiveCellInfo[i].matrixModelActiveCellCount(); + m_globalFractureModelActiveCellCount += m_perGridActiveCellInfo[i].fractureModelActiveCellCount(); } } From 86696d85e5cafaff582c5e9601da2d0b9482c5c4 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 7 Mar 2013 09:21:29 +0100 Subject: [PATCH 081/242] Delete child objects when object is deleted p4#: 20799 --- ApplicationCode/ProjectDataModel/RimCaseCollection.cpp | 2 +- .../ProjectDataModel/RimIdenticalGridCaseGroup.cpp | 6 ++++++ .../ProjectDataModel/RimStatisticalCollection.cpp | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimCaseCollection.cpp b/ApplicationCode/ProjectDataModel/RimCaseCollection.cpp index 8001c8bffe..9840dddd6a 100644 --- a/ApplicationCode/ProjectDataModel/RimCaseCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimCaseCollection.cpp @@ -40,5 +40,5 @@ RimCaseCollection::RimCaseCollection() //-------------------------------------------------------------------------------------------------- RimCaseCollection::~RimCaseCollection() { - + reservoirs.deleteAllChildObjects(); } diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index eab45f8957..21574c36be 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -52,7 +52,13 @@ RimIdenticalGridCaseGroup::RimIdenticalGridCaseGroup() //-------------------------------------------------------------------------------------------------- RimIdenticalGridCaseGroup::~RimIdenticalGridCaseGroup() { + m_mainGrid = NULL; + delete caseCollection; + caseCollection = NULL; + + delete statisticalReservoirCollection; + statisticalReservoirCollection = NULL; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCollection.cpp b/ApplicationCode/ProjectDataModel/RimStatisticalCollection.cpp index da22bc2b29..3b8a5f6436 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCollection.cpp @@ -42,7 +42,7 @@ RimStatisticalCollection::RimStatisticalCollection() //-------------------------------------------------------------------------------------------------- RimStatisticalCollection::~RimStatisticalCollection() { - + reservoirs.deleteAllChildObjects(); } //-------------------------------------------------------------------------------------------------- From 705bb185e0503615f6e815673549be8383e333ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 7 Mar 2013 09:42:34 +0100 Subject: [PATCH 082/242] Fixed assert regarding wrong clamping of current timestep p4#: 20802 --- ApplicationCode/ProjectDataModel/RimReservoirView.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp index d5d574908b..f8c4a7eb78 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp @@ -274,7 +274,7 @@ void RimReservoirView::clampCurrentTimestep() // Clamp the current timestep to actual possibilities if (this->gridCellResults()) { - if (m_currentTimeStep() > static_cast(this->gridCellResults()->maxTimeStepCount())) + if (m_currentTimeStep() >= static_cast(this->gridCellResults()->maxTimeStepCount())) { m_currentTimeStep = static_cast(this->gridCellResults()->maxTimeStepCount()) -1; } From fcdf14c0facbce49265a0b6b704cbc06f05cd856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 7 Mar 2013 09:43:25 +0100 Subject: [PATCH 083/242] Improved progress information when reading large projects p4#: 20803 --- ApplicationCode/Application/RIApplication.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ApplicationCode/Application/RIApplication.cpp b/ApplicationCode/Application/RIApplication.cpp index 19cfe414e4..d8bb354d10 100644 --- a/ApplicationCode/Application/RIApplication.cpp +++ b/ApplicationCode/Application/RIApplication.cpp @@ -250,20 +250,30 @@ bool RIApplication::loadProject(const QString& projectFileName) m_preferences->lastUsedProjectFileName = projectFileName; writePreferences(); + caf::ProgressInfo caseProgress(m_project->reservoirs().size() , "Reading Cases"); size_t i; for (i = 0; i < m_project->reservoirs().size(); ++i) { RimReservoir* ri = m_project->reservoirs()[i]; CVF_ASSERT(ri); + caseProgress.setProgressDescription(ri->caseName()); + + caf::ProgressInfo viewProgress(ri->reservoirViews().size() , "Creating Views"); + size_t j; for (j = 0; j < ri->reservoirViews().size(); j++) { RimReservoirView* riv = ri->reservoirViews()[j]; CVF_ASSERT(riv); + viewProgress.setProgressDescription(riv->name()); + riv->loadDataAndUpdate(); + viewProgress.incrementProgress(); } + + caseProgress.incrementProgress(); } } From 868c90dd0328e9379193ddb6a5610705a4b69283 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 7 Mar 2013 09:49:33 +0100 Subject: [PATCH 084/242] Removed checkbox selections for statistical configuration p4#: 20805 --- .../RimStatisticalCalculation.cpp | 46 ------------------- .../RimStatisticalCalculation.h | 11 ----- 2 files changed, 57 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp index 7045832b0f..c11aa7b19a 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp @@ -39,11 +39,6 @@ RimStatisticalCalculation::RimStatisticalCalculation() { CAF_PDM_InitField(&m_resultName, "ResultName", QString("PRESSURE"), "ResultName", "", "", ""); - CAF_PDM_InitField(&statisticsMin, "StatisticsMin", true, "Minimum", "", "" ,""); - CAF_PDM_InitField(&statisticsMax, "StatisticsMax", true, "Maximum", "", "" ,""); - CAF_PDM_InitField(&statisticsMean, "StatisticsMean", true, "Mean", "", "" ,""); - CAF_PDM_InitField(&statisticsStdDev, "StatisticsStdDev", true, "Std dev", "", "" ,""); - m_readerInterface = new RifReaderStatisticalCalculation; openEclipseGridFile(); @@ -96,15 +91,6 @@ bool RimStatisticalCalculation::openEclipseGridFile() //-------------------------------------------------------------------------------------------------- void RimStatisticalCalculation::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const { - // Fields declared in RimCellFilter - uiOrdering.add(&caseName); - - // Fields declared in RimResultDefinition - caf::PdmUiGroup* group1 = uiOrdering.addNewGroup("Statistical parameters"); - group1->add(&statisticsMin); - group1->add(&statisticsMax); - group1->add(&statisticsMean); - group1->add(&statisticsStdDev); } @@ -165,38 +151,6 @@ void RimStatisticalCalculation::computeStatistics() stat.evaluateStatistics(RimDefines::DYNAMIC_NATIVE, m_resultName); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimStatisticalCalculation::createAndComputeMin() -{ - -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimStatisticalCalculation::createAndComputeMax() -{ - -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimStatisticalCalculation::createAndComputeMean() -{ - -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimStatisticalCalculation::createAndComputeStdDev() -{ - -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h index 84aec72d1d..8e8cfc4f5c 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h @@ -51,11 +51,6 @@ public: caf::PdmField m_resultName; - caf::PdmField statisticsMin; - caf::PdmField statisticsMax; - caf::PdmField statisticsMean; - caf::PdmField statisticsStdDev; - RimStatisticalCollection* parent(); virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) const; @@ -64,14 +59,8 @@ public: private: RimIdenticalGridCaseGroup* caseGroup(); - void createAndComputeMin(); - void createAndComputeMax(); - void createAndComputeMean(); - void createAndComputeStdDev(); - void getSourceCases(cvf::Collection& sourceCases); - private: cvf::ref m_readerInterface; From 6bf3776a5dc2534c7d093233e3aea0f1499dda0f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 7 Mar 2013 10:06:31 +0100 Subject: [PATCH 085/242] Add one statistical case object when creating a case group p4#: 20808 --- .../ProjectDataModel/RimIdenticalGridCaseGroup.cpp | 5 +++++ ApplicationCode/ProjectDataModel/RimUiTreeView.cpp | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index 21574c36be..13d4c97b03 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -80,6 +80,11 @@ void RimIdenticalGridCaseGroup::addCase(RimReservoir* reservoir) CVF_ASSERT(m_mainGrid.p() == incomingMainGrid); caseCollection()->reservoirs().push_back(reservoir); + + if (statisticalReservoirCollection->reservoirs().size() == 0) + { + statisticalReservoirCollection->createAndAppendStatisticalCalculation(); + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index 5037814912..02920e9c50 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -789,5 +789,10 @@ void RimUiTreeView::slotComputeStatisticalCases() if (!statisticalObject) return; statisticalObject->computeStatistics(); + + if (statisticalObject->reservoirViews.size() == 0) + { + slotAddView(); + } } From aab18ba0a0e5e4ebcefacb7f6b52a09e7d0096dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 7 Mar 2013 12:25:27 +0100 Subject: [PATCH 086/242] Set root as default start directory for grid case group import p4#: 20811 --- ApplicationCode/Application/RIApplication.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/Application/RIApplication.cpp b/ApplicationCode/Application/RIApplication.cpp index d8bb354d10..9efb5e83fa 100644 --- a/ApplicationCode/Application/RIApplication.cpp +++ b/ApplicationCode/Application/RIApplication.cpp @@ -133,7 +133,7 @@ RIApplication::RIApplication(int& argc, char** argv) #ifdef WIN32 //m_startupDefaultDirectory += "/My Documents/"; #endif - + setDefaultFileDialogDirectory("MULTICASEIMPORT", "/"); } From 78f2c359cb2b3dd1cca19645b450b90fb9abc5ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 7 Mar 2013 12:32:19 +0100 Subject: [PATCH 087/242] Renamed the multicase command to "Create Grid Case Group From Files" p4#: 20814 --- .../ProjectDataModel/RimIdenticalGridCaseGroup.cpp | 6 +++--- .../ProjectDataModel/RimStatisticalCollection.cpp | 2 +- ApplicationCode/UserInterface/RIMainWindow.cpp | 3 ++- ApplicationCode/UserInterface/RiuMultiCaseImportDialog.ui | 6 +++--- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index 13d4c97b03..2087510dd8 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -37,11 +37,11 @@ RimIdenticalGridCaseGroup::RimIdenticalGridCaseGroup() { CAF_PDM_InitObject("Grid Case Group", "", "", ""); - CAF_PDM_InitField(&name, "UserDescription", QString("Identical Grid Case Group"), "Name", "", "", ""); + CAF_PDM_InitField(&name, "UserDescription", QString("Grid Case Group"), "Name", "", "", ""); - CAF_PDM_InitFieldNoDefault(&caseCollection, "CaseCollection", "Cases", "", "", ""); CAF_PDM_InitFieldNoDefault(&statisticalReservoirCollection, "StatisticalReservoirCollection", "Derived Statistics", "", "", ""); - + CAF_PDM_InitFieldNoDefault(&caseCollection, "CaseCollection", "Cases", "", "", ""); + caseCollection = new RimCaseCollection; statisticalReservoirCollection = new RimStatisticalCollection; diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCollection.cpp b/ApplicationCode/ProjectDataModel/RimStatisticalCollection.cpp index 3b8a5f6436..511917b769 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCollection.cpp @@ -58,7 +58,7 @@ RimStatisticalCalculation* RimStatisticalCollection::createAndAppendStatisticalC newObject->setMainGrid(gridCaseGroup->mainGrid()); - newObject->caseName = "Statistics 1"; + newObject->caseName = QString("Statistics ") + QString::number(reservoirs.size()+1); reservoirs.push_back(newObject); diff --git a/ApplicationCode/UserInterface/RIMainWindow.cpp b/ApplicationCode/UserInterface/RIMainWindow.cpp index 354f8dce7a..1bfe378096 100644 --- a/ApplicationCode/UserInterface/RIMainWindow.cpp +++ b/ApplicationCode/UserInterface/RIMainWindow.cpp @@ -178,7 +178,7 @@ void RIMainWindow::createActions() // File actions m_openAction = new QAction(QIcon(":/AppLogo48x48.png"), "&Open Eclipse Case", this); m_openInputEclipseFileAction= new QAction(QIcon(":/EclipseInput48x48.png"), "&Open Input Eclipse Case", this); - m_openMultipleEclipseCasesAction = new QAction(QIcon(":/EclipseInput48x48.png"), "&Open Multiple Eclipse Folders", this); + m_openMultipleEclipseCasesAction = new QAction(QIcon(":/AppLogo48x48.png"), "&Create Grid Case Group from Files", this); m_openProjectAction = new QAction(style()->standardIcon(QStyle::SP_DirOpenIcon), "&Open Project", this); m_openLastUsedProjectAction = new QAction("Open &Last Used Project", this); @@ -350,6 +350,7 @@ void RIMainWindow::createToolBars() // View toolbar m_viewToolBar = addToolBar(tr("View")); m_viewToolBar->setObjectName(m_viewToolBar->windowTitle()); + m_viewToolBar->addAction(m_zoomAll); m_viewToolBar->addAction(m_viewFromNorth); m_viewToolBar->addAction(m_viewFromSouth); m_viewToolBar->addAction(m_viewFromEast); diff --git a/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.ui b/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.ui index 101bf899e7..ca27248841 100644 --- a/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.ui +++ b/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.ui @@ -11,7 +11,7 @@ - Import multiple cases + Create Grid Case Group From Files true @@ -22,7 +22,7 @@ Qt::Horizontal - + @@ -80,7 +80,7 @@ - + From ec825145dffa9fb53227f311632d58f6e4182af9 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 7 Mar 2013 13:13:34 +0100 Subject: [PATCH 088/242] Fixed invalid active global index p4#: 20816 --- ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index a410e56d20..838921b441 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -436,6 +436,7 @@ bool RifReaderEclipseOutput::openAndReadActiveCellData(const QString& fileName, //-------------------------------------------------------------------------------------------------- /// +/// See also RigStatistics::computeActiveCellUnion() //-------------------------------------------------------------------------------------------------- bool RifReaderEclipseOutput::readActiveCellInfo() { @@ -474,6 +475,8 @@ bool RifReaderEclipseOutput::readActiveCellInfo() activeCellInfo->setGridCount(actnumKeywordCount); size_t cellIdx = 0; + size_t globalActiveMatrixIndex = 0; + size_t globalActiveFractureIndex = 0; for (size_t gridIdx = 0; gridIdx < static_cast(actnumKeywordCount); gridIdx++) { size_t activeMatrixIndex = 0; @@ -485,12 +488,14 @@ bool RifReaderEclipseOutput::readActiveCellInfo() { if (actnumValues[i] == 1 || actnumValues[i] == 3) { - activeCellInfo->setActiveIndexInMatrixModel(cellIdx, activeMatrixIndex++); + activeCellInfo->setActiveIndexInMatrixModel(cellIdx, globalActiveMatrixIndex++); + activeMatrixIndex++; } if (actnumValues[i] == 2 || actnumValues[i] == 3) { - activeCellInfo->setActiveIndexInFractureModel(cellIdx, activeFractureIndex++); + activeCellInfo->setActiveIndexInFractureModel(cellIdx, globalActiveFractureIndex++); + activeFractureIndex++; } cellIdx++; From 05b6c1ad184aef03f404a2cfb3843a0ca18fd314 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 7 Mar 2013 13:20:15 +0100 Subject: [PATCH 089/242] Compute active cell info grid by grid p4#: 20817 --- .../ReservoirDataModel/RigStatistics.cpp | 81 ++++++++++++------- 1 file changed, 50 insertions(+), 31 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp index 21455ce8c3..0f1a4f2dab 100644 --- a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp +++ b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp @@ -45,57 +45,76 @@ void RigStatistics::addNamedResult(RigReservoirCellResults* cellResults, RimDefi //-------------------------------------------------------------------------------------------------- /// +// See also RifReaderEclipseOutput::readActiveCellInfo() //-------------------------------------------------------------------------------------------------- void RigStatistics::computeActiveCellUnion() { - // Early exit if active cell union is already computed - if (m_destinationCase->activeCellInfo()->globalFractureModelActiveCellCount() + - m_destinationCase->activeCellInfo()->globalFractureModelActiveCellCount() > 0) + if (m_sourceCases.size() == 0) { return; } - std::vector activeM(m_globalCellCount, 0); - std::vector activeF(m_globalCellCount, 0); + RigMainGrid* mainGrid = m_sourceCases[0]->mainGrid(); + CVF_ASSERT(mainGrid); - for (size_t cellIdx = 0; cellIdx < m_globalCellCount; cellIdx++) + m_destinationCase->activeCellInfo()->setGlobalCellCount(mainGrid->cells().size()); + m_destinationCase->activeCellInfo()->setGridCount(mainGrid->gridCount()); + + size_t globalActiveMatrixIndex = 0; + size_t globalActiveFractureIndex = 0; + + for (size_t gridIdx = 0; gridIdx < mainGrid->gridCount(); gridIdx++) { - for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++) - { - if (activeM[cellIdx] == 0) - { - if (m_sourceCases[caseIdx]->activeCellInfo()->isActiveInMatrixModel(cellIdx)) - { - activeM[cellIdx] = 1; - } - } + RigGridBase* grid = mainGrid->gridByIndex(gridIdx); - if (activeF[cellIdx] == 0) + std::vector activeM(grid->cellCount(), 0); + std::vector activeF(grid->cellCount(), 0); + + for (size_t localGridCellIdx = 0; localGridCellIdx < grid->cellCount(); localGridCellIdx++) + { + for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++) { - if (m_sourceCases[caseIdx]->activeCellInfo()->isActiveInFractureModel(cellIdx)) + size_t globalCellIdx = grid->globalGridCellIndex(localGridCellIdx); + + if (activeM[localGridCellIdx] == 0) { - activeF[cellIdx] = 1; + if (m_sourceCases[caseIdx]->activeCellInfo()->isActiveInMatrixModel(globalCellIdx)) + { + activeM[localGridCellIdx] = 1; + } + } + + if (activeF[localGridCellIdx] == 0) + { + if (m_sourceCases[caseIdx]->activeCellInfo()->isActiveInFractureModel(globalCellIdx)) + { + activeF[localGridCellIdx] = 1; + } } } } - } - m_destinationCase->activeCellInfo()->setGlobalCellCount(m_globalCellCount); + size_t activeMatrixIndex = 0; + size_t activeFractureIndex = 0; - size_t activeMIndex = 0; - size_t activeFIndex = 0; - - for (size_t cellIdx = 0; cellIdx < m_globalCellCount; cellIdx++) - { - if (activeM[cellIdx] != 0) + for (size_t localGridCellIdx = 0; localGridCellIdx < grid->cellCount(); localGridCellIdx++) { - m_destinationCase->activeCellInfo()->setActiveIndexInMatrixModel(cellIdx, activeMIndex++); + size_t globalCellIdx = grid->globalGridCellIndex(localGridCellIdx); + + if (activeM[localGridCellIdx] != 0) + { + m_destinationCase->activeCellInfo()->setActiveIndexInMatrixModel(globalCellIdx, globalActiveMatrixIndex++); + activeMatrixIndex++; + } + + if (activeF[localGridCellIdx] != 0) + { + m_destinationCase->activeCellInfo()->setActiveIndexInFractureModel(globalCellIdx, globalActiveFractureIndex++); + activeFractureIndex++; + } } - if (activeF[cellIdx] != 0) - { - m_destinationCase->activeCellInfo()->setActiveIndexInFractureModel(cellIdx, activeFIndex++); - } + m_destinationCase->activeCellInfo()->setGridActiveCellCounts(gridIdx, activeMatrixIndex, activeFractureIndex); } m_destinationCase->activeCellInfo()->computeDerivedData(); From 1bf1d5a7cf47a814ab4e47a98d46770b8b9e993a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 7 Mar 2013 14:56:52 +0100 Subject: [PATCH 090/242] Rebuild geometry after computing new active cell info, and update views p4#: 20821 --- .../ReservoirDataModel/RigActiveCellInfo.cpp | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp index 07d93fd055..8c4f7c3970 100644 --- a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp @@ -45,6 +45,11 @@ void RigActiveCellInfo::setGlobalCellCount(size_t globalCellCount) //-------------------------------------------------------------------------------------------------- bool RigActiveCellInfo::isActiveInMatrixModel(size_t globalCellIndex) const { + if (m_activeInMatrixModel.size() == 0) + { + return false; + } + CVF_TIGHT_ASSERT(globalCellIndex < m_activeInMatrixModel.size()); return m_activeInMatrixModel[globalCellIndex] != cvf::UNDEFINED_SIZE_T; @@ -55,6 +60,11 @@ bool RigActiveCellInfo::isActiveInMatrixModel(size_t globalCellIndex) const //-------------------------------------------------------------------------------------------------- size_t RigActiveCellInfo::activeIndexInMatrixModel(size_t globalCellIndex) const { + if (m_activeInMatrixModel.size() == 0) + { + return cvf::UNDEFINED_SIZE_T; + } + CVF_TIGHT_ASSERT(globalCellIndex < m_activeInMatrixModel.size()); return m_activeInMatrixModel[globalCellIndex]; @@ -75,6 +85,11 @@ void RigActiveCellInfo::setActiveIndexInMatrixModel(size_t globalCellIndex, size //-------------------------------------------------------------------------------------------------- bool RigActiveCellInfo::isActiveInFractureModel(size_t globalCellIndex) const { + if (m_activeInFractureModel.size() == 0) + { + return false; + } + CVF_TIGHT_ASSERT(globalCellIndex < m_activeInFractureModel.size()); return m_activeInFractureModel[globalCellIndex] != cvf::UNDEFINED_SIZE_T; @@ -85,6 +100,11 @@ bool RigActiveCellInfo::isActiveInFractureModel(size_t globalCellIndex) const //-------------------------------------------------------------------------------------------------- size_t RigActiveCellInfo::activeIndexInFractureModel(size_t globalCellIndex) const { + if (m_activeInFractureModel.size() == 0) + { + return cvf::UNDEFINED_SIZE_T; + } + CVF_TIGHT_ASSERT(globalCellIndex < m_activeInFractureModel.size()); return m_activeInFractureModel[globalCellIndex]; From 208e904f574da6b3a5a468e3f85636263bb38b34 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 7 Mar 2013 14:57:28 +0100 Subject: [PATCH 091/242] Rebuild geometry after computing new active cell info, and update views p4#: 20821 --- .../ProjectDataModel/RimStatisticalCalculation.cpp | 9 +++++++++ ApplicationCode/ReservoirDataModel/RigStatistics.cpp | 1 + 2 files changed, 10 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp index c11aa7b19a..7941e0892f 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp @@ -149,6 +149,15 @@ void RimStatisticalCalculation::computeStatistics() RigStatistics stat(sourceCases, timeStepIndices, statisticsConfig, resultCase); stat.evaluateStatistics(RimDefines::DYNAMIC_NATIVE, m_resultName); + + for (size_t i = 0; i < reservoirViews().size(); i++) + { + RimReservoirView* reservoirView = reservoirViews()[i]; + CVF_ASSERT(reservoirView); + + reservoirView->scheduleGeometryRegen(RivReservoirViewPartMgr::ACTIVE); + reservoirView->createDisplayModelAndRedraw(); + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp index 0f1a4f2dab..5f02c52a4e 100644 --- a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp +++ b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp @@ -118,6 +118,7 @@ void RigStatistics::computeActiveCellUnion() } m_destinationCase->activeCellInfo()->computeDerivedData(); + m_destinationCase->computeCachedData(); } //-------------------------------------------------------------------------------------------------- From d4a28126d180ff45590a1d7cdcf462e52948794c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 7 Mar 2013 16:47:42 +0100 Subject: [PATCH 092/242] Added several new icons, including zoom all p4#: 20823 --- .../RimIdenticalGridCaseGroup.cpp | 6 +++--- .../ProjectDataModel/RimResultReservoir.cpp | 2 ++ .../RimStatisticalCalculation.cpp | 1 + ApplicationCode/Resources/AppLogo48x48.png | Bin 2520 -> 2842 bytes ApplicationCode/Resources/Cases16x16.png | Bin 0 -> 686 bytes .../Resources/CreateGridCaseGroup16x16.png | Bin 0 -> 669 bytes .../Resources/GridCaseGroup16x16.png | Bin 0 -> 525 bytes ApplicationCode/Resources/Histogram16x16.png | Bin 0 -> 280 bytes ApplicationCode/Resources/Histograms16x16.png | Bin 0 -> 454 bytes ApplicationCode/Resources/ResInsight.qrc | 8 +++++++- ApplicationCode/Resources/ZoomAll16x16.png | Bin 0 -> 899 bytes ApplicationCode/Resources/new16x16.png | Bin 0 -> 342 bytes .../UserInterface/RIMainWindow.cpp | 4 ++-- 13 files changed, 15 insertions(+), 6 deletions(-) create mode 100644 ApplicationCode/Resources/Cases16x16.png create mode 100644 ApplicationCode/Resources/CreateGridCaseGroup16x16.png create mode 100644 ApplicationCode/Resources/GridCaseGroup16x16.png create mode 100644 ApplicationCode/Resources/Histogram16x16.png create mode 100644 ApplicationCode/Resources/Histograms16x16.png create mode 100644 ApplicationCode/Resources/ZoomAll16x16.png create mode 100644 ApplicationCode/Resources/new16x16.png diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index 2087510dd8..d4e4c78894 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -35,12 +35,12 @@ CAF_PDM_SOURCE_INIT(RimIdenticalGridCaseGroup, "RimIdenticalGridCaseGroup"); //-------------------------------------------------------------------------------------------------- RimIdenticalGridCaseGroup::RimIdenticalGridCaseGroup() { - CAF_PDM_InitObject("Grid Case Group", "", "", ""); + CAF_PDM_InitObject("Grid Case Group", ":/GridCaseGroup16x16.png", "", ""); CAF_PDM_InitField(&name, "UserDescription", QString("Grid Case Group"), "Name", "", "", ""); - CAF_PDM_InitFieldNoDefault(&statisticalReservoirCollection, "StatisticalReservoirCollection", "Derived Statistics", "", "", ""); - CAF_PDM_InitFieldNoDefault(&caseCollection, "CaseCollection", "Cases", "", "", ""); + CAF_PDM_InitFieldNoDefault(&statisticalReservoirCollection, "StatisticalReservoirCollection", "Derived Statistics", ":/Histograms16x16.png", "", ""); + CAF_PDM_InitFieldNoDefault(&caseCollection, "CaseCollection", "Cases", ":/Cases16x16.png", "", ""); caseCollection = new RimCaseCollection; statisticalReservoirCollection = new RimStatisticalCollection; diff --git a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp index 69d1d04d6c..0305842bac 100644 --- a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp @@ -35,6 +35,8 @@ CAF_PDM_SOURCE_INIT(RimResultReservoir, "EclipseCase"); RimResultReservoir::RimResultReservoir() : RimReservoir() { + CAF_PDM_InitObject("Eclipse Case", ":/AppLogo48x48.png", "", ""); + CAF_PDM_InitField(&caseFileName, "CaseFileName", QString(), "Case file name", "", "" ,""); CAF_PDM_InitField(&caseDirectory, "CaseFolder", QString(), "Directory", "", "" ,""); } diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp index 7941e0892f..27d6f00e80 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp @@ -37,6 +37,7 @@ CAF_PDM_SOURCE_INIT(RimStatisticalCalculation, "RimStatisticalCalculation"); RimStatisticalCalculation::RimStatisticalCalculation() : RimReservoir() { + CAF_PDM_InitObject("Case Group Statistics", ":/Histogram16x16.png", "", ""); CAF_PDM_InitField(&m_resultName, "ResultName", QString("PRESSURE"), "ResultName", "", "", ""); m_readerInterface = new RifReaderStatisticalCalculation; diff --git a/ApplicationCode/Resources/AppLogo48x48.png b/ApplicationCode/Resources/AppLogo48x48.png index ec13d014fcc2b0b2d2e547876f66133e020cad50..8015d06ea7a66a9244b42f3eaf4b0fe542bb6aa6 100644 GIT binary patch delta 2795 zcmVCU_oshOIr(2{K_wW`_Jh0GJ$Sdw!yi178Ln%$>d) zbAZi(E&|7aZ;egxjXPO9^8D94!2Q?rf2wx`U~-%&cXA8x2(SzIJaA+^=S9HxK^<7T z>g6p=^Qc?~z5~2EHo?~?$C0s#^_S)VBtHn1$#I6QcpXn|3rPDHPL4AS4Cnbh3LMVA zfA7gjYdjA;59(DYgmB;PVS2G;xs|ZA5_6@|!ntb!0@wVOTNgM1OaRBnCYZmY6q+38 zFMxUA959=QwGP||JPK?84ge1TMIaIgf&g~ys7tvVP$_yCfiMhn=agP-Nz#mB6kwgw zi!(B-H0D?6#VNhSX&fu6*JMElcn$blf8g)$M789Hf5N}05&%niIBkB)`*PGzHe^MQl}WRKD|UB3=CTaE0hX>EG+i)a-*%Ce{N=S z00Ho4!0!S71pN7}02t$O#Rvu8XV4fni7=Q0@YVqMzL7%Yn|ifi2CC5w&a0|+dYPS` z@1_?UUHks|#Z+&@UJptMw$#MSumixT&6<$E(b0~FC z5o09ug>9Q_QYl5^`9^)uh%tf)e@MZc>CRHZFk*z@~%Kjm3I_=fBy7e^T!_u zz$yV%7g~u<&vo6IOUo{?_?bmj@z!zLI>i&Y#u2R+kl#IeBakGqG+VL$?EN`)in+-p znDyQEa#sM7Om(i=(>LF5XeYsD7T+mqUBB~!9~H4#0?u;XRi^ntXy_qd`0V=8NHgU> zUcIOo;^g=Ke@2q-@(mz{D)70- zZ%*(FmzD_w!=)<=wAzqe*I9UnHa9o^;$m~~?4_ohn`ydpmzQ;Ru_fnb+S*v`O0$Q= zDdJqe^MYTfFtq!S?mhezTSp!tDi3J4(_y|bBk#WTigr6)5Yebm)W8q5P#cn^>9gW& za!n!Gj-k2SWY4yNe{~}

YB{pUs0+HV#CTO98ERigT+c?)~N=Mtdpyy9w1+57UnE zmpX`3B*~D>A^qVKF_i0D*>V44?EAIfrZTuwt#!1Pm*l(OctKzN@%MCLzG43R^v_7* zo(^mnk|2tR3S})+H%i=Ek~HpMj6qdJ1eQAJ?0l1bJJtu`e|duE8H$B~Y9(a*)+)o> zD$F)kzVChhS11766*ehU^RmKZ_D1Isp|W8cdk#Ov&Vx^=_@O3A%$ZXsIX?NXI(7bx z=d3kxw&(U9Q=(hX?^Q`pm6!p zc`p3&7joj*cV%&I*66iN6M)w860?`5O%xWiSQ*fAZHS;)A&knhVaqUKu}*tw27ow& zUrsl5Wu>XAO0813ZMpAzLHI;iuJ13D2C9BoFj-;=e~OWoszZe3I$>0%wt1%nQAxv6 zeO2a?m@}tO@ybj8W>Cw@(&Bn`{?(T+G^Tm|#7kbc`zd?i;IC2}+DTZfxYm{PrhWcB z{IG~kdy-@-nMFGZdTwr6-Kk}*7GX=x$dLz!*9GHm9eMP?!6*M+IA@)zA|hAI z2Im}#f1%S}CP`A6y*#C_zx+e#wwD1_5t01#Q{a4F+Xs0)qk!LPE_v^re8UuqW!-=9 zu&WO4G@c)6lC-7Wm||}F47eUnRpJy$($$5X1Z}K1PG7m8Mo{Mv=Rky0#_*DFyu!IG z%i4%nwKkJ(r!CEehE{5IsniB=&e2+FYGZmzf9GbVWo5akiWQe6q;af@s;VYH3-~$k zLjHXc_%^Trd^q>3935kL&pwHw0?uY+X^*6{Ow#MHvM>$SsR;sX7UR+s>oTxb!eUvC7o3;z z(cARhV$}DHf>8wLY-XKv3D5+70DK*I8|X|NyKw?HKFUtu)4&&jCxB8v*}Wj3f4*Um zoqI=Q*S-U~cjQ5WC`1&TT20ebT-qZ`V^x~~24g&lN&^~|s&c!YPzANlsZ(r*x~{4& z0%w5tfPV(wm^eoF7JE$P0Jr6B>PVkLiA_`HXJ?q7o#Eu`CnSm@Hg4I*@SYKU;Ls8A z!w}#1@q!}8j}VMlRl1#yAbu+2f1|5qX6v^)xg8kHCxAmasPJ|^eq;dpA|m6&#XW xB|o^0JpVQMuv2V&6thPDJ`uQQ_w0Ym{s$%36X@Vn{(}Gj002ovPDHLkV1fq-ZFm3x delta 2473 zcmV;a30C%+7T6PzF_A+Xf7=Qb1|1%lwA76N010YIL_t(&-tC!Nh@Dpz$A4?@{e9oL zcQTWiWHN1%#>Tc<1+`ekNTeu65w8e7XemAjB@{*9e9(wK_@+_{ijN8wd{9K%6tz-~ z;;m}Eq&6|vrkzYOmvhd{Ip24_%U(X5J#m_(29t`2vtaWLY-aQSf3LmPf339-Y}%%6 z+NN#Vrfu4${eRltLl4DrqlX;chX4++fCmzw7Pbu#g*^q9fZ>57=*s|pI}phYf;T`1 z;Wm^Rv8-yvYk}JX;1;kwkcxmG0*?Um2aZr)C-4TaGo1OHyFu_1z{G8A4@<56hQfJ+)55SAO3G7ft3OD_@M{&-vD0+?gBoJ;jQ9` zYEzsohft+VsN%)a5hP2k^1MdOe zh_KDnC_8(I>NCt5N1`w+OL|#BJ}k&e&#hSY!sU=nysD1NsAUEt5a z(Zl<$e^e^@7v2YW6YyCquZWs#t4&j{Z%1sMQeZhP=q(Ru_fuxloTO4rIJ1&*9gy{< zAOhO1QSIJ}ZzYH-SuvtFSfHQIV~Rdalol`wo_C=DJ_kGw`~sXT*G0ck-!FKJgwO_k-m;>3kMD+_&YPjhar#_=16nD?rv zSG1pD(*i%p@!Q%|vBRuoXjW1-5@Hk(thFR!F~%{9n^eUP=$&VI&}ECa)V)Qmf2W7z zVjSaU+r;iN@CMl8mAi*I@6QT$S;Lenoyyay6jUh{p3iblztE#xT;XB3X_d<~V1Oyh1Pb(M}DGEFxplMufy!rqz;JhnSrxHM+|^dO75c7RTyM&b8{a z8!?lY-+%$yz@1)sqgUERb*ZOUe}!JsVi7jieXN_J4Cxfb`M8v^W*Bet}ta#pFFhLvZ2-(Kt>hOe;_AqB^Yb4 zrHA=0qKeLRP%Gdp;sX`|F@ldAHD`&vVu7>3Q^4>>?-gy@T1T{o(XxN8;1K|0r#wjQb<;pSC}HDOmj50NW1<|PvzBEsnQ&^ z7L6Ti7&(@k`og(re>W{%mAU*mZ^K9_=cixam|6VuO|HuJhMTBuAmBHU%!9}0L%2K! zd>?ocIL&w#C<3`6v=n7<%59-eYz#fA6v+xqWWgHn9+fc@(eb|K6=yE$#E-wX<-QAl zXxyXE+qwM9U;S<60FEDeQ1^cRYg2!^^Zx2}fBnYeQJJ=Zf7gciFD|=*vtd0A{3Rsr zJTQ3piAzM+tvq-y{ctPup;eAUXbwW&bO4icg-~h*@5g~a2Am7)h0y9=4fu=f;Jq|} zw*wCVcZPF|f3UsvYQkX0@}tHuFv2rK+xq5jZvVt@dYxS-kALBlt5=-|)VTSRJKs5& zz4+8w;MW1P-JtbV2$2e?t_6I9rNA%3cR%m}U~dR7A6B#>th7>mrF8Ke6L_RopZ>vW zYi{NE7e1N)tAS>1(43WrpSYwV>mC$?BRp~)3*aMQ_)_5iD+DehV}n4f$8{9)tGwQD n-L(I;A0HTG(+ivSKW_g3HR?FK-)0L^00000NkvXXu0mjf>`k1; diff --git a/ApplicationCode/Resources/Cases16x16.png b/ApplicationCode/Resources/Cases16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..843e4d95a5d6655d9c6c84e8ee7db8a59df4d5c2 GIT binary patch literal 686 zcmV;f0#W^mP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2i*e) z4ipHI=#^Cf0013nR9JLFZ*6U5Zgc_CX>@2HM@dakWG-a~00067 zNklW&1(}u9LDkIw=>zyHZPk*Y&S+Jl_Cm?mEuiB5HE$^L=f-Q-uf5lKVVNi z6ublx#H$DC#fvw=lP?#+B3qlZ=_c9Tu4Z?$-5C!C329oe56txo^I?WCw2dWHq2W3K zd8y!K6u#bljx8KBdiMymBt?mI%$4$)`-Z{q5D|~!RQAH;OBl<#;;1jIAs!p}{8T(4 zjUF00uNpZ$7euM*r=WshBpC2>C-Ay%zb*-{7uNA{G{CEtX(m$6xGXvYas-*tYSn=G4JObG2gl=Fao2>ox(sMC0B6+z~2@t{^=C6*-n@Qs(quOcoma&~CLcs8`YBOCFbD>0?*{Iu2Mt0R0OhPtJxioqaf5`K9#mw^ zD8&THph0I07t^N&+TEUVy=e2s>R%5&2uJ`p+M{B&VvWXm@L`aXc+ha*Bpx*8as8JE z9}_s%qh?vAMr9oA*<_i5_)(u^*u(cWw{{!$OO;}C->*G2It?F=3z1ev*4Kf14+_9 U@Lf7dVgLXD07*qoM6N<$f=coyVgLXD literal 0 HcmV?d00001 diff --git a/ApplicationCode/Resources/CreateGridCaseGroup16x16.png b/ApplicationCode/Resources/CreateGridCaseGroup16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..65bb871267f6dbe6b0a578e6f4c241b3b658a4af GIT binary patch literal 669 zcmV;O0%HA%P)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2i*e) z4hS(Tnm_;m0013nR9JLFZ*6U5Zgc_CX>@2HM@dakWG-a~0005> zNkln#Xz=3!MfoIEwTfSX%zjbe>K>pQs4q2ESBa-H71_p)} zDEH2l^}VV(fyK8c@%EZ31eoRVO9;IcR8*ME@c;L$=Qm!Tx^i3m!Qsc^T8uh@#s3)? z7;2C;GcYiyz{Iv^U7Rlobo87S+zC+W(`H~ap6m|M*7x{!h4O=;zmdk+pCJgt6>fq{X62}zSY5?cj13@np& z2YmTteEY|5S%wd9RoIyRxJ?hrYz{>U10>MIz`#(4EU+PoftQnsL788eHJpiw(dPHB zfA>Co__M@&F2inY2K+}i_q(yrdBKe>PkOpn!|#t{-D!W6J*dCo=)-_i%R00000NkvXXu0mjf D-;giT literal 0 HcmV?d00001 diff --git a/ApplicationCode/Resources/GridCaseGroup16x16.png b/ApplicationCode/Resources/GridCaseGroup16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..ed3a90af25ea540f309a59ce2c96822bf6ab4096 GIT binary patch literal 525 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPggqW_Df^tFwRO^ngOLnIRD+&iT2y zsd*(pE(3#eQEFmIYKlU6W=V#EyQgnJie4%^(7F^)7sn8b(@Q7r^>zxBI5xlf+{Xn| z-QwF6B2hesR-}W`xgYZT)lMVf*7x$iioCA#=LuNsKaN1EL^MoKb9UTzPxHZXmg`9lsx4Z+p*yOzo*7Mi>ER>A z!`k-S_uQNqtJ&w`1^uo)SvK+9vJVQUcluQ3lw5o*tuXf`wRuk+W6ZJ5yLc*2z6V8w Mr>mdKI;Vst0L#_YkpKVy literal 0 HcmV?d00001 diff --git a/ApplicationCode/Resources/Histogram16x16.png b/ApplicationCode/Resources/Histogram16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..0a500bb9971d58a5a31e7e73235d98d3ec3754c9 GIT binary patch literal 280 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPggqW_CUq`J0bs%>oL^W`;zRIOpf) zrskCZxeN@>MX8A;sVNHOnI#zt?w-B@DSD~wK=FJ}7sn8b(`P4b(u3Sh9h4w?OvGuE3ql`LSvTIC$a(ORjRAiInGi<(0() Oa+9a4pUXO@geCw!h+Fgk literal 0 HcmV?d00001 diff --git a/ApplicationCode/Resources/Histograms16x16.png b/ApplicationCode/Resources/Histograms16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..08b0aa9f81bf2e19cd3c23b6937390e899b033b3 GIT binary patch literal 454 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPggqW_CU`>jNGOjDSM2nIRD+&iT2y zsd*(pE(3#eQEFmIYKlU6W=V#EyQgnJie4%^&^lR97sn8b(@Q6A^kQ}taXmlx<_<$4 z!6Sz_+;n_mHgI*^i0lYu5&YAXkSNNsal2n)YPxbq>(a1)4G}k%ZT%>mv^8!1($#NT zT=Pvo?09bYyffxj^M~DjoZf$|FVv(-y#1#B0Ayq45^}5 zYfFFMW;hx2cEt)Ffvx<0;igIu^pdsq1=T_Ww7$)88>{Z)Hd?3+n$m z#ZtcdiqI-$gT+Z38ZY$~%w`c%ygFxb`;6%((`TC=m~}70QKyB0i}w^)Y2!bag-fo! z`!4<|+M8?Y&0@s`YXToctave.png Folder.png EclipseInput48x48.png - + Cases16x16.png + CreateGridCaseGroup16x16.png + GridCaseGroup16x16.png + Histogram16x16.png + Histograms16x16.png + ZoomAll16x16.png + fs_CellFace.glsl vs_CellFace.glsl diff --git a/ApplicationCode/Resources/ZoomAll16x16.png b/ApplicationCode/Resources/ZoomAll16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..9970c772eed3f18453d0f130fa48385eb841a24b GIT binary patch literal 899 zcmV-}1AP36P)Px#24YJ`L;#Bbv;fH;nieDg000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2i*e) z4-+wiZsDx}0013nR9JLFZ*6U5Zgc_CX>@2HM@dakWG-a~0008o zNklAIr z{Q)jjBhdN;MpF~Dav2bmN{cMaPILL&5pGZZ0}xEaqp3PT0IR&3hy*%r{4~ncR02)Y`RwF3C?yFmUy9e`=HR&>P)bAT8g@rB{+6ZB z0UI{$4fOS}kj?SQwl((_t(2IVnnDwT$hsHvK&E~J4RBbNMJzhXiuN}8zZyarc6^47 zqeE9P(GPz-Av-87CCyu1=H*pmZ(``1KE-%$;8JE{jdUl$vZ}c)VJ73LYQqr*5 znEY#EP%5z}cJWj}G+OoirX4LVpMURDovWWo&&@7b*VUz@Qc0WJ|J&uSFRsnZ{QHvE z@0VHAtSy+?0U^Xeaeq1bhp&5qwLmj44Ws~TJa!}Z%jmTsx62s`JQgCIOja|Q{Cn~t z1v7ykfh)kTzy$E;$wMFA!jkV7?k<{UCXL(UQT8U|xZn};?B;hR!rEkL@_Zl^^5paR Z)PKeT1!k%> literal 0 HcmV?d00001 diff --git a/ApplicationCode/Resources/new16x16.png b/ApplicationCode/Resources/new16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..7acec898d27de660779935cb4655d8f9f777da51 GIT binary patch literal 342 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPggqW_CUEr|jCYg?Ofr@Q0JD%Ql z{T}^2jq6E#?(+$E=QB)9R$EdTFVoym(-0}Qz2}s6oa9jnM$@nE^%g3Y^NMeBYDrX7 z8Veac_?S1nk|}7BVvLf|8lM;~8J_?9jQ>;>KlwiWd(QS&->^*Kl6}og%!fZ#u9L32 z`{eYm`u?~7|L^V*EiadT6KB4+%+&B+dVomFh4+5eyXy9@{PX{{=-Ef=?X&hsx*gPz ah+|+VXSaMHk$U?d$VZ;8elF{r5}E+Fczc@w literal 0 HcmV?d00001 diff --git a/ApplicationCode/UserInterface/RIMainWindow.cpp b/ApplicationCode/UserInterface/RIMainWindow.cpp index 1bfe378096..5ac2d342d6 100644 --- a/ApplicationCode/UserInterface/RIMainWindow.cpp +++ b/ApplicationCode/UserInterface/RIMainWindow.cpp @@ -178,7 +178,7 @@ void RIMainWindow::createActions() // File actions m_openAction = new QAction(QIcon(":/AppLogo48x48.png"), "&Open Eclipse Case", this); m_openInputEclipseFileAction= new QAction(QIcon(":/EclipseInput48x48.png"), "&Open Input Eclipse Case", this); - m_openMultipleEclipseCasesAction = new QAction(QIcon(":/AppLogo48x48.png"), "&Create Grid Case Group from Files", this); + m_openMultipleEclipseCasesAction = new QAction(QIcon(":/CreateGridCaseGroup16x16.png"), "&Create Grid Case Group from Files", this); m_openProjectAction = new QAction(style()->standardIcon(QStyle::SP_DirOpenIcon), "&Open Project", this); m_openLastUsedProjectAction = new QAction("Open &Last Used Project", this); @@ -238,7 +238,7 @@ void RIMainWindow::createActions() m_viewFromBelow = new QAction(QIcon(":/UpViewArrow.png"),"Look Up", this); m_viewFromBelow->setToolTip("Look Up"); - m_zoomAll = new QAction(QIcon(),"Zoom all", this); + m_zoomAll = new QAction(QIcon(":/ZoomAll16x16.png"),"Zoom all", this); m_zoomAll->setToolTip("Zoom to view all"); connect(m_viewFromNorth, SIGNAL(triggered()), SLOT(slotViewFromNorth())); From f6fa8016077f8163b8f0586fb401e29e02a3b8eb Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 8 Mar 2013 08:24:40 +0100 Subject: [PATCH 093/242] Use raw pointers in file readers to avoid circular references p4#: 20826 --- ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp | 7 ++++--- ApplicationCode/FileInterface/RifReaderEclipseOutput.h | 2 +- ApplicationCode/FileInterface/RifReaderMockModel.cpp | 6 +++--- ApplicationCode/FileInterface/RifReaderMockModel.h | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index 838921b441..9541d311b3 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -207,6 +207,7 @@ RifReaderEclipseOutput::RifReaderEclipseOutput() //-------------------------------------------------------------------------------------------------- RifReaderEclipseOutput::~RifReaderEclipseOutput() { + close(); } @@ -440,7 +441,7 @@ bool RifReaderEclipseOutput::openAndReadActiveCellData(const QString& fileName, //-------------------------------------------------------------------------------------------------- bool RifReaderEclipseOutput::readActiveCellInfo() { - CVF_ASSERT(m_eclipseCase.notNull()); + CVF_ASSERT(m_eclipseCase); CVF_ASSERT(m_eclipseCase->mainGrid()); QString egridFileName = RifEclipseOutputFileTools::fileNameByType(m_fileSet, ECL_EGRID_FILE); @@ -521,7 +522,7 @@ bool RifReaderEclipseOutput::readActiveCellInfo() //-------------------------------------------------------------------------------------------------- bool RifReaderEclipseOutput::buildMetaData() { - CVF_ASSERT(m_eclipseCase.notNull()); + CVF_ASSERT(m_eclipseCase); CVF_ASSERT(m_fileSet.size() > 0); caf::ProgressInfo progInfo(m_fileSet.size() + 3,""); @@ -712,7 +713,7 @@ bool RifReaderEclipseOutput::dynamicResult(const QString& result, PorosityModelR //-------------------------------------------------------------------------------------------------- void RifReaderEclipseOutput::readWellCells() { - CVF_ASSERT(m_eclipseCase.notNull()); + CVF_ASSERT(m_eclipseCase); if (m_dynamicResultsAccess.isNull()) return; diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.h b/ApplicationCode/FileInterface/RifReaderEclipseOutput.h index e69781b20f..832eaa5376 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.h +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.h @@ -71,7 +71,7 @@ private: QString m_fileName; // Name of file used to start accessing Eclipse output files QStringList m_fileSet; // Set of files in filename's path with same base name as filename - cvf::ref m_eclipseCase; + RigEclipseCase* m_eclipseCase; QList m_timeSteps; diff --git a/ApplicationCode/FileInterface/RifReaderMockModel.cpp b/ApplicationCode/FileInterface/RifReaderMockModel.cpp index 43d7a76e74..e81d5cb840 100644 --- a/ApplicationCode/FileInterface/RifReaderMockModel.cpp +++ b/ApplicationCode/FileInterface/RifReaderMockModel.cpp @@ -96,7 +96,7 @@ void RifReaderMockModel::close() //-------------------------------------------------------------------------------------------------- bool RifReaderMockModel::inputProperty(const QString& propertyName, std::vector* values) { - return m_reservoirBuilder.inputProperty(m_reservoir.p(), propertyName, values); + return m_reservoirBuilder.inputProperty(m_reservoir, propertyName, values); } //-------------------------------------------------------------------------------------------------- @@ -104,7 +104,7 @@ bool RifReaderMockModel::inputProperty(const QString& propertyName, std::vector< //-------------------------------------------------------------------------------------------------- bool RifReaderMockModel::staticResult(const QString& result, RifReaderInterface::PorosityModelResultType matrixOrFracture, std::vector* values) { - m_reservoirBuilder.staticResult(m_reservoir.p(), result, values); + m_reservoirBuilder.staticResult(m_reservoir, result, values); return true; } @@ -114,7 +114,7 @@ bool RifReaderMockModel::staticResult(const QString& result, RifReaderInterface: //-------------------------------------------------------------------------------------------------- bool RifReaderMockModel::dynamicResult(const QString& result, RifReaderInterface::PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector* values) { - m_reservoirBuilder.dynamicResult(m_reservoir.p(), result, stepIndex, values); + m_reservoirBuilder.dynamicResult(m_reservoir, result, stepIndex, values); return true; } diff --git a/ApplicationCode/FileInterface/RifReaderMockModel.h b/ApplicationCode/FileInterface/RifReaderMockModel.h index 22f9dc05e3..b2e4f1cbd4 100644 --- a/ApplicationCode/FileInterface/RifReaderMockModel.h +++ b/ApplicationCode/FileInterface/RifReaderMockModel.h @@ -44,6 +44,6 @@ private: bool inputProperty( const QString& propertyName, std::vector* values ); RigReservoirBuilderMock m_reservoirBuilder; - cvf::ref m_reservoir; + RigEclipseCase* m_reservoir; }; From 0a02805a8f0452bc76a3d80eb856c8970228f7ed Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 8 Mar 2013 08:35:27 +0100 Subject: [PATCH 094/242] Added assert on ref count of referenced object, as this object is assumed to be released in the destructor p4#: 20827 --- ApplicationCode/ProjectDataModel/RimReservoir.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/RimReservoir.cpp b/ApplicationCode/ProjectDataModel/RimReservoir.cpp index d31bceba9c..a6f60f67a2 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoir.cpp @@ -88,6 +88,9 @@ void RimReservoir::initAfterRead() RimReservoir::~RimReservoir() { reservoirViews.deleteAllChildObjects(); + + // At this point, we assume that memory should be released + CVF_ASSERT(m_rigEclipseCase->refCount() == 1); } //-------------------------------------------------------------------------------------------------- From 9605a1eec94425409db22424d503675481cdc74a Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 8 Mar 2013 08:36:30 +0100 Subject: [PATCH 095/242] Added clear method to make sure all objects are destroyed. p4#: 20828 --- ApplicationCode/ProjectDataModel/RimProject.cpp | 5 +---- ApplicationCode/ReservoirDataModel/RigGridCollection.cpp | 8 ++++++++ ApplicationCode/ReservoirDataModel/RigGridCollection.h | 2 ++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 06747c47e8..b0d63ecee7 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -65,10 +65,7 @@ RimProject::~RimProject(void) //-------------------------------------------------------------------------------------------------- void RimProject::close() { - for (size_t i = 0; i < reservoirs.size(); i++) - { - m_gridCollection->removeCase(reservoirs[i]->reservoirData()); - } + m_gridCollection->clear(); reservoirs.deleteAllChildObjects(); caseGroups.deleteAllChildObjects(); diff --git a/ApplicationCode/ReservoirDataModel/RigGridCollection.cpp b/ApplicationCode/ReservoirDataModel/RigGridCollection.cpp index fa6c0822a9..f75659d19a 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridCollection.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridCollection.cpp @@ -88,6 +88,14 @@ bool RigGridCollection::isEqual(RigMainGrid* gridA, RigMainGrid* gridB) return true; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigGridCollection::clear() +{ + m_caseToGrid.clear(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigGridCollection.h b/ApplicationCode/ReservoirDataModel/RigGridCollection.h index 29ca2c84e0..446c48aa5b 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridCollection.h +++ b/ApplicationCode/ReservoirDataModel/RigGridCollection.h @@ -36,6 +36,8 @@ public: RigMainGrid* findEqualGrid(RigMainGrid* candidateGrid); + void clear(); + private: static bool isEqual(RigMainGrid* gridA, RigMainGrid* gridB); From 0a5102894bcd9ac21d8bbf24842c55aeca22e7ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 8 Mar 2013 10:49:33 +0100 Subject: [PATCH 096/242] Calculate statistics for all available properties in main case by default p4#: 20832 --- .../RimStatisticalCalculation.cpp | 11 +++- .../ReservoirDataModel/RigStatistics.cpp | 62 +++++++++++-------- .../ReservoirDataModel/RigStatistics.h | 2 +- 3 files changed, 46 insertions(+), 29 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp index 27d6f00e80..573b82ef8d 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp @@ -136,11 +136,13 @@ void RimStatisticalCalculation::computeStatistics() return; } + // The first source has been read completely from disk, and contains grid and meta data + // Use this information for all cases in the case group + size_t timeStepCount = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->maxTimeStepCount(); + RigStatisticsConfig statisticsConfig; std::vector timeStepIndices; - - size_t timeStepCount = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->maxTimeStepCount(); for (size_t i = 0; i < timeStepCount; i++) { timeStepIndices.push_back(i); @@ -149,7 +151,9 @@ void RimStatisticalCalculation::computeStatistics() RigEclipseCase* resultCase = reservoirData(); RigStatistics stat(sourceCases, timeStepIndices, statisticsConfig, resultCase); - stat.evaluateStatistics(RimDefines::DYNAMIC_NATIVE, m_resultName); + QStringList resultNames = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->resultNames(RimDefines::DYNAMIC_NATIVE); + + stat.evaluateStatistics(RimDefines::DYNAMIC_NATIVE, resultNames); for (size_t i = 0; i < reservoirViews().size(); i++) { @@ -159,6 +163,7 @@ void RimStatisticalCalculation::computeStatistics() reservoirView->scheduleGeometryRegen(RivReservoirViewPartMgr::ACTIVE); reservoirView->createDisplayModelAndRedraw(); } + } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp index 5f02c52a4e..173e87e1a7 100644 --- a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp +++ b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp @@ -71,28 +71,28 @@ void RigStatistics::computeActiveCellUnion() std::vector activeF(grid->cellCount(), 0); for (size_t localGridCellIdx = 0; localGridCellIdx < grid->cellCount(); localGridCellIdx++) + { + for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++) { - for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++) - { size_t globalCellIdx = grid->globalGridCellIndex(localGridCellIdx); if (activeM[localGridCellIdx] == 0) - { + { if (m_sourceCases[caseIdx]->activeCellInfo()->isActiveInMatrixModel(globalCellIdx)) - { + { activeM[localGridCellIdx] = 1; - } } + } if (activeF[localGridCellIdx] == 0) - { + { if (m_sourceCases[caseIdx]->activeCellInfo()->isActiveInFractureModel(globalCellIdx)) - { + { activeF[localGridCellIdx] = 1; - } } } } + } size_t activeMatrixIndex = 0; size_t activeFractureIndex = 0; @@ -102,17 +102,17 @@ void RigStatistics::computeActiveCellUnion() size_t globalCellIdx = grid->globalGridCellIndex(localGridCellIdx); if (activeM[localGridCellIdx] != 0) - { + { m_destinationCase->activeCellInfo()->setActiveIndexInMatrixModel(globalCellIdx, globalActiveMatrixIndex++); activeMatrixIndex++; - } + } if (activeF[localGridCellIdx] != 0) - { + { m_destinationCase->activeCellInfo()->setActiveIndexInFractureModel(globalCellIdx, globalActiveFractureIndex++); activeFractureIndex++; - } } + } m_destinationCase->activeCellInfo()->setGridActiveCellCounts(gridIdx, activeMatrixIndex, activeFractureIndex); } @@ -121,25 +121,33 @@ void RigStatistics::computeActiveCellUnion() m_destinationCase->computeCachedData(); } +QString createResultNameMin(const QString& resultName) { return resultName + "_MIN"; } +QString createResultNameMax(const QString& resultName) { return resultName + "_MAX"; } +QString createResultNameMean(const QString& resultName) { return resultName + "_MEAN"; } +QString createResultNameDev(const QString& resultName) { return resultName + "_DEV"; } + + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, const QString& resultName) +void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, const QStringList& resultNames) { CVF_ASSERT(m_destinationCase.notNull()); computeActiveCellUnion(); - buildSourceMetaData(resultType, resultName); - - QString minResultName = resultName + "_MIN"; - QString maxResultName = resultName + "_MAX"; - QString meanResultName = resultName + "_MEAN"; - QString devResultName = resultName + "_DEV"; - + size_t activeMatrixCellCount = m_destinationCase->activeCellInfo()->globalMatrixModelActiveCellCount(); RigReservoirCellResults* matrixResults = m_destinationCase->results(RifReaderInterface::MATRIX_RESULTS); - size_t activeMatrixCellCount = m_destinationCase->activeCellInfo()->globalMatrixModelActiveCellCount(); + foreach(QString resultName, resultNames) + { + buildSourceMetaData(resultType, resultName); + + QString minResultName = createResultNameMin(resultName); + QString maxResultName = createResultNameMax(resultName); + QString meanResultName = createResultNameMean(resultName); + QString devResultName = createResultNameDev(resultName); + if (activeMatrixCellCount > 0) { addNamedResult(matrixResults, resultType, minResultName, activeMatrixCellCount); @@ -147,6 +155,7 @@ void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, con addNamedResult(matrixResults, resultType, meanResultName, activeMatrixCellCount); addNamedResult(matrixResults, resultType, devResultName, activeMatrixCellCount); } + } if (activeMatrixCellCount > 0) { @@ -161,6 +170,8 @@ void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, con { RigGridBase* grid = m_destinationCase->grid(gridIdx); + foreach(QString resultName, resultNames) + { // Build data access objects for source scalar results cvf::Collection dataAccesObjectList; for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++) @@ -183,7 +194,7 @@ void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, con cvf::ref dataAccessObjectDev = NULL; { - size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, minResultName); + size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, createResultNameMin(resultName)); if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) { dataAccessObjectMin = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); @@ -191,7 +202,7 @@ void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, con } { - size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, maxResultName); + size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, createResultNameMax(resultName)); if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) { dataAccessObjectMax = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); @@ -199,7 +210,7 @@ void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, con } { - size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, meanResultName); + size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, createResultNameMean(resultName)); if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) { dataAccessObjectMean = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); @@ -207,7 +218,7 @@ void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, con } { - size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, devResultName); + size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, createResultNameDev(resultName)); if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) { dataAccessObjectDev = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); @@ -252,6 +263,7 @@ void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, con } } } + } for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++) { diff --git a/ApplicationCode/ReservoirDataModel/RigStatistics.h b/ApplicationCode/ReservoirDataModel/RigStatistics.h index b3fb935d06..78845900a9 100644 --- a/ApplicationCode/ReservoirDataModel/RigStatistics.h +++ b/ApplicationCode/ReservoirDataModel/RigStatistics.h @@ -128,7 +128,7 @@ public: RigEclipseCase* destinationCase); - void evaluateStatistics(RimDefines::ResultCatType resultType, const QString& resultName); + void evaluateStatistics(RimDefines::ResultCatType resultType, const QStringList& resultNames); void debugOutput(RimDefines::ResultCatType resultType, const QString& resultName, size_t timeStepIdx); From 85f0d8b195eef0b4be755d7032b15aaf42b01903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 8 Mar 2013 11:14:27 +0100 Subject: [PATCH 097/242] Fixed "New View" command tree refresh behaviour. Still the expand icon is missing sometimes... p4#: 20833 --- ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index bb776ca2b0..8c9925f102 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -325,13 +325,17 @@ RimReservoirView* RimUiTreeModelPdm::addReservoirView(const QModelIndex& itemInd caf::PdmUiTreeItem* collectionItem = NULL; + bool itemIndexIsCollection = false; + QModelIndex collectionIndex; if (dynamic_cast(currentItem->dataObject().p())) { collectionItem = currentItem->parent(); + collectionIndex = itemIndex.parent(); } else if (dynamic_cast(currentItem->dataObject().p())) { collectionItem = currentItem; + collectionIndex = itemIndex; } if (collectionItem) @@ -339,8 +343,8 @@ RimReservoirView* RimUiTreeModelPdm::addReservoirView(const QModelIndex& itemInd RimReservoir* rimReservoir = dynamic_cast(collectionItem->dataObject().p()); RimReservoirView* insertedView = rimReservoir->createAndAddReservoirView(); - int viewCount = rowCount(itemIndex); - beginInsertRows(itemIndex, viewCount, viewCount); + int viewCount = rowCount(collectionIndex.parent()); + beginInsertRows(collectionIndex.parent(), viewCount, viewCount); caf::PdmUiTreeItem* childItem = new caf::PdmUiTreeItem(collectionItem, viewCount, insertedView); From 086262a4b6b8303eb41e508ff1365090ee54b072 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 11 Mar 2013 08:24:45 +0100 Subject: [PATCH 098/242] Fixed how to compute number of views in a collection p4#: 20842 --- ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index 8c9925f102..3efd3de8f6 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -343,8 +343,8 @@ RimReservoirView* RimUiTreeModelPdm::addReservoirView(const QModelIndex& itemInd RimReservoir* rimReservoir = dynamic_cast(collectionItem->dataObject().p()); RimReservoirView* insertedView = rimReservoir->createAndAddReservoirView(); - int viewCount = rowCount(collectionIndex.parent()); - beginInsertRows(collectionIndex.parent(), viewCount, viewCount); + int viewCount = rowCount(collectionIndex); + beginInsertRows(collectionIndex, viewCount, viewCount); caf::PdmUiTreeItem* childItem = new caf::PdmUiTreeItem(collectionItem, viewCount, insertedView); From 61e81151417e0af3285141024e8fffdce76cfe01 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 11 Mar 2013 14:04:48 +0100 Subject: [PATCH 099/242] Fixed indentation issues Renamed and added asserts p4#: 20846 --- .../ReservoirDataModel/RigStatistics.cpp | 190 +++++++++--------- 1 file changed, 96 insertions(+), 94 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp index 173e87e1a7..08fe187986 100644 --- a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp +++ b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp @@ -25,21 +25,23 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigStatistics::addNamedResult(RigReservoirCellResults* cellResults, RimDefines::ResultCatType resultType, const QString& resultName, size_t activeCellCount) +void RigStatistics::addNamedResult(RigReservoirCellResults* destinationCellResults, RimDefines::ResultCatType resultType, const QString& resultName, size_t activeUnionCellCount) { // Use time step dates from first result in first source case CVF_ASSERT(m_sourceCases.size() > 0); - QList timeStepDates = m_sourceCases[0]->results(RifReaderInterface::MATRIX_RESULTS)->timeStepDates(0); - size_t resultIndexMin = cellResults->addEmptyScalarResult(resultType, resultName); - cellResults->setTimeStepDates(resultIndexMin, timeStepDates); - - std::vector< std::vector >& dataValues = cellResults->cellScalarResults(resultIndexMin); - dataValues.resize(timeStepDates.size()); + QList sourceTimeStepDates = m_sourceCases[0]->results(RifReaderInterface::MATRIX_RESULTS)->timeStepDates(0); + size_t destinationScalarResultIndex = destinationCellResults->addEmptyScalarResult(resultType, resultName); + CVF_ASSERT(destinationScalarResultIndex != cvf::UNDEFINED_SIZE_T); - for (int i = 0; i < timeStepDates.size(); i++) + destinationCellResults->setTimeStepDates(destinationScalarResultIndex, sourceTimeStepDates); + std::vector< std::vector >& dataValues = destinationCellResults->cellScalarResults(destinationScalarResultIndex); + dataValues.resize(sourceTimeStepDates.size()); + + // Initializes the size of the destination dataset to active union cell count + for (int i = 0; i < sourceTimeStepDates.size(); i++) { - dataValues[i].resize(activeCellCount, HUGE_VAL); + dataValues[i].resize(activeUnionCellCount, HUGE_VAL); } } @@ -71,28 +73,28 @@ void RigStatistics::computeActiveCellUnion() std::vector activeF(grid->cellCount(), 0); for (size_t localGridCellIdx = 0; localGridCellIdx < grid->cellCount(); localGridCellIdx++) - { - for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++) { + for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++) + { size_t globalCellIdx = grid->globalGridCellIndex(localGridCellIdx); if (activeM[localGridCellIdx] == 0) - { - if (m_sourceCases[caseIdx]->activeCellInfo()->isActiveInMatrixModel(globalCellIdx)) { + if (m_sourceCases[caseIdx]->activeCellInfo()->isActiveInMatrixModel(globalCellIdx)) + { activeM[localGridCellIdx] = 1; + } } - } if (activeF[localGridCellIdx] == 0) - { - if (m_sourceCases[caseIdx]->activeCellInfo()->isActiveInFractureModel(globalCellIdx)) { + if (m_sourceCases[caseIdx]->activeCellInfo()->isActiveInFractureModel(globalCellIdx)) + { activeF[localGridCellIdx] = 1; + } } } } - } size_t activeMatrixIndex = 0; size_t activeFractureIndex = 0; @@ -102,17 +104,17 @@ void RigStatistics::computeActiveCellUnion() size_t globalCellIdx = grid->globalGridCellIndex(localGridCellIdx); if (activeM[localGridCellIdx] != 0) - { + { m_destinationCase->activeCellInfo()->setActiveIndexInMatrixModel(globalCellIdx, globalActiveMatrixIndex++); activeMatrixIndex++; - } + } if (activeF[localGridCellIdx] != 0) - { + { m_destinationCase->activeCellInfo()->setActiveIndexInFractureModel(globalCellIdx, globalActiveFractureIndex++); activeFractureIndex++; + } } - } m_destinationCase->activeCellInfo()->setGridActiveCellCounts(gridIdx, activeMatrixIndex, activeFractureIndex); } @@ -141,20 +143,20 @@ void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, con foreach(QString resultName, resultNames) { - buildSourceMetaData(resultType, resultName); + buildSourceMetaData(resultType, resultName); QString minResultName = createResultNameMin(resultName); QString maxResultName = createResultNameMax(resultName); QString meanResultName = createResultNameMean(resultName); QString devResultName = createResultNameDev(resultName); - if (activeMatrixCellCount > 0) - { - addNamedResult(matrixResults, resultType, minResultName, activeMatrixCellCount); - addNamedResult(matrixResults, resultType, maxResultName, activeMatrixCellCount); - addNamedResult(matrixResults, resultType, meanResultName, activeMatrixCellCount); - addNamedResult(matrixResults, resultType, devResultName, activeMatrixCellCount); - } + if (activeMatrixCellCount > 0) + { + addNamedResult(matrixResults, resultType, minResultName, activeMatrixCellCount); + addNamedResult(matrixResults, resultType, maxResultName, activeMatrixCellCount); + addNamedResult(matrixResults, resultType, meanResultName, activeMatrixCellCount); + addNamedResult(matrixResults, resultType, devResultName, activeMatrixCellCount); + } } if (activeMatrixCellCount > 0) @@ -172,98 +174,98 @@ void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, con foreach(QString resultName, resultNames) { - // Build data access objects for source scalar results - cvf::Collection dataAccesObjectList; - for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++) - { - RigEclipseCase* eclipseCase = m_sourceCases.at(caseIdx); - - size_t scalarResultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->findOrLoadScalarResultForTimeStep(resultType, resultName, timeStepIdx); - - cvf::ref dataAccessObject = eclipseCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); - if (dataAccessObject.notNull()) + // Build data access objects for source scalar results + cvf::Collection dataAccesObjectList; + for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++) { - dataAccesObjectList.push_back(dataAccessObject.p()); + RigEclipseCase* eclipseCase = m_sourceCases.at(caseIdx); + + size_t scalarResultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->findOrLoadScalarResultForTimeStep(resultType, resultName, timeStepIdx); + + cvf::ref dataAccessObject = eclipseCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); + if (dataAccessObject.notNull()) + { + dataAccesObjectList.push_back(dataAccessObject.p()); + } } - } - // Build data access objects form destination scalar results - cvf::ref dataAccessObjectMin = NULL; - cvf::ref dataAccessObjectMax = NULL; - cvf::ref dataAccessObjectMean = NULL; - cvf::ref dataAccessObjectDev = NULL; + // Build data access objects form destination scalar results + cvf::ref dataAccessObjectMin = NULL; + cvf::ref dataAccessObjectMax = NULL; + cvf::ref dataAccessObjectMean = NULL; + cvf::ref dataAccessObjectDev = NULL; - { + { size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, createResultNameMin(resultName)); - if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) - { - dataAccessObjectMin = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); + if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) + { + dataAccessObjectMin = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); + } } - } - { + { size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, createResultNameMax(resultName)); - if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) - { - dataAccessObjectMax = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); + if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) + { + dataAccessObjectMax = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); + } } - } - { + { size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, createResultNameMean(resultName)); - if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) - { - dataAccessObjectMean = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); + if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) + { + dataAccessObjectMean = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); + } } - } - { + { size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, createResultNameDev(resultName)); - if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) - { - dataAccessObjectDev = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); + if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) + { + dataAccessObjectDev = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); + } } - } - double min, max, mean, dev; - std::vector values(dataAccesObjectList.size(), HUGE_VAL); - for (size_t cellIdx = 0; cellIdx < grid->cellCount(); cellIdx++) - { - size_t globalGridCellIdx = grid->globalGridCellIndex(cellIdx); - if (m_destinationCase->activeCellInfo()->isActiveInMatrixModel(globalGridCellIdx)) + double min, max, mean, dev; + std::vector values(dataAccesObjectList.size(), HUGE_VAL); + for (size_t cellIdx = 0; cellIdx < grid->cellCount(); cellIdx++) { - for (size_t caseIdx = 0; caseIdx < dataAccesObjectList.size(); caseIdx++) + size_t globalGridCellIdx = grid->globalGridCellIndex(cellIdx); + if (m_destinationCase->activeCellInfo()->isActiveInMatrixModel(globalGridCellIdx)) { - double val = dataAccesObjectList.at(caseIdx)->cellScalar(cellIdx); - values[caseIdx] = val; - } + for (size_t caseIdx = 0; caseIdx < dataAccesObjectList.size(); caseIdx++) + { + double val = dataAccesObjectList.at(caseIdx)->cellScalar(cellIdx); + values[caseIdx] = val; + } - RigStatisticsEvaluator stat(values); - stat.getStatistics(min, max, mean, dev); + RigStatisticsEvaluator stat(values); + stat.getStatistics(min, max, mean, dev); - if (dataAccessObjectMin.notNull()) - { - dataAccessObjectMin->setCellScalar(cellIdx, min); - } + if (dataAccessObjectMin.notNull()) + { + dataAccessObjectMin->setCellScalar(cellIdx, min); + } - if (dataAccessObjectMax.notNull()) - { - dataAccessObjectMax->setCellScalar(cellIdx, max); - } + if (dataAccessObjectMax.notNull()) + { + dataAccessObjectMax->setCellScalar(cellIdx, max); + } - if (dataAccessObjectMean.notNull()) - { - dataAccessObjectMean->setCellScalar(cellIdx, mean); - } + if (dataAccessObjectMean.notNull()) + { + dataAccessObjectMean->setCellScalar(cellIdx, mean); + } - if (dataAccessObjectDev.notNull()) - { - dataAccessObjectDev->setCellScalar(cellIdx, dev); + if (dataAccessObjectDev.notNull()) + { + dataAccessObjectDev->setCellScalar(cellIdx, dev); + } } } } } - } for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++) { From 94065f29ed2383f71806c1ab0149372ba4063f11 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 12 Mar 2013 09:59:33 +0100 Subject: [PATCH 100/242] Removed obsolete code p4#: 20857 --- .../ReservoirDataModel/RigStatistics.cpp | 25 ------------------- .../ReservoirDataModel/RigStatistics.h | 2 +- 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp index 08fe187986..f1241dfd61 100644 --- a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp +++ b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp @@ -143,8 +143,6 @@ void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, con foreach(QString resultName, resultNames) { - buildSourceMetaData(resultType, resultName); - QString minResultName = createResultNameMin(resultName); QString maxResultName = createResultNameMax(resultName); QString meanResultName = createResultNameMean(resultName); @@ -317,26 +315,3 @@ RigStatistics::RigStatistics(cvf::Collection& sourceCases, const } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigStatistics::buildSourceMetaData(RimDefines::ResultCatType resultType, const QString& resultName) -{ - for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++) - { - RigEclipseCase* eclipseCase = m_sourceCases.at(caseIdx); - - RigReservoirCellResults* matrixResults = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS); - size_t scalarResultIndex = matrixResults->findOrLoadScalarResult(resultType, resultName); - if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) - { - QList timeStepDates = m_sourceCases[0]->results(RifReaderInterface::MATRIX_RESULTS)->timeStepDates(0); - - size_t scalarResultIndex = matrixResults->addEmptyScalarResult(resultType, resultName); - matrixResults->setTimeStepDates(scalarResultIndex, timeStepDates); - - std::vector< std::vector >& dataValues = matrixResults->cellScalarResults(scalarResultIndex); - dataValues.resize(timeStepDates.size()); - } - } -} diff --git a/ApplicationCode/ReservoirDataModel/RigStatistics.h b/ApplicationCode/ReservoirDataModel/RigStatistics.h index 78845900a9..88d1696429 100644 --- a/ApplicationCode/ReservoirDataModel/RigStatistics.h +++ b/ApplicationCode/ReservoirDataModel/RigStatistics.h @@ -135,7 +135,7 @@ public: private: void computeActiveCellUnion(); void addNamedResult(RigReservoirCellResults* cellResults, RimDefines::ResultCatType resultType, const QString& resultName, size_t activeCellCount); - void buildSourceMetaData( RimDefines::ResultCatType resultType, const QString& resultName ); + private: cvf::Collection m_sourceCases; std::vector m_timeStepIndices; From 9ab0a397ef360ef5e6f40ae036255e9c92b8f573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 12 Mar 2013 10:03:25 +0100 Subject: [PATCH 101/242] Removed the m_isWellCell member from RigCell, to make the grid data completely independent of case / result data p4#: 20859 --- .../RivReservoirViewPartMgr.cpp | 72 ++++++++++--------- .../RivReservoirViewPartMgr.h | 8 +-- .../ReservoirDataModel/RigCell.cpp | 1 - ApplicationCode/ReservoirDataModel/RigCell.h | 7 -- .../ReservoirDataModel/RigEclipseCase.cpp | 2 - 5 files changed, 41 insertions(+), 49 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp index dde461ce42..78ed1122b7 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp @@ -252,10 +252,10 @@ void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility, switch (geometryType) { case ACTIVE: - computeNativeVisibility(cellVisibility, grid, activeCellInfo, false, false, true, m_reservoirView->showMainGrid() ); + computeNativeVisibility(cellVisibility, grid, activeCellInfo, eclipseCase->wellCellsInGrid(gridIdx), false, false, true, m_reservoirView->showMainGrid() ); break; case ALL_WELL_CELLS: - computeAllWellCellsVisibility(cellVisibility, grid); + copyByteArray(cellVisibility, eclipseCase->wellCellsInGrid(gridIdx)); break; case VISIBLE_WELL_CELLS: { @@ -290,7 +290,7 @@ void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility, } break; case INACTIVE: - computeNativeVisibility(cellVisibility, grid, activeCellInfo, m_reservoirView->showInvalidCells(), true, false, m_reservoirView->showMainGrid()); + computeNativeVisibility(cellVisibility, grid, activeCellInfo, eclipseCase->wellCellsInGrid(gridIdx), m_reservoirView->showInvalidCells(), true, false, m_reservoirView->showMainGrid()); break; case RANGE_FILTERED: { @@ -385,28 +385,29 @@ void RivReservoirViewPartMgr::createPropertyFilteredGeometry(size_t frameIndex) bool hasActiveRangeFilters = m_reservoirView->rangeFilterCollection()->hasActiveFilters() || m_reservoirView->wellCollection()->hasVisibleWellCells(); - for (size_t i = 0; i < grids.size(); ++i) + for (size_t gIdx = 0; gIdx < grids.size(); ++gIdx) { - cvf::ref cellVisibility = m_propFilteredGeometryFrames[frameIndex]->cellVisibility(i); + cvf::ref cellVisibility = m_propFilteredGeometryFrames[frameIndex]->cellVisibility(gIdx); cvf::ref rangeVisibility; cvf::ref fenceVisibility; + cvf::cref cellIsWellCellStatuses = res->wellCellsInGrid(gIdx); if (m_geometriesNeedsRegen[RANGE_FILTERED]) createGeometry(RANGE_FILTERED); if (m_geometriesNeedsRegen[VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER]) createGeometry(VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER); - rangeVisibility = m_geometries[RANGE_FILTERED].cellVisibility(i); - fenceVisibility = m_geometries[VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER].cellVisibility(i); + rangeVisibility = m_geometries[RANGE_FILTERED].cellVisibility(gIdx); + fenceVisibility = m_geometries[VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER].cellVisibility(gIdx); cellVisibility->resize(rangeVisibility->size()); #pragma omp parallel for for (int cellIdx = 0; cellIdx < static_cast(cellVisibility->size()); ++cellIdx) { - (*cellVisibility)[cellIdx] = (!hasActiveRangeFilters && !grids[i]->cell(cellIdx).isWellCell()) || (*rangeVisibility)[cellIdx] || (*fenceVisibility)[cellIdx]; + (*cellVisibility)[cellIdx] = (!hasActiveRangeFilters && !(*cellIsWellCellStatuses)[cellIdx]) || (*rangeVisibility)[cellIdx] || (*fenceVisibility)[cellIdx]; } - computePropertyVisibility(cellVisibility.p(), grids[i], frameIndex, cellVisibility.p(), m_reservoirView->propertyFilterCollection()); + computePropertyVisibility(cellVisibility.p(), grids[gIdx], frameIndex, cellVisibility.p(), m_reservoirView->propertyFilterCollection()); - m_propFilteredGeometryFrames[frameIndex]->setCellVisibility(i, cellVisibility.p()); + m_propFilteredGeometryFrames[frameIndex]->setCellVisibility(gIdx, cellVisibility.p()); } m_propFilteredGeometryFramesNeedsRegen[frameIndex] = false; @@ -435,26 +436,28 @@ void RivReservoirViewPartMgr::createPropertyFilteredWellGeometry(size_t frameInd bool hasActiveRangeFilters = m_reservoirView->rangeFilterCollection()->hasActiveFilters() || m_reservoirView->wellCollection()->hasVisibleWellCells(); - for (size_t i = 0; i < grids.size(); ++i) + for (size_t gIdx = 0; gIdx < grids.size(); ++gIdx) { - cvf::ref cellVisibility = m_propFilteredWellGeometryFrames[frameIndex]->cellVisibility(i); + cvf::ref cellVisibility = m_propFilteredWellGeometryFrames[frameIndex]->cellVisibility(gIdx); cvf::ref rangeVisibility; cvf::ref wellCellsOutsideVisibility; + cvf::cref cellIsWellCellStatuses = res->wellCellsInGrid(gIdx); + if (m_geometriesNeedsRegen[RANGE_FILTERED_WELL_CELLS]) createGeometry(RANGE_FILTERED_WELL_CELLS); - rangeVisibility = m_geometries[RANGE_FILTERED_WELL_CELLS].cellVisibility(i); + rangeVisibility = m_geometries[RANGE_FILTERED_WELL_CELLS].cellVisibility(gIdx); if (m_geometriesNeedsRegen[VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER]) createGeometry(VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER); - wellCellsOutsideVisibility = m_geometries[VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER].cellVisibility(i); + wellCellsOutsideVisibility = m_geometries[VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER].cellVisibility(gIdx); cellVisibility->resize(rangeVisibility->size()); #pragma omp parallel for for (int cellIdx = 0; cellIdx < static_cast(cellVisibility->size()); ++cellIdx) { - (*cellVisibility)[cellIdx] = (!hasActiveRangeFilters && grids[i]->cell(cellIdx).isWellCell()) || (*rangeVisibility)[cellIdx] || (*wellCellsOutsideVisibility)[cellIdx]; + (*cellVisibility)[cellIdx] = (!hasActiveRangeFilters && !(*cellIsWellCellStatuses)[cellIdx]) || (*rangeVisibility)[cellIdx] || (*wellCellsOutsideVisibility)[cellIdx]; } - computePropertyVisibility(cellVisibility.p(), grids[i], frameIndex, cellVisibility.p(), m_reservoirView->propertyFilterCollection()); - m_propFilteredWellGeometryFrames[frameIndex]->setCellVisibility(i, cellVisibility.p()); + computePropertyVisibility(cellVisibility.p(), grids[gIdx], frameIndex, cellVisibility.p(), m_reservoirView->propertyFilterCollection()); + m_propFilteredWellGeometryFrames[frameIndex]->setCellVisibility(gIdx, cellVisibility.p()); } m_propFilteredWellGeometryFramesNeedsRegen[frameIndex] = false; @@ -463,7 +466,7 @@ void RivReservoirViewPartMgr::createPropertyFilteredWellGeometry(size_t frameInd //-------------------------------------------------------------------------------------------------- /// Evaluate visibility based on cell state //-------------------------------------------------------------------------------------------------- -void RivReservoirViewPartMgr::computeNativeVisibility(cvf::UByteArray* cellVisibility, const RigGridBase* grid, const RigActiveCellInfo* activeCellInfo, +void RivReservoirViewPartMgr::computeNativeVisibility(cvf::UByteArray* cellVisibility, const RigGridBase* grid, const RigActiveCellInfo* activeCellInfo, const cvf::UByteArray* cellIsInWellStatuses, bool invalidCellsIsVisible, bool inactiveCellsIsVisible, bool activeCellsIsVisible, @@ -472,6 +475,9 @@ void RivReservoirViewPartMgr::computeNativeVisibility(cvf::UByteArray* cellVisib CVF_ASSERT(cellVisibility != NULL); CVF_ASSERT(grid != NULL); CVF_ASSERT(activeCellInfo != NULL); + CVF_ASSERT(cellIsInWellStatuses != NULL); + CVF_ASSERT(cellIsInWellStatuses->size() >= grid->cellCount()); + cellVisibility->resize(grid->cellCount()); #pragma omp parallel for @@ -484,7 +490,7 @@ void RivReservoirViewPartMgr::computeNativeVisibility(cvf::UByteArray* cellVisib || !inactiveCellsIsVisible && !activeCellInfo->isActiveInMatrixModel(globalCellIndex) || !activeCellsIsVisible && activeCellInfo->isActiveInMatrixModel(globalCellIndex) || mainGridIsVisible && (cell.subGrid() != NULL) - || cell.isWellCell() + || (*cellIsInWellStatuses)[cellIndex] ) { (*cellVisibility)[cellIndex] = false; @@ -498,27 +504,23 @@ void RivReservoirViewPartMgr::computeNativeVisibility(cvf::UByteArray* cellVisib //-------------------------------------------------------------------------------------------------- -/// Evaluate Well cell visibility based on cell state +/// Copy the data from source into destination. This is not trivial to do using cvf::Array ... +/// using parallelized operator [] and not memcopy. Do not know what is faster. //-------------------------------------------------------------------------------------------------- -void RivReservoirViewPartMgr::computeAllWellCellsVisibility(cvf::UByteArray* cellVisibility, const RigGridBase* grid ) +void RivReservoirViewPartMgr::copyByteArray(cvf::UByteArray* destination, const cvf::UByteArray* source ) { - CVF_ASSERT(cellVisibility != NULL); - CVF_ASSERT(grid != NULL); - cellVisibility->resize(grid->cellCount()); + CVF_ASSERT(destination != NULL); + CVF_ASSERT(source != NULL); + + if (destination->size() != source->size()) + { + destination->resize(source->size()); + } #pragma omp parallel for - for (int cellIndex = 0; cellIndex < static_cast(grid->cellCount()); cellIndex++) + for (int cellIndex = 0; cellIndex < static_cast(source->size()); cellIndex++) { - const RigCell& cell = grid->cell(cellIndex); - - if ( cell.isWellCell() ) - { - (*cellVisibility)[cellIndex] = true; - } - else - { - (*cellVisibility)[cellIndex] = false; - } + (*destination)[cellIndex] = (*source)[cellIndex]; } } diff --git a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.h b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.h index b70bd89051..fb4bb6420b 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.h @@ -78,10 +78,10 @@ private: void clearGeometryCache(ReservoirGeometryCacheType geomType); - 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 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 computeNativeVisibility (cvf::UByteArray* cellVisibilities, const RigGridBase* grid, const RigActiveCellInfo* activeCellInfo, const cvf::UByteArray* cellIsInWellStatuses, bool invalidCellsIsVisible, bool inactiveCellsIsVisible, bool activeCellsIsVisible, bool mainGridIsVisible); + static void computeRangeVisibility (cvf::UByteArray* cellVisibilities, const RigGridBase* grid, const cvf::UByteArray* nativeVisibility, const RimCellRangeFilterCollection* rangeFilterColl); + static void computePropertyVisibility(cvf::UByteArray* cellVisibilities, const RigGridBase* grid, size_t timeStepIndex, const cvf::UByteArray* rangeFilterVisibility, RimCellPropertyFilterCollection* propFilterColl); + static void copyByteArray(cvf::UByteArray* cellVisibilities, const cvf::UByteArray* cellIsWellStatuses ); private: diff --git a/ApplicationCode/ReservoirDataModel/RigCell.cpp b/ApplicationCode/ReservoirDataModel/RigCell.cpp index 84f16b9fdc..7e0a83724d 100644 --- a/ApplicationCode/ReservoirDataModel/RigCell.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCell.cpp @@ -41,7 +41,6 @@ RigCell::RigCell() : m_subGrid(NULL), m_hostGrid(NULL), m_isInvalid(false), - m_isWellCell(false), m_cellIndex(cvf::UNDEFINED_SIZE_T), m_isInCoarseCell(false) { diff --git a/ApplicationCode/ReservoirDataModel/RigCell.h b/ApplicationCode/ReservoirDataModel/RigCell.h index f328103f05..7e920a3bdf 100644 --- a/ApplicationCode/ReservoirDataModel/RigCell.h +++ b/ApplicationCode/ReservoirDataModel/RigCell.h @@ -40,13 +40,9 @@ public: bool isInvalid() const { return m_isInvalid; } void setInvalid( bool val ) { m_isInvalid = val; } - bool isWellCell() const { return m_isWellCell; } - void setAsWellCell(bool isWellCell) { m_isWellCell = isWellCell; } - size_t cellIndex() const { return m_cellIndex; } void setCellIndex(size_t val) { m_cellIndex = val; } - RigLocalGrid* subGrid() const { return m_subGrid; } void setSubGrid(RigLocalGrid* subGrid) { m_subGrid = subGrid; } @@ -82,7 +78,4 @@ private: bool m_cellFaceFaults[6]; bool m_isInvalid; - - // Result case specific data - bool m_isWellCell; }; diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp index 474c5d0cc4..542081f701 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp @@ -141,7 +141,6 @@ void RigEclipseCase::computeWellCellsPrGrid() size_t gridCellIndex = wellCells.m_wellHead.m_gridCellIndex; CVF_ASSERT(gridIndex < m_wellCellsInGrid.size() && gridCellIndex < m_wellCellsInGrid[gridIndex]->size()); - grids[gridIndex]->cell(gridCellIndex).setAsWellCell(true); m_wellCellsInGrid[gridIndex]->set(gridCellIndex, true); size_t sIdx; @@ -156,7 +155,6 @@ void RigEclipseCase::computeWellCellsPrGrid() CVF_ASSERT(gridIndex < m_wellCellsInGrid.size() && gridCellIndex < m_wellCellsInGrid[gridIndex]->size()); - grids[gridIndex]->cell(gridCellIndex).setAsWellCell(true); m_wellCellsInGrid[gridIndex]->set(gridCellIndex, true); } } From 766996a9fde010203a224f537142cc5b4452a047 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 13 Mar 2013 07:58:49 +0100 Subject: [PATCH 102/242] Include static properties when computing statistics p4#: 20870 --- .../RimStatisticalCalculation.cpp | 22 ++++- .../RigReservoirCellResults.cpp | 4 + .../ReservoirDataModel/RigStatistics.cpp | 94 +++++++++++++++---- .../ReservoirDataModel/RigStatistics.h | 9 +- 4 files changed, 106 insertions(+), 23 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp index 573b82ef8d..a46b39bf8c 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp @@ -150,10 +150,26 @@ void RimStatisticalCalculation::computeStatistics() RigEclipseCase* resultCase = reservoirData(); - RigStatistics stat(sourceCases, timeStepIndices, statisticsConfig, resultCase); - QStringList resultNames = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->resultNames(RimDefines::DYNAMIC_NATIVE); + QList > resultSpecification; - stat.evaluateStatistics(RimDefines::DYNAMIC_NATIVE, resultNames); + { + QStringList resultNames = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->resultNames(RimDefines::DYNAMIC_NATIVE); + foreach(QString resultName, resultNames) + { + resultSpecification.append(qMakePair(RimDefines::DYNAMIC_NATIVE, resultName)); + } + } + + { + QStringList resultNames = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->resultNames(RimDefines::STATIC_NATIVE); + foreach(QString resultName, resultNames) + { + resultSpecification.append(qMakePair(RimDefines::STATIC_NATIVE, resultName)); + } + } + + RigStatistics stat(sourceCases, timeStepIndices, statisticsConfig, resultCase); + stat.evaluateStatistics(resultSpecification); for (size_t i = 0; i < reservoirViews().size(); i++) { diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp index 185f4ca982..0874a7ebac 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp @@ -294,6 +294,8 @@ size_t RigReservoirCellResults::findOrLoadScalarResultForTimeStep(RimDefines::Re if (type == RimDefines::DYNAMIC_NATIVE && timeStepCount > 0) { + m_cellScalarResults[resultGridIndex].resize(timeStepCount); + std::vector& values = m_cellScalarResults[resultGridIndex][timeStepIndex]; if (values.size() == 0) { @@ -305,6 +307,8 @@ size_t RigReservoirCellResults::findOrLoadScalarResultForTimeStep(RimDefines::Re } else if (type == RimDefines::STATIC_NATIVE) { + m_cellScalarResults[resultGridIndex].resize(1); + std::vector& values = m_cellScalarResults[resultGridIndex][0]; if (!m_readerInterface->staticResult(resultName, RifReaderInterface::MATRIX_RESULTS, &values)) { diff --git a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp index f1241dfd61..d6ff960aaf 100644 --- a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp +++ b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp @@ -132,7 +132,31 @@ QString createResultNameDev(const QString& resultName) { return resultName + "_ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, const QStringList& resultNames) +void RigStatistics::buildSourceMetaData(RimDefines::ResultCatType resultType, const QString& resultName) +{ + for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++) + { + RigEclipseCase* eclipseCase = m_sourceCases.at(caseIdx); + + RigReservoirCellResults* matrixResults = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS); + size_t scalarResultIndex = matrixResults->findOrLoadScalarResult(resultType, resultName); + if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) + { + QList timeStepDates = m_sourceCases[0]->results(RifReaderInterface::MATRIX_RESULTS)->timeStepDates(0); + + size_t scalarResultIndex = matrixResults->addEmptyScalarResult(resultType, resultName); + matrixResults->setTimeStepDates(scalarResultIndex, timeStepDates); + + std::vector< std::vector >& dataValues = matrixResults->cellScalarResults(scalarResultIndex); + dataValues.resize(timeStepDates.size()); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigStatistics::evaluateStatistics(const QList >& resultSpecification) { CVF_ASSERT(m_destinationCase.notNull()); @@ -141,8 +165,15 @@ void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, con size_t activeMatrixCellCount = m_destinationCase->activeCellInfo()->globalMatrixModelActiveCellCount(); RigReservoirCellResults* matrixResults = m_destinationCase->results(RifReaderInterface::MATRIX_RESULTS); - foreach(QString resultName, resultNames) + for (int i = 0; i < resultSpecification.size(); i++) { + RimDefines::ResultCatType resultType = resultSpecification[i].first; + QString resultName = resultSpecification[i].second; + + // Meta info is loaded from disk for first case only + // Build metadata for all other source cases + buildSourceMetaData(resultType, resultName); + QString minResultName = createResultNameMin(resultName); QString maxResultName = createResultNameMax(resultName); QString meanResultName = createResultNameMean(resultName); @@ -170,23 +201,37 @@ void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, con { RigGridBase* grid = m_destinationCase->grid(gridIdx); - foreach(QString resultName, resultNames) + for (int i = 0; i < resultSpecification.size(); i++) { + RimDefines::ResultCatType resultType = resultSpecification[i].first; + QString resultName = resultSpecification[i].second; + + size_t dataAccessTimeStepIndex = timeStepIdx; + + // Always evaluate statistics once, and always use time step index zero + if (resultType == RimDefines::STATIC_NATIVE) + { + if (timeIndicesIdx > 0) continue; + + dataAccessTimeStepIndex = 0; + } + // Build data access objects for source scalar results cvf::Collection dataAccesObjectList; for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++) { RigEclipseCase* eclipseCase = m_sourceCases.at(caseIdx); - size_t scalarResultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->findOrLoadScalarResultForTimeStep(resultType, resultName, timeStepIdx); + size_t scalarResultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->findOrLoadScalarResultForTimeStep(resultType, resultName, dataAccessTimeStepIndex); - cvf::ref dataAccessObject = eclipseCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); + cvf::ref dataAccessObject = eclipseCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, dataAccessTimeStepIndex, scalarResultIndex); if (dataAccessObject.notNull()) { dataAccesObjectList.push_back(dataAccessObject.p()); } } + // Build data access objects form destination scalar results cvf::ref dataAccessObjectMin = NULL; cvf::ref dataAccessObjectMax = NULL; @@ -194,52 +239,67 @@ void RigStatistics::evaluateStatistics(RimDefines::ResultCatType resultType, con cvf::ref dataAccessObjectDev = NULL; { - size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, createResultNameMin(resultName)); + size_t scalarResultIndex = matrixResults->findScalarResultIndex(resultType, createResultNameMin(resultName)); if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) { - dataAccessObjectMin = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); + dataAccessObjectMin = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, dataAccessTimeStepIndex, scalarResultIndex); } } { - size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, createResultNameMax(resultName)); + size_t scalarResultIndex = matrixResults->findScalarResultIndex(resultType, createResultNameMax(resultName)); if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) { - dataAccessObjectMax = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); + dataAccessObjectMax = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, dataAccessTimeStepIndex, scalarResultIndex); } } { - size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, createResultNameMean(resultName)); + size_t scalarResultIndex = matrixResults->findScalarResultIndex(resultType, createResultNameMean(resultName)); if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) { - dataAccessObjectMean = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); + dataAccessObjectMean = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, dataAccessTimeStepIndex, scalarResultIndex); } } { - size_t scalarResultIndex = matrixResults->findScalarResultIndex(RimDefines::DYNAMIC_NATIVE, createResultNameDev(resultName)); + size_t scalarResultIndex = matrixResults->findScalarResultIndex(resultType, createResultNameDev(resultName)); if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) { - dataAccessObjectDev = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); + dataAccessObjectDev = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, dataAccessTimeStepIndex, scalarResultIndex); } } double min, max, mean, dev; - std::vector values(dataAccesObjectList.size(), HUGE_VAL); for (size_t cellIdx = 0; cellIdx < grid->cellCount(); cellIdx++) { + std::vector values(dataAccesObjectList.size(), HUGE_VAL); + size_t globalGridCellIdx = grid->globalGridCellIndex(cellIdx); if (m_destinationCase->activeCellInfo()->isActiveInMatrixModel(globalGridCellIdx)) { + bool foundAnyValidValues = false; for (size_t caseIdx = 0; caseIdx < dataAccesObjectList.size(); caseIdx++) { double val = dataAccesObjectList.at(caseIdx)->cellScalar(cellIdx); values[caseIdx] = val; + + if (val != HUGE_VAL) + { + foundAnyValidValues = true; + } } - RigStatisticsEvaluator stat(values); - stat.getStatistics(min, max, mean, dev); + min = HUGE_VAL; + max = HUGE_VAL; + mean = HUGE_VAL; + dev = HUGE_VAL; + + if (foundAnyValidValues) + { + RigStatisticsEvaluator stat(values); + stat.getStatistics(min, max, mean, dev); + } if (dataAccessObjectMin.notNull()) { @@ -289,7 +349,7 @@ void RigStatistics::debugOutput(RimDefines::ResultCatType resultType, const QStr qDebug() << resultName << "timeIdx : " << timeStepIdx; RigReservoirCellResults* matrixResults = m_destinationCase->results(RifReaderInterface::MATRIX_RESULTS); - size_t scalarResultIndex = m_destinationCase->results(RifReaderInterface::MATRIX_RESULTS)->findOrLoadScalarResult(resultName); + size_t scalarResultIndex = m_destinationCase->results(RifReaderInterface::MATRIX_RESULTS)->findOrLoadScalarResult(resultType, resultName); cvf::ref dataAccessObject = m_destinationCase->dataAccessObject(m_destinationCase->mainGrid(), RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); if (dataAccessObject.isNull()) return; diff --git a/ApplicationCode/ReservoirDataModel/RigStatistics.h b/ApplicationCode/ReservoirDataModel/RigStatistics.h index 88d1696429..05d609903c 100644 --- a/ApplicationCode/ReservoirDataModel/RigStatistics.h +++ b/ApplicationCode/ReservoirDataModel/RigStatistics.h @@ -27,6 +27,8 @@ #include #include +#include + class RigStatisticsEvaluator { public: @@ -34,8 +36,8 @@ public: : m_values(values), m_min(HUGE_VAL), m_max(-HUGE_VAL), - m_mean(cvf::UNDEFINED_DOUBLE), - m_dev(0.0) + m_mean(HUGE_VAL), + m_dev(HUGE_VAL) { } @@ -128,13 +130,14 @@ public: RigEclipseCase* destinationCase); - void evaluateStatistics(RimDefines::ResultCatType resultType, const QStringList& resultNames); + void evaluateStatistics(const QList >& resultSpecification); void debugOutput(RimDefines::ResultCatType resultType, const QString& resultName, size_t timeStepIdx); private: void computeActiveCellUnion(); void addNamedResult(RigReservoirCellResults* cellResults, RimDefines::ResultCatType resultType, const QString& resultName, size_t activeCellCount); + void buildSourceMetaData(RimDefines::ResultCatType resultType, const QString& resultName); private: cvf::Collection m_sourceCases; From 06460424affb588285db7ee8fc37ffe165e91347 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 13 Mar 2013 08:03:26 +0100 Subject: [PATCH 103/242] Check for empty source cases p4#: 20871 --- ApplicationCode/ReservoirDataModel/RigStatistics.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp index d6ff960aaf..7bb9974a63 100644 --- a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp +++ b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp @@ -134,7 +134,11 @@ QString createResultNameDev(const QString& resultName) { return resultName + "_ //-------------------------------------------------------------------------------------------------- void RigStatistics::buildSourceMetaData(RimDefines::ResultCatType resultType, const QString& resultName) { - for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++) + if (m_sourceCases.size() == 0) return; + + QList timeStepDates = m_sourceCases[0]->results(RifReaderInterface::MATRIX_RESULTS)->timeStepDates(0); + + for (size_t caseIdx = 1; caseIdx < m_sourceCases.size(); caseIdx++) { RigEclipseCase* eclipseCase = m_sourceCases.at(caseIdx); @@ -142,8 +146,6 @@ void RigStatistics::buildSourceMetaData(RimDefines::ResultCatType resultType, co size_t scalarResultIndex = matrixResults->findOrLoadScalarResult(resultType, resultName); if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) { - QList timeStepDates = m_sourceCases[0]->results(RifReaderInterface::MATRIX_RESULTS)->timeStepDates(0); - size_t scalarResultIndex = matrixResults->addEmptyScalarResult(resultType, resultName); matrixResults->setTimeStepDates(scalarResultIndex, timeStepDates); From 99917c60ade17623497a4e2c76ace7bd35bf6902 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 13 Mar 2013 10:29:47 +0100 Subject: [PATCH 104/242] Compute SOIL for each time step Added support for computing statistics for derived SOIL p4#: 20873 --- .../RigReservoirCellResults.cpp | 141 +++++++++++------- .../RigReservoirCellResults.h | 4 +- .../ReservoirDataModel/RigStatistics.cpp | 25 +++- 3 files changed, 113 insertions(+), 57 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp index 0874a7ebac..a12cdeb6fa 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp @@ -250,6 +250,17 @@ std::vector< std::vector > & RigReservoirCellResults::cellScalarResults( return m_cellScalarResults[scalarResultIndex]; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector& RigReservoirCellResults::cellScalarResults(size_t scalarResultIndex, size_t timeStepIndex) +{ + CVF_TIGHT_ASSERT(scalarResultIndex < resultCount()); + CVF_TIGHT_ASSERT(timeStepIndex < m_cellScalarResults[scalarResultIndex].size()); + + return m_cellScalarResults[scalarResultIndex][timeStepIndex]; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -274,6 +285,12 @@ double RigReservoirCellResults::cellScalarResult( size_t scalarResultIndex, size //-------------------------------------------------------------------------------------------------- size_t RigReservoirCellResults::findOrLoadScalarResultForTimeStep(RimDefines::ResultCatType type, const QString& resultName, size_t timeStepIndex) { + // Special handling for SOIL + if (type == RimDefines::DYNAMIC_NATIVE && resultName.toUpper() == "SOIL") + { + loadOrComputeSOILForTimeStep(timeStepIndex); + } + size_t resultGridIndex = cvf::UNDEFINED_SIZE_T; resultGridIndex = findScalarResultIndex(type, resultName); @@ -287,7 +304,6 @@ size_t RigReservoirCellResults::findOrLoadScalarResultForTimeStep(RimDefines::Re if (m_readerInterface.notNull()) { - // Add one more result to result container size_t timeStepCount = m_resultInfos[resultGridIndex].m_timeStepDates.size(); bool resultLoadingSucess = true; @@ -453,78 +469,97 @@ size_t RigReservoirCellResults::findScalarResultIndex(const QString& resultName) //-------------------------------------------------------------------------------------------------- void RigReservoirCellResults::loadOrComputeSOIL() { - size_t soilResultGridIndex = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL"); - - if (soilResultGridIndex == cvf::UNDEFINED_SIZE_T) + for (size_t timeStepIdx = 0; timeStepIdx < maxTimeStepCount(); timeStepIdx++) { - size_t scalarIndexSWAT = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SWAT"); - size_t scalarIndexSGAS = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SGAS"); + loadOrComputeSOILForTimeStep(timeStepIdx); + } +} - // Early exit if none of SWAT or SGAS is present - if (scalarIndexSWAT == cvf::UNDEFINED_SIZE_T && scalarIndexSGAS == cvf::UNDEFINED_SIZE_T) + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigReservoirCellResults::loadOrComputeSOILForTimeStep(size_t timeStepIndex) +{ + size_t scalarIndexSWAT = findOrLoadScalarResultForTimeStep(RimDefines::DYNAMIC_NATIVE, "SWAT", timeStepIndex); + size_t scalarIndexSGAS = findOrLoadScalarResultForTimeStep(RimDefines::DYNAMIC_NATIVE, "SGAS", timeStepIndex); + + // Early exit if none of SWAT or SGAS is present + if (scalarIndexSWAT == cvf::UNDEFINED_SIZE_T && scalarIndexSGAS == cvf::UNDEFINED_SIZE_T) + { + return; + } + + size_t soilResultValueCount = 0; + size_t soilTimeStepCount = 0; + + std::vector* swatForTimeStep = NULL; + std::vector* sgasForTimeStep = NULL; + if (scalarIndexSWAT != cvf::UNDEFINED_SIZE_T) + { + swatForTimeStep = &(cellScalarResults(scalarIndexSWAT, timeStepIndex)); + if (swatForTimeStep->size() == 0) { - return; + swatForTimeStep = NULL; } - - soilResultGridIndex = addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL"); - - const std::vector< std::vector >* swat = NULL; - const std::vector< std::vector >* sgas = NULL; - if (scalarIndexSWAT != cvf::UNDEFINED_SIZE_T) + else { - swat = &(cellScalarResults(scalarIndexSWAT)); - } - - if (scalarIndexSGAS != cvf::UNDEFINED_SIZE_T) - { - sgas = &(cellScalarResults(scalarIndexSGAS)); - } - - size_t soilResultValueCount = 0; - size_t soilTimeStepCount = 0; - if (swat) - { - soilResultValueCount = swat->at(0).size(); + soilResultValueCount = swatForTimeStep->size(); soilTimeStepCount = m_resultInfos[scalarIndexSWAT].m_timeStepDates.size(); } + } - if (sgas) + if (scalarIndexSGAS != cvf::UNDEFINED_SIZE_T) + { + sgasForTimeStep = &(cellScalarResults(scalarIndexSGAS, timeStepIndex)); + if (sgasForTimeStep->size() == 0) { - soilResultValueCount = qMax(soilResultValueCount, sgas->at(0).size()); - + sgasForTimeStep = NULL; + } + else + { + soilResultValueCount = qMax(soilResultValueCount, sgasForTimeStep->size()); + size_t sgasTimeStepCount = m_resultInfos[scalarIndexSGAS].m_timeStepDates.size(); soilTimeStepCount = qMax(soilTimeStepCount, sgasTimeStepCount); } + } + + size_t soilResultGridIndex = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL"); + if (soilResultGridIndex == cvf::UNDEFINED_SIZE_T) + { + soilResultGridIndex = addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL"); + CVF_ASSERT(soilResultGridIndex != cvf::UNDEFINED_SIZE_T); m_cellScalarResults[soilResultGridIndex].resize(soilTimeStepCount); - std::vector< std::vector >& soil = cellScalarResults(soilResultGridIndex); - - int timeStepIdx = 0; - for (timeStepIdx = 0; timeStepIdx < static_cast(soilTimeStepCount); timeStepIdx++) + for (size_t timeStepIdx = 0; timeStepIdx < soilTimeStepCount; timeStepIdx++) { - soil[timeStepIdx].resize(soilResultValueCount); - -#pragma omp parallel for - for (int idx = 0; idx < static_cast(soilResultValueCount); idx++) - { - double soilValue = 1.0; - if (sgas) - { - soilValue -= sgas->at(timeStepIdx)[idx]; - } - - if (swat) - { - soilValue -= swat->at(timeStepIdx)[idx]; - } - - soil[timeStepIdx][idx] = soilValue; - } + m_cellScalarResults[soilResultGridIndex][timeStepIdx].resize(soilResultValueCount); } } + + std::vector& soilForTimeStep = cellScalarResults(soilResultGridIndex, timeStepIndex); + +#pragma omp parallel for + for (int idx = 0; idx < static_cast(soilResultValueCount); idx++) + { + double soilValue = 1.0; + if (sgasForTimeStep) + { + soilValue -= sgasForTimeStep->at(idx); + } + + if (swatForTimeStep) + { + soilValue -= swatForTimeStep->at(idx); + } + + soilForTimeStep[idx] = soilValue; + } } + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h index 2673a5fb05..8af96eb8a1 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h +++ b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h @@ -70,11 +70,13 @@ public: void clearAllResults(); void loadOrComputeSOIL(); + void loadOrComputeSOILForTimeStep(size_t timeStepIndex); void computeDepthRelatedResults(); // Access the results data - const std::vector< std::vector > & cellScalarResults(size_t scalarResultIndex) const; + const std::vector< std::vector > & cellScalarResults(size_t scalarResultIndex) const; std::vector< std::vector > & cellScalarResults(size_t scalarResultIndex); + std::vector& cellScalarResults(size_t scalarResultIndex, size_t timeStepIndex); double cellScalarResult(size_t scalarResultIndex, size_t timeStepIndex, size_t resultValueIndex); static RifReaderInterface::PorosityModelResultType convertFromProjectModelPorosityModel(RimDefines::PorosityModelType porosityModel); diff --git a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp index 7bb9974a63..b78e8f9b9f 100644 --- a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp +++ b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp @@ -172,9 +172,28 @@ void RigStatistics::evaluateStatistics(const QListresults(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(resultType, "SWAT"); + if (swatIndex != cvf::UNDEFINED_SIZE_T) + { + buildSourceMetaData(resultType, "SWAT"); + } + + size_t sgasIndex = m_sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(resultType, "SGAS"); + if (sgasIndex != cvf::UNDEFINED_SIZE_T) + { + buildSourceMetaData(resultType, "SGAS"); + } + } + else + { + // Meta info is loaded from disk for first case only + // Build metadata for all other source cases + buildSourceMetaData(resultType, resultName); + } QString minResultName = createResultNameMin(resultName); QString maxResultName = createResultNameMax(resultName); From 231004c709842b2df5a52b2e2ff05478c9fe2c96 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 13 Mar 2013 11:38:46 +0100 Subject: [PATCH 105/242] Do not use smart pointer in this class p4#: 20875 --- cafProjectDataModel/cafPdmObject.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/cafProjectDataModel/cafPdmObject.h b/cafProjectDataModel/cafPdmObject.h index 660c4335f4..4f6757bb6a 100644 --- a/cafProjectDataModel/cafPdmObject.h +++ b/cafProjectDataModel/cafPdmObject.h @@ -126,6 +126,10 @@ public: /// void parentObjects(std::vector& objects) const; + /// + template + void parentObjectsOfType(std::vector& objects) const; + /// Method to be called from the Ui classes creating Auto Gui to get the group information /// supplied by the \sa defineUiOrdering method that can be reimplemented void uiOrdering(QString uiConfigName, PdmUiOrdering& uiOrdering) const; @@ -210,4 +214,24 @@ private: std::set m_pointersReferencingMe; }; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +void PdmObject::parentObjectsOfType(std::vector& objects) const +{ + std::vector parentFields; + this->parentFields(parentFields); + + for (size_t i = 0; i < parentFields.size(); i++) + { + T* objectOfType = dynamic_cast(parentFields[i]->ownerObject()); + if (objectOfType) + { + objects.push_back(objectOfType); + } + } +} + + } // End of namespace caf From 449b22c6810789f5fee0e07e5a472fda906c433d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 13 Mar 2013 11:39:27 +0100 Subject: [PATCH 106/242] Do not use smart pointer in this class p4#: 20875 --- ApplicationCode/ReservoirDataModel/RigGridCollection.cpp | 2 +- ApplicationCode/ReservoirDataModel/RigGridCollection.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigGridCollection.cpp b/ApplicationCode/ReservoirDataModel/RigGridCollection.cpp index f75659d19a..0bd0a98a6b 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridCollection.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridCollection.cpp @@ -54,7 +54,7 @@ RigMainGrid* RigGridCollection::findEqualGrid(RigMainGrid* candidateGrid) { for (size_t i = 0; i < m_caseToGrid.size(); i++) { - RigMainGrid* mainGrid = m_caseToGrid.at(i)->m_mainGrid.p(); + RigMainGrid* mainGrid = m_caseToGrid.at(i)->m_mainGrid; if (RigGridCollection::isEqual(mainGrid, candidateGrid)) { return mainGrid; diff --git a/ApplicationCode/ReservoirDataModel/RigGridCollection.h b/ApplicationCode/ReservoirDataModel/RigGridCollection.h index 446c48aa5b..caa6476703 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridCollection.h +++ b/ApplicationCode/ReservoirDataModel/RigGridCollection.h @@ -47,8 +47,8 @@ private: public: CaseToGridMap(RigEclipseCase* eclipseCase, RigMainGrid* mainGrid); - cvf::ref m_eclipseCase; - cvf::ref m_mainGrid; + RigEclipseCase* m_eclipseCase; + RigMainGrid* m_mainGrid; }; From 4358d87c09685b40c6c3d646ebe670d92a214773 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 13 Mar 2013 11:42:26 +0100 Subject: [PATCH 107/242] If no views are created for RimReservoird, delete the current RigEclipseCase. Then all data will be read from file as if the case was opened as a stand alone case. p4#: 20876 --- .../ProjectDataModel/RimReservoir.cpp | 24 +++++++++++++++++++ .../ProjectDataModel/RimReservoir.h | 4 ++++ 2 files changed, 28 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/RimReservoir.cpp b/ApplicationCode/ProjectDataModel/RimReservoir.cpp index a6f60f67a2..776f779bbb 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoir.cpp @@ -98,6 +98,13 @@ RimReservoir::~RimReservoir() //-------------------------------------------------------------------------------------------------- RimReservoirView* RimReservoir::createAndAddReservoirView() { + // If parent is collection, and number of views is zero, make sure rig is set to NULL to initiate normal case loading + if (parentCaseCollection() != NULL && reservoirViews().size() == 0) + { + CVF_ASSERT(m_rigEclipseCase->refCount() == 1); + m_rigEclipseCase = NULL; + } + RimReservoirView* riv = new RimReservoirView(); riv->setEclipseCase(this); @@ -253,3 +260,20 @@ void RimReservoir::computeCachedData() } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCaseCollection* RimReservoir::parentCaseCollection() +{ + std::vector parentObjects; + this->parentObjectsOfType(parentObjects); + + if (parentObjects.size() > 0) + { + return parentObjects[0]; + } + + return NULL; +} + diff --git a/ApplicationCode/ProjectDataModel/RimReservoir.h b/ApplicationCode/ProjectDataModel/RimReservoir.h index a342e9e853..d68f9b84a6 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoir.h +++ b/ApplicationCode/ProjectDataModel/RimReservoir.h @@ -29,6 +29,7 @@ class QString; class RigEclipseCase; class RigGridBase; class RimReservoirView; +class RimCaseCollection; //================================================================================================== // @@ -72,6 +73,9 @@ protected: void computeCachedData(); +private: + RimCaseCollection* parentCaseCollection(); + protected: cvf::ref m_rigEclipseCase; }; From 8a604aca24c8a3ad9e0a38b24908ac8bfbb6d030 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 13 Mar 2013 11:50:31 +0100 Subject: [PATCH 108/242] Refactored RigActiveCellinfo to only have one set of information. Fracture and Matrix separated information thus needs two such obejcts. There still needs to remove some out-commented code p4#: 20877 --- .../FileInterface/RifReaderEclipseOutput.cpp | 118 ++++++++++-------- .../FileInterface/RifReaderEclipseOutput.h | 2 +- .../RivReservoirViewPartMgr.cpp | 2 +- .../Rim3dOverlayInfoConfig.cpp | 28 +++-- .../RimCellEdgeResultSlot.cpp | 14 +-- .../RimCellPropertyFilter.cpp | 2 +- .../RimCellRangeFilterCollection.cpp | 8 +- .../ProjectDataModel/RimInputReservoir.cpp | 3 +- .../ProjectDataModel/RimReservoirView.cpp | 41 +++--- .../ProjectDataModel/RimReservoirView.h | 3 +- .../ProjectDataModel/RimResultDefinition.cpp | 18 +-- .../RigActiveCellInfo-Test.cpp | 24 ++-- .../ReservoirDataModel/RigActiveCellInfo.cpp | 46 +++++-- .../ReservoirDataModel/RigActiveCellInfo.h | 32 ++--- .../ReservoirDataModel/RigEclipseCase.cpp | 67 ++++++---- .../ReservoirDataModel/RigEclipseCase.h | 63 +++++----- .../ReservoirDataModel/RigGridBase.cpp | 36 +----- .../ReservoirDataModel/RigGridBase.h | 10 +- .../RigGridScalarDataAccess.cpp | 20 +-- .../RigReservoirBuilderMock.cpp | 2 +- .../ReservoirDataModel/RigStatistics.cpp | 31 +++-- .../SocketInterface/RiaSocketServer.cpp | 4 +- .../UserInterface/RIMainWindow.cpp | 4 +- 23 files changed, 301 insertions(+), 277 deletions(-) diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index 9541d311b3..5450991ae6 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -86,9 +86,9 @@ static const size_t cellMappingECLRi[8] = { 0, 1, 3, 2, 4, 5, 7, 6 }; // Static functions //************************************************************************************************** -bool transferGridCellData(RigMainGrid* mainGrid, RigActiveCellInfo* activeCellInfo, RigGridBase* localGrid, const ecl_grid_type* localEclGrid, size_t matrixActiveStartIndex, size_t fractureActiveStartIndex) +bool transferGridCellData(RigMainGrid* mainGrid, RigActiveCellInfo* activeCellInfo, RigActiveCellInfo* fractureActiveCellInfo, RigGridBase* localGrid, const ecl_grid_type* localEclGrid, size_t matrixActiveStartIndex, size_t fractureActiveStartIndex) { - CVF_ASSERT(activeCellInfo); + CVF_ASSERT(activeCellInfo && fractureActiveCellInfo); int cellCount = ecl_grid_get_global_size(localEclGrid); size_t cellStartIndex = mainGrid->cells().size(); @@ -126,7 +126,7 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigActiveCellInfo* activeCellIn int fractureActiveIndex = ecl_grid_get_active_fracture_index1(localEclGrid, localCellIdx); if (fractureActiveIndex != -1) { - activeCellInfo->setActiveIndexInFractureModel(cellStartIndex + localCellIdx, fractureActiveStartIndex + fractureActiveIndex); + fractureActiveCellInfo->setActiveIndexInMatrixModel(cellStartIndex + localCellIdx, fractureActiveStartIndex + fractureActiveIndex); } // Parent cell index @@ -241,8 +241,10 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid, return false; } - RigActiveCellInfo* activeCellInfo = eclipseCase->activeCellInfo(); - CVF_ASSERT(activeCellInfo); + RigActiveCellInfo* activeCellInfo = eclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS); + RigActiveCellInfo* fractureActiveCellInfo = eclipseCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS); + + CVF_ASSERT(activeCellInfo && fractureActiveCellInfo); RigMainGrid* mainGrid = eclipseCase->mainGrid(); { @@ -280,6 +282,7 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid, } activeCellInfo->setGlobalCellCount(totalCellCount); + fractureActiveCellInfo->setGlobalCellCount(totalCellCount); // Reserve room for the cells and nodes and fill them with data @@ -290,7 +293,7 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid, progInfo.setProgressDescription("Main Grid"); progInfo.setNextProgressIncrement(3); - transferGridCellData(mainGrid, activeCellInfo, mainGrid, mainEclGrid, 0, 0); + transferGridCellData(mainGrid, activeCellInfo, fractureActiveCellInfo, mainGrid, mainEclGrid, 0, 0); progInfo.setProgress(3); @@ -298,10 +301,12 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid, size_t globalFractureActiveSize = ecl_grid_get_nactive_fracture(mainEclGrid); activeCellInfo->setGridCount(1 + numLGRs); - activeCellInfo->setGridActiveCellCounts(0, globalMatrixActiveSize, globalFractureActiveSize); + fractureActiveCellInfo->setGridCount(1 + numLGRs); - mainGrid->setMatrixModelActiveCellCount(globalMatrixActiveSize); - mainGrid->setFractureModelActiveCellCount(globalFractureActiveSize); + activeCellInfo->setGridActiveCellCounts(0, globalMatrixActiveSize); + fractureActiveCellInfo->setGridActiveCellCounts(0, globalFractureActiveSize); + + for (lgrIdx = 0; lgrIdx < numLGRs; ++lgrIdx) { @@ -310,22 +315,21 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid, ecl_grid_type* localEclGrid = ecl_grid_iget_lgr(mainEclGrid, lgrIdx); RigLocalGrid* localGrid = static_cast(mainGrid->gridByIndex(lgrIdx+1)); - transferGridCellData(mainGrid, activeCellInfo, localGrid, localEclGrid, globalMatrixActiveSize, globalFractureActiveSize); + transferGridCellData(mainGrid, activeCellInfo, fractureActiveCellInfo, localGrid, localEclGrid, globalMatrixActiveSize, globalFractureActiveSize); int matrixActiveCellCount = ecl_grid_get_nactive(localEclGrid); - localGrid->setMatrixModelActiveCellCount(matrixActiveCellCount); globalMatrixActiveSize += matrixActiveCellCount; int fractureActiveCellCount = ecl_grid_get_nactive_fracture(localEclGrid); - localGrid->setFractureModelActiveCellCount(fractureActiveCellCount); globalFractureActiveSize += fractureActiveCellCount; - activeCellInfo->setGridActiveCellCounts(lgrIdx + 1, matrixActiveCellCount, fractureActiveCellCount); - + activeCellInfo->setGridActiveCellCounts(lgrIdx + 1, matrixActiveCellCount); + fractureActiveCellInfo->setGridActiveCellCounts(lgrIdx + 1, fractureActiveCellCount); progInfo.setProgress(3 + lgrIdx); } activeCellInfo->computeDerivedData(); + fractureActiveCellInfo->computeDerivedData(); return true; } @@ -470,10 +474,13 @@ bool RifReaderEclipseOutput::readActiveCellInfo() return false; } - RigActiveCellInfo* activeCellInfo = m_eclipseCase->activeCellInfo(); + RigActiveCellInfo* activeCellInfo = m_eclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS); + RigActiveCellInfo* fractureActiveCellInfo = m_eclipseCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS); activeCellInfo->setGlobalCellCount(globalCellCount); + fractureActiveCellInfo->setGlobalCellCount(globalCellCount); activeCellInfo->setGridCount(actnumKeywordCount); + fractureActiveCellInfo->setGridCount(actnumKeywordCount); size_t cellIdx = 0; size_t globalActiveMatrixIndex = 0; @@ -495,17 +502,19 @@ bool RifReaderEclipseOutput::readActiveCellInfo() if (actnumValues[i] == 2 || actnumValues[i] == 3) { - activeCellInfo->setActiveIndexInFractureModel(cellIdx, globalActiveFractureIndex++); + fractureActiveCellInfo->setActiveIndexInMatrixModel(cellIdx, globalActiveFractureIndex++); activeFractureIndex++; } cellIdx++; } - activeCellInfo->setGridActiveCellCounts(gridIdx, activeMatrixIndex, activeFractureIndex); + activeCellInfo->setGridActiveCellCounts(gridIdx, activeMatrixIndex); + fractureActiveCellInfo->setGridActiveCellCounts(gridIdx, activeFractureIndex); } activeCellInfo->computeDerivedData(); + fractureActiveCellInfo->computeDerivedData(); } ecl_file_close(ecl_file); @@ -554,7 +563,10 @@ bool RifReaderEclipseOutput::buildMetaData() m_dynamicResultsAccess->resultNames(&resultNames, &resultNamesDataItemCounts); { - QStringList matrixResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, m_eclipseCase->activeCellInfo(), RifReaderInterface::MATRIX_RESULTS, m_dynamicResultsAccess->timeStepCount()); + QStringList matrixResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, + m_eclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS), + m_eclipseCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS), + RifReaderInterface::MATRIX_RESULTS, m_dynamicResultsAccess->timeStepCount()); for (int i = 0; i < matrixResultNames.size(); ++i) { @@ -564,7 +576,10 @@ bool RifReaderEclipseOutput::buildMetaData() } { - QStringList fractureResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, m_eclipseCase->activeCellInfo(), RifReaderInterface::FRACTURE_RESULTS, m_dynamicResultsAccess->timeStepCount()); + QStringList fractureResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, + m_eclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS), + m_eclipseCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS), + RifReaderInterface::FRACTURE_RESULTS, m_dynamicResultsAccess->timeStepCount()); for (int i = 0; i < fractureResultNames.size(); ++i) { @@ -588,7 +603,10 @@ bool RifReaderEclipseOutput::buildMetaData() RifEclipseOutputFileTools::findKeywordsAndDataItemCounts(m_ecl_init_file, &resultNames, &resultNamesDataItemCounts); { - QStringList matrixResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, m_eclipseCase->activeCellInfo(), RifReaderInterface::MATRIX_RESULTS, 1); + QStringList matrixResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, + m_eclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS), + m_eclipseCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS), + RifReaderInterface::MATRIX_RESULTS, 1); QList staticDate; if (m_timeSteps.size() > 0) @@ -604,7 +622,10 @@ bool RifReaderEclipseOutput::buildMetaData() } { - QStringList fractureResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, m_eclipseCase->activeCellInfo(), RifReaderInterface::FRACTURE_RESULTS, 1); + QStringList fractureResultNames = validKeywordsForPorosityModel(resultNames, resultNamesDataItemCounts, + m_eclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS), + m_eclipseCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS), + RifReaderInterface::FRACTURE_RESULTS, 1); QList staticDate; if (m_timeSteps.size() > 0) @@ -891,7 +912,9 @@ void RifReaderEclipseOutput::readWellCells() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringList& keywords, const std::vector& keywordDataItemCounts, const RigActiveCellInfo* activeCellInfo, PorosityModelResultType matrixOrFracture, size_t timeStepCount) const +QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringList& keywords, const std::vector& keywordDataItemCounts, + const RigActiveCellInfo* activeCellInfo, const RigActiveCellInfo* fractureActiveCellInfo, + PorosityModelResultType matrixOrFracture, size_t timeStepCount) const { CVF_ASSERT(activeCellInfo); @@ -902,7 +925,7 @@ QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringL if (matrixOrFracture == RifReaderInterface::FRACTURE_RESULTS) { - if (activeCellInfo->globalFractureModelActiveCellCount() == 0) + if (fractureActiveCellInfo->globalMatrixModelActiveCellCount() == 0) { return QStringList(); } @@ -920,8 +943,8 @@ QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringL size_t timeStepsMatrix = keywordDataItemCounts[i] / activeCellInfo->globalMatrixModelActiveCellCount(); size_t timeStepsMatrixRest = keywordDataItemCounts[i] % activeCellInfo->globalMatrixModelActiveCellCount(); - size_t timeStepsMatrixAndFracture = keywordDataItemCounts[i] / (activeCellInfo->globalMatrixModelActiveCellCount() + activeCellInfo->globalFractureModelActiveCellCount()); - size_t timeStepsMatrixAndFractureRest = keywordDataItemCounts[i] % (activeCellInfo->globalMatrixModelActiveCellCount() + activeCellInfo->globalFractureModelActiveCellCount()); + size_t timeStepsMatrixAndFracture = keywordDataItemCounts[i] / (activeCellInfo->globalMatrixModelActiveCellCount() + fractureActiveCellInfo->globalMatrixModelActiveCellCount()); + size_t timeStepsMatrixAndFractureRest = keywordDataItemCounts[i] % (activeCellInfo->globalMatrixModelActiveCellCount() + fractureActiveCellInfo->globalMatrixModelActiveCellCount()); if (matrixOrFracture == RifReaderInterface::MATRIX_RESULTS) { @@ -956,33 +979,17 @@ QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringL //-------------------------------------------------------------------------------------------------- void RifReaderEclipseOutput::extractResultValuesBasedOnPorosityModel(PorosityModelResultType matrixOrFracture, std::vector* destinationResultValues, const std::vector& sourceResultValues) { - RigActiveCellInfo* actCellInfo = m_eclipseCase->activeCellInfo(); + RigActiveCellInfo* fracActCellInfo = m_eclipseCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS); - if (matrixOrFracture == RifReaderInterface::MATRIX_RESULTS) + + if (matrixOrFracture == RifReaderInterface::MATRIX_RESULTS && fracActCellInfo->globalMatrixModelActiveCellCount() == 0) { - if (actCellInfo->globalFractureModelActiveCellCount() == 0) - { - destinationResultValues->insert(destinationResultValues->end(), sourceResultValues.begin(), sourceResultValues.end()); - } - else - { - size_t dataItemCount = 0; - size_t sourceStartPosition = 0; - - for (size_t i = 0; i < m_eclipseCase->mainGrid()->gridCount(); i++) - { - size_t matrixActiveCellCount = 0; - size_t fractureActiveCellCount = 0; - actCellInfo->gridActiveCellCounts(i, matrixActiveCellCount, fractureActiveCellCount); - - destinationResultValues->insert(destinationResultValues->end(), sourceResultValues.begin() + sourceStartPosition, sourceResultValues.begin() + sourceStartPosition + matrixActiveCellCount); - - sourceStartPosition += (matrixActiveCellCount + fractureActiveCellCount); - } - } + destinationResultValues->insert(destinationResultValues->end(), sourceResultValues.begin(), sourceResultValues.end()); } else { + RigActiveCellInfo* actCellInfo = m_eclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS); + size_t dataItemCount = 0; size_t sourceStartPosition = 0; @@ -990,9 +997,22 @@ void RifReaderEclipseOutput::extractResultValuesBasedOnPorosityModel(PorosityMod { size_t matrixActiveCellCount = 0; size_t fractureActiveCellCount = 0; - actCellInfo->gridActiveCellCounts(i, matrixActiveCellCount, fractureActiveCellCount); + + actCellInfo->gridActiveCellCounts(i, matrixActiveCellCount); + fracActCellInfo->gridActiveCellCounts(i, fractureActiveCellCount); - destinationResultValues->insert(destinationResultValues->end(), sourceResultValues.begin() + sourceStartPosition + matrixActiveCellCount, sourceResultValues.begin() + sourceStartPosition + matrixActiveCellCount + fractureActiveCellCount); + if (matrixOrFracture == RifReaderInterface::MATRIX_RESULTS) + { + destinationResultValues->insert(destinationResultValues->end(), + sourceResultValues.begin() + sourceStartPosition, + sourceResultValues.begin() + sourceStartPosition + matrixActiveCellCount); + } + else + { + destinationResultValues->insert(destinationResultValues->end(), + sourceResultValues.begin() + sourceStartPosition + matrixActiveCellCount, + sourceResultValues.begin() + sourceStartPosition + matrixActiveCellCount + fractureActiveCellCount); + } sourceStartPosition += (matrixActiveCellCount + fractureActiveCellCount); } diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.h b/ApplicationCode/FileInterface/RifReaderEclipseOutput.h index 832eaa5376..43c6fd91d0 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.h +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.h @@ -64,7 +64,7 @@ private: static RifEclipseRestartDataAccess* createDynamicResultsAccess(const QStringList& fileSet); - QStringList validKeywordsForPorosityModel(const QStringList& keywords, const std::vector& keywordDataItemCounts, const RigActiveCellInfo* activeCellInfo, PorosityModelResultType matrixOrFracture, size_t timeStepCount) const; + QStringList validKeywordsForPorosityModel(const QStringList& keywords, const std::vector& keywordDataItemCounts, const RigActiveCellInfo* activeCellInfo, const RigActiveCellInfo* fractureActiveCellInfo, PorosityModelResultType matrixOrFracture, size_t timeStepCount) const; virtual QList timeSteps(); private: diff --git a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp index 78ed1122b7..301ef347cf 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp @@ -247,7 +247,7 @@ void RivReservoirViewPartMgr::createGeometry(ReservoirGeometryCacheType geometry void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility, ReservoirGeometryCacheType geometryType, RigGridBase* grid, size_t gridIdx) { RigEclipseCase* eclipseCase = m_reservoirView->eclipseCase()->reservoirData(); - RigActiveCellInfo* activeCellInfo = eclipseCase->activeCellInfo(); + RigActiveCellInfo* activeCellInfo = m_reservoirView->currentActiveCellInfo(); switch (geometryType) { diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index 0865c45cb8..e0ab0982b7 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -80,7 +80,8 @@ void Rim3dOverlayInfoConfig::update3DInfo() { QString caseName; QString totCellCount; - QString activeCellCount; + QString activeCellCountText; + QString fractureActiveCellCount; QString iSize, jSize, kSize; QString propName; QString cellEdgeName; @@ -89,7 +90,12 @@ void Rim3dOverlayInfoConfig::update3DInfo() { caseName = m_reservoirView->eclipseCase()->caseName(); totCellCount = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->cells().size()); - activeCellCount = QString::number(m_reservoirView->eclipseCase()->reservoirData()->activeCellInfo()->globalMatrixModelActiveCellCount()); + size_t mxActCellCount = m_reservoirView->eclipseCase()->reservoirData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->globalMatrixModelActiveCellCount(); + size_t frActCellCount = m_reservoirView->eclipseCase()->reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->globalMatrixModelActiveCellCount(); + if (frActCellCount > 0) activeCellCountText += "Matrix : "; + activeCellCountText += QString::number(mxActCellCount); + if (frActCellCount > 0) activeCellCountText += " Fracture : " + QString::number(frActCellCount); + iSize = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->cellCountI()); jSize = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->cellCountJ()); kSize = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->cellCountK()); @@ -100,7 +106,7 @@ void Rim3dOverlayInfoConfig::update3DInfo() QString infoText = QString( "

-- %1 --

" "Cell count. Total: %2 Active: %3
" - "Main Grid I,J,K: %4, %5, %6
").arg(caseName, totCellCount, activeCellCount, iSize, jSize, kSize); + "Main Grid I,J,K: %4, %5, %6
").arg(caseName, totCellCount, activeCellCountText, iSize, jSize, kSize); if (m_reservoirView->animationMode() && m_reservoirView->cellResult()->hasResult()) { @@ -110,9 +116,9 @@ void Rim3dOverlayInfoConfig::update3DInfo() double p10, p90; double mean; size_t scalarIndex = m_reservoirView->cellResult()->gridScalarIndex(); - m_reservoirView->gridCellResults()->minMaxCellScalarValues(scalarIndex, min, max); - m_reservoirView->gridCellResults()->p10p90CellScalarValues(scalarIndex, p10, p90); - m_reservoirView->gridCellResults()->meanCellScalarValues(scalarIndex, mean); + m_reservoirView->currentGridCellResults()->minMaxCellScalarValues(scalarIndex, min, max); + m_reservoirView->currentGridCellResults()->p10p90CellScalarValues(scalarIndex, p10, p90); + m_reservoirView->currentGridCellResults()->meanCellScalarValues(scalarIndex, mean); //infoText += QString("

Min: %1 P10: %2 Mean: %3 P90: %4 Max: %5
").arg(min).arg(p10).arg(mean).arg(p90).arg(max); //infoText += QString("
Min: %1   P10: %2   Mean: %3 \n  P90: %4   Max: %5 
").arg(min).arg(p10).arg(mean).arg(p90).arg(max); @@ -134,7 +140,7 @@ void Rim3dOverlayInfoConfig::update3DInfo() || m_reservoirView->wellCollection()->hasVisibleWellPipes()) { int currentTimeStep = m_reservoirView->currentTimeStep(); - QDateTime date = m_reservoirView->gridCellResults()->timeStepDate(0, currentTimeStep); + QDateTime date = m_reservoirView->currentGridCellResults()->timeStepDate(0, currentTimeStep); infoText += QString("Time Step: %1 Time: %2").arg(currentTimeStep).arg(date.toString("dd.MMM yyyy")); } @@ -150,12 +156,12 @@ void Rim3dOverlayInfoConfig::update3DInfo() double mean; size_t scalarIndex = m_reservoirView->cellResult()->gridScalarIndex(); - m_reservoirView->gridCellResults()->minMaxCellScalarValues(scalarIndex, min, max); - m_reservoirView->gridCellResults()->p10p90CellScalarValues(scalarIndex, p10, p90); - m_reservoirView->gridCellResults()->meanCellScalarValues(scalarIndex, mean); + m_reservoirView->currentGridCellResults()->minMaxCellScalarValues(scalarIndex, min, max); + m_reservoirView->currentGridCellResults()->p10p90CellScalarValues(scalarIndex, p10, p90); + m_reservoirView->currentGridCellResults()->meanCellScalarValues(scalarIndex, mean); m_reservoirView->viewer()->showHistogram(true); - m_reservoirView->viewer()->setHistogram(min, max, m_reservoirView->gridCellResults()->cellScalarValuesHistogram(scalarIndex)); + m_reservoirView->viewer()->setHistogram(min, max, m_reservoirView->currentGridCellResults()->cellScalarValuesHistogram(scalarIndex)); m_reservoirView->viewer()->setHistogramPercentiles(p10, p90, mean); } } diff --git a/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp b/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp index fc7e1987da..26721a0bf9 100644 --- a/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp @@ -71,7 +71,7 @@ void RimCellEdgeResultSlot::setReservoirView(RimReservoirView* ownerReservoirVie //-------------------------------------------------------------------------------------------------- void RimCellEdgeResultSlot::loadResult() { - CVF_ASSERT(m_reservoirView && m_reservoirView->gridCellResults()); + CVF_ASSERT(m_reservoirView && m_reservoirView->currentGridCellResults()); resetResultIndices(); QStringList vars = findResultVariableNames(); @@ -80,7 +80,7 @@ void RimCellEdgeResultSlot::loadResult() int i; for (i = 0; i < vars.size(); ++i) { - size_t resultindex = m_reservoirView->gridCellResults()->findOrLoadScalarResult(RimDefines::STATIC_NATIVE, vars[i]); + size_t resultindex = m_reservoirView->currentGridCellResults()->findOrLoadScalarResult(RimDefines::STATIC_NATIVE, vars[i]); int cubeFaceIdx; for (cubeFaceIdx = 0; cubeFaceIdx < 6; ++cubeFaceIdx) { @@ -130,10 +130,10 @@ QList RimCellEdgeResultSlot::calculateValueOptions(const { if (fieldNeedingOptions == &resultVariable) { - if (m_reservoirView && m_reservoirView->gridCellResults()) + if (m_reservoirView && m_reservoirView->currentGridCellResults()) { QStringList varList; - varList = m_reservoirView->gridCellResults()->resultNames(RimDefines::STATIC_NATIVE); + varList = m_reservoirView->currentGridCellResults()->resultNames(RimDefines::STATIC_NATIVE); //TODO: Must also handle input properties //varList += m_reservoirView->gridCellResults()->resultNames(RimDefines::INPUT_PROPERTY); @@ -205,10 +205,10 @@ QStringList RimCellEdgeResultSlot::findResultVariableNames() { QStringList varNames; - if (m_reservoirView && m_reservoirView->gridCellResults() && !resultVariable().isEmpty()) + if (m_reservoirView && m_reservoirView->currentGridCellResults() && !resultVariable().isEmpty()) { QStringList varList; - varList = m_reservoirView->gridCellResults()->resultNames(RimDefines::STATIC_NATIVE); + varList = m_reservoirView->currentGridCellResults()->resultNames(RimDefines::STATIC_NATIVE); //TODO: Must handle Input properties int i; @@ -313,7 +313,7 @@ void RimCellEdgeResultSlot::minMaxCellEdgeValues(double& min, double& max) { double cMin, cMax; - m_reservoirView->gridCellResults()->minMaxCellScalarValues(resultIndices[idx], cMin, cMax); + m_reservoirView->currentGridCellResults()->minMaxCellScalarValues(resultIndices[idx], cMin, cMax); globalMin = CVF_MIN(globalMin, cMin); globalMax = CVF_MAX(globalMax, cMax); diff --git a/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.cpp b/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.cpp index d4c887a866..542d6c23f9 100644 --- a/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.cpp @@ -143,7 +143,7 @@ void RimCellPropertyFilter::setDefaultValues() size_t scalarIndex = resultDefinition->gridScalarIndex(); if (scalarIndex != cvf::UNDEFINED_SIZE_T) { - RigReservoirCellResults* results = m_parentContainer->reservoirView()->gridCellResults(); + RigReservoirCellResults* results = m_parentContainer->reservoirView()->currentGridCellResults(); if (results) { results->minMaxCellScalarValues(scalarIndex, min, max); diff --git a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp index 4301aabd26..7118b05f70 100644 --- a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp @@ -136,13 +136,9 @@ RigMainGrid* RimCellRangeFilterCollection::mainGrid() const //-------------------------------------------------------------------------------------------------- RigActiveCellInfo* RimCellRangeFilterCollection::activeCellInfo() const { - if (m_reservoirView && - m_reservoirView->eclipseCase() && - m_reservoirView->eclipseCase()->reservoirData() && - m_reservoirView->eclipseCase()->reservoirData()->activeCellInfo()) + if (m_reservoirView ) { - - return m_reservoirView->eclipseCase()->reservoirData()->activeCellInfo(); + return m_reservoirView->currentActiveCellInfo(); } return NULL; diff --git a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp index 27c50d2e63..a86b85f396 100644 --- a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp @@ -75,7 +75,8 @@ void RimInputReservoir::openDataFileSet(const QStringList& filenames) m_rigEclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p()); m_rigEclipseCase->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p()); - m_rigEclipseCase->activeCellInfo()->computeDerivedData(); + m_rigEclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->computeDerivedData(); + m_rigEclipseCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->computeDerivedData(); return; } diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp index f8c4a7eb78..be44b948a3 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp @@ -272,11 +272,11 @@ void RimReservoirView::updateViewerWidgetWindowTitle() void RimReservoirView::clampCurrentTimestep() { // Clamp the current timestep to actual possibilities - if (this->gridCellResults()) + if (this->currentGridCellResults()) { - if (m_currentTimeStep() >= static_cast(this->gridCellResults()->maxTimeStepCount())) + if (m_currentTimeStep() >= static_cast(this->currentGridCellResults()->maxTimeStepCount())) { - m_currentTimeStep = static_cast(this->gridCellResults()->maxTimeStepCount()) -1; + m_currentTimeStep = static_cast(this->currentGridCellResults()->maxTimeStepCount()) -1; } } @@ -460,10 +460,10 @@ void RimReservoirView::createDisplayModel() || this->propertyFilterCollection()->hasActiveDynamicFilters() || this->wellCollection->hasVisibleWellPipes()) { - CVF_ASSERT(gridCellResults()); + CVF_ASSERT(currentGridCellResults()); size_t i; - for (i = 0; i < gridCellResults()->maxTimeStepCount(); i++) + for (i = 0; i < currentGridCellResults()->maxTimeStepCount(); i++) { timeStepIndices.push_back(i); } @@ -711,7 +711,7 @@ void RimReservoirView::loadDataAndUpdate() RIApplication* app = RIApplication::instance(); if (app->preferences()->autocomputeSOIL) { - RigReservoirCellResults* results = gridCellResults(); + RigReservoirCellResults* results = currentGridCellResults(); CVF_ASSERT(results); results->loadOrComputeSOIL(); } @@ -721,7 +721,7 @@ void RimReservoirView::loadDataAndUpdate() CVF_ASSERT(this->cellResult() != NULL); this->cellResult()->loadResult(); - if (m_reservoir->reservoirData()->activeCellInfo()->globalFractureModelActiveCellCount() == 0) + if (m_reservoir->reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->globalMatrixModelActiveCellCount() == 0) { this->cellResult->porosityModel.setUiHidden(true); } @@ -882,7 +882,6 @@ void RimReservoirView::appendCellResultInfo(size_t gridIndex, size_t cellIndex, { RigEclipseCase* eclipseCase = m_reservoir->reservoirData(); RigGridBase* grid = eclipseCase->grid(gridIndex); - RigActiveCellInfo* activeCellInfo = eclipseCase->activeCellInfo(); if (this->cellResult()->hasResult()) { @@ -971,7 +970,7 @@ void RimReservoirView::setupBeforeSave() //-------------------------------------------------------------------------------------------------- /// Convenience for quick access to results //-------------------------------------------------------------------------------------------------- -RigReservoirCellResults* RimReservoirView::gridCellResults() +RigReservoirCellResults* RimReservoirView::currentGridCellResults() { if (m_reservoir && m_reservoir->reservoirData() && @@ -986,6 +985,23 @@ RigReservoirCellResults* RimReservoirView::gridCellResults() return NULL; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigActiveCellInfo* RimReservoirView::currentActiveCellInfo() +{ + if (m_reservoir && + m_reservoir->reservoirData() + ) + { + RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResult->porosityModel()); + + return m_reservoir->reservoirData()->activeCellInfo(porosityModel); + } + + return NULL; +} + //-------------------------------------------------------------------------------------------------- /// @@ -1185,11 +1201,8 @@ void RimReservoirView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibl // If all wells are forced off, return if (this->wellCollection()->wellCellVisibility() == RimWellCollection::FORCE_ALL_OFF) return; - RigActiveCellInfo* activeCellInfo = NULL; - if (eclipseCase() && eclipseCase()->reservoirData()) - { - activeCellInfo = eclipseCase()->reservoirData()->activeCellInfo(); - } + RigActiveCellInfo* activeCellInfo = this->currentActiveCellInfo(); + CVF_ASSERT(activeCellInfo); // Loop over the wells and find their contribution diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.h b/ApplicationCode/ProjectDataModel/RimReservoirView.h index 7eb628e114..af46ea2515 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.h +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.h @@ -118,7 +118,8 @@ public: caf::PdmField animationMode; // Access internal objects - RigReservoirCellResults* gridCellResults(); + RigReservoirCellResults* currentGridCellResults(); + RigActiveCellInfo* currentActiveCellInfo(); void setEclipseCase(RimReservoir* reservoir); RimReservoir* eclipseCase(); diff --git a/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp index 0c2a122621..a255d57408 100644 --- a/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp @@ -63,9 +63,9 @@ void RimResultDefinition::setReservoirView(RimReservoirView* ownerReservoirView) // TODO: This code is executed before reservoir is read, and then porosity model is never set to zero if (m_reservoirView->eclipseCase() && m_reservoirView->eclipseCase()->reservoirData() && - m_reservoirView->eclipseCase()->reservoirData()->activeCellInfo() ) + m_reservoirView->eclipseCase()->reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS) ) { - if (m_reservoirView->eclipseCase()->reservoirData()->activeCellInfo()->globalFractureModelActiveCellCount() == 0) + if (m_reservoirView->eclipseCase()->reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->globalMatrixModelActiveCellCount() == 0) { porosityModel.setUiHidden(true); } @@ -92,9 +92,9 @@ QList RimResultDefinition::calculateValueOptions(const c { if (fieldNeedingOptions == &resultVariable) { - if (m_reservoirView && m_reservoirView->gridCellResults()) + if (m_reservoirView && m_reservoirView->currentGridCellResults()) { - QStringList varList = m_reservoirView->gridCellResults()->resultNames(resultType()); + QStringList varList = m_reservoirView->currentGridCellResults()->resultNames(resultType()); QList optionList; int i; for (i = 0; i < varList.size(); ++i) @@ -119,7 +119,7 @@ size_t RimResultDefinition::gridScalarIndex() const { if (m_gridScalarResultIndex == cvf::UNDEFINED_SIZE_T) { - const RigReservoirCellResults* gridCellResults = m_reservoirView->gridCellResults(); + const RigReservoirCellResults* gridCellResults = m_reservoirView->currentGridCellResults(); if (gridCellResults) m_gridScalarResultIndex = gridCellResults->findScalarResultIndex(resultType(), resultVariable()); } return m_gridScalarResultIndex; @@ -130,7 +130,7 @@ size_t RimResultDefinition::gridScalarIndex() const //-------------------------------------------------------------------------------------------------- void RimResultDefinition::loadResult() { - RigReservoirCellResults* gridCellResults = m_reservoirView->gridCellResults(); + RigReservoirCellResults* gridCellResults = m_reservoirView->currentGridCellResults(); if (gridCellResults) { m_gridScalarResultIndex = gridCellResults->findOrLoadScalarResult(resultType(), resultVariable); @@ -148,7 +148,7 @@ void RimResultDefinition::loadResult() //-------------------------------------------------------------------------------------------------- bool RimResultDefinition::hasStaticResult() const { - const RigReservoirCellResults* gridCellResults = m_reservoirView->gridCellResults(); + const RigReservoirCellResults* gridCellResults = m_reservoirView->currentGridCellResults(); if (hasResult() && gridCellResults->timeStepCount(m_gridScalarResultIndex) == 1 ) { return true; @@ -166,7 +166,7 @@ bool RimResultDefinition::hasResult() const { if (m_gridScalarResultIndex != cvf::UNDEFINED_SIZE_T) return true; - const RigReservoirCellResults* gridCellResults = m_reservoirView->gridCellResults(); + const RigReservoirCellResults* gridCellResults = m_reservoirView->currentGridCellResults(); if (gridCellResults) { m_gridScalarResultIndex = gridCellResults->findScalarResultIndex(resultType(), resultVariable()); @@ -182,7 +182,7 @@ bool RimResultDefinition::hasResult() const //-------------------------------------------------------------------------------------------------- bool RimResultDefinition::hasDynamicResult() const { - const RigReservoirCellResults* gridCellResults = m_reservoirView->gridCellResults(); + const RigReservoirCellResults* gridCellResults = m_reservoirView->currentGridCellResults(); if (hasResult() && gridCellResults->timeStepCount(m_gridScalarResultIndex) > 1 ) return true; else diff --git a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigActiveCellInfo-Test.cpp b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigActiveCellInfo-Test.cpp index 3004cd6e45..a5349f3b95 100644 --- a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigActiveCellInfo-Test.cpp +++ b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigActiveCellInfo-Test.cpp @@ -35,16 +35,10 @@ TEST(RigActiveCellInfo, BasicTest) { EXPECT_TRUE(rigActiveCellInfo.activeIndexInMatrixModel(i) == cvf::UNDEFINED_SIZE_T); EXPECT_FALSE(rigActiveCellInfo.isActiveInMatrixModel(i)); - - EXPECT_TRUE(rigActiveCellInfo.activeIndexInFractureModel(i) == cvf::UNDEFINED_SIZE_T); - EXPECT_FALSE(rigActiveCellInfo.isActiveInFractureModel(i)); } rigActiveCellInfo.setActiveIndexInMatrixModel(3, 1); EXPECT_TRUE(rigActiveCellInfo.activeIndexInMatrixModel(3) == 1); - - rigActiveCellInfo.setActiveIndexInFractureModel(9, 3); - EXPECT_TRUE(rigActiveCellInfo.activeIndexInFractureModel(9) == 3); } //-------------------------------------------------------------------------------------------------- @@ -55,27 +49,23 @@ TEST(RigActiveCellInfo, GridCellCounts) { RigActiveCellInfo rigActiveCellInfo; rigActiveCellInfo.setGridCount(3); - rigActiveCellInfo.setGridActiveCellCounts(0, 0, 0); - rigActiveCellInfo.setGridActiveCellCounts(1, 1, 0); - rigActiveCellInfo.setGridActiveCellCounts(2, 2, 0); + rigActiveCellInfo.setGridActiveCellCounts(0, 0); + rigActiveCellInfo.setGridActiveCellCounts(1, 1); + rigActiveCellInfo.setGridActiveCellCounts(2, 2); rigActiveCellInfo.computeDerivedData(); EXPECT_TRUE(rigActiveCellInfo.globalMatrixModelActiveCellCount() == 3); - EXPECT_TRUE(rigActiveCellInfo.globalFractureModelActiveCellCount() == 0); } { RigActiveCellInfo rigActiveCellInfo; rigActiveCellInfo.setGridCount(3); - rigActiveCellInfo.setGridActiveCellCounts(0, 0, 3); - rigActiveCellInfo.setGridActiveCellCounts(1, 1, 4); - rigActiveCellInfo.setGridActiveCellCounts(2, 2, 5); + rigActiveCellInfo.setGridActiveCellCounts(0, 3 ); + rigActiveCellInfo.setGridActiveCellCounts(1, 4 ); + rigActiveCellInfo.setGridActiveCellCounts(2, 5 ); rigActiveCellInfo.computeDerivedData(); - EXPECT_TRUE(rigActiveCellInfo.globalMatrixModelActiveCellCount() == 3); - EXPECT_TRUE(rigActiveCellInfo.globalFractureModelActiveCellCount() == 12); + EXPECT_TRUE(rigActiveCellInfo.globalMatrixModelActiveCellCount() == 12); } - - } diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp index 8c4f7c3970..deb2e561ea 100644 --- a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp @@ -24,7 +24,7 @@ //-------------------------------------------------------------------------------------------------- RigActiveCellInfo::RigActiveCellInfo() : m_globalMatrixModelActiveCellCount(0), - m_globalFractureModelActiveCellCount(0), + // m_globalFractureModelActiveCellCount(0), m_activeCellPositionMin(cvf::Vec3d::ZERO), m_activeCellPositionMax(cvf::Vec3d::ZERO) { @@ -37,7 +37,7 @@ RigActiveCellInfo::RigActiveCellInfo() void RigActiveCellInfo::setGlobalCellCount(size_t globalCellCount) { m_activeInMatrixModel.resize(globalCellCount, cvf::UNDEFINED_SIZE_T); - m_activeInFractureModel.resize(globalCellCount, cvf::UNDEFINED_SIZE_T); + // m_activeInFractureModel.resize(globalCellCount, cvf::UNDEFINED_SIZE_T); } //-------------------------------------------------------------------------------------------------- @@ -79,7 +79,7 @@ void RigActiveCellInfo::setActiveIndexInMatrixModel(size_t globalCellIndex, size m_activeInMatrixModel[globalCellIndex] = globalActiveCellIndex; } - +/* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -119,7 +119,7 @@ void RigActiveCellInfo::setActiveIndexInFractureModel(size_t globalCellIndex, si m_activeInFractureModel[globalCellIndex] = globalActiveCellIndex; } - +*/ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -127,7 +127,7 @@ void RigActiveCellInfo::setGridCount(size_t gridCount) { m_perGridActiveCellInfo.resize(gridCount); } - +/* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -136,7 +136,19 @@ void RigActiveCellInfo::setGridActiveCellCounts(size_t gridIndex, size_t matrixA CVF_ASSERT(gridIndex < m_perGridActiveCellInfo.size()); m_perGridActiveCellInfo[gridIndex].setMatrixModelActiveCellCount(matrixActiveCellCount); - m_perGridActiveCellInfo[gridIndex].setFractureModelActiveCellCount(fractureActiveCellCount); + //m_perGridActiveCellInfo[gridIndex].setFractureModelActiveCellCount(fractureActiveCellCount); +} +*/ + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigActiveCellInfo::setGridActiveCellCounts(size_t gridIndex, size_t matrixActiveCellCount) +{ + CVF_ASSERT(gridIndex < m_perGridActiveCellInfo.size()); + + m_perGridActiveCellInfo[gridIndex].setMatrixModelActiveCellCount(matrixActiveCellCount); + //m_perGridActiveCellInfo[gridIndex].setFractureModelActiveCellCount(fractureActiveCellCount); } //-------------------------------------------------------------------------------------------------- @@ -145,12 +157,12 @@ void RigActiveCellInfo::setGridActiveCellCounts(size_t gridIndex, size_t matrixA void RigActiveCellInfo::computeDerivedData() { m_globalMatrixModelActiveCellCount = 0; - m_globalFractureModelActiveCellCount = 0; + //m_globalFractureModelActiveCellCount = 0; for (size_t i = 0; i < m_perGridActiveCellInfo.size(); i++) { m_globalMatrixModelActiveCellCount += m_perGridActiveCellInfo[i].matrixModelActiveCellCount(); - m_globalFractureModelActiveCellCount += m_perGridActiveCellInfo[i].fractureModelActiveCellCount(); + // m_globalFractureModelActiveCellCount += m_perGridActiveCellInfo[i].fractureModelActiveCellCount(); } } @@ -161,7 +173,7 @@ size_t RigActiveCellInfo::globalMatrixModelActiveCellCount() const { return m_globalMatrixModelActiveCellCount; } - +/* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -169,7 +181,7 @@ size_t RigActiveCellInfo::globalFractureModelActiveCellCount() const { return m_globalFractureModelActiveCellCount; } - +*/ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -187,7 +199,7 @@ void RigActiveCellInfo::matrixModelActiveCellsBoundingBox(cvf::Vec3st& min, cvf: min = m_activeCellPositionMin; max = m_activeCellPositionMax; } - +/* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -214,7 +226,16 @@ void RigActiveCellInfo::gridActiveCellCounts(size_t gridIndex, size_t& matrixAct matrixActiveCellCount = m_perGridActiveCellInfo[gridIndex].matrixModelActiveCellCount(); fractureActiveCellCount = m_perGridActiveCellInfo[gridIndex].fractureModelActiveCellCount(); } +*/ +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigActiveCellInfo::gridActiveCellCounts(size_t gridIndex, size_t& matrixActiveCellCount) +{ + matrixActiveCellCount = m_perGridActiveCellInfo[gridIndex].matrixModelActiveCellCount(); + //fractureActiveCellCount = m_perGridActiveCellInfo[gridIndex].fractureModelActiveCellCount(); +} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -246,7 +267,7 @@ void RigActiveCellInfo::GridActiveCellCounts::setMatrixModelActiveCellCount(size { m_matrixModelActiveCellCount = activeMatrixModelCellCount; } - +/* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -262,3 +283,4 @@ void RigActiveCellInfo::GridActiveCellCounts::setFractureModelActiveCellCount(si { m_fractureModelActiveCellCount = activeFractureModelCellCount; } +*/ \ No newline at end of file diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h index 7d5955ac2d..f38f95ec86 100644 --- a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h @@ -38,22 +38,24 @@ public: size_t activeIndexInMatrixModel(size_t globalCellIndex) const; void setActiveIndexInMatrixModel(size_t globalCellIndex, size_t globalActiveCellIndex); - bool isActiveInFractureModel(size_t globalCellIndex) const; - size_t activeIndexInFractureModel(size_t globalCellIndex) const; - void setActiveIndexInFractureModel(size_t globalCellIndex, size_t globalActiveCellIndex); + //bool isActiveInFractureModel(size_t globalCellIndex) const; + //size_t activeIndexInFractureModel(size_t globalCellIndex) const; + //void setActiveIndexInFractureModel(size_t globalCellIndex, size_t globalActiveCellIndex); void setGridCount(size_t gridCount); - void setGridActiveCellCounts(size_t gridIndex, size_t matrixActiveCellCount, size_t fractureActiveCellCount); - void gridActiveCellCounts(size_t gridIndex, size_t& matrixActiveCellCount, size_t& fractureActiveCellCount); + //void setGridActiveCellCounts(size_t gridIndex, size_t matrixActiveCellCount, size_t fractureActiveCellCount); + void setGridActiveCellCounts(size_t gridIndex, size_t matrixActiveCellCount); + //void gridActiveCellCounts(size_t gridIndex, size_t& matrixActiveCellCount, size_t& fractureActiveCellCount); + void gridActiveCellCounts(size_t gridIndex, size_t& matrixActiveCellCount); void computeDerivedData(); size_t globalMatrixModelActiveCellCount() const; - size_t globalFractureModelActiveCellCount() const; + //size_t globalFractureModelActiveCellCount() const; void setMatrixModelActiveCellsBoundingBox(const cvf::Vec3st& min, const cvf::Vec3st& max); void matrixModelActiveCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const; - void setFractureModelActiveCellsBoundingBox(const cvf::Vec3st& min, const cvf::Vec3st& max); - void fractureModelActiveCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const; + //void setFractureModelActiveCellsBoundingBox(const cvf::Vec3st& min, const cvf::Vec3st& max); + //void fractureModelActiveCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const; cvf::BoundingBox matrixActiveCellsGeometryBoundingBox() const; void setMatrixActiveCellsGeometryBoundingBox(cvf::BoundingBox bb); @@ -65,12 +67,12 @@ private: public: size_t matrixModelActiveCellCount() const; void setMatrixModelActiveCellCount(size_t activeMatrixModelCellCount); - size_t fractureModelActiveCellCount() const; - void setFractureModelActiveCellCount(size_t activeFractureModelCellCount); + //size_t fractureModelActiveCellCount() const; + //void setFractureModelActiveCellCount(size_t activeFractureModelCellCount); private: size_t m_matrixModelActiveCellCount; - size_t m_fractureModelActiveCellCount; + //size_t m_fractureModelActiveCellCount; }; @@ -78,15 +80,15 @@ private: std::vector m_perGridActiveCellInfo; std::vector m_activeInMatrixModel; - std::vector m_activeInFractureModel; + //std::vector m_activeInFractureModel; size_t m_globalMatrixModelActiveCellCount; - size_t m_globalFractureModelActiveCellCount; + //size_t m_globalFractureModelActiveCellCount; cvf::Vec3st m_activeCellPositionMin; cvf::Vec3st m_activeCellPositionMax; - cvf::Vec3st m_fractureModelActiveCellPositionMin; - cvf::Vec3st m_fractureModelActiveCellPositionMax; + //cvf::Vec3st m_fractureModelActiveCellPositionMin; + //cvf::Vec3st m_fractureModelActiveCellPositionMax; cvf::BoundingBox m_matrixActiveCellsBoundingBox; }; diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp index 542081f701..d557e6845b 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp @@ -287,14 +287,14 @@ void RigEclipseCase::computeActiveCellData() matrixModelActiveBB.add(i, j, k); } - if (m_activeCellInfo.isActiveInFractureModel(idx)) + if (m_fractureActiveCellInfo.isActiveInMatrixModel(idx)) { fractureModelActiveBB.add(i, j, k); } } m_activeCellInfo.setMatrixModelActiveCellsBoundingBox(matrixModelActiveBB.m_min, matrixModelActiveBB.m_max); - m_activeCellInfo.setFractureModelActiveCellsBoundingBox(fractureModelActiveBB.m_min, fractureModelActiveBB.m_max); + m_fractureActiveCellInfo.setMatrixModelActiveCellsBoundingBox(fractureModelActiveBB.m_min, fractureModelActiveBB.m_max); } //-------------------------------------------------------------------------------------------------- @@ -309,17 +309,27 @@ void RigEclipseCase::computeCachedData() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigActiveCellInfo* RigEclipseCase::activeCellInfo() +RigActiveCellInfo* RigEclipseCase::activeCellInfo(RifReaderInterface::PorosityModelResultType porosityModel) { - return &m_activeCellInfo; + if (porosityModel == RifReaderInterface::MATRIX_RESULTS) + { + return &m_activeCellInfo; + } + + return &m_fractureActiveCellInfo; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const RigActiveCellInfo* RigEclipseCase::activeCellInfo() const +const RigActiveCellInfo* RigEclipseCase::activeCellInfo(RifReaderInterface::PorosityModelResultType porosityModel) const { - return &m_activeCellInfo; + if (porosityModel == RifReaderInterface::MATRIX_RESULTS) + { + return &m_activeCellInfo; + } + + return &m_fractureActiveCellInfo; } //-------------------------------------------------------------------------------------------------- @@ -331,33 +341,42 @@ void RigEclipseCase::computeActiveCellsGeometryBoundingBox() { cvf::BoundingBox bb; m_activeCellInfo.setMatrixActiveCellsGeometryBoundingBox(bb); + m_fractureActiveCellInfo.setMatrixActiveCellsGeometryBoundingBox(bb); return; } - cvf::BoundingBox bb; - if (m_mainGrid->nodes().size() == 0) - { - bb.add(cvf::Vec3d::ZERO); - } - else - { - for (size_t i = 0; i < m_mainGrid->cellCount(); i++) - { - if (m_activeCellInfo.isActiveInMatrixModel(i)) - { - const RigCell& c = m_mainGrid->cells()[i]; - const caf::SizeTArray8& indices = c.cornerIndices(); + RigActiveCellInfo* activeInfos[2]; + activeInfos[0] = &m_fractureActiveCellInfo; + activeInfos[1] = &m_activeCellInfo; // Last, to make this bb.min become display offset - size_t idx; - for (idx = 0; idx < 8; idx++) + cvf::BoundingBox bb; + for (int acIdx = 0; acIdx < 2; ++acIdx) + { + bb.reset(); + if (m_mainGrid->nodes().size() == 0) + { + bb.add(cvf::Vec3d::ZERO); + } + else + { + for (size_t i = 0; i < m_mainGrid->cellCount(); i++) + { + if (activeInfos[acIdx]->isActiveInMatrixModel(i)) { - bb.add(m_mainGrid->nodes()[indices[idx]]); + const RigCell& c = m_mainGrid->cells()[i]; + const caf::SizeTArray8& indices = c.cornerIndices(); + + size_t idx; + for (idx = 0; idx < 8; idx++) + { + bb.add(m_mainGrid->nodes()[indices[idx]]); + } } } } - } - m_activeCellInfo.setMatrixActiveCellsGeometryBoundingBox(bb); + activeInfos[acIdx]->setMatrixActiveCellsGeometryBoundingBox(bb); + } m_mainGrid->setDisplayModelOffset(bb.min()); } diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCase.h b/ApplicationCode/ReservoirDataModel/RigEclipseCase.h index c188179e68..f16ba77562 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCase.h +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCase.h @@ -36,55 +36,54 @@ public: RigEclipseCase(); ~RigEclipseCase(); - RigMainGrid* mainGrid() { return m_mainGrid.p(); } - const RigMainGrid* mainGrid() const { return m_mainGrid.p(); } - void setMainGrid(RigMainGrid* mainGrid); + RigMainGrid* mainGrid() { return m_mainGrid.p(); } + const RigMainGrid* mainGrid() const { return m_mainGrid.p(); } + void setMainGrid(RigMainGrid* mainGrid); - void allGrids(std::vector* grids); // To be removed - void allGrids(std::vector* grids) const;// To be removed - const RigGridBase* grid(size_t index) const; - RigGridBase* grid(size_t index); - size_t gridCount() const; + void allGrids(std::vector* grids); // To be removed + void allGrids(std::vector* grids) const;// To be removed + const RigGridBase* grid(size_t index) const; + RigGridBase* grid(size_t index); + size_t gridCount() const; - RigReservoirCellResults* results(RifReaderInterface::PorosityModelResultType porosityModel); - const RigReservoirCellResults* results(RifReaderInterface::PorosityModelResultType porosityModel) const; + RigReservoirCellResults* results(RifReaderInterface::PorosityModelResultType porosityModel); + const RigReservoirCellResults* results(RifReaderInterface::PorosityModelResultType porosityModel) const; + + RigActiveCellInfo* activeCellInfo(RifReaderInterface::PorosityModelResultType porosityModel); + const RigActiveCellInfo* activeCellInfo(RifReaderInterface::PorosityModelResultType porosityModel) const; - void closeReaderInterface(); - cvf::ref dataAccessObject(const RigGridBase* grid, + cvf::ref dataAccessObject(const RigGridBase* grid, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStepIndex, size_t scalarSetIndex); - void computeCachedData(); - - void setWellResults(const cvf::Collection& data); - const cvf::Collection& wellResults() { return m_wellResults; } + void setWellResults(const cvf::Collection& data); + const cvf::Collection& wellResults() { return m_wellResults; } - cvf::UByteArray* wellCellsInGrid(size_t gridIndex); + cvf::UByteArray* wellCellsInGrid(size_t gridIndex); - RigCell& cellFromWellResultCell(const RigWellResultCell& wellResultCell); - bool findSharedSourceFace(cvf::StructGridInterface::FaceType& sharedSourceFace, const RigWellResultCell& sourceWellCellResult, const RigWellResultCell& otherWellCellResult) const; - - RigActiveCellInfo* activeCellInfo(); - const RigActiveCellInfo* activeCellInfo() const; + RigCell& cellFromWellResultCell(const RigWellResultCell& wellResultCell); + bool findSharedSourceFace(cvf::StructGridInterface::FaceType& sharedSourceFace, const RigWellResultCell& sourceWellCellResult, const RigWellResultCell& otherWellCellResult) const; + void computeCachedData(); + void closeReaderInterface(); private: - void computeActiveCellData(); - void computeWellCellsPrGrid(); - void computeActiveCellsGeometryBoundingBox(); + void computeActiveCellData(); + void computeWellCellsPrGrid(); + void computeActiveCellsGeometryBoundingBox(); private: - RigActiveCellInfo m_activeCellInfo; + cvf::ref m_mainGrid; - cvf::ref m_mainGrid; + RigActiveCellInfo m_activeCellInfo; + RigActiveCellInfo m_fractureActiveCellInfo; - cvf::ref m_matrixModelResults; - cvf::ref m_fractureModelResults; + cvf::ref m_matrixModelResults; + cvf::ref m_fractureModelResults; - - cvf::Collection m_wellResults; - cvf::Collection m_wellCellsInGrid; + cvf::Collection m_wellResults; + cvf::Collection m_wellCellsInGrid; //< A bool array pr grid with one bool pr cell telling wether the cell is a well cell or not }; diff --git a/ApplicationCode/ReservoirDataModel/RigGridBase.cpp b/ApplicationCode/ReservoirDataModel/RigGridBase.cpp index c4073bcd2c..69b62a8856 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridBase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridBase.cpp @@ -28,9 +28,7 @@ RigGridBase::RigGridBase(RigMainGrid* mainGrid): m_gridPointDimensions(0,0,0), m_mainGrid(mainGrid), - m_indexToStartOfCells(0), - m_matrixModelActiveCellCount(cvf::UNDEFINED_SIZE_T), - m_fractureModelActiveCellCount(cvf::UNDEFINED_SIZE_T) + m_indexToStartOfCells(0) { if (mainGrid == NULL) { @@ -451,38 +449,6 @@ double RigGridBase::characteristicIJCellSize() return characteristicCellSize; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -size_t RigGridBase::matrixModelActiveCellCount() const -{ - return m_matrixModelActiveCellCount; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -size_t RigGridBase::fractureModelActiveCellCount() const -{ - return m_fractureModelActiveCellCount; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigGridBase::setFractureModelActiveCellCount(size_t activeFractureModelCellCount) -{ - m_fractureModelActiveCellCount = activeFractureModelCellCount; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigGridBase::setMatrixModelActiveCellCount(size_t activeMatrixModelCellCount) -{ - m_matrixModelActiveCellCount = activeMatrixModelCellCount; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigGridBase.h b/ApplicationCode/ReservoirDataModel/RigGridBase.h index 59a492450d..364de6ae10 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridBase.h +++ b/ApplicationCode/ReservoirDataModel/RigGridBase.h @@ -63,12 +63,7 @@ public: void computeFaults(); bool isMainGrid() const; RigMainGrid* mainGrid() const { return m_mainGrid; } - - size_t matrixModelActiveCellCount() const; - void setMatrixModelActiveCellCount(size_t activeMatrixModelCellCount); - size_t fractureModelActiveCellCount() const ; - void setFractureModelActiveCellCount(size_t activeFractureModelCellCount); - + protected: friend class RigMainGrid;//::initAllSubGridsParentGridPointer(); void initSubGridParentPointer(); @@ -106,9 +101,6 @@ private: size_t m_gridIndex; ///< The LGR index of this grid. Starts with 1. Main grid has index 0. RigMainGrid* m_mainGrid; - size_t m_matrixModelActiveCellCount; - size_t m_fractureModelActiveCellCount; - }; diff --git a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp index d4d3aeba05..c7c7f5e25e 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp @@ -130,7 +130,7 @@ private: - +/* //-------------------------------------------------------------------------------------------------- /// @@ -179,7 +179,7 @@ private: - +*/ //-------------------------------------------------------------------------------------------------- /// @@ -194,11 +194,11 @@ cvf::ref RigGridScalarDataAccessFactory::create CVF_ASSERT(gridIndex < eclipseCase->gridCount()); CVF_ASSERT(eclipseCase); CVF_ASSERT(eclipseCase->results(porosityModel)); - CVF_ASSERT(eclipseCase->activeCellInfo()); + CVF_ASSERT(eclipseCase->activeCellInfo(porosityModel)); RigGridBase *grid = eclipseCase->grid(gridIndex); - if ( !eclipseCase || !eclipseCase->results(porosityModel) || !eclipseCase->activeCellInfo()) + if ( !eclipseCase || !eclipseCase->results(porosityModel) || !eclipseCase->activeCellInfo(porosityModel)) { return NULL; } @@ -215,16 +215,8 @@ cvf::ref RigGridScalarDataAccessFactory::create bool useGlobalActiveIndex = eclipseCase->results(porosityModel)->isUsingGlobalActiveIndex(scalarSetIndex); if (useGlobalActiveIndex) { - if (porosityModel == RifReaderInterface::MATRIX_RESULTS) - { - cvf::ref object = new RigGridMatrixActiveCellsScalarDataAccess(grid, resultValues, eclipseCase->activeCellInfo()); - return object; - } - else - { - cvf::ref object = new RigGridFractureActiveCellsScalarDataAccess(grid, resultValues, eclipseCase->activeCellInfo()); - return object; - } + cvf::ref object = new RigGridMatrixActiveCellsScalarDataAccess(grid, resultValues, eclipseCase->activeCellInfo(porosityModel)); + return object; } else { diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp index 00efac4260..6b8145a4aa 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp @@ -247,7 +247,7 @@ void RigReservoirBuilderMock::populateReservoir(RigEclipseCase* eclipseCase) addWellData(eclipseCase, eclipseCase->mainGrid()); // Set all cells active - RigActiveCellInfo* activeCellInfo = eclipseCase->activeCellInfo(); + RigActiveCellInfo* activeCellInfo = eclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS); activeCellInfo->setGlobalCellCount(eclipseCase->mainGrid()->cells().size()); for (size_t i = 0; i < eclipseCase->mainGrid()->cells().size(); i++) { diff --git a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp index b78e8f9b9f..b9b1f0bbfc 100644 --- a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp +++ b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp @@ -59,8 +59,10 @@ void RigStatistics::computeActiveCellUnion() RigMainGrid* mainGrid = m_sourceCases[0]->mainGrid(); CVF_ASSERT(mainGrid); - m_destinationCase->activeCellInfo()->setGlobalCellCount(mainGrid->cells().size()); - m_destinationCase->activeCellInfo()->setGridCount(mainGrid->gridCount()); + m_destinationCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->setGlobalCellCount(mainGrid->cells().size()); + m_destinationCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->setGlobalCellCount(mainGrid->cells().size()); + m_destinationCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->setGridCount(mainGrid->gridCount()); + m_destinationCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->setGridCount(mainGrid->gridCount()); size_t globalActiveMatrixIndex = 0; size_t globalActiveFractureIndex = 0; @@ -80,7 +82,7 @@ void RigStatistics::computeActiveCellUnion() if (activeM[localGridCellIdx] == 0) { - if (m_sourceCases[caseIdx]->activeCellInfo()->isActiveInMatrixModel(globalCellIdx)) + if (m_sourceCases[caseIdx]->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->isActiveInMatrixModel(globalCellIdx)) { activeM[localGridCellIdx] = 1; } @@ -88,7 +90,7 @@ void RigStatistics::computeActiveCellUnion() if (activeF[localGridCellIdx] == 0) { - if (m_sourceCases[caseIdx]->activeCellInfo()->isActiveInFractureModel(globalCellIdx)) + if (m_sourceCases[caseIdx]->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->isActiveInMatrixModel(globalCellIdx)) { activeF[localGridCellIdx] = 1; } @@ -105,21 +107,24 @@ void RigStatistics::computeActiveCellUnion() if (activeM[localGridCellIdx] != 0) { - m_destinationCase->activeCellInfo()->setActiveIndexInMatrixModel(globalCellIdx, globalActiveMatrixIndex++); + m_destinationCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->setActiveIndexInMatrixModel(globalCellIdx, globalActiveMatrixIndex++); activeMatrixIndex++; } if (activeF[localGridCellIdx] != 0) { - m_destinationCase->activeCellInfo()->setActiveIndexInFractureModel(globalCellIdx, globalActiveFractureIndex++); + m_destinationCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->setActiveIndexInMatrixModel(globalCellIdx, globalActiveFractureIndex++); activeFractureIndex++; } } - m_destinationCase->activeCellInfo()->setGridActiveCellCounts(gridIdx, activeMatrixIndex, activeFractureIndex); + m_destinationCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->setGridActiveCellCounts(gridIdx, activeMatrixIndex); + m_destinationCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->setGridActiveCellCounts(gridIdx, activeFractureIndex); } - m_destinationCase->activeCellInfo()->computeDerivedData(); + m_destinationCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->computeDerivedData(); + m_destinationCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->computeDerivedData(); + m_destinationCase->computeCachedData(); } @@ -164,7 +169,7 @@ void RigStatistics::evaluateStatistics(const QListactiveCellInfo()->globalMatrixModelActiveCellCount(); + size_t activeMatrixCellCount = m_destinationCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->globalMatrixModelActiveCellCount(); RigReservoirCellResults* matrixResults = m_destinationCase->results(RifReaderInterface::MATRIX_RESULTS); for (int i = 0; i < resultSpecification.size(); i++) @@ -190,9 +195,9 @@ void RigStatistics::evaluateStatistics(const QList values(dataAccesObjectList.size(), HUGE_VAL); size_t globalGridCellIdx = grid->globalGridCellIndex(cellIdx); - if (m_destinationCase->activeCellInfo()->isActiveInMatrixModel(globalGridCellIdx)) + if (m_destinationCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->isActiveInMatrixModel(globalGridCellIdx)) { bool foundAnyValidValues = false; for (size_t caseIdx = 0; caseIdx < dataAccesObjectList.size(); caseIdx++) diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.cpp b/ApplicationCode/SocketInterface/RiaSocketServer.cpp index 80308f3e8e..8afa8aece5 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.cpp +++ b/ApplicationCode/SocketInterface/RiaSocketServer.cpp @@ -446,7 +446,7 @@ void RiaSocketServer::readPropertyDataFromOctave() size_t cellCountFromOctave = m_bytesPerTimeStepToRead / sizeof(double); - size_t gridActiveCellCount = m_currentReservoir->reservoirData()->activeCellInfo()->globalMatrixModelActiveCellCount(); + size_t gridActiveCellCount = m_currentReservoir->reservoirData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->globalMatrixModelActiveCellCount(); size_t gridTotalCellCount = m_currentReservoir->reservoirData()->mainGrid()->cellCount(); if (cellCountFromOctave != gridActiveCellCount && cellCountFromOctave != gridTotalCellCount) @@ -634,7 +634,7 @@ void RiaSocketServer::calculateMatrixModelActiveCellInfo(std::vector& gr return; } - RigActiveCellInfo* actCellInfo = m_currentReservoir->reservoirData()->activeCellInfo(); + RigActiveCellInfo* actCellInfo = m_currentReservoir->reservoirData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS); size_t numMatrixModelActiveCells = actCellInfo->globalMatrixModelActiveCellCount(); gridNumber.reserve(numMatrixModelActiveCells); diff --git a/ApplicationCode/UserInterface/RIMainWindow.cpp b/ApplicationCode/UserInterface/RIMainWindow.cpp index 5ac2d342d6..48b8438e36 100644 --- a/ApplicationCode/UserInterface/RIMainWindow.cpp +++ b/ApplicationCode/UserInterface/RIMainWindow.cpp @@ -540,13 +540,13 @@ void RIMainWindow::refreshAnimationActions() { enableAnimControls = true; - if (app->activeReservoirView()->gridCellResults()) + if (app->activeReservoirView()->currentGridCellResults()) { if (app->activeReservoirView()->cellResult()->hasDynamicResult() || app->activeReservoirView()->propertyFilterCollection()->hasActiveDynamicFilters() || app->activeReservoirView()->wellCollection()->hasVisibleWellPipes()) { - QList timeStepDates = app->activeReservoirView()->gridCellResults()->timeStepDates(0); + QList timeStepDates = app->activeReservoirView()->currentGridCellResults()->timeStepDates(0); bool showHoursAndMinutes = false; for (int i = 0; i < timeStepDates.size(); i++) { From 055319a8465b245aaa0644130d515c91b276d6f8 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 13 Mar 2013 11:58:26 +0100 Subject: [PATCH 109/242] Use parentObjects instead of parentFields p4#: 20878 --- cafProjectDataModel/cafPdmObject.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cafProjectDataModel/cafPdmObject.h b/cafProjectDataModel/cafPdmObject.h index 4f6757bb6a..16e8576120 100644 --- a/cafProjectDataModel/cafPdmObject.h +++ b/cafProjectDataModel/cafPdmObject.h @@ -220,12 +220,12 @@ private: template void PdmObject::parentObjectsOfType(std::vector& objects) const { - std::vector parentFields; - this->parentFields(parentFields); + std::vector parents; + this->parentObjects(parents); - for (size_t i = 0; i < parentFields.size(); i++) + for (size_t i = 0; i < parents.size(); i++) { - T* objectOfType = dynamic_cast(parentFields[i]->ownerObject()); + T* objectOfType = dynamic_cast(parents[i]); if (objectOfType) { objects.push_back(objectOfType); From 30139925187347eb95806c4fed52983b9177d24d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 13 Mar 2013 13:06:37 +0100 Subject: [PATCH 110/242] Fixed error regarding missing well cells in property filtered views p4#: 20882 --- ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp index 301ef347cf..74a80eb3a2 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp @@ -454,7 +454,7 @@ void RivReservoirViewPartMgr::createPropertyFilteredWellGeometry(size_t frameInd #pragma omp parallel for for (int cellIdx = 0; cellIdx < static_cast(cellVisibility->size()); ++cellIdx) { - (*cellVisibility)[cellIdx] = (!hasActiveRangeFilters && !(*cellIsWellCellStatuses)[cellIdx]) || (*rangeVisibility)[cellIdx] || (*wellCellsOutsideVisibility)[cellIdx]; + (*cellVisibility)[cellIdx] = (!hasActiveRangeFilters && (*cellIsWellCellStatuses)[cellIdx]) || (*rangeVisibility)[cellIdx] || (*wellCellsOutsideVisibility)[cellIdx]; } computePropertyVisibility(cellVisibility.p(), grids[gIdx], frameIndex, cellVisibility.p(), m_reservoirView->propertyFilterCollection()); m_propFilteredWellGeometryFrames[frameIndex]->setCellVisibility(gIdx, cellVisibility.p()); From ec889920d537e38d8e5525e65b8fc39e9a5beae9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 13 Mar 2013 13:41:35 +0100 Subject: [PATCH 111/242] Removed out-commented code from the ActiveCellInfo refactoring p4#: 20886 --- ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index e0ab0982b7..d35b7d9cb7 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -70,7 +70,8 @@ void Rim3dOverlayInfoConfig::setPosition(cvf::Vec2ui position) //-------------------------------------------------------------------------------------------------- void Rim3dOverlayInfoConfig::update3DInfo() { - if (!m_reservoirView && m_reservoirView->viewer()) return; + if (!m_reservoirView) return; + if (!m_reservoirView->viewer()) return; m_reservoirView->viewer()->showInfoText(showInfoText()); m_reservoirView->viewer()->showHistogram(false); From 3c446c4018d8b7c5275640151a333c6a0d9c393f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 13 Mar 2013 13:42:27 +0100 Subject: [PATCH 112/242] Removed out-commented code from the ActiveCellInfo refactoring p4#: 20886 --- .../ReservoirDataModel/RigActiveCellInfo.cpp | 113 +----------------- .../ReservoirDataModel/RigActiveCellInfo.h | 29 +---- .../RigGridScalarDataAccess.cpp | 53 -------- 3 files changed, 7 insertions(+), 188 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp index deb2e561ea..bdf3305543 100644 --- a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp @@ -24,7 +24,6 @@ //-------------------------------------------------------------------------------------------------- RigActiveCellInfo::RigActiveCellInfo() : m_globalMatrixModelActiveCellCount(0), - // m_globalFractureModelActiveCellCount(0), m_activeCellPositionMin(cvf::Vec3d::ZERO), m_activeCellPositionMax(cvf::Vec3d::ZERO) { @@ -37,7 +36,6 @@ RigActiveCellInfo::RigActiveCellInfo() void RigActiveCellInfo::setGlobalCellCount(size_t globalCellCount) { m_activeInMatrixModel.resize(globalCellCount, cvf::UNDEFINED_SIZE_T); - // m_activeInFractureModel.resize(globalCellCount, cvf::UNDEFINED_SIZE_T); } //-------------------------------------------------------------------------------------------------- @@ -79,47 +77,7 @@ void RigActiveCellInfo::setActiveIndexInMatrixModel(size_t globalCellIndex, size m_activeInMatrixModel[globalCellIndex] = globalActiveCellIndex; } -/* -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RigActiveCellInfo::isActiveInFractureModel(size_t globalCellIndex) const -{ - if (m_activeInFractureModel.size() == 0) - { - return false; - } - CVF_TIGHT_ASSERT(globalCellIndex < m_activeInFractureModel.size()); - - return m_activeInFractureModel[globalCellIndex] != cvf::UNDEFINED_SIZE_T; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -size_t RigActiveCellInfo::activeIndexInFractureModel(size_t globalCellIndex) const -{ - if (m_activeInFractureModel.size() == 0) - { - return cvf::UNDEFINED_SIZE_T; - } - - CVF_TIGHT_ASSERT(globalCellIndex < m_activeInFractureModel.size()); - - return m_activeInFractureModel[globalCellIndex]; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigActiveCellInfo::setActiveIndexInFractureModel(size_t globalCellIndex, size_t globalActiveCellIndex) -{ - CVF_TIGHT_ASSERT(globalActiveCellIndex < m_activeInFractureModel.size()); - - m_activeInFractureModel[globalCellIndex] = globalActiveCellIndex; -} -*/ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -127,18 +85,6 @@ void RigActiveCellInfo::setGridCount(size_t gridCount) { m_perGridActiveCellInfo.resize(gridCount); } -/* -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigActiveCellInfo::setGridActiveCellCounts(size_t gridIndex, size_t matrixActiveCellCount, size_t fractureActiveCellCount) -{ - CVF_ASSERT(gridIndex < m_perGridActiveCellInfo.size()); - - m_perGridActiveCellInfo[gridIndex].setMatrixModelActiveCellCount(matrixActiveCellCount); - //m_perGridActiveCellInfo[gridIndex].setFractureModelActiveCellCount(fractureActiveCellCount); -} -*/ //-------------------------------------------------------------------------------------------------- /// @@ -148,7 +94,6 @@ void RigActiveCellInfo::setGridActiveCellCounts(size_t gridIndex, size_t matrixA CVF_ASSERT(gridIndex < m_perGridActiveCellInfo.size()); m_perGridActiveCellInfo[gridIndex].setMatrixModelActiveCellCount(matrixActiveCellCount); - //m_perGridActiveCellInfo[gridIndex].setFractureModelActiveCellCount(fractureActiveCellCount); } //-------------------------------------------------------------------------------------------------- @@ -157,12 +102,10 @@ void RigActiveCellInfo::setGridActiveCellCounts(size_t gridIndex, size_t matrixA void RigActiveCellInfo::computeDerivedData() { m_globalMatrixModelActiveCellCount = 0; - //m_globalFractureModelActiveCellCount = 0; for (size_t i = 0; i < m_perGridActiveCellInfo.size(); i++) { m_globalMatrixModelActiveCellCount += m_perGridActiveCellInfo[i].matrixModelActiveCellCount(); - // m_globalFractureModelActiveCellCount += m_perGridActiveCellInfo[i].fractureModelActiveCellCount(); } } @@ -173,15 +116,7 @@ size_t RigActiveCellInfo::globalMatrixModelActiveCellCount() const { return m_globalMatrixModelActiveCellCount; } -/* -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -size_t RigActiveCellInfo::globalFractureModelActiveCellCount() const -{ - return m_globalFractureModelActiveCellCount; -} -*/ + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -199,34 +134,6 @@ void RigActiveCellInfo::matrixModelActiveCellsBoundingBox(cvf::Vec3st& min, cvf: min = m_activeCellPositionMin; max = m_activeCellPositionMax; } -/* -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigActiveCellInfo::setFractureModelActiveCellsBoundingBox(const cvf::Vec3st& min, const cvf::Vec3st& max) -{ - m_fractureModelActiveCellPositionMin = min; - m_fractureModelActiveCellPositionMax = max; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigActiveCellInfo::fractureModelActiveCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const -{ - min = m_fractureModelActiveCellPositionMin; - max = m_fractureModelActiveCellPositionMax; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigActiveCellInfo::gridActiveCellCounts(size_t gridIndex, size_t& matrixActiveCellCount, size_t& fractureActiveCellCount) -{ - matrixActiveCellCount = m_perGridActiveCellInfo[gridIndex].matrixModelActiveCellCount(); - fractureActiveCellCount = m_perGridActiveCellInfo[gridIndex].fractureModelActiveCellCount(); -} -*/ //-------------------------------------------------------------------------------------------------- /// @@ -234,7 +141,6 @@ void RigActiveCellInfo::gridActiveCellCounts(size_t gridIndex, size_t& matrixAct void RigActiveCellInfo::gridActiveCellCounts(size_t gridIndex, size_t& matrixActiveCellCount) { matrixActiveCellCount = m_perGridActiveCellInfo[gridIndex].matrixModelActiveCellCount(); - //fractureActiveCellCount = m_perGridActiveCellInfo[gridIndex].fractureModelActiveCellCount(); } //-------------------------------------------------------------------------------------------------- /// @@ -267,20 +173,3 @@ void RigActiveCellInfo::GridActiveCellCounts::setMatrixModelActiveCellCount(size { m_matrixModelActiveCellCount = activeMatrixModelCellCount; } -/* -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -size_t RigActiveCellInfo::GridActiveCellCounts::fractureModelActiveCellCount() const -{ - return m_fractureModelActiveCellCount; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigActiveCellInfo::GridActiveCellCounts::setFractureModelActiveCellCount(size_t activeFractureModelCellCount) -{ - m_fractureModelActiveCellCount = activeFractureModelCellCount; -} -*/ \ No newline at end of file diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h index f38f95ec86..a03b138f81 100644 --- a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h @@ -38,57 +38,40 @@ public: size_t activeIndexInMatrixModel(size_t globalCellIndex) const; void setActiveIndexInMatrixModel(size_t globalCellIndex, size_t globalActiveCellIndex); - //bool isActiveInFractureModel(size_t globalCellIndex) const; - //size_t activeIndexInFractureModel(size_t globalCellIndex) const; - //void setActiveIndexInFractureModel(size_t globalCellIndex, size_t globalActiveCellIndex); - void setGridCount(size_t gridCount); - //void setGridActiveCellCounts(size_t gridIndex, size_t matrixActiveCellCount, size_t fractureActiveCellCount); void setGridActiveCellCounts(size_t gridIndex, size_t matrixActiveCellCount); - //void gridActiveCellCounts(size_t gridIndex, size_t& matrixActiveCellCount, size_t& fractureActiveCellCount); - void gridActiveCellCounts(size_t gridIndex, size_t& matrixActiveCellCount); + void gridActiveCellCounts(size_t gridIndex, size_t& matrixActiveCellCount); void computeDerivedData(); size_t globalMatrixModelActiveCellCount() const; - //size_t globalFractureModelActiveCellCount() const; void setMatrixModelActiveCellsBoundingBox(const cvf::Vec3st& min, const cvf::Vec3st& max); void matrixModelActiveCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const; - //void setFractureModelActiveCellsBoundingBox(const cvf::Vec3st& min, const cvf::Vec3st& max); - //void fractureModelActiveCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const; cvf::BoundingBox matrixActiveCellsGeometryBoundingBox() const; void setMatrixActiveCellsGeometryBoundingBox(cvf::BoundingBox bb); - private: class GridActiveCellCounts { public: size_t matrixModelActiveCellCount() const; void setMatrixModelActiveCellCount(size_t activeMatrixModelCellCount); - //size_t fractureModelActiveCellCount() const; - //void setFractureModelActiveCellCount(size_t activeFractureModelCellCount); private: size_t m_matrixModelActiveCellCount; - //size_t m_fractureModelActiveCellCount; }; private: std::vector m_perGridActiveCellInfo; - std::vector m_activeInMatrixModel; - //std::vector m_activeInFractureModel; + std::vector m_activeInMatrixModel; - size_t m_globalMatrixModelActiveCellCount; - //size_t m_globalFractureModelActiveCellCount; + size_t m_globalMatrixModelActiveCellCount; - cvf::Vec3st m_activeCellPositionMin; - cvf::Vec3st m_activeCellPositionMax; - //cvf::Vec3st m_fractureModelActiveCellPositionMin; - //cvf::Vec3st m_fractureModelActiveCellPositionMax; + cvf::Vec3st m_activeCellPositionMin; + cvf::Vec3st m_activeCellPositionMax; - cvf::BoundingBox m_matrixActiveCellsBoundingBox; + cvf::BoundingBox m_matrixActiveCellsBoundingBox; }; diff --git a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp index c7c7f5e25e..b9d6a61d3b 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp @@ -128,59 +128,6 @@ private: }; - - -/* - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -class RigGridFractureActiveCellsScalarDataAccess : public cvf::StructGridScalarDataAccess -{ -public: - RigGridFractureActiveCellsScalarDataAccess(const RigGridBase* grid, std::vector* reservoirResultValues, const RigActiveCellInfo* activeCellInfo) - : m_grid(grid), - m_reservoirResultValues(reservoirResultValues), - m_activeCellInfo(activeCellInfo) - { - } - - virtual double cellScalar(size_t gridLocalCellIndex) const - { - if (m_reservoirResultValues->size() == 0 ) return HUGE_VAL; - - size_t globalGridCellIndex = m_grid->globalGridCellIndex(gridLocalCellIndex); - size_t resultValueIndex = m_activeCellInfo->activeIndexInFractureModel(globalGridCellIndex); - if (resultValueIndex == cvf::UNDEFINED_SIZE_T) return HUGE_VAL; - - CVF_TIGHT_ASSERT (resultValueIndex < m_reservoirResultValues->size()); - - return m_reservoirResultValues->at(resultValueIndex); - } - - //-------------------------------------------------------------------------------------------------- - /// - //-------------------------------------------------------------------------------------------------- - virtual void setCellScalar(size_t gridLocalCellIndex, double scalarValue) - { - size_t globalGridCellIndex = m_grid->globalGridCellIndex(gridLocalCellIndex); - size_t resultValueIndex = m_activeCellInfo->activeIndexInFractureModel(globalGridCellIndex); - - CVF_TIGHT_ASSERT (resultValueIndex < m_reservoirResultValues->size()); - - (*m_reservoirResultValues)[resultValueIndex] = scalarValue; - } - -private: - const RigActiveCellInfo* m_activeCellInfo; - cvf::cref m_grid; - std::vector* m_reservoirResultValues; -}; - - - -*/ - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- From 973eb5c8f7f24cdd992499de636f45dce619580f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 13 Mar 2013 13:51:26 +0100 Subject: [PATCH 113/242] Use concept of parentObjectsOfType to avoid dynamic cast in application code. p4#: 20887 --- .../RimStatisticalCalculation.cpp | 40 ++++++------------- .../RimStatisticalCalculation.h | 2 +- .../RimStatisticalCollection.cpp | 19 ++++----- .../RimStatisticalCollection.h | 2 +- .../ProjectDataModel/RimUiTreeModelPdm.cpp | 22 +++++----- .../ProjectDataModel/RimUiTreeView.cpp | 12 +++--- 6 files changed, 38 insertions(+), 59 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp index a46b39bf8c..45639a773c 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp @@ -98,23 +98,17 @@ void RimStatisticalCalculation::defineUiOrdering(QString uiConfigName, caf::PdmU //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimStatisticalCollection* RimStatisticalCalculation::parent() +RimStatisticalCollection* RimStatisticalCalculation::parentStatisticalCollection() { - std::vector parentObjects; - this->parentObjects(parentObjects); + std::vector parentObjects; + this->parentObjectsOfType(parentObjects); - RimStatisticalCollection* parentObject = NULL; - for (size_t i = 0; i < parentObjects.size(); i++) + if (parentObjects.size() > 0) { - if (parentObject) continue; - - caf::PdmObject* obj = parentObjects[i]; - parentObject = dynamic_cast(obj); + return parentObjects[0]; } - CVF_ASSERT(parentObject); - - return parentObject; + return NULL; } //-------------------------------------------------------------------------------------------------- @@ -152,6 +146,9 @@ void RimStatisticalCalculation::computeStatistics() QList > resultSpecification; + resultSpecification.append(qMakePair(RimDefines::DYNAMIC_NATIVE, QString("PRESSURE"))); + + /* { QStringList resultNames = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->resultNames(RimDefines::DYNAMIC_NATIVE); foreach(QString resultName, resultNames) @@ -167,6 +164,7 @@ void RimStatisticalCalculation::computeStatistics() resultSpecification.append(qMakePair(RimDefines::STATIC_NATIVE, resultName)); } } + */ RigStatistics stat(sourceCases, timeStepIndices, statisticsConfig, resultCase); stat.evaluateStatistics(resultSpecification); @@ -208,22 +206,10 @@ void RimStatisticalCalculation::getSourceCases(cvf::Collection& //-------------------------------------------------------------------------------------------------- RimIdenticalGridCaseGroup* RimStatisticalCalculation::caseGroup() { - RimStatisticalCollection* statColl = parent(); - if (statColl) + RimStatisticalCollection* parentCollection = parentStatisticalCollection(); + if (parentCollection) { - std::vector parentObjects; - statColl->parentObjects(parentObjects); - - RimIdenticalGridCaseGroup* gridCaseGroup = NULL; - for (size_t i = 0; i < parentObjects.size(); i++) - { - if (gridCaseGroup) continue; - - caf::PdmObject* obj = parentObjects[i]; - gridCaseGroup = dynamic_cast(obj); - } - - return gridCaseGroup; + return parentCollection->parentCaseGroup(); } return NULL; diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h index 8e8cfc4f5c..9fb8b706c3 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h @@ -51,7 +51,7 @@ public: caf::PdmField m_resultName; - RimStatisticalCollection* parent(); + RimStatisticalCollection* parentStatisticalCollection(); virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) const; void computeStatistics(); diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCollection.cpp b/ApplicationCode/ProjectDataModel/RimStatisticalCollection.cpp index 511917b769..79b63b400f 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCollection.cpp @@ -51,7 +51,7 @@ RimStatisticalCollection::~RimStatisticalCollection() RimStatisticalCalculation* RimStatisticalCollection::createAndAppendStatisticalCalculation() { RimStatisticalCalculation* newObject = new RimStatisticalCalculation; - RimIdenticalGridCaseGroup* gridCaseGroup = parent(); + RimIdenticalGridCaseGroup* gridCaseGroup = parentCaseGroup(); CVF_ASSERT(gridCaseGroup); CVF_ASSERT(gridCaseGroup->mainGrid()); @@ -68,21 +68,16 @@ RimStatisticalCalculation* RimStatisticalCollection::createAndAppendStatisticalC //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimIdenticalGridCaseGroup* RimStatisticalCollection::parent() +RimIdenticalGridCaseGroup* RimStatisticalCollection::parentCaseGroup() { - std::vector parentObjects; - this->parentObjects(parentObjects); + std::vector parentObjects; + this->parentObjectsOfType(parentObjects); - RimIdenticalGridCaseGroup* gridCaseGroup = NULL; - for (size_t i = 0; i < parentObjects.size(); i++) + if (parentObjects.size() > 0) { - if (gridCaseGroup) continue; - - caf::PdmObject* obj = parentObjects[i]; - gridCaseGroup = dynamic_cast(obj); + return parentObjects[0]; } - return gridCaseGroup; - + return NULL; } diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCollection.h b/ApplicationCode/ProjectDataModel/RimStatisticalCollection.h index 8b8d7c5eec..85d55996b4 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCollection.h +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCollection.h @@ -44,7 +44,7 @@ public: RimStatisticalCalculation* createAndAppendStatisticalCalculation(); - RimIdenticalGridCaseGroup* parent(); + RimIdenticalGridCaseGroup* parentCaseGroup(); private: diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index 3efd3de8f6..95c62cf281 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -408,13 +408,11 @@ void RimUiTreeModelPdm::addInputProperty(const QModelIndex& itemIndex, const QSt RimInputPropertyCollection* inputPropertyCollection = dynamic_cast(currentItem->dataObject().p()); CVF_ASSERT(inputPropertyCollection); - std::vector parentObjects; - inputPropertyCollection->parentObjects(parentObjects); - - + std::vector parentObjects; + inputPropertyCollection->parentObjectsOfType(parentObjects); CVF_ASSERT(parentObjects.size() == 1); - RimInputReservoir* inputReservoir = dynamic_cast(parentObjects[0]); + RimInputReservoir* inputReservoir = parentObjects[0]; CVF_ASSERT(inputReservoir); if (inputReservoir) { @@ -441,18 +439,18 @@ void RimUiTreeModelPdm::deleteInputProperty(const QModelIndex& itemIndex) // Remove item from UI tree model before delete of project data structure removeRow(itemIndex.row(), itemIndex.parent()); - std::vector parentObjects; - object->parentObjects(parentObjects); + std::vector parentObjects; + object->parentObjectsOfType(parentObjects); CVF_ASSERT(parentObjects.size() == 1); - RimInputPropertyCollection* inputPropertyCollection = dynamic_cast(parentObjects[0]); + RimInputPropertyCollection* inputPropertyCollection = parentObjects[0]; if (!inputPropertyCollection) return; - std::vector parentObjects2; - inputPropertyCollection->parentObjects(parentObjects2); + std::vector parentObjects2; + inputPropertyCollection->parentObjectsOfType(parentObjects2); CVF_ASSERT(parentObjects2.size() == 1); - RimInputReservoir* inputReservoir = dynamic_cast(parentObjects2[0]); + RimInputReservoir* inputReservoir = parentObjects2[0]; if (!inputReservoir) return; inputReservoir->removeProperty(inputProperty); @@ -475,7 +473,7 @@ RimStatisticalCalculation* RimUiTreeModelPdm::addStatisticalCalculation(const QM if (dynamic_cast(currentItem->dataObject().p())) { RimStatisticalCalculation* currentObject = dynamic_cast(currentItem->dataObject().p()); - caseGroup = currentObject->parent(); + caseGroup = currentObject->parentStatisticalCollection(); parentCollectionItem = currentItem->parent(); position = itemIndex.row(); collectionIndex = itemIndex.parent(); diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index 02920e9c50..61276d9841 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -647,18 +647,18 @@ void RimUiTreeView::slotWriteInputProperty() // Find input reservoir for this property RimInputReservoir* inputReservoir = NULL; { - std::vector parentObjects; - inputProperty->parentObjects(parentObjects); + std::vector parentObjects; + inputProperty->parentObjectsOfType(parentObjects); CVF_ASSERT(parentObjects.size() == 1); - RimInputPropertyCollection* inputPropertyCollection = dynamic_cast(parentObjects[0]); + RimInputPropertyCollection* inputPropertyCollection = parentObjects[0]; if (!inputPropertyCollection) return; - std::vector parentObjects2; - inputPropertyCollection->parentObjects(parentObjects2); + std::vector parentObjects2; + inputPropertyCollection->parentObjectsOfType(parentObjects2); CVF_ASSERT(parentObjects2.size() == 1); - inputReservoir = dynamic_cast(parentObjects2[0]); + inputReservoir = parentObjects2[0]; } if (!inputReservoir) return; From d33a27a082c5f7f0bf5aec638026058635fcaed2 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 13 Mar 2013 14:41:54 +0100 Subject: [PATCH 114/242] Fixed ref counts p4#: 20890 --- .../ReservoirDataModel_UnitTests/RigReservoir-Test.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp index d2467c7e23..db4d09c889 100644 --- a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp +++ b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp @@ -40,10 +40,10 @@ TEST(RigGridCollection, BasicTest) RigGridCollection gridCollection; gridCollection.addCase(eclipseCase.p()); - EXPECT_EQ(mainGridA->refCount(), 3); + EXPECT_EQ(mainGridA->refCount(), 2); cvf::ref mainGridB = mainGridA; - EXPECT_EQ(mainGridA->refCount(), 4); + EXPECT_EQ(mainGridA->refCount(), 3); cvf::ref existingGrid = gridCollection.findEqualGrid(mainGridB.p()); EXPECT_TRUE(existingGrid.notNull()); From 160456106a52ee519e4bdc4e042b1c23b2fae9b5 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 13 Mar 2013 14:43:27 +0100 Subject: [PATCH 115/242] Use raw pointers instead of ref count Added more asserts and cleanup p4#: 20891 --- .../RigGridScalarDataAccess.cpp | 23 +++++++++---------- .../ReservoirDataModel/RigStatistics.cpp | 9 ++++++-- .../ReservoirDataModel/RigStatistics.h | 2 +- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp index b9d6a61d3b..931ef6fc4c 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp @@ -43,7 +43,7 @@ public: virtual void setCellScalar(size_t cellIndex, double value); private: - cvf::cref m_grid; + const RigGridBase* m_grid; std::vector* m_reservoirResultValues; }; @@ -55,6 +55,7 @@ RigGridAllCellsScalarDataAccess::RigGridAllCellsScalarDataAccess(const RigGridBa m_reservoirResultValues(reservoirResultValues) { CVF_ASSERT(reservoirResultValues != NULL); + CVF_ASSERT(grid != NULL); } //-------------------------------------------------------------------------------------------------- @@ -65,7 +66,7 @@ double RigGridAllCellsScalarDataAccess::cellScalar(size_t gridLocalCellIndex) co if (m_reservoirResultValues->size() == 0 ) return HUGE_VAL; size_t globalGridCellIndex = m_grid->globalGridCellIndex(gridLocalCellIndex); - CVF_TIGHT_ASSERT(globalGridCellIndex < m_reservoirResultValues->size() ); + CVF_TIGHT_ASSERT(globalGridCellIndex < m_reservoirResultValues->size()); return m_reservoirResultValues->at(globalGridCellIndex); } @@ -76,7 +77,7 @@ double RigGridAllCellsScalarDataAccess::cellScalar(size_t gridLocalCellIndex) co void RigGridAllCellsScalarDataAccess::setCellScalar(size_t gridLocalCellIndex, double scalarValue) { size_t globalGridCellIndex = m_grid->globalGridCellIndex(gridLocalCellIndex); - CVF_TIGHT_ASSERT(globalGridCellIndex < m_reservoirResultValues->size() ); + CVF_TIGHT_ASSERT(globalGridCellIndex < m_reservoirResultValues->size()); (*m_reservoirResultValues)[globalGridCellIndex] = scalarValue; } @@ -92,7 +93,8 @@ public: m_reservoirResultValues(reservoirResultValues), m_activeCellInfo(activeCellInfo) { - + CVF_ASSERT(reservoirResultValues != NULL); + CVF_ASSERT(grid != NULL); } virtual double cellScalar(size_t gridLocalCellIndex) const @@ -103,7 +105,7 @@ public: size_t resultValueIndex = m_activeCellInfo->activeIndexInMatrixModel(globalGridCellIndex); if (resultValueIndex == cvf::UNDEFINED_SIZE_T) return HUGE_VAL; - CVF_TIGHT_ASSERT (resultValueIndex < m_reservoirResultValues->size()); + CVF_TIGHT_ASSERT(resultValueIndex < m_reservoirResultValues->size()); return m_reservoirResultValues->at(resultValueIndex); } @@ -116,14 +118,14 @@ public: size_t globalGridCellIndex = m_grid->globalGridCellIndex(gridLocalCellIndex); size_t resultValueIndex = m_activeCellInfo->activeIndexInMatrixModel(globalGridCellIndex); - CVF_TIGHT_ASSERT (resultValueIndex < m_reservoirResultValues->size()); + CVF_TIGHT_ASSERT(resultValueIndex < m_reservoirResultValues->size()); (*m_reservoirResultValues)[resultValueIndex] = scalarValue; } private: const RigActiveCellInfo* m_activeCellInfo; - cvf::cref m_grid; + const RigGridBase* m_grid; std::vector* m_reservoirResultValues; }; @@ -137,7 +139,6 @@ cvf::ref RigGridScalarDataAccessFactory::create size_t timeStepIndex, size_t scalarSetIndex) { - CVF_ASSERT(gridIndex < eclipseCase->gridCount()); CVF_ASSERT(eclipseCase); CVF_ASSERT(eclipseCase->results(porosityModel)); @@ -145,12 +146,12 @@ cvf::ref RigGridScalarDataAccessFactory::create RigGridBase *grid = eclipseCase->grid(gridIndex); - if ( !eclipseCase || !eclipseCase->results(porosityModel) || !eclipseCase->activeCellInfo(porosityModel)) + if (!eclipseCase || !eclipseCase->results(porosityModel) || !eclipseCase->activeCellInfo(porosityModel)) { return NULL; } - std::vector< std::vector > & scalarSetResults = eclipseCase->results(porosityModel)->cellScalarResults(scalarSetIndex); + std::vector< std::vector >& scalarSetResults = eclipseCase->results(porosityModel)->cellScalarResults(scalarSetIndex); if (timeStepIndex >= scalarSetResults.size()) { return NULL; @@ -158,7 +159,6 @@ cvf::ref RigGridScalarDataAccessFactory::create std::vector* resultValues = &(scalarSetResults[timeStepIndex]); - bool useGlobalActiveIndex = eclipseCase->results(porosityModel)->isUsingGlobalActiveIndex(scalarSetIndex); if (useGlobalActiveIndex) { @@ -170,6 +170,5 @@ cvf::ref RigGridScalarDataAccessFactory::create cvf::ref object = new RigGridAllCellsScalarDataAccess(grid, resultValues); return object; } - } diff --git a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp index b9b1f0bbfc..51d29d7ed7 100644 --- a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp +++ b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp @@ -56,6 +56,8 @@ void RigStatistics::computeActiveCellUnion() return; } + CVF_ASSERT(m_destinationCase); + RigMainGrid* mainGrid = m_sourceCases[0]->mainGrid(); CVF_ASSERT(mainGrid); @@ -165,7 +167,7 @@ void RigStatistics::buildSourceMetaData(RimDefines::ResultCatType resultType, co //-------------------------------------------------------------------------------------------------- void RigStatistics::evaluateStatistics(const QList >& resultSpecification) { - CVF_ASSERT(m_destinationCase.notNull()); + CVF_ASSERT(m_destinationCase); computeActiveCellUnion(); @@ -372,9 +374,10 @@ void RigStatistics::evaluateStatistics(const QListresults(RifReaderInterface::MATRIX_RESULTS); size_t scalarResultIndex = m_destinationCase->results(RifReaderInterface::MATRIX_RESULTS)->findOrLoadScalarResult(resultType, resultName); cvf::ref dataAccessObject = m_destinationCase->dataAccessObject(m_destinationCase->mainGrid(), RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); @@ -399,5 +402,7 @@ RigStatistics::RigStatistics(cvf::Collection& sourceCases, const { m_globalCellCount = sourceCases[0]->mainGrid()->cells().size(); } + + CVF_ASSERT(m_destinationCase); } diff --git a/ApplicationCode/ReservoirDataModel/RigStatistics.h b/ApplicationCode/ReservoirDataModel/RigStatistics.h index 05d609903c..f0792129f8 100644 --- a/ApplicationCode/ReservoirDataModel/RigStatistics.h +++ b/ApplicationCode/ReservoirDataModel/RigStatistics.h @@ -147,6 +147,6 @@ private: RigStatisticsConfig m_statisticsConfig; - cvf::ref m_destinationCase; + RigEclipseCase* m_destinationCase; }; From 422c4ca54b3e804fe9e84d9620c133d410231904 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 13 Mar 2013 14:58:36 +0100 Subject: [PATCH 116/242] Use raw pointer instead of smart pointer p4#: 20892 --- .../ProjectDataModel/RimIdenticalGridCaseGroup.cpp | 6 +++--- .../ProjectDataModel/RimIdenticalGridCaseGroup.h | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index d4e4c78894..d641ed7946 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -72,12 +72,12 @@ void RimIdenticalGridCaseGroup::addCase(RimReservoir* reservoir) RigMainGrid* incomingMainGrid = reservoir->reservoirData()->mainGrid(); - if (m_mainGrid.isNull()) + if (!m_mainGrid) { m_mainGrid = incomingMainGrid; } - CVF_ASSERT(m_mainGrid.p() == incomingMainGrid); + CVF_ASSERT(m_mainGrid == incomingMainGrid); caseCollection()->reservoirs().push_back(reservoir); @@ -92,7 +92,7 @@ void RimIdenticalGridCaseGroup::addCase(RimReservoir* reservoir) //-------------------------------------------------------------------------------------------------- RigMainGrid* RimIdenticalGridCaseGroup::mainGrid() { - if (m_mainGrid.notNull()) return m_mainGrid.p(); + if (m_mainGrid) return m_mainGrid; return NULL; } diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h index 909ad78283..30c52aa0f3 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h @@ -55,6 +55,5 @@ protected: virtual caf::PdmFieldHandle* userDescriptionField(); private: - cvf::ref m_mainGrid; - + RigMainGrid* m_mainGrid; }; From 99159cb12d34e9a630ab84614db2100a5382d4b1 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 14 Mar 2013 08:47:42 +0100 Subject: [PATCH 117/242] Fixed missing initialization p4#: 20903 --- ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index d641ed7946..9e0838c726 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -45,6 +45,7 @@ RimIdenticalGridCaseGroup::RimIdenticalGridCaseGroup() caseCollection = new RimCaseCollection; statisticalReservoirCollection = new RimStatisticalCollection; + m_mainGrid = NULL; } //-------------------------------------------------------------------------------------------------- From 469c5a96572c723cff6463af9364aa4d6dc74f67 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 14 Mar 2013 09:28:49 +0100 Subject: [PATCH 118/242] Added initAfterRead for case group p4#: 20904 --- ApplicationCode/Application/RIApplication.cpp | 2 +- .../RimIdenticalGridCaseGroup.cpp | 54 +++++++++++++++++++ .../RimIdenticalGridCaseGroup.h | 1 + .../ProjectDataModel/RimReservoir.cpp | 13 +++-- 4 files changed, 66 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/Application/RIApplication.cpp b/ApplicationCode/Application/RIApplication.cpp index 9efb5e83fa..8e8998f376 100644 --- a/ApplicationCode/Application/RIApplication.cpp +++ b/ApplicationCode/Application/RIApplication.cpp @@ -1306,7 +1306,7 @@ void RIApplication::updateRegressionTest(const QString& testRootPath) } //-------------------------------------------------------------------------------------------------- -/// +/// Make sure changes in this functions is validated to RimIdenticalGridCaseGroup::initAfterRead() //-------------------------------------------------------------------------------------------------- bool RIApplication::addEclipseCases(const QStringList& fileNames) { diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index 9e0838c726..22053140db 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -26,6 +26,8 @@ #include "RimStatisticalCalculation.h" #include "RimStatisticalCollection.h" +#include "RimResultReservoir.h" +#include "cafProgressInfo.h" CAF_PDM_SOURCE_INIT(RimIdenticalGridCaseGroup, "RimIdenticalGridCaseGroup"); @@ -106,3 +108,55 @@ caf::PdmFieldHandle* RimIdenticalGridCaseGroup::userDescriptionField() return &name; } +//-------------------------------------------------------------------------------------------------- +/// Make sure changes in this functions is validated to RIApplication::addEclipseCases() +//-------------------------------------------------------------------------------------------------- +void RimIdenticalGridCaseGroup::initAfterRead() +{ + if (caseCollection()->reservoirs().size() == 0) + { + return; + } + + // First file is read completely including grid. + // The main grid from the first case is reused directly in for the other cases. + // When reading active cell info, only the total cell count is tested for consistency + RigEclipseCase* mainEclipseCase = NULL; + + RimResultReservoir* rimReservoir = dynamic_cast(caseCollection()->reservoirs()[0]); + CVF_ASSERT(rimReservoir); + + rimReservoir->openEclipseGridFile(); + + mainEclipseCase = rimReservoir->reservoirData(); + CVF_ASSERT(mainEclipseCase); + + + // Read active cell info from all source cases + caf::ProgressInfo info(caseCollection()->reservoirs().size(), "Case group - Reading Active Cell data"); + for (size_t i = 1; i < caseCollection()->reservoirs().size(); i++) + { + RimResultReservoir* rimReservoir = dynamic_cast(caseCollection()->reservoirs()[i]); + CVF_ASSERT(rimReservoir); + + if (!rimReservoir->openAndReadActiveCellData(mainEclipseCase)) + { + CVF_ASSERT(false); + } + + info.setProgress(i); + } + + + // Set main grid for statistical calculations + for (size_t i = 0; i < statisticalReservoirCollection()->reservoirs().size(); i++) + { + RimStatisticalCalculation* rimReservoir = dynamic_cast(statisticalReservoirCollection()->reservoirs()[i]); + CVF_ASSERT(rimReservoir); + + rimReservoir->setMainGrid(mainEclipseCase->mainGrid()); + } + + m_mainGrid = mainEclipseCase->mainGrid(); +} + diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h index 30c52aa0f3..8ffacb62c4 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h @@ -54,6 +54,7 @@ public: protected: virtual caf::PdmFieldHandle* userDescriptionField(); + virtual void initAfterRead(); private: RigMainGrid* m_mainGrid; }; diff --git a/ApplicationCode/ProjectDataModel/RimReservoir.cpp b/ApplicationCode/ProjectDataModel/RimReservoir.cpp index 776f779bbb..e10043fc4e 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoir.cpp @@ -89,8 +89,11 @@ RimReservoir::~RimReservoir() { reservoirViews.deleteAllChildObjects(); - // At this point, we assume that memory should be released - CVF_ASSERT(m_rigEclipseCase->refCount() == 1); + if (m_rigEclipseCase.notNull()) + { + // At this point, we assume that memory should be released + CVF_ASSERT(m_rigEclipseCase->refCount() == 1); + } } //-------------------------------------------------------------------------------------------------- @@ -101,7 +104,11 @@ RimReservoirView* RimReservoir::createAndAddReservoirView() // If parent is collection, and number of views is zero, make sure rig is set to NULL to initiate normal case loading if (parentCaseCollection() != NULL && reservoirViews().size() == 0) { - CVF_ASSERT(m_rigEclipseCase->refCount() == 1); + if (m_rigEclipseCase.notNull()) + { + CVF_ASSERT(m_rigEclipseCase->refCount() == 1); + } + m_rigEclipseCase = NULL; } From e92ed43fc3d528178beb3a9331d1a4415a5fe8b8 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 14 Mar 2013 09:50:40 +0100 Subject: [PATCH 119/242] Added context menu for adding new case group p4#: 20905 --- .../ProjectDataModel/RimUiTreeModelPdm.cpp | 34 +++++++++++++++++++ .../ProjectDataModel/RimUiTreeModelPdm.h | 2 ++ .../ProjectDataModel/RimUiTreeView.cpp | 20 +++++++++++ .../ProjectDataModel/RimUiTreeView.h | 1 + 4 files changed, 57 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index 95c62cf281..cc06521933 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -498,3 +498,37 @@ RimStatisticalCalculation* RimUiTreeModelPdm::addStatisticalCalculation(const QM return createdObject; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimIdenticalGridCaseGroup* RimUiTreeModelPdm::addCaseGroup(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex) +{ + RimProject* proj = RIApplication::instance()->project(); + CVF_ASSERT(proj); + + caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex); + + if (dynamic_cast(currentItem->dataObject().p())) + { + QModelIndex rootIndex = itemIndex.parent(); + caf::PdmUiTreeItem* rootTreeItem = currentItem->parent(); + + int position = rootTreeItem->childCount(); + + beginInsertRows(rootIndex, position, position); + + RimIdenticalGridCaseGroup* createdObject = new RimIdenticalGridCaseGroup; + proj->caseGroups().push_back(createdObject); + + caf::PdmUiTreeItem* childItem = new caf::PdmUiTreeItem(rootTreeItem, position, createdObject); + + endInsertRows(); + + insertedModelIndex = index(position, 0, rootIndex); + + return createdObject; + } + + return NULL; +} + diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h index 7e8e51db88..7f63aa7229 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h @@ -29,6 +29,7 @@ class RimCellRangeFilter; class RimReservoirView; class RimInputProperty; class RimStatisticalCalculation; +class RimIdenticalGridCaseGroup; //================================================================================================== /// @@ -57,6 +58,7 @@ public: void addInputProperty(const QModelIndex& itemIndex, const QStringList& fileNames); RimStatisticalCalculation* addStatisticalCalculation(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); + RimIdenticalGridCaseGroup* addCaseGroup(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); void updateScriptPaths(); diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index 61276d9841..efd22f5c22 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -165,6 +165,12 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event) menu.addAction(QString("New View"), this, SLOT(slotAddView())); menu.exec(event->globalPos()); } + else if (dynamic_cast(uiItem->dataObject().p())) + { + QMenu menu; + menu.addAction(QString("New Case Group"), this, SLOT(slotAddCaseGroup())); + menu.exec(event->globalPos()); + } } } } @@ -796,3 +802,17 @@ void RimUiTreeView::slotComputeStatisticalCases() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUiTreeView::slotAddCaseGroup() +{ + RimUiTreeModelPdm* myModel = dynamic_cast(model()); + if (myModel) + { + QModelIndex insertedIndex; + myModel->addCaseGroup(currentIndex(), insertedIndex); + setCurrentIndex(insertedIndex); + } +} + diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.h b/ApplicationCode/ProjectDataModel/RimUiTreeView.h index aa4a9e27ef..af2ba497bd 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.h @@ -71,6 +71,7 @@ private slots: void slotNewStatisticalCase(); void slotComputeStatisticalCases(); + void slotAddCaseGroup(); void slotSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected); From 62e4cac4b01b56a93e04d7f23da9573c2a9e99a2 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 18 Mar 2013 11:40:39 +0100 Subject: [PATCH 120/242] Added inherited object of MimeData to carry model index list p4#: 20926 --- ApplicationCode/CMakeLists.txt | 3 +- .../RifEclipseOutputFileTools.cpp | 8 +- .../FileInterface/RifEclipseOutputFileTools.h | 2 +- .../RifEclipseRestartDataAccess.h | 4 +- .../RifEclipseRestartFilesetAccess.cpp | 6 +- .../RifEclipseRestartFilesetAccess.h | 6 +- .../RifEclipseUnifiedRestartFileAccess.cpp | 4 +- .../RifEclipseUnifiedRestartFileAccess.h | 2 +- .../FileInterface/RifReaderEclipseOutput.cpp | 8 +- .../FileInterface/RifReaderEclipseOutput.h | 4 +- .../FileInterface/RifReaderInterface.h | 2 +- .../FileInterface/RifReaderMockModel.cpp | 4 +- .../RifReaderStatisticalCalculation.cpp | 4 +- .../RifReaderStatisticalCalculation.h | 18 +- .../ProjectDataModel/RimReservoir.cpp | 4 +- .../ProjectDataModel/RimReservoir.h | 6 +- .../RimReservoirCellResultsCacher.cpp | 164 ++++++++++++++++++ .../RimReservoirCellResultsCacher.h | 69 ++++++++ .../ProjectDataModel/RimUiTreeModelPdm.h | 51 ++++++ .../RigReservoir-Test.cpp | 2 +- .../RigReservoirCellResults.cpp | 6 +- .../RigReservoirCellResults.h | 36 ++-- .../ReservoirDataModel/RigStatistics.cpp | 4 +- .../ReservoirDataModel/RigWellResults.cpp | 2 +- .../ReservoirDataModel/RigWellResults.h | 2 +- .../UserInterface/RIMainWindow.cpp | 2 +- cafProjectDataModel/cafPdmDocument.h | 39 ++++- cafProjectDataModel/cafPdmField.cpp | 30 +++- cafProjectDataModel/cafPdmField.h | 1 + cafProjectDataModel/cafPdmField.inl | 19 ++ cafProjectDataModel/cafPdmFieldImpl.h | 33 ++-- cafProjectDataModel/cafPdmObject.cpp | 23 --- cafProjectDataModel/cafPdmObject.h | 10 +- 33 files changed, 472 insertions(+), 106 deletions(-) create mode 100644 ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp create mode 100644 ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index 10e2d226ce..5fd4c0cd30 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -24,7 +24,7 @@ include_directories( ) -# Use all cpp and h files in the subdirectories +# Use all h files in the subdirectories to make them available in the project file( GLOB_RECURSE HEADER_FILES *.h ) list( APPEND CPP_SOURCES @@ -85,6 +85,7 @@ list( APPEND CPP_SOURCES ProjectDataModel/Rim3dOverlayInfoConfig.cpp ProjectDataModel/RimUiTreeModelPdm.cpp ProjectDataModel/RimUiTreeView.cpp + ProjectDataModel/RimReservoirCellResultsCacher.cpp ) # Populate the filenames into variable lists diff --git a/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp b/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp index de6f679d6d..8e3a4cbb8b 100644 --- a/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp @@ -46,7 +46,7 @@ RifEclipseOutputFileTools::~RifEclipseOutputFileTools() //-------------------------------------------------------------------------------------------------- /// Get list of time step texts (dates) //-------------------------------------------------------------------------------------------------- -void RifEclipseOutputFileTools::timeSteps(ecl_file_type* ecl_file, QList* timeSteps, bool* detectedFractionOfDay ) +void RifEclipseOutputFileTools::timeSteps(ecl_file_type* ecl_file, std::vector* timeSteps, bool* detectedFractionOfDay ) { CVF_ASSERT(timeSteps); CVF_ASSERT(ecl_file); @@ -84,7 +84,7 @@ void RifEclipseOutputFileTools::timeSteps(ecl_file_type* ecl_file, QList timeStepsFound; + std::vector timeStepsFound; if (hasFractionOfDay) { @@ -110,7 +110,7 @@ void RifEclipseOutputFileTools::timeSteps(ecl_file_type* ecl_file, QList* values); // static void timeStepsText(ecl_file_type* ecl_file, QStringList* timeSteps); - static void timeSteps(ecl_file_type* ecl_file, QList* timeSteps, bool* detectedFractionOfDay = NULL); + static void timeSteps(ecl_file_type* ecl_file, std::vector* timeSteps, bool* detectedFractionOfDay = NULL); static bool fileSet(const QString& fileName, QStringList* fileSet); diff --git a/ApplicationCode/FileInterface/RifEclipseRestartDataAccess.h b/ApplicationCode/FileInterface/RifEclipseRestartDataAccess.h index a7d61d27ce..dd8bff2460 100644 --- a/ApplicationCode/FileInterface/RifEclipseRestartDataAccess.h +++ b/ApplicationCode/FileInterface/RifEclipseRestartDataAccess.h @@ -46,9 +46,9 @@ public: virtual void setFileSet(const QStringList& fileSet) = 0; virtual void close() = 0; - virtual void setTimeSteps(const QList& timeSteps) {}; + virtual void setTimeSteps(const std::vector& timeSteps) {}; virtual size_t timeStepCount() = 0; - virtual QList timeSteps() = 0; + virtual std::vector timeSteps() = 0; virtual void resultNames(QStringList* resultNames, std::vector* resultDataItemCounts) = 0; virtual bool results(const QString& resultName, size_t timeStep, size_t gridCount, std::vector* values) = 0; diff --git a/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp b/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp index dd8b4ffa07..208a6b48bc 100644 --- a/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp +++ b/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp @@ -97,7 +97,7 @@ void RifEclipseRestartFilesetAccess::close() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RifEclipseRestartFilesetAccess::setTimeSteps(const QList& timeSteps) +void RifEclipseRestartFilesetAccess::setTimeSteps(const std::vector& timeSteps) { CVF_ASSERT(m_fileNames.size() == timeSteps.size()); m_timeSteps = timeSteps; @@ -114,7 +114,7 @@ size_t RifEclipseRestartFilesetAccess::timeStepCount() //-------------------------------------------------------------------------------------------------- /// Get the time steps //-------------------------------------------------------------------------------------------------- -QList RifEclipseRestartFilesetAccess::timeSteps() +std::vector RifEclipseRestartFilesetAccess::timeSteps() { if (m_timeSteps.size() == 0) { @@ -122,7 +122,7 @@ QList RifEclipseRestartFilesetAccess::timeSteps() size_t i; for (i = 0; i < numSteps; i++) { - QList stepTime; + std::vector stepTime; openTimeStep(i); diff --git a/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.h b/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.h index 8fe26540d3..00403233d3 100644 --- a/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.h +++ b/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.h @@ -39,9 +39,9 @@ public: void setFileSet(const QStringList& fileSet); void close(); - void setTimeSteps(const QList& timeSteps); + void setTimeSteps(const std::vector& timeSteps); size_t timeStepCount(); - QList timeSteps(); + std::vector timeSteps(); void resultNames(QStringList* resultNames, std::vector* resultDataItemCounts); bool results(const QString& resultName, size_t timeStep, size_t gridCount, std::vector* values); @@ -53,7 +53,7 @@ private: private: QStringList m_fileNames; - QList m_timeSteps; + std::vector m_timeSteps; std::vector< ecl_file_type* > m_ecl_files; }; diff --git a/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp b/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp index b5e79ea6bb..c8fb1391fc 100644 --- a/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp +++ b/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp @@ -89,9 +89,9 @@ size_t RifEclipseUnifiedRestartFileAccess::timeStepCount() //-------------------------------------------------------------------------------------------------- /// Get the time steps //-------------------------------------------------------------------------------------------------- -QList RifEclipseUnifiedRestartFileAccess::timeSteps() +std::vector RifEclipseUnifiedRestartFileAccess::timeSteps() { - QList timeSteps; + std::vector timeSteps; if (openFile()) { diff --git a/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.h b/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.h index 95e3d4858f..f80d11fe11 100644 --- a/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.h +++ b/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.h @@ -42,7 +42,7 @@ public: void close(); size_t timeStepCount(); - QList timeSteps(); + std::vector timeSteps(); void resultNames(QStringList* resultNames, std::vector* resultDataItemCounts); bool results(const QString& resultName, size_t timeStep, size_t gridCount, std::vector* values); diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index 5450991ae6..e85260a844 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -432,7 +432,7 @@ bool RifReaderEclipseOutput::openAndReadActiveCellData(const QString& fileName, m_dynamicResultsAccess = createDynamicResultsAccess(m_fileSet); - QList mainCaseTimeSteps = mainEclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->readerInterface()->timeSteps(); + std::vector mainCaseTimeSteps = mainEclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->readerInterface()->timeSteps(); m_dynamicResultsAccess->setTimeSteps(mainCaseTimeSteps); return true; @@ -608,7 +608,7 @@ bool RifReaderEclipseOutput::buildMetaData() m_eclipseCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS), RifReaderInterface::MATRIX_RESULTS, 1); - QList staticDate; + std::vector staticDate; if (m_timeSteps.size() > 0) { staticDate.push_back(m_timeSteps.front()); @@ -627,7 +627,7 @@ bool RifReaderEclipseOutput::buildMetaData() m_eclipseCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS), RifReaderInterface::FRACTURE_RESULTS, 1); - QList staticDate; + std::vector staticDate; if (m_timeSteps.size() > 0) { staticDate.push_back(m_timeSteps.front()); @@ -1045,7 +1045,7 @@ bool RifReaderEclipseOutput::openInitFile() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RifReaderEclipseOutput::timeSteps() +std::vector RifReaderEclipseOutput::timeSteps() { return m_timeSteps; } diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.h b/ApplicationCode/FileInterface/RifReaderEclipseOutput.h index 43c6fd91d0..bdbec6f0ad 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.h +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.h @@ -66,14 +66,14 @@ private: QStringList validKeywordsForPorosityModel(const QStringList& keywords, const std::vector& keywordDataItemCounts, const RigActiveCellInfo* activeCellInfo, const RigActiveCellInfo* fractureActiveCellInfo, PorosityModelResultType matrixOrFracture, size_t timeStepCount) const; - virtual QList timeSteps(); + virtual std::vector timeSteps(); private: QString m_fileName; // Name of file used to start accessing Eclipse output files QStringList m_fileSet; // Set of files in filename's path with same base name as filename RigEclipseCase* m_eclipseCase; - QList m_timeSteps; + std::vector m_timeSteps; ecl_file_type* m_ecl_init_file; // File access to static results cvf::ref m_dynamicResultsAccess; // File access to dynamic results diff --git a/ApplicationCode/FileInterface/RifReaderInterface.h b/ApplicationCode/FileInterface/RifReaderInterface.h index 2848aa363d..e313ca4bbd 100644 --- a/ApplicationCode/FileInterface/RifReaderInterface.h +++ b/ApplicationCode/FileInterface/RifReaderInterface.h @@ -54,5 +54,5 @@ public: virtual bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector* values) = 0; virtual bool dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector* values) = 0; - virtual QList timeSteps() { QList timeSteps; return timeSteps; } + virtual std::vector timeSteps() { std::vector timeSteps; return timeSteps; } }; diff --git a/ApplicationCode/FileInterface/RifReaderMockModel.cpp b/ApplicationCode/FileInterface/RifReaderMockModel.cpp index e81d5cb840..fc8257bcf7 100644 --- a/ApplicationCode/FileInterface/RifReaderMockModel.cpp +++ b/ApplicationCode/FileInterface/RifReaderMockModel.cpp @@ -34,7 +34,7 @@ bool RifReaderMockModel::open(const QString& fileName, RigEclipseCase* eclipseCa RigReservoirCellResults* cellResults = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS); - QList dates; + std::vector dates; for (int i = 0; i < static_cast(m_reservoirBuilder.timeStepCount()); i++) { @@ -49,7 +49,7 @@ bool RifReaderMockModel::open(const QString& fileName, RigEclipseCase* eclipseCa if (m_reservoirBuilder.timeStepCount() == 0) return true; - QList staticDates; + std::vector staticDates; staticDates.push_back(dates[0]); for (int i = 0; i < static_cast(m_reservoirBuilder.resultCount()); i++) { diff --git a/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.cpp b/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.cpp index c109a1cded..ca9d4cdc08 100644 --- a/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.cpp +++ b/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.cpp @@ -70,7 +70,7 @@ void RifReaderStatisticalCalculation::buildMetaData(RigEclipseCase* eclipseCase) fractureModelResults->setTimeStepDates(resIndex, m_timeSteps); } - QList staticDate; + std::vector staticDate; if (m_timeSteps.size() > 0) { staticDate.push_back(m_timeSteps.front()); @@ -111,7 +111,7 @@ void RifReaderStatisticalCalculation::setFractureResultNames(const QStringList& //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RifReaderStatisticalCalculation::setTimeSteps(const QList& timesteps) +void RifReaderStatisticalCalculation::setTimeSteps(const std::vector& timesteps) { m_timeSteps = timesteps; } diff --git a/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.h b/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.h index 70814ae583..649fd08b74 100644 --- a/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.h +++ b/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.h @@ -28,23 +28,23 @@ public: virtual ~RifReaderStatisticalCalculation(); // Virtual interface implementation - virtual bool open(const QString& fileName, RigEclipseCase* eclipseCase); + virtual bool open(const QString& fileName, RigEclipseCase* eclipseCase); - virtual void close() {} + virtual void close() {} - virtual bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector* values ); - virtual bool dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector* values ); + virtual bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector* values ); + virtual bool dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector* values ); - void setMatrixResultNames(const QStringList& staticResultNames, const QStringList& dynamicResultNames); - void setFractureResultNames(const QStringList& staticResultNames, const QStringList& dynamicResultNames); + void setMatrixResultNames(const QStringList& staticResultNames, const QStringList& dynamicResultNames); + void setFractureResultNames(const QStringList& staticResultNames, const QStringList& dynamicResultNames); - void setTimeSteps(const QList& timesteps); + void setTimeSteps(const std::vector& timesteps); private: - void buildMetaData(RigEclipseCase* eclipseCase); + void buildMetaData(RigEclipseCase* eclipseCase); private: - QList m_timeSteps; + std::vector m_timeSteps; QStringList m_matrixDynamicResultNames; QStringList m_fractureDynamicResultNames; diff --git a/ApplicationCode/ProjectDataModel/RimReservoir.cpp b/ApplicationCode/ProjectDataModel/RimReservoir.cpp index e10043fc4e..5da41eae67 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoir.cpp @@ -35,7 +35,9 @@ #include #include "RimProject.h" -//-------------------------------------------------------------------------------------------------- +CAF_PDM_SOURCE_INIT(RimReservoir, "RimReservoir"); + +//------------------------------------------------------------------------------------------------ /// //-------------------------------------------------------------------------------------------------- RimReservoir::RimReservoir() diff --git a/ApplicationCode/ProjectDataModel/RimReservoir.h b/ApplicationCode/ProjectDataModel/RimReservoir.h index d68f9b84a6..0b3c384eda 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoir.h +++ b/ApplicationCode/ProjectDataModel/RimReservoir.h @@ -40,12 +40,12 @@ class RimCaseCollection; //================================================================================================== class RimReservoir : public caf::PdmObject { - + CAF_PDM_HEADER_INIT; public: RimReservoir(); virtual ~RimReservoir(); - virtual bool openEclipseGridFile() = 0; + virtual bool openEclipseGridFile() { return false;}; // Should be pure virtual but PDM does not allow that. RigEclipseCase* reservoirData(); const RigEclipseCase* reservoirData() const; @@ -78,5 +78,5 @@ private: protected: cvf::ref m_rigEclipseCase; -}; +}; diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp new file mode 100644 index 0000000000..3e6878cb57 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp @@ -0,0 +1,164 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 "RIStdInclude.h" +#include "RimReservoirCellResultsCacher.h" +#include "RigReservoirCellResults.h" +#include "RIApplication.h" + +CAF_PDM_SOURCE_INIT(RimReservoirCellResultsCacher, "ReservoirCellResultCacher"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimReservoirCellResultsCacher::RimReservoirCellResultsCacher() + : m_cellResults(NULL) +{ + CAF_PDM_InitObject("Cacher", "", "", ""); + + CAF_PDM_InitField(&m_resultCacheFileName, "ResultCacheFileName", QString(), "UiDummyname", "", "" ,""); + m_resultCacheFileName.setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_resultCacheMetaData, "ResultCacheEntries", "UiDummyname", "", "", ""); + m_resultCacheMetaData.setUiHidden(true); + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimReservoirCellResultsCacher::~RimReservoirCellResultsCacher() +{ + m_resultCacheMetaData.deleteAllChildObjects(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimReservoirCellResultsCacher::setupBeforeSave() +{ + if (!m_cellResults) return; + + const std::vector& resInfo = m_cellResults->infoForEachResultIndex(); + m_resultCacheMetaData.deleteAllChildObjects(); + + if(resInfo.size()) + { + QDir::root().mkpath(getCacheDirectoryPath()); + + QString newValidCacheFileName = getValidCacheFileName(); + QFile cacheFile(newValidCacheFileName); + + if (!cacheFile.open(QIODevice::WriteOnly)) qWarning() << "Saving project: Can't open the cache file : " + newValidCacheFileName; + + QDataStream stream(&cacheFile); + stream.setVersion(QDataStream::Qt_4_0); + stream << (quint32)0xCEECAC4E; // magic number + stream << (qint32)1; // Version + + for (int rIdx = 0; rIdx < resInfo.size(); ++rIdx) + { + RimReservoirCellResultsCacheEntryInfo* cacheEntry = new RimReservoirCellResultsCacheEntryInfo; + m_resultCacheMetaData.push_back(cacheEntry); + + cacheEntry->m_resultType = resInfo[rIdx].m_resultType; + cacheEntry->m_resultName = resInfo[rIdx].m_resultName; + cacheEntry->m_timeStepDates = resInfo[rIdx].m_timeStepDates; + + cacheEntry->m_filePosition = cacheFile.pos(); + + for (int tsIdx = 0; tsIdx < resInfo[rIdx].m_timeStepDates.size() ; ++tsIdx) + { + std::vector& data = m_cellResults->cellScalarResults(resInfo[rIdx].m_gridScalarResultIndex, tsIdx); + if (data.size()) + { + cacheEntry->m_timeStepHasData.v().push_back(1); + + for (size_t cIdx = 0; cIdx < data.size(); ++cIdx) + { + stream << data[cIdx]; + } + } + else + { + cacheEntry->m_timeStepHasData.v().push_back(0); + } + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimReservoirCellResultsCacher::getValidCacheFileName() +{ + QString cacheFileName; + if (m_resultCacheFileName().isEmpty()) + { + QString newCacheDirPath = getCacheDirectoryPath(); + QUuid guid = QUuid::createUuid(); + cacheFileName = newCacheDirPath + "/" + guid.toString(); + } + else + { + // Make the path correct related to the possibly new project filename + QString newCacheDirPath = getCacheDirectoryPath(); + QFileInfo oldCacheFile(m_resultCacheFileName()); + + cacheFileName = newCacheDirPath + "/" + oldCacheFile.fileName(); + } + return cacheFileName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimReservoirCellResultsCacher::getCacheDirectoryPath() +{ + QString cacheDirPath; + QString projectFileName = RIApplication::instance()->project()->fileName(); + QFileInfo fileInfo(projectFileName); + cacheDirPath = fileInfo.canonicalPath(); + cacheDirPath += "/" + fileInfo.completeBaseName() + "_cache"; + return cacheDirPath; +} + + +CAF_PDM_SOURCE_INIT(RimReservoirCellResultsCacheEntryInfo, "ResultCacheEntryInfo"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimReservoirCellResultsCacheEntryInfo::RimReservoirCellResultsCacheEntryInfo() +{ + CAF_PDM_InitObject("Cache Entry", "", "", ""); + + CAF_PDM_InitField(&m_resultType, "ResultType", caf::AppEnum(RimDefines::REMOVED), "ResultType", "", "" ,""); + CAF_PDM_InitField(&m_resultName, "ResultName", QString(), "ResultName", "", "" ,""); + CAF_PDM_InitFieldNoDefault(&m_timeStepDates, "TimeSteps", "TimeSteps", "", "" ,""); + CAF_PDM_InitField(&m_filePosition, "FilePositionDataStart", qint64(-1), "FilePositionDataStart", "", "" ,""); + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimReservoirCellResultsCacheEntryInfo::~RimReservoirCellResultsCacheEntryInfo() +{ + +} diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h new file mode 100644 index 0000000000..a07a3bf7e2 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h @@ -0,0 +1,69 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 +#include "cafPdmField.h" +#include "cafPdmObject.h" +#include "cafAppEnum.h" +#include "RimDefines.h" + +class RimReservoirCellResultsCacheEntryInfo; +class RigReservoirCellResults; + +class RimReservoirCellResultsCacher : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; +public: + RimReservoirCellResultsCacher(); + virtual ~RimReservoirCellResultsCacher(); + + //RigReservoirCellResults* cellResults() const { return m_cellResults; } + void setCellResults(RigReservoirCellResults* cellResults) { m_cellResults = cellResults; } + + + virtual void setupBeforeSave(); + + caf::PdmField m_resultCacheFileName; + caf::PdmPointersField m_resultCacheMetaData; + + + +private: + QString getValidCacheFileName(); + QString getCacheDirectoryPath(); + + RigReservoirCellResults* m_cellResults; + +}; + +class RimReservoirCellResultsCacheEntryInfo : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; +public: + RimReservoirCellResultsCacheEntryInfo(); + virtual ~RimReservoirCellResultsCacheEntryInfo(); + + caf::PdmField > m_resultType; + caf::PdmField m_resultName; + caf::PdmField< std::vector > m_timeStepDates; + caf::PdmField< std::vector > m_timeStepHasData; + caf::PdmField m_filePosition; +}; + diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h index 7f63aa7229..6991b29bc0 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h @@ -22,6 +22,8 @@ #include "cafPdmPointer.h" #include "cafUiTreeModelPdm.h" +#include + class QFileSystemWatcher; class RimCellPropertyFilter; @@ -31,6 +33,55 @@ class RimInputProperty; class RimStatisticalCalculation; class RimIdenticalGridCaseGroup; +//-------------------------------------------------------------------------------------------------- +/// MimeData class used to carry a QModelIndexList +//-------------------------------------------------------------------------------------------------- +class MimeDataWithIndexes : public QMimeData +{ + Q_OBJECT + +public: + MimeDataWithIndexes() + { + } + + MimeDataWithIndexes(const MimeDataWithIndexes & other) + { + setIndexes(other.indexes()); + } + + void setIndexes(const QModelIndexList & indexes) + { + m_indexes = indexes; + } + + const QModelIndexList& indexes() const { return m_indexes; } + + virtual bool hasFormat( const QString &mimetype ) const + { + return (mimetype == formatName()); + } + + virtual QStringList formats() const + { + QStringList supportedFormats = QMimeData::formats(); + supportedFormats << formatName(); + + return supportedFormats; + } + + static QString formatName() + { + return "MimeDataWithIndexes"; + } + +private: + QModelIndexList m_indexes; +}; + +Q_DECLARE_METATYPE(MimeDataWithIndexes) + + //================================================================================================== /// /// diff --git a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp index db4d09c889..80689eb35f 100644 --- a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp +++ b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp @@ -110,7 +110,7 @@ TEST(RigReservoirTest, BasicTest) } int resultTimeStepCount = 2 * wellTimeStepCount; - QList resultTimes; + std::vector resultTimes; for (i = 0; i < resultTimeStepCount; i++) { resultTimes.push_back(QDateTime(wellStartTime).addMonths(i * 6)); diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp index a12cdeb6fa..35f4829d2c 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp @@ -777,18 +777,18 @@ QDateTime RigReservoirCellResults::timeStepDate(size_t scalarResultIndex, size_t //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RigReservoirCellResults::timeStepDates(size_t scalarResultIndex) const +std::vector RigReservoirCellResults::timeStepDates(size_t scalarResultIndex) const { if (scalarResultIndex < m_resultInfos.size() ) return m_resultInfos[scalarResultIndex].m_timeStepDates; else - return QList(); + return std::vector(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigReservoirCellResults::setTimeStepDates(size_t scalarResultIndex, const QList& dates) +void RigReservoirCellResults::setTimeStepDates(size_t scalarResultIndex, const std::vector& dates) { CVF_ASSERT(scalarResultIndex < m_resultInfos.size() ); diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h index 8af96eb8a1..b37c94d2d5 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h +++ b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h @@ -54,8 +54,8 @@ public: bool isUsingGlobalActiveIndex(size_t scalarResultIndex) const; QDateTime timeStepDate(size_t scalarResultIndex, size_t timeStepIndex) const; - QList timeStepDates(size_t scalarResultIndex) const; - void setTimeStepDates(size_t scalarResultIndex, const QList& dates); + std::vector timeStepDates(size_t scalarResultIndex) const; + void setTimeStepDates(size_t scalarResultIndex, const std::vector& dates); // Find or create a slot for the results size_t findOrLoadScalarResultForTimeStep(RimDefines::ResultCatType type, const QString& resultName, size_t timeStepIndex); @@ -80,19 +80,8 @@ public: double cellScalarResult(size_t scalarResultIndex, size_t timeStepIndex, size_t resultValueIndex); static RifReaderInterface::PorosityModelResultType convertFromProjectModelPorosityModel(RimDefines::PorosityModelType porosityModel); - -private: - size_t addStaticScalarResult(RimDefines::ResultCatType type, const QString& resultName, size_t resultValueCount); - -private: - std::vector< std::vector< std::vector > > m_cellScalarResults; ///< Scalar results for each timestep for each Result index (ResultVariable) - std::vector< std::pair > m_maxMinValues; ///< Max min values for each Result index - std::vector< std::vector > m_histograms; ///< Histogram for each Result Index - std::vector< std::pair > m_p10p90; ///< P10 and p90 values for each Result Index - std::vector< double > m_meanValues; ///< Mean value for each Result Index - - std::vector< std::vector< std::pair > > m_maxMinValuesPrTs; ///< Max min values for each timestep and Result index +public: class ResultInfo { public: @@ -103,9 +92,26 @@ private: RimDefines::ResultCatType m_resultType; QString m_resultName; size_t m_gridScalarResultIndex; - QList m_timeStepDates; + std::vector m_timeStepDates; }; + const std::vector& infoForEachResultIndex() { return m_resultInfos;} + +private: + size_t addStaticScalarResult(RimDefines::ResultCatType type, const QString& resultName, size_t resultValueCount); + +private: + std::vector< std::vector< std::vector > > m_cellScalarResults; ///< Scalar results on the complete reservoir for each Result index (ResultVariable) and timestep + std::vector< std::pair > m_maxMinValues; ///< Max min values for each Result index + std::vector< std::vector > m_histograms; ///< Histogram for each Result Index + std::vector< std::pair > m_p10p90; ///< P10 and p90 values for each Result Index + std::vector< double > m_meanValues; ///< Mean value for each Result Index + + std::vector< std::vector< std::pair > > m_maxMinValuesPrTs; ///< Max min values for each Result index and timestep + + + +private: std::vector m_resultInfos; cvf::ref m_readerInterface; RigMainGrid* m_ownerMainGrid; diff --git a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp index 51d29d7ed7..d9ec30b045 100644 --- a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp +++ b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp @@ -30,7 +30,7 @@ void RigStatistics::addNamedResult(RigReservoirCellResults* destinationCellResul // Use time step dates from first result in first source case CVF_ASSERT(m_sourceCases.size() > 0); - QList sourceTimeStepDates = m_sourceCases[0]->results(RifReaderInterface::MATRIX_RESULTS)->timeStepDates(0); + std::vector sourceTimeStepDates = m_sourceCases[0]->results(RifReaderInterface::MATRIX_RESULTS)->timeStepDates(0); size_t destinationScalarResultIndex = destinationCellResults->addEmptyScalarResult(resultType, resultName); CVF_ASSERT(destinationScalarResultIndex != cvf::UNDEFINED_SIZE_T); @@ -143,7 +143,7 @@ void RigStatistics::buildSourceMetaData(RimDefines::ResultCatType resultType, co { if (m_sourceCases.size() == 0) return; - QList timeStepDates = m_sourceCases[0]->results(RifReaderInterface::MATRIX_RESULTS)->timeStepDates(0); + std::vector timeStepDates = m_sourceCases[0]->results(RifReaderInterface::MATRIX_RESULTS)->timeStepDates(0); for (size_t caseIdx = 1; caseIdx < m_sourceCases.size(); caseIdx++) { diff --git a/ApplicationCode/ReservoirDataModel/RigWellResults.cpp b/ApplicationCode/ReservoirDataModel/RigWellResults.cpp index 43436bec64..4a752ded4a 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellResults.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellResults.cpp @@ -37,7 +37,7 @@ const RigWellResultFrame& RigWellResults::wellResultFrame(size_t resultTimeStepI //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigWellResults::computeMappingFromResultTimeIndicesToWellTimeIndices(const QList& resultTimes) +void RigWellResults::computeMappingFromResultTimeIndicesToWellTimeIndices(const std::vector& resultTimes) { m_resultTimeStepIndexToWellTimeStepIndex.clear(); if (m_wellCellsTimeSteps.size() == 0) return; diff --git a/ApplicationCode/ReservoirDataModel/RigWellResults.h b/ApplicationCode/ReservoirDataModel/RigWellResults.h index 0cc0553adc..dce4c4c7ec 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellResults.h +++ b/ApplicationCode/ReservoirDataModel/RigWellResults.h @@ -109,7 +109,7 @@ public: void computeStaticWellCellPath(); - void computeMappingFromResultTimeIndicesToWellTimeIndices(const QList& resultTimes); + void computeMappingFromResultTimeIndicesToWellTimeIndices(const std::vector& resultTimes); public: QString m_wellName; diff --git a/ApplicationCode/UserInterface/RIMainWindow.cpp b/ApplicationCode/UserInterface/RIMainWindow.cpp index 48b8438e36..24e12b144d 100644 --- a/ApplicationCode/UserInterface/RIMainWindow.cpp +++ b/ApplicationCode/UserInterface/RIMainWindow.cpp @@ -546,7 +546,7 @@ void RIMainWindow::refreshAnimationActions() || app->activeReservoirView()->propertyFilterCollection()->hasActiveDynamicFilters() || app->activeReservoirView()->wellCollection()->hasVisibleWellPipes()) { - QList timeStepDates = app->activeReservoirView()->currentGridCellResults()->timeStepDates(0); + std::vector timeStepDates = app->activeReservoirView()->currentGridCellResults()->timeStepDates(0); bool showHoursAndMinutes = false; for (int i = 0; i < timeStepDates.size(); i++) { diff --git a/cafProjectDataModel/cafPdmDocument.h b/cafProjectDataModel/cafPdmDocument.h index 7289c654f8..a620d539f6 100644 --- a/cafProjectDataModel/cafPdmDocument.h +++ b/cafProjectDataModel/cafPdmDocument.h @@ -44,7 +44,6 @@ public: void removeNullPtrs(); void addObject(PdmObject * obj); - // Needs renaming to objectsByType template void objectsByType(std::vector >* typedObjects ) const { @@ -57,6 +56,44 @@ public: } } + template + void createCopyByType(std::vector >* copyOfTypedObjects) const + { + std::vector > sourceTypedObjects; + objectsByType(&sourceTypedObjects); + + QString encodedXml; + { + // Write original objects to XML file + PdmObjectGroup typedObjectGroup; + for (size_t i = 0; i < sourceTypedObjects.size(); i++) + { + typedObjectGroup.addObject(sourceTypedObjects[i]); + } + + QXmlStreamWriter xmlStream(&encodedXml); + xmlStream.setAutoFormatting(true); + + typedObjectGroup.writeFields(xmlStream); + + // Call clear to avoid destruction of objects + typedObjectGroup.objects().clear(); + } + + // Read back XML into object group, factory methods will be called that will create new objects + PdmObjectGroup destinationObjectGroup; + QXmlStreamReader xmlStream(encodedXml); + destinationObjectGroup.readFields(xmlStream); + + for (size_t it = 0; it < destinationObjectGroup.objects.size(); it++) + { + T* obj = dynamic_cast(destinationObjectGroup.objects[it]); + if (obj) copyOfTypedObjects->push_back(obj); + } + + // Call clear to avoid destruction of objects + destinationObjectGroup.objects().clear(); + } }; //================================================================================================== diff --git a/cafProjectDataModel/cafPdmField.cpp b/cafProjectDataModel/cafPdmField.cpp index 7a398f8aaa..fb0f118c7b 100644 --- a/cafProjectDataModel/cafPdmField.cpp +++ b/cafProjectDataModel/cafPdmField.cpp @@ -59,13 +59,13 @@ bool PdmFieldHandle::assertValid() const { if (m_keyword == "UNDEFINED") { - std::cout << "Detected use of non-initialized field\n"; + std::cout << "PdmField: Detected use of non-initialized field. Did you forget to do CAF_PDM_InitField() on this field ?\n"; return false; } if (!PdmObject::isValidXmlElementName(m_keyword)) { - std::cout << "Detected keyword " << m_keyword.toStdString() << " which is an invalid Xml element name\n"; + std::cout << "PdmField: The supplied keyword: \"" << m_keyword.toStdString() << "\" is an invalid XML element name, and will break your file format!\n"; return false; } @@ -136,18 +136,40 @@ void PdmFieldReader::readFieldData(PdmField & field, QXmlStrea //-------------------------------------------------------------------------------------------------- /// Specialized read operation for Bool`s //-------------------------------------------------------------------------------------------------- -void operator >> (QTextStream& str, bool& value) +QTextStream& operator >> (QTextStream& str, bool& value) { QString text; str >> text; if (text == "True" || text == "true" || text == "1" || text == "Yes" || text == "yes") value = true; else value = false; + + return str; } -void operator << (QTextStream& str, const bool& value) +QTextStream& operator << (QTextStream& str, const bool& value) { if (value) str << "True "; else str << "False "; + + return str; } +//-------------------------------------------------------------------------------------------------- +/// Specialized read operation for QDateTimes`s +//-------------------------------------------------------------------------------------------------- +#include +QTextStream& operator >> (QTextStream& str, QDateTime& value) +{ + QString text; + str >> text; + value = QDateTime::fromString(text, "yyyy_MM_dd-HH:mm:ss"); + return str; +} + +QTextStream& operator << (QTextStream& str, const QDateTime& value) +{ + QString text = value.toString("yyyy_MM_dd-HH:mm:ss"); + str << text; + return str; +} diff --git a/cafProjectDataModel/cafPdmField.h b/cafProjectDataModel/cafPdmField.h index 0498119946..7c77f03997 100644 --- a/cafProjectDataModel/cafPdmField.h +++ b/cafProjectDataModel/cafPdmField.h @@ -212,6 +212,7 @@ public: void push_back(DataType* pointer); void set(size_t index, DataType* pointer); void insert(size_t indexAfter, DataType* pointer); + void insert(size_t indexAfter, const std::vector >& objects); void clear(); void erase(size_t index); diff --git a/cafProjectDataModel/cafPdmField.inl b/cafProjectDataModel/cafPdmField.inl index 12c7c9331d..d2654c8f2b 100644 --- a/cafProjectDataModel/cafPdmField.inl +++ b/cafProjectDataModel/cafPdmField.inl @@ -422,6 +422,25 @@ void PdmPointersField::insert(size_t indexAfter, DataType* pointer) if (pointer) pointer->addParentField(this); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +void PdmPointersField::insert(size_t indexAfter, const std::vector >& objects) +{ + m_pointers.insert(m_pointers.begin()+indexAfter, objects.begin(), objects.end()); + + typename std::vector< PdmPointer< DataType > >::iterator it; + for (it = m_pointers.begin()+indexAfter; it != m_pointers.end(); ++it) + { + if (!it->isNull()) + { + (*it)->addParentField(this); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/cafProjectDataModel/cafPdmFieldImpl.h b/cafProjectDataModel/cafPdmFieldImpl.h index 33f04d52c0..ac3bb79c51 100644 --- a/cafProjectDataModel/cafPdmFieldImpl.h +++ b/cafProjectDataModel/cafPdmFieldImpl.h @@ -411,6 +411,24 @@ struct PdmFieldReader > > } // End of namespace caf +//================================================================================================== +/// QTextStream Stream operator overloading for bool`s +/// Prints bool`s as "True"/"False", and reads them too +//================================================================================================== + +QTextStream& operator >> (QTextStream& str, bool& value); +QTextStream& operator << (QTextStream& str, const bool& value); + + +//================================================================================================== +/// QTextStream Stream operator overloading for QDateTimes`s +/// +//================================================================================================== +//class QDateTime; +QTextStream& operator >> (QTextStream& str, QDateTime& value); +QTextStream& operator << (QTextStream& str, const QDateTime& value); + + //================================================================================================== /// QTextStream Stream operator overloading for std::vector of things. /// Makes automated IO of PdmField< std::vector< Whatever > possible as long as @@ -418,17 +436,18 @@ struct PdmFieldReader > > //================================================================================================== template < typename T > -void operator << (QTextStream& str, const std::vector& sobj) +QTextStream& operator << (QTextStream& str, const std::vector& sobj) { size_t i; for (i = 0; i < sobj.size(); ++i) { str << sobj[i] << " "; } + return str; } template < typename T > -void operator >> (QTextStream& str, std::vector& sobj) +QTextStream& operator >> (QTextStream& str, std::vector& sobj) { while (str.status() == QTextStream::Ok ) { @@ -436,13 +455,5 @@ void operator >> (QTextStream& str, std::vector& sobj) str >> d; if (str.status() == QTextStream::Ok ) sobj.push_back(d); } + return str; } - -//================================================================================================== -/// QTextStream Stream operator overloading for bool`s -/// Prints bool`s as "True"/"False", and reads them too -//================================================================================================== - -void operator >> (QTextStream& str, bool& value); -void operator << (QTextStream& str, const bool& value); - diff --git a/cafProjectDataModel/cafPdmObject.cpp b/cafProjectDataModel/cafPdmObject.cpp index 56eff83b56..7d02f36a45 100644 --- a/cafProjectDataModel/cafPdmObject.cpp +++ b/cafProjectDataModel/cafPdmObject.cpp @@ -37,29 +37,6 @@ namespace caf //-------------------------------------------------------------------------------------------------- void PdmObject::readFields (QXmlStreamReader& xmlStream ) { - if (!xmlStream.isStartElement()) - { - // Error - return ; - } -/* - Attributes will not be used ... - - QXmlStreamAttributes attribs = xmlStream.attributes(); - int i; - for (i = 0; i < attribs.size(); ++i) - { - QString name = attribs[i].name().toString(); - - PdmFieldBase* field = findField(name); - - if (field) - { - //field->readFieldData(attribs[i].value().toString()); - } - } - */ - bool isObjectFinished = false; QXmlStreamReader::TokenType type; while(!isObjectFinished) diff --git a/cafProjectDataModel/cafPdmObject.h b/cafProjectDataModel/cafPdmObject.h index 16e8576120..82861bf202 100644 --- a/cafProjectDataModel/cafPdmObject.h +++ b/cafProjectDataModel/cafPdmObject.h @@ -61,14 +61,16 @@ class PdmUiEditorAttribute; #define CAF_PDM_HEADER_INIT \ public: \ virtual QString classKeyword() { return classKeywordStatic(); } \ - static QString classKeywordStatic() + static QString classKeywordStatic(); \ + static bool Error_You_forgot_to_add_the_macro_CAF_PDM_HEADER_INIT_and_or_CAF_PDM_SOURCE_INIT_to_your_cpp_file_for_this_class() /// CAF_PDM_SOURCE_INIT associates the file keyword used for storage with the class and initializes the factory /// Place this in the cpp file, preferably above the constructor #define CAF_PDM_SOURCE_INIT(ClassName, keyword) \ + bool ClassName::Error_You_forgot_to_add_the_macro_CAF_PDM_HEADER_INIT_and_or_CAF_PDM_SOURCE_INIT_to_your_cpp_file_for_this_class() { return false;} \ QString ClassName::classKeywordStatic() { assert(PdmObject::isValidXmlElementName(keyword)); return keyword; } \ - static bool PDM_OBJECT_STRING_CONCATENATE(pdm_object_factory_init_, __LINE__) = caf::PdmObjectFactory::instance()->registerCreator() + static bool PDM_OBJECT_STRING_CONCATENATE(pdm_object_factory_init_, __LINE__) = caf::PdmObjectFactory::instance()->registerCreator() /// InitObject sets up the user interface related information for the object /// Placed in the constructor of your PdmObject @@ -86,6 +88,8 @@ public: \ #define CAF_PDM_InitField(field, keyword, default, uiName, iconResourceName, toolTip, whatsThis) \ { \ + static bool chekingThePresenceOfHeaderAndSourceInitMacros = Error_You_forgot_to_add_the_macro_CAF_PDM_HEADER_INIT_and_or_CAF_PDM_SOURCE_INIT_to_your_cpp_file_for_this_class(); \ + \ static caf::PdmUiItemInfo objDescr(uiName, QIcon(QString(iconResourceName)), toolTip, whatsThis); \ addField(field, keyword, default, &objDescr); \ } @@ -94,6 +98,8 @@ public: \ #define CAF_PDM_InitFieldNoDefault(field, keyword, uiName, iconResourceName, toolTip, whatsThis) \ { \ + static bool chekingThePresenceOfHeaderAndSourceInitMacros = Error_You_forgot_to_add_the_macro_CAF_PDM_HEADER_INIT_and_or_CAF_PDM_SOURCE_INIT_to_your_cpp_file_for_this_class(); \ + \ static caf::PdmUiItemInfo objDescr(uiName, QIcon(QString(iconResourceName)), toolTip, whatsThis); \ addFieldNoDefault(field, keyword, &objDescr); \ } From f7248f3999180988333ecc34dbd9c808fd5e220c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 18 Mar 2013 14:34:29 +0100 Subject: [PATCH 121/242] Results Storage: A huge refactorisation to make way for storing generated properties to an internal file. This does not yet compile due to a unfortunate mix of perforce, cmake setup and unit_test project shortcomings. Need to move RigStatistics into ProjectDataModel and rename it before this is running again. p4#: 20945 --- .../FileInterface_UnitTests/CMakeLists.txt | 3 + .../FileInterface/RifReaderEclipseOutput.cpp | 8 +- .../FileInterface/RifReaderEclipseOutput.h | 2 +- .../Rim3dOverlayInfoConfig.cpp | 16 +- .../ProjectDataModel/RimCaseCollection.h | 1 - .../RimCellEdgeResultSlot.cpp | 6 +- .../RimCellPropertyFilter.cpp | 4 +- .../ProjectDataModel/RimInputReservoir.cpp | 32 +- .../ProjectDataModel/RimReservoir.cpp | 94 ++-- .../ProjectDataModel/RimReservoir.h | 61 +-- .../RimReservoirCellResultsCacher.cpp | 440 +++++++++++++++++- .../RimReservoirCellResultsCacher.h | 38 +- .../ProjectDataModel/RimReservoirView.cpp | 19 +- .../ProjectDataModel/RimReservoirView.h | 2 +- .../ProjectDataModel/RimResultDefinition.cpp | 16 +- .../ProjectDataModel/RimResultReservoir.cpp | 25 +- .../RimStatisticalCalculation.cpp | 22 +- .../RimStatisticalCalculation.h | 2 +- .../CMakeLists.txt | 3 + .../ReservoirDataModel/RigEclipseCase.cpp | 3 +- .../ReservoirDataModel/RigEclipseCase.h | 2 +- .../RigReservoirCellResults.cpp | 374 +-------------- .../RigReservoirCellResults.h | 68 ++- .../ReservoirDataModel/RigStatistics.cpp | 45 +- .../ReservoirDataModel/RigStatistics.h | 11 +- .../SocketInterface/RiaSocketServer.cpp | 8 +- .../UserInterface/RIMainWindow.cpp | 2 +- 27 files changed, 705 insertions(+), 602 deletions(-) diff --git a/ApplicationCode/FileInterface/FileInterface_UnitTests/CMakeLists.txt b/ApplicationCode/FileInterface/FileInterface_UnitTests/CMakeLists.txt index 33a34260a3..e66fbc896c 100644 --- a/ApplicationCode/FileInterface/FileInterface_UnitTests/CMakeLists.txt +++ b/ApplicationCode/FileInterface/FileInterface_UnitTests/CMakeLists.txt @@ -18,6 +18,9 @@ include_directories( ${ResInsight_SOURCE_DIR}/cafProjectDataModel ${ResInsight_SOURCE_DIR}/CommonCode + + #Remove when RigStatistics is out + ${ResInsight_SOURCE_DIR}/ApplicationCode/ModelVisualization ) diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index e85260a844..584f731876 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -377,9 +377,6 @@ bool RifReaderEclipseOutput::open(const QString& fileName, RigEclipseCase* eclip m_eclipseCase = eclipseCase; - eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(this); - eclipseCase->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(this); - // Build results meta data if (!buildMetaData()) return false; progInfo.incrementProgress(); @@ -397,7 +394,7 @@ bool RifReaderEclipseOutput::open(const QString& fileName, RigEclipseCase* eclip //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifReaderEclipseOutput::openAndReadActiveCellData(const QString& fileName, RigEclipseCase* mainEclipseCase, RigEclipseCase* eclipseCase) +bool RifReaderEclipseOutput::openAndReadActiveCellData(const QString& fileName, const std::vector& mainCaseTimeSteps, RigEclipseCase* eclipseCase) { CVF_ASSERT(eclipseCase); @@ -417,8 +414,6 @@ bool RifReaderEclipseOutput::openAndReadActiveCellData(const QString& fileName, m_fileSet = fileSet; m_eclipseCase = eclipseCase; - eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(this); - eclipseCase->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(this); if (!readActiveCellInfo()) { @@ -432,7 +427,6 @@ bool RifReaderEclipseOutput::openAndReadActiveCellData(const QString& fileName, m_dynamicResultsAccess = createDynamicResultsAccess(m_fileSet); - std::vector mainCaseTimeSteps = mainEclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->readerInterface()->timeSteps(); m_dynamicResultsAccess->setTimeSteps(mainCaseTimeSteps); return true; diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.h b/ApplicationCode/FileInterface/RifReaderEclipseOutput.h index bdbec6f0ad..d902795935 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.h +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.h @@ -44,7 +44,7 @@ public: virtual ~RifReaderEclipseOutput(); bool open(const QString& fileName, RigEclipseCase* eclipseCase); - virtual bool openAndReadActiveCellData(const QString& fileName, RigEclipseCase* mainEclipseCase, RigEclipseCase* eclipseCase); + virtual bool openAndReadActiveCellData(const QString& fileName, const std::vector& mainCaseTimeSteps, RigEclipseCase* eclipseCase); void close(); bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector* values); diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index d35b7d9cb7..1e00f95e13 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -117,9 +117,9 @@ void Rim3dOverlayInfoConfig::update3DInfo() double p10, p90; double mean; size_t scalarIndex = m_reservoirView->cellResult()->gridScalarIndex(); - m_reservoirView->currentGridCellResults()->minMaxCellScalarValues(scalarIndex, min, max); - m_reservoirView->currentGridCellResults()->p10p90CellScalarValues(scalarIndex, p10, p90); - m_reservoirView->currentGridCellResults()->meanCellScalarValues(scalarIndex, mean); + m_reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, min, max); + m_reservoirView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, p10, p90); + m_reservoirView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, mean); //infoText += QString("
Min: %1 P10: %2 Mean: %3 P90: %4 Max: %5
").arg(min).arg(p10).arg(mean).arg(p90).arg(max); //infoText += QString("
Min: %1   P10: %2   Mean: %3 \n  P90: %4   Max: %5 
").arg(min).arg(p10).arg(mean).arg(p90).arg(max); @@ -141,7 +141,7 @@ void Rim3dOverlayInfoConfig::update3DInfo() || m_reservoirView->wellCollection()->hasVisibleWellPipes()) { int currentTimeStep = m_reservoirView->currentTimeStep(); - QDateTime date = m_reservoirView->currentGridCellResults()->timeStepDate(0, currentTimeStep); + QDateTime date = m_reservoirView->currentGridCellResults()->cellResults()->timeStepDate(0, currentTimeStep); infoText += QString("Time Step: %1 Time: %2").arg(currentTimeStep).arg(date.toString("dd.MMM yyyy")); } @@ -157,12 +157,12 @@ void Rim3dOverlayInfoConfig::update3DInfo() double mean; size_t scalarIndex = m_reservoirView->cellResult()->gridScalarIndex(); - m_reservoirView->currentGridCellResults()->minMaxCellScalarValues(scalarIndex, min, max); - m_reservoirView->currentGridCellResults()->p10p90CellScalarValues(scalarIndex, p10, p90); - m_reservoirView->currentGridCellResults()->meanCellScalarValues(scalarIndex, mean); + m_reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(scalarIndex, min, max); + m_reservoirView->currentGridCellResults()->cellResults()->p10p90CellScalarValues(scalarIndex, p10, p90); + m_reservoirView->currentGridCellResults()->cellResults()->meanCellScalarValues(scalarIndex, mean); m_reservoirView->viewer()->showHistogram(true); - m_reservoirView->viewer()->setHistogram(min, max, m_reservoirView->currentGridCellResults()->cellScalarValuesHistogram(scalarIndex)); + m_reservoirView->viewer()->setHistogram(min, max, m_reservoirView->currentGridCellResults()->cellResults()->cellScalarValuesHistogram(scalarIndex)); m_reservoirView->viewer()->setHistogramPercentiles(p10, p90, mean); } } diff --git a/ApplicationCode/ProjectDataModel/RimCaseCollection.h b/ApplicationCode/ProjectDataModel/RimCaseCollection.h index 137435fc32..49989fc9b3 100644 --- a/ApplicationCode/ProjectDataModel/RimCaseCollection.h +++ b/ApplicationCode/ProjectDataModel/RimCaseCollection.h @@ -26,7 +26,6 @@ #include "RimStatisticalCalculation.h" - //================================================================================================== // // diff --git a/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp b/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp index 26721a0bf9..c2558cc09c 100644 --- a/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp @@ -133,7 +133,7 @@ QList RimCellEdgeResultSlot::calculateValueOptions(const if (m_reservoirView && m_reservoirView->currentGridCellResults()) { QStringList varList; - varList = m_reservoirView->currentGridCellResults()->resultNames(RimDefines::STATIC_NATIVE); + varList = m_reservoirView->currentGridCellResults()->cellResults()->resultNames(RimDefines::STATIC_NATIVE); //TODO: Must also handle input properties //varList += m_reservoirView->gridCellResults()->resultNames(RimDefines::INPUT_PROPERTY); @@ -208,7 +208,7 @@ QStringList RimCellEdgeResultSlot::findResultVariableNames() if (m_reservoirView && m_reservoirView->currentGridCellResults() && !resultVariable().isEmpty()) { QStringList varList; - varList = m_reservoirView->currentGridCellResults()->resultNames(RimDefines::STATIC_NATIVE); + varList = m_reservoirView->currentGridCellResults()->cellResults()->resultNames(RimDefines::STATIC_NATIVE); //TODO: Must handle Input properties int i; @@ -313,7 +313,7 @@ void RimCellEdgeResultSlot::minMaxCellEdgeValues(double& min, double& max) { double cMin, cMax; - m_reservoirView->currentGridCellResults()->minMaxCellScalarValues(resultIndices[idx], cMin, cMax); + m_reservoirView->currentGridCellResults()->cellResults()->minMaxCellScalarValues(resultIndices[idx], cMin, cMax); globalMin = CVF_MIN(globalMin, cMin); globalMax = CVF_MAX(globalMax, cMax); diff --git a/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.cpp b/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.cpp index 542d6c23f9..ad47fc70c6 100644 --- a/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.cpp @@ -143,10 +143,10 @@ void RimCellPropertyFilter::setDefaultValues() size_t scalarIndex = resultDefinition->gridScalarIndex(); if (scalarIndex != cvf::UNDEFINED_SIZE_T) { - RigReservoirCellResults* results = m_parentContainer->reservoirView()->currentGridCellResults(); + RimReservoirCellResultsCacher* results = m_parentContainer->reservoirView()->currentGridCellResults(); if (results) { - results->minMaxCellScalarValues(scalarIndex, min, max); + results->cellResults()->minMaxCellScalarValues(scalarIndex, min, max); } } diff --git a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp index a86b85f396..c221244c7b 100644 --- a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp @@ -72,18 +72,18 @@ void RimInputReservoir::openDataFileSet(const QStringList& filenames) if (caseName().contains("Input Mock Debug Model")) { cvf::ref readerInterface = this->createMockModel(this->caseName()); - m_rigEclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p()); - m_rigEclipseCase->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p()); + results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p()); + results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p()); - m_rigEclipseCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->computeDerivedData(); - m_rigEclipseCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->computeDerivedData(); + reservoirData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->computeDerivedData(); + reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->computeDerivedData(); return; } - if (m_rigEclipseCase.isNull()) + if (this->reservoirData() == NULL) { - m_rigEclipseCase = new RigEclipseCase; + this->setReservoirData(new RigEclipseCase); } // First find and read the grid data @@ -157,7 +157,7 @@ void RimInputReservoir::openDataFileSet(const QStringList& filenames) bool RimInputReservoir::openEclipseGridFile() { // Early exit if reservoir data is created - if (m_rigEclipseCase.isNull()) + if (this->reservoirData() == NULL) { cvf::ref readerInterface; @@ -174,14 +174,14 @@ bool RimInputReservoir::openEclipseGridFile() return false; } - m_rigEclipseCase = eclipseCase; + this->setReservoirData( eclipseCase.p() ); } - CVF_ASSERT(m_rigEclipseCase.notNull()); + CVF_ASSERT(this->reservoirData()); CVF_ASSERT(readerInterface.notNull()); - m_rigEclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p()); - m_rigEclipseCase->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p()); + results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p()); + results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p()); computeCachedData(); loadAndSyncronizeInputProperties(); @@ -191,8 +191,8 @@ bool RimInputReservoir::openEclipseGridFile() RIApplication* app = RIApplication::instance(); if (app->preferences()->autocomputeDepthRelatedProperties) { - RigReservoirCellResults* matrixResults = m_rigEclipseCase->results(RifReaderInterface::MATRIX_RESULTS); - RigReservoirCellResults* fractureResults = m_rigEclipseCase->results(RifReaderInterface::FRACTURE_RESULTS); + RimReservoirCellResultsCacher* matrixResults = results(RifReaderInterface::MATRIX_RESULTS); + RimReservoirCellResultsCacher* fractureResults = results(RifReaderInterface::FRACTURE_RESULTS); matrixResults->computeDepthRelatedResults(); fractureResults->computeDepthRelatedResults(); @@ -210,7 +210,7 @@ void RimInputReservoir::loadAndSyncronizeInputProperties() { // Make sure we actually have reservoir data - CVF_ASSERT(m_rigEclipseCase.notNull()); + CVF_ASSERT(this->reservoirData()); CVF_ASSERT(this->reservoirData()->mainGrid()->gridPointDimensions() != cvf::Vec3st(0,0,0)); // Then read the properties from all the files referenced by the InputReservoir @@ -359,7 +359,7 @@ void RimInputReservoir::removeProperty(RimInputProperty* inputProperty) } // Remove the results pointed to by this input property - RigReservoirCellResults* results = m_rigEclipseCase->results(RifReaderInterface::MATRIX_RESULTS); + RigReservoirCellResults* results = reservoirData()->results(RifReaderInterface::MATRIX_RESULTS); results->removeResult(inputProperty->resultName); this->removeResult(inputProperty->resultName); @@ -404,7 +404,7 @@ cvf::ref RimInputReservoir::createMockModel(QString modelNam m_inputPropertyCollection->inputProperties.push_back(inputProperty); } - m_rigEclipseCase = reservoir; + this->setReservoirData( reservoir.p() ); return mockFileInterface.p(); } diff --git a/ApplicationCode/ProjectDataModel/RimReservoir.cpp b/ApplicationCode/ProjectDataModel/RimReservoir.cpp index 5da41eae67..4078d2eeb1 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoir.cpp @@ -34,6 +34,7 @@ #include #include "RimProject.h" +#include "RimReservoirCellResultsCacher.h" CAF_PDM_SOURCE_INIT(RimReservoir, "RimReservoir"); @@ -42,15 +43,33 @@ CAF_PDM_SOURCE_INIT(RimReservoir, "RimReservoir"); //-------------------------------------------------------------------------------------------------- RimReservoir::RimReservoir() { - m_rigEclipseCase = NULL; - CAF_PDM_InitField(&caseName, "CaseName", QString(), "Case name", "", "" ,""); -// CAF_PDM_InitField(&releaseResultMemory, "ReleaseResultMemory", true, "Release result memory", "", "" ,""); -// releaseResultMemory.setIOReadable(false); -// releaseResultMemory.setIOWritable(false); -// releaseResultMemory.setUiEditorTypeName(caf::PdmUiPushButtonEditor::uiEditorTypeName()); - CAF_PDM_InitFieldNoDefault(&reservoirViews, "ReservoirViews", "", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_matrixModelResults, "MatrixModelResults", "", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_fractureModelResults, "FractureModelResults", "", "", "", ""); + + m_matrixModelResults = new RimReservoirCellResultsCacher; + m_fractureModelResults = new RimReservoirCellResultsCacher; + + this->setReservoirData( NULL ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimReservoir::~RimReservoir() +{ + reservoirViews.deleteAllChildObjects(); + + delete m_matrixModelResults(); + delete m_fractureModelResults(); + + if (this->reservoirData()) + { + // At this point, we assume that memory should be released + CVF_ASSERT(this->reservoirData()->refCount() == 1); + } } //-------------------------------------------------------------------------------------------------- @@ -84,20 +103,6 @@ void RimReservoir::initAfterRead() } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimReservoir::~RimReservoir() -{ - reservoirViews.deleteAllChildObjects(); - - if (m_rigEclipseCase.notNull()) - { - // At this point, we assume that memory should be released - CVF_ASSERT(m_rigEclipseCase->refCount() == 1); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -106,12 +111,12 @@ RimReservoirView* RimReservoir::createAndAddReservoirView() // If parent is collection, and number of views is zero, make sure rig is set to NULL to initiate normal case loading if (parentCaseCollection() != NULL && reservoirViews().size() == 0) { - if (m_rigEclipseCase.notNull()) + if (this->reservoirData()) { - CVF_ASSERT(m_rigEclipseCase->refCount() == 1); + CVF_ASSERT(this->reservoirData()->refCount() == 1); } - m_rigEclipseCase = NULL; + this->setReservoirData( NULL ); } RimReservoirView* riv = new RimReservoirView(); @@ -207,7 +212,7 @@ void RimReservoir::fieldChangedByUi(const caf::PdmFieldHandle* changedField, con { if (changedField == &releaseResultMemory) { - if (m_rigEclipseCase.notNull()) + if (this->reservoirData()) { for (size_t i = 0; i < reservoirViews().size(); i++) { @@ -229,13 +234,13 @@ void RimReservoir::fieldChangedByUi(const caf::PdmFieldHandle* changedField, con reservoirView->createDisplayModelAndRedraw(); } - RigReservoirCellResults* matrixModelResults = m_rigEclipseCase->results(RifReaderInterface::MATRIX_RESULTS); + RigReservoirCellResults* matrixModelResults = reservoirData()->results(RifReaderInterface::MATRIX_RESULTS); if (matrixModelResults) { matrixModelResults->clearAllResults(); } - RigReservoirCellResults* fractureModelResults = m_rigEclipseCase->results(RifReaderInterface::FRACTURE_RESULTS); + RigReservoirCellResults* fractureModelResults = reservoirData()->results(RifReaderInterface::FRACTURE_RESULTS); if (fractureModelResults) { fractureModelResults->clearAllResults(); @@ -286,3 +291,38 @@ RimCaseCollection* RimReservoir::parentCaseCollection() return NULL; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimReservoir::setReservoirData(RigEclipseCase* eclipseCase) +{ + m_rigEclipseCase = eclipseCase; + if (this->reservoirData()) + { + m_fractureModelResults()->setCellResults(reservoirData()->results(RifReaderInterface::FRACTURE_RESULTS)); + m_matrixModelResults()->setCellResults(reservoirData()->results(RifReaderInterface::MATRIX_RESULTS)); + m_fractureModelResults()->setMainGrid(this->reservoirData()->mainGrid()); + m_matrixModelResults()->setMainGrid(this->reservoirData()->mainGrid()); + } + else + { + m_fractureModelResults()->setCellResults(NULL); + m_matrixModelResults()->setCellResults(NULL); + m_fractureModelResults()->setMainGrid(NULL); + m_matrixModelResults()->setMainGrid(NULL); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimReservoirCellResultsCacher* RimReservoir::results(RifReaderInterface::PorosityModelResultType porosityModel) +{ + if (porosityModel == RifReaderInterface::MATRIX_RESULTS) + { + return m_matrixModelResults(); + } + + return m_fractureModelResults(); +} + diff --git a/ApplicationCode/ProjectDataModel/RimReservoir.h b/ApplicationCode/ProjectDataModel/RimReservoir.h index 0b3c384eda..05b634e706 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoir.h +++ b/ApplicationCode/ProjectDataModel/RimReservoir.h @@ -22,7 +22,8 @@ #include "cvfObject.h" #include "cafPdmField.h" #include "cafPdmObject.h" - +#include "RimReservoirCellResultsCacher.h" +#include "RifReaderInterface.h" class QString; @@ -30,12 +31,11 @@ class RigEclipseCase; class RigGridBase; class RimReservoirView; class RimCaseCollection; +//class RimReservoirCellResultsCacher; //================================================================================================== // // Interface for reservoirs. -// As this is a pure virtual class, the factory macros are not relevant (nor possible) to use -// CAF_PDM_HEADER_INIT and CAF_PDM_SOURCE_INIT // //================================================================================================== class RimReservoir : public caf::PdmObject @@ -45,38 +45,45 @@ public: RimReservoir(); virtual ~RimReservoir(); - virtual bool openEclipseGridFile() { return false;}; // Should be pure virtual but PDM does not allow that. - - RigEclipseCase* reservoirData(); - const RigEclipseCase* reservoirData() const; - - RimReservoirView* createAndAddReservoirView(); - void removeReservoirView(RimReservoirView* reservoirView); + // Fields: + caf::PdmField caseName; + caf::PdmField releaseResultMemory; + caf::PdmPointersField reservoirViews; - void removeResult(const QString& resultName); - - // Fields: - caf::PdmField caseName; - caf::PdmField releaseResultMemory; + virtual bool openEclipseGridFile() { return false;}; // Should be pure virtual but PDM does not allow that. + + RigEclipseCase* reservoirData(); + const RigEclipseCase* reservoirData() const; - caf::PdmPointersField reservoirViews; + RimReservoirCellResultsCacher* results(RifReaderInterface::PorosityModelResultType porosityModel); + + RimReservoirView* createAndAddReservoirView(); + void removeReservoirView(RimReservoirView* reservoirView); - virtual caf::PdmFieldHandle* userDescriptionField() { return &caseName; } - - virtual QString locationOnDisc() const { return QString(); } + void removeResult(const QString& resultName); + virtual QString locationOnDisc() const { return QString(); } + + // Overridden methods from PdmObject +public: + virtual caf::PdmFieldHandle* userDescriptionField() { return &caseName; } protected: - // Overridden methods - virtual void initAfterRead(); + virtual void initAfterRead(); + virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ); - virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ); - - void computeCachedData(); + // Internal methods +protected: + void computeCachedData(); + void setReservoirData(RigEclipseCase* eclipseCase); private: - RimCaseCollection* parentCaseCollection(); + RimCaseCollection* parentCaseCollection(); -protected: - cvf::ref m_rigEclipseCase; +private: + cvf::ref m_rigEclipseCase; + +private: + caf::PdmField m_matrixModelResults; + caf::PdmField m_fractureModelResults; }; diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp index 3e6878cb57..8213c8e107 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp @@ -20,6 +20,8 @@ #include "RimReservoirCellResultsCacher.h" #include "RigReservoirCellResults.h" #include "RIApplication.h" +#include "RigMainGrid.h" +#include "RigCell.h" CAF_PDM_SOURCE_INIT(RimReservoirCellResultsCacher, "ReservoirCellResultCacher"); @@ -27,7 +29,8 @@ CAF_PDM_SOURCE_INIT(RimReservoirCellResultsCacher, "ReservoirCellResultCacher"); /// //-------------------------------------------------------------------------------------------------- RimReservoirCellResultsCacher::RimReservoirCellResultsCacher() - : m_cellResults(NULL) + : m_cellResults(NULL), + m_ownerMainGrid(NULL) { CAF_PDM_InitObject("Cacher", "", "", ""); @@ -72,30 +75,39 @@ void RimReservoirCellResultsCacher::setupBeforeSave() for (int rIdx = 0; rIdx < resInfo.size(); ++rIdx) { - RimReservoirCellResultsCacheEntryInfo* cacheEntry = new RimReservoirCellResultsCacheEntryInfo; - m_resultCacheMetaData.push_back(cacheEntry); - - cacheEntry->m_resultType = resInfo[rIdx].m_resultType; - cacheEntry->m_resultName = resInfo[rIdx].m_resultName; - cacheEntry->m_timeStepDates = resInfo[rIdx].m_timeStepDates; - - cacheEntry->m_filePosition = cacheFile.pos(); - - for (int tsIdx = 0; tsIdx < resInfo[rIdx].m_timeStepDates.size() ; ++tsIdx) + size_t timestepCount = m_cellResults->cellScalarResults(resInfo[rIdx].m_gridScalarResultIndex).size(); + if (timestepCount) { - std::vector& data = m_cellResults->cellScalarResults(resInfo[rIdx].m_gridScalarResultIndex, tsIdx); - if (data.size()) - { - cacheEntry->m_timeStepHasData.v().push_back(1); + RimReservoirCellResultsCacheEntryInfo* cacheEntry = new RimReservoirCellResultsCacheEntryInfo; + m_resultCacheMetaData.push_back(cacheEntry); - for (size_t cIdx = 0; cIdx < data.size(); ++cIdx) - { - stream << data[cIdx]; - } - } - else + cacheEntry->m_resultType = resInfo[rIdx].m_resultType; + cacheEntry->m_resultName = resInfo[rIdx].m_resultName; + cacheEntry->m_timeStepDates = resInfo[rIdx].m_timeStepDates; + + cacheEntry->m_filePosition = cacheFile.pos(); + + for (int tsIdx = 0; tsIdx < resInfo[rIdx].m_timeStepDates.size() ; ++tsIdx) { - cacheEntry->m_timeStepHasData.v().push_back(0); + const std::vector* data = NULL; + if (tsIdx < timestepCount) + { + data = &(m_cellResults->cellScalarResults(resInfo[rIdx].m_gridScalarResultIndex, tsIdx)); + } + + if (data && data->size()) + { + cacheEntry->m_timeStepHasData.v().push_back(1); + + for (size_t cIdx = 0; cIdx < data->size(); ++cIdx) + { + stream << (*data)[cIdx]; + } + } + else + { + cacheEntry->m_timeStepHasData.v().push_back(0); + } } } } @@ -138,6 +150,390 @@ QString RimReservoirCellResultsCacher::getCacheDirectoryPath() return cacheDirPath; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimReservoirCellResultsCacher::setReaderInterface(RifReaderInterface* readerInterface) +{ + m_readerInterface = readerInterface; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifReaderInterface* RimReservoirCellResultsCacher::readerInterface() +{ + return m_readerInterface.p(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RimReservoirCellResultsCacher::findOrLoadScalarResultForTimeStep(RimDefines::ResultCatType type, const QString& resultName, size_t timeStepIndex) +{ + // Special handling for SOIL + if (type == RimDefines::DYNAMIC_NATIVE && resultName.toUpper() == "SOIL") + { + loadOrComputeSOILForTimeStep(timeStepIndex); + } + + size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T; + + scalarResultIndex = m_cellResults->findScalarResultIndex(type, resultName); + + if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) return cvf::UNDEFINED_SIZE_T; + + if (type == RimDefines::GENERATED) + { + return cvf::UNDEFINED_SIZE_T; + } + + if (m_readerInterface.notNull()) + { + size_t timeStepCount = m_cellResults->infoForEachResultIndex()[scalarResultIndex].m_timeStepDates.size(); + + bool resultLoadingSucess = true; + + if (type == RimDefines::DYNAMIC_NATIVE && timeStepCount > 0) + { + m_cellResults->cellScalarResults(scalarResultIndex).resize(timeStepCount); + + std::vector& values = m_cellResults->cellScalarResults(scalarResultIndex)[timeStepIndex]; + if (values.size() == 0) + { + if (!m_readerInterface->dynamicResult(resultName, RifReaderInterface::MATRIX_RESULTS, timeStepIndex, &values)) + { + resultLoadingSucess = false; + } + } + } + else if (type == RimDefines::STATIC_NATIVE) + { + m_cellResults->cellScalarResults(scalarResultIndex).resize(1); + + std::vector& values = m_cellResults->cellScalarResults(scalarResultIndex)[0]; + if (!m_readerInterface->staticResult(resultName, RifReaderInterface::MATRIX_RESULTS, &values)) + { + resultLoadingSucess = false; + } + } + + if (!resultLoadingSucess) + { + // Error logging + CVF_ASSERT(false); + } + } + + return scalarResultIndex; + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RimReservoirCellResultsCacher::findOrLoadScalarResult(RimDefines::ResultCatType type, const QString& resultName) +{ + size_t resultGridIndex = cvf::UNDEFINED_SIZE_T; + + resultGridIndex = m_cellResults->findScalarResultIndex(type, resultName); + + if (resultGridIndex == cvf::UNDEFINED_SIZE_T) return cvf::UNDEFINED_SIZE_T; + + if (m_cellResults->cellScalarResults(resultGridIndex).size()) return resultGridIndex; + + if (type == RimDefines::GENERATED) + { + return cvf::UNDEFINED_SIZE_T; + } + + if (m_readerInterface.notNull()) + { + // Add one more result to result container + size_t timeStepCount = m_cellResults->infoForEachResultIndex()[resultGridIndex].m_timeStepDates.size(); + + bool resultLoadingSucess = true; + + if (type == RimDefines::DYNAMIC_NATIVE && timeStepCount > 0) + { + m_cellResults->cellScalarResults(resultGridIndex).resize(timeStepCount); + + size_t i; + for (i = 0; i < timeStepCount; i++) + { + std::vector& values = m_cellResults->cellScalarResults(resultGridIndex)[i]; + if (!m_readerInterface->dynamicResult(resultName, RifReaderInterface::MATRIX_RESULTS, i, &values)) + { + resultLoadingSucess = false; + } + } + } + else if (type == RimDefines::STATIC_NATIVE) + { + m_cellResults->cellScalarResults(resultGridIndex).resize(1); + + std::vector& values = m_cellResults->cellScalarResults(resultGridIndex)[0]; + if (!m_readerInterface->staticResult(resultName, RifReaderInterface::MATRIX_RESULTS, &values)) + { + resultLoadingSucess = false; + } + } + + if (!resultLoadingSucess) + { + // Remove last scalar result because loading of result failed + m_cellResults->cellScalarResults(resultGridIndex).clear(); + } + } + + return resultGridIndex; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimReservoirCellResultsCacher::loadOrComputeSOIL() +{ + for (size_t timeStepIdx = 0; timeStepIdx < m_cellResults->maxTimeStepCount(); timeStepIdx++) + { + loadOrComputeSOILForTimeStep(timeStepIdx); + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimReservoirCellResultsCacher::loadOrComputeSOILForTimeStep(size_t timeStepIndex) +{ + size_t scalarIndexSWAT = findOrLoadScalarResultForTimeStep(RimDefines::DYNAMIC_NATIVE, "SWAT", timeStepIndex); + size_t scalarIndexSGAS = findOrLoadScalarResultForTimeStep(RimDefines::DYNAMIC_NATIVE, "SGAS", timeStepIndex); + + // Early exit if none of SWAT or SGAS is present + if (scalarIndexSWAT == cvf::UNDEFINED_SIZE_T && scalarIndexSGAS == cvf::UNDEFINED_SIZE_T) + { + return; + } + + size_t soilResultValueCount = 0; + size_t soilTimeStepCount = 0; + + std::vector* swatForTimeStep = NULL; + std::vector* sgasForTimeStep = NULL; + if (scalarIndexSWAT != cvf::UNDEFINED_SIZE_T) + { + swatForTimeStep = &(m_cellResults->cellScalarResults(scalarIndexSWAT, timeStepIndex)); + if (swatForTimeStep->size() == 0) + { + swatForTimeStep = NULL; + } + else + { + soilResultValueCount = swatForTimeStep->size(); + soilTimeStepCount = m_cellResults->infoForEachResultIndex()[scalarIndexSWAT].m_timeStepDates.size(); + } + } + + if (scalarIndexSGAS != cvf::UNDEFINED_SIZE_T) + { + sgasForTimeStep = &(m_cellResults->cellScalarResults(scalarIndexSGAS, timeStepIndex)); + if (sgasForTimeStep->size() == 0) + { + sgasForTimeStep = NULL; + } + else + { + soilResultValueCount = qMax(soilResultValueCount, sgasForTimeStep->size()); + + size_t sgasTimeStepCount = m_cellResults->infoForEachResultIndex()[scalarIndexSGAS].m_timeStepDates.size(); + soilTimeStepCount = qMax(soilTimeStepCount, sgasTimeStepCount); + } + } + + size_t soilResultGridIndex = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL"); + if (soilResultGridIndex == cvf::UNDEFINED_SIZE_T) + { + soilResultGridIndex = m_cellResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL"); + CVF_ASSERT(soilResultGridIndex != cvf::UNDEFINED_SIZE_T); + + m_cellResults->cellScalarResults(soilResultGridIndex).resize(soilTimeStepCount); + + for (size_t timeStepIdx = 0; timeStepIdx < soilTimeStepCount; timeStepIdx++) + { + m_cellResults->cellScalarResults(soilResultGridIndex, timeStepIdx).resize(soilResultValueCount); + } + } + + std::vector& soilForTimeStep = m_cellResults->cellScalarResults(soilResultGridIndex, timeStepIndex); + +#pragma omp parallel for + for (int idx = 0; idx < static_cast(soilResultValueCount); idx++) + { + double soilValue = 1.0; + if (sgasForTimeStep) + { + soilValue -= sgasForTimeStep->at(idx); + } + + if (swatForTimeStep) + { + soilValue -= swatForTimeStep->at(idx); + } + + soilForTimeStep[idx] = soilValue; + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimReservoirCellResultsCacher::computeDepthRelatedResults() +{ + size_t depthResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DEPTH"); + size_t dxResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DX"); + size_t dyResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DY"); + size_t dzResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DZ"); + size_t topsResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "TOPS"); + size_t bottomResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "BOTTOM"); + + bool computeDepth = false; + bool computeDx = false; + bool computeDy = false; + bool computeDz = false; + bool computeTops = false; + bool computeBottom = false; + + size_t resultValueCount = m_ownerMainGrid->cells().size(); + + if (depthResultGridIndex == cvf::UNDEFINED_SIZE_T) + { + depthResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "DEPTH", resultValueCount); + computeDepth = true; + } + + if (dxResultGridIndex == cvf::UNDEFINED_SIZE_T) + { + dxResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "DX", resultValueCount); + computeDx = true; + } + + if (dyResultGridIndex == cvf::UNDEFINED_SIZE_T) + { + dyResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "DY", resultValueCount); + computeDy = true; + } + + if (dzResultGridIndex == cvf::UNDEFINED_SIZE_T) + { + dzResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "DZ", resultValueCount); + computeDz = true; + } + + if (topsResultGridIndex == cvf::UNDEFINED_SIZE_T) + { + topsResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "TOPS", resultValueCount); + computeTops = true; + } + + if (bottomResultGridIndex == cvf::UNDEFINED_SIZE_T) + { + bottomResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "BOTTOM", resultValueCount); + computeBottom = true; + } + + std::vector< std::vector >& depth = m_cellResults->cellScalarResults(depthResultGridIndex); + std::vector< std::vector >& dx = m_cellResults->cellScalarResults(dxResultGridIndex); + std::vector< std::vector >& dy = m_cellResults->cellScalarResults(dyResultGridIndex); + std::vector< std::vector >& dz = m_cellResults->cellScalarResults(dzResultGridIndex); + std::vector< std::vector >& tops = m_cellResults->cellScalarResults(topsResultGridIndex); + std::vector< std::vector >& bottom = m_cellResults->cellScalarResults(bottomResultGridIndex); + + size_t cellIdx = 0; + for (cellIdx = 0; cellIdx < m_ownerMainGrid->cells().size(); cellIdx++) + { + const RigCell& cell = m_ownerMainGrid->cells()[cellIdx]; + + if (computeDepth) + { + depth[0][cellIdx] = cvf::Math::abs(cell.center().z()); + } + + if (computeDx) + { + cvf::Vec3d cellWidth = cell.faceCenter(cvf::StructGridInterface::NEG_I) - cell.faceCenter(cvf::StructGridInterface::POS_I); + dx[0][cellIdx] = cvf::Math::abs(cellWidth.x()); + } + + if (computeDy) + { + cvf::Vec3d cellWidth = cell.faceCenter(cvf::StructGridInterface::NEG_J) - cell.faceCenter(cvf::StructGridInterface::POS_J); + dy[0][cellIdx] = cvf::Math::abs(cellWidth.y()); + } + + if (computeDz) + { + cvf::Vec3d cellWidth = cell.faceCenter(cvf::StructGridInterface::NEG_K) - cell.faceCenter(cvf::StructGridInterface::POS_K); + dz[0][cellIdx] = cvf::Math::abs(cellWidth.z()); + } + + if (computeTops) + { + tops[0][cellIdx] = cvf::Math::abs(cell.faceCenter(cvf::StructGridInterface::NEG_K).z()); + } + + if (computeBottom) + { + bottom[0][cellIdx] = cvf::Math::abs(cell.faceCenter(cvf::StructGridInterface::POS_K).z()); + } + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RimReservoirCellResultsCacher::findOrLoadScalarResult(const QString& resultName) +{ + size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T; + + scalarResultIndex = this->findOrLoadScalarResult(RimDefines::STATIC_NATIVE, resultName); + + if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) + { + scalarResultIndex = this->findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, resultName); + } + + if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) + { + scalarResultIndex = m_cellResults->findScalarResultIndex(RimDefines::GENERATED, resultName); + } + + if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) + { + scalarResultIndex = m_cellResults->findScalarResultIndex(RimDefines::INPUT_PROPERTY, resultName); + } + + return scalarResultIndex; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimReservoirCellResultsCacher::setCellResults(RigReservoirCellResults* cellResults) +{ + m_cellResults = cellResults; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimReservoirCellResultsCacher::setMainGrid(RigMainGrid* mainGrid) +{ + m_ownerMainGrid = mainGrid; +} + CAF_PDM_SOURCE_INIT(RimReservoirCellResultsCacheEntryInfo, "ResultCacheEntryInfo"); diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h index a07a3bf7e2..fcf703e02d 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h @@ -26,6 +26,8 @@ class RimReservoirCellResultsCacheEntryInfo; class RigReservoirCellResults; +class RifReaderInterface; +class RigMainGrid; class RimReservoirCellResultsCacher : public caf::PdmObject { @@ -34,23 +36,37 @@ public: RimReservoirCellResultsCacher(); virtual ~RimReservoirCellResultsCacher(); - //RigReservoirCellResults* cellResults() const { return m_cellResults; } - void setCellResults(RigReservoirCellResults* cellResults) { m_cellResults = cellResults; } + // Fields + caf::PdmField m_resultCacheFileName; + caf::PdmPointersField + m_resultCacheMetaData; + RigReservoirCellResults* cellResults() { return m_cellResults; } + const RigReservoirCellResults* cellResults() const { return m_cellResults; } - virtual void setupBeforeSave(); + void setCellResults(RigReservoirCellResults* cellResults); + void setMainGrid(RigMainGrid* mainGrid); - caf::PdmField m_resultCacheFileName; - caf::PdmPointersField m_resultCacheMetaData; + void setReaderInterface(RifReaderInterface* readerInterface); + RifReaderInterface* readerInterface(); - + void loadOrComputeSOIL(); + void loadOrComputeSOILForTimeStep(size_t timeStepIndex); + void computeDepthRelatedResults(); + + size_t findOrLoadScalarResultForTimeStep(RimDefines::ResultCatType type, const QString& resultName, size_t timeStepIndex); + size_t findOrLoadScalarResult(RimDefines::ResultCatType type, const QString& resultName); + size_t findOrLoadScalarResult(const QString& resultName); ///< Simplified search. Assumes unique names across types. + + // Overridden methods from PdmObject + virtual void setupBeforeSave(); private: - QString getValidCacheFileName(); - QString getCacheDirectoryPath(); - - RigReservoirCellResults* m_cellResults; - + QString getValidCacheFileName(); + QString getCacheDirectoryPath(); + cvf::ref m_readerInterface; + RigReservoirCellResults* m_cellResults; + RigMainGrid* m_ownerMainGrid; }; class RimReservoirCellResultsCacheEntryInfo : public caf::PdmObject diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp index be44b948a3..353698c7bd 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp @@ -272,11 +272,11 @@ void RimReservoirView::updateViewerWidgetWindowTitle() void RimReservoirView::clampCurrentTimestep() { // Clamp the current timestep to actual possibilities - if (this->currentGridCellResults()) + if (this->currentGridCellResults()->cellResults()) { - if (m_currentTimeStep() >= static_cast(this->currentGridCellResults()->maxTimeStepCount())) + if (m_currentTimeStep() >= static_cast(this->currentGridCellResults()->cellResults()->maxTimeStepCount())) { - m_currentTimeStep = static_cast(this->currentGridCellResults()->maxTimeStepCount()) -1; + m_currentTimeStep = static_cast(this->currentGridCellResults()->cellResults()->maxTimeStepCount()) -1; } } @@ -463,7 +463,7 @@ void RimReservoirView::createDisplayModel() CVF_ASSERT(currentGridCellResults()); size_t i; - for (i = 0; i < currentGridCellResults()->maxTimeStepCount(); i++) + for (i = 0; i < currentGridCellResults()->cellResults()->maxTimeStepCount(); i++) { timeStepIndices.push_back(i); } @@ -711,7 +711,7 @@ void RimReservoirView::loadDataAndUpdate() RIApplication* app = RIApplication::instance(); if (app->preferences()->autocomputeSOIL) { - RigReservoirCellResults* results = currentGridCellResults(); + RimReservoirCellResultsCacher* results = currentGridCellResults(); CVF_ASSERT(results); results->loadOrComputeSOIL(); } @@ -970,16 +970,13 @@ void RimReservoirView::setupBeforeSave() //-------------------------------------------------------------------------------------------------- /// Convenience for quick access to results //-------------------------------------------------------------------------------------------------- -RigReservoirCellResults* RimReservoirView::currentGridCellResults() +RimReservoirCellResultsCacher* RimReservoirView::currentGridCellResults() { - if (m_reservoir && - m_reservoir->reservoirData() && - m_reservoir->reservoirData()->mainGrid() - ) + if (m_reservoir) { RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResult->porosityModel()); - return m_reservoir->reservoirData()->results(porosityModel); + return m_reservoir->results(porosityModel); } return NULL; diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.h b/ApplicationCode/ProjectDataModel/RimReservoirView.h index af46ea2515..a0cb0126e4 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.h +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.h @@ -118,7 +118,7 @@ public: caf::PdmField animationMode; // Access internal objects - RigReservoirCellResults* currentGridCellResults(); + RimReservoirCellResultsCacher* currentGridCellResults(); RigActiveCellInfo* currentActiveCellInfo(); void setEclipseCase(RimReservoir* reservoir); diff --git a/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp index a255d57408..c3fbd388eb 100644 --- a/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp @@ -94,7 +94,7 @@ QList RimResultDefinition::calculateValueOptions(const c { if (m_reservoirView && m_reservoirView->currentGridCellResults()) { - QStringList varList = m_reservoirView->currentGridCellResults()->resultNames(resultType()); + QStringList varList = m_reservoirView->currentGridCellResults()->cellResults()->resultNames(resultType()); QList optionList; int i; for (i = 0; i < varList.size(); ++i) @@ -119,8 +119,8 @@ size_t RimResultDefinition::gridScalarIndex() const { if (m_gridScalarResultIndex == cvf::UNDEFINED_SIZE_T) { - const RigReservoirCellResults* gridCellResults = m_reservoirView->currentGridCellResults(); - if (gridCellResults) m_gridScalarResultIndex = gridCellResults->findScalarResultIndex(resultType(), resultVariable()); + const RimReservoirCellResultsCacher* gridCellResults = m_reservoirView->currentGridCellResults(); + if (gridCellResults) m_gridScalarResultIndex = gridCellResults->cellResults()->findScalarResultIndex(resultType(), resultVariable()); } return m_gridScalarResultIndex; } @@ -130,7 +130,7 @@ size_t RimResultDefinition::gridScalarIndex() const //-------------------------------------------------------------------------------------------------- void RimResultDefinition::loadResult() { - RigReservoirCellResults* gridCellResults = m_reservoirView->currentGridCellResults(); + RimReservoirCellResultsCacher* gridCellResults = m_reservoirView->currentGridCellResults(); if (gridCellResults) { m_gridScalarResultIndex = gridCellResults->findOrLoadScalarResult(resultType(), resultVariable); @@ -148,8 +148,8 @@ void RimResultDefinition::loadResult() //-------------------------------------------------------------------------------------------------- bool RimResultDefinition::hasStaticResult() const { - const RigReservoirCellResults* gridCellResults = m_reservoirView->currentGridCellResults(); - if (hasResult() && gridCellResults->timeStepCount(m_gridScalarResultIndex) == 1 ) + const RimReservoirCellResultsCacher* gridCellResults = m_reservoirView->currentGridCellResults(); + if (hasResult() && gridCellResults->cellResults()->timeStepCount(m_gridScalarResultIndex) == 1 ) { return true; } @@ -166,7 +166,7 @@ bool RimResultDefinition::hasResult() const { if (m_gridScalarResultIndex != cvf::UNDEFINED_SIZE_T) return true; - const RigReservoirCellResults* gridCellResults = m_reservoirView->currentGridCellResults(); + const RigReservoirCellResults* gridCellResults = m_reservoirView->currentGridCellResults()->cellResults(); if (gridCellResults) { m_gridScalarResultIndex = gridCellResults->findScalarResultIndex(resultType(), resultVariable()); @@ -182,7 +182,7 @@ bool RimResultDefinition::hasResult() const //-------------------------------------------------------------------------------------------------- bool RimResultDefinition::hasDynamicResult() const { - const RigReservoirCellResults* gridCellResults = m_reservoirView->currentGridCellResults(); + const RigReservoirCellResults* gridCellResults = m_reservoirView->currentGridCellResults()->cellResults(); if (hasResult() && gridCellResults->timeStepCount(m_gridScalarResultIndex) > 1 ) return true; else diff --git a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp index 0305842bac..655a175c0c 100644 --- a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp @@ -52,7 +52,7 @@ bool RimResultReservoir::openEclipseGridFile() progInfo.setProgressDescription("Open Grid File"); progInfo.setNextProgressIncrement(48); // Early exit if reservoir data is created - if (m_rigEclipseCase.notNull()) return true; + if (this->reservoirData()) return true; cvf::ref readerInterface; @@ -60,8 +60,6 @@ bool RimResultReservoir::openEclipseGridFile() { readerInterface = this->createMockModel(this->caseName()); - m_rigEclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p()); - m_rigEclipseCase->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p()); } else { @@ -78,12 +76,15 @@ bool RimResultReservoir::openEclipseGridFile() return false; } - m_rigEclipseCase = eclipseCase; + this->setReservoirData( eclipseCase.p() ); } + results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p()); + results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p()); + progInfo.incrementProgress(); - CVF_ASSERT(m_rigEclipseCase.notNull()); + CVF_ASSERT(this->reservoirData()); CVF_ASSERT(readerInterface.notNull()); progInfo.setProgressDescription("Computing Case Cache"); @@ -102,9 +103,6 @@ bool RimResultReservoir::openAndReadActiveCellData(RigEclipseCase* mainEclipseCa if (caseName().contains("Result Mock Debug Model")) { readerInterface = this->createMockModel(this->caseName()); - - m_rigEclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p()); - m_rigEclipseCase->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p()); } else { @@ -127,13 +125,16 @@ bool RimResultReservoir::openAndReadActiveCellData(RigEclipseCase* mainEclipseCa readerInterface->close(); - m_rigEclipseCase = eclipseCase; + this->setReservoirData( eclipseCase.p() ); } - CVF_ASSERT(m_rigEclipseCase.notNull()); + results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p()); + results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p()); + + CVF_ASSERT(this->reservoirData()); CVF_ASSERT(readerInterface.notNull()); - m_rigEclipseCase->computeCachedData(); + reservoirData()->computeCachedData(); return true; } @@ -212,7 +213,7 @@ cvf::ref RimResultReservoir::createMockModel(QString modelNa } - m_rigEclipseCase = reservoir; + this->setReservoirData( reservoir.p() ); return mockFileInterface.p(); } diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp index 45639a773c..98a9381a3d 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp @@ -60,9 +60,9 @@ RimStatisticalCalculation::~RimStatisticalCalculation() void RimStatisticalCalculation::setMainGrid(RigMainGrid* mainGrid) { CVF_ASSERT(mainGrid); - CVF_ASSERT(m_rigEclipseCase.notNull()); + CVF_ASSERT(this->reservoirData()); - m_rigEclipseCase->setMainGrid(mainGrid); + reservoirData()->setMainGrid(mainGrid); } //-------------------------------------------------------------------------------------------------- @@ -70,7 +70,7 @@ void RimStatisticalCalculation::setMainGrid(RigMainGrid* mainGrid) //-------------------------------------------------------------------------------------------------- bool RimStatisticalCalculation::openEclipseGridFile() { - if (m_rigEclipseCase.notNull()) return true; + if (this->reservoirData()) return true; cvf::ref eclipseCase = new RigEclipseCase; @@ -79,10 +79,10 @@ bool RimStatisticalCalculation::openEclipseGridFile() return false; } - m_rigEclipseCase = eclipseCase; + this->setReservoirData( eclipseCase.p() ); - m_rigEclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(m_readerInterface.p()); - m_rigEclipseCase->results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(m_readerInterface.p()); + results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(m_readerInterface.p()); + results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(m_readerInterface.p()); return true; } @@ -116,12 +116,12 @@ RimStatisticalCollection* RimStatisticalCalculation::parentStatisticalCollection //-------------------------------------------------------------------------------------------------- void RimStatisticalCalculation::computeStatistics() { - if (m_rigEclipseCase.isNull()) + if (this->reservoirData() == NULL) { openEclipseGridFile(); } - cvf::Collection sourceCases; + std::vector sourceCases; getSourceCases(sourceCases); @@ -132,7 +132,7 @@ void RimStatisticalCalculation::computeStatistics() // The first source has been read completely from disk, and contains grid and meta data // Use this information for all cases in the case group - size_t timeStepCount = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->maxTimeStepCount(); + size_t timeStepCount = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->maxTimeStepCount(); RigStatisticsConfig statisticsConfig; @@ -183,7 +183,7 @@ void RimStatisticalCalculation::computeStatistics() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimStatisticalCalculation::getSourceCases(cvf::Collection& sourceCases) +void RimStatisticalCalculation::getSourceCases(std::vector& sourceCases) { RimIdenticalGridCaseGroup* gridCaseGroup = caseGroup(); if (gridCaseGroup) @@ -195,7 +195,7 @@ void RimStatisticalCalculation::getSourceCases(cvf::Collection& CVF_ASSERT(gridCaseGroup->caseCollection->reservoirs[i]); CVF_ASSERT(gridCaseGroup->caseCollection->reservoirs[i]->reservoirData()); - RigEclipseCase* sourceCase = gridCaseGroup->caseCollection->reservoirs[i]->reservoirData(); + RimReservoir* sourceCase = gridCaseGroup->caseCollection->reservoirs[i]; sourceCases.push_back(sourceCase); } } diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h index 9fb8b706c3..d7b67ce785 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h @@ -59,7 +59,7 @@ public: private: RimIdenticalGridCaseGroup* caseGroup(); - void getSourceCases(cvf::Collection& sourceCases); + void getSourceCases(std::vector& sourceCases); private: cvf::ref m_readerInterface; diff --git a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/CMakeLists.txt b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/CMakeLists.txt index d21c6599a9..9f20f90ac9 100644 --- a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/CMakeLists.txt +++ b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/CMakeLists.txt @@ -22,6 +22,9 @@ include_directories( ${ResInsight_SOURCE_DIR}/cafProjectDataModel ${ResInsight_SOURCE_DIR}/CommonCode + + #Remove when RigStatistics is out + ${ResInsight_SOURCE_DIR}/ApplicationCode/ModelVisualization ) # Populate the filenames into variable lists diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp index d557e6845b..8724e9ff4c 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp @@ -425,7 +425,7 @@ cvf::ref RigEclipseCase::dataAccessObject(const return NULL; } - +/* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -438,3 +438,4 @@ void RigEclipseCase::closeReaderInterface() readerInterface->close(); } } +*/ \ No newline at end of file diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCase.h b/ApplicationCode/ReservoirDataModel/RigEclipseCase.h index f16ba77562..9deeedf3f0 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCase.h +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCase.h @@ -68,7 +68,7 @@ public: bool findSharedSourceFace(cvf::StructGridInterface::FaceType& sharedSourceFace, const RigWellResultCell& sourceWellCellResult, const RigWellResultCell& otherWellCellResult) const; void computeCachedData(); - void closeReaderInterface(); + //void closeReaderInterface(); private: void computeActiveCellData(); diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp index 35f4829d2c..6bb393d684 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp @@ -280,146 +280,6 @@ double RigReservoirCellResults::cellScalarResult( size_t scalarResultIndex, size } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -size_t RigReservoirCellResults::findOrLoadScalarResultForTimeStep(RimDefines::ResultCatType type, const QString& resultName, size_t timeStepIndex) -{ - // Special handling for SOIL - if (type == RimDefines::DYNAMIC_NATIVE && resultName.toUpper() == "SOIL") - { - loadOrComputeSOILForTimeStep(timeStepIndex); - } - - size_t resultGridIndex = cvf::UNDEFINED_SIZE_T; - - resultGridIndex = findScalarResultIndex(type, resultName); - - if (resultGridIndex == cvf::UNDEFINED_SIZE_T) return cvf::UNDEFINED_SIZE_T; - - if (type == RimDefines::GENERATED) - { - return cvf::UNDEFINED_SIZE_T; - } - - if (m_readerInterface.notNull()) - { - size_t timeStepCount = m_resultInfos[resultGridIndex].m_timeStepDates.size(); - - bool resultLoadingSucess = true; - - if (type == RimDefines::DYNAMIC_NATIVE && timeStepCount > 0) - { - m_cellScalarResults[resultGridIndex].resize(timeStepCount); - - std::vector& values = m_cellScalarResults[resultGridIndex][timeStepIndex]; - if (values.size() == 0) - { - if (!m_readerInterface->dynamicResult(resultName, RifReaderInterface::MATRIX_RESULTS, timeStepIndex, &values)) - { - resultLoadingSucess = false; - } - } - } - else if (type == RimDefines::STATIC_NATIVE) - { - m_cellScalarResults[resultGridIndex].resize(1); - - std::vector& values = m_cellScalarResults[resultGridIndex][0]; - if (!m_readerInterface->staticResult(resultName, RifReaderInterface::MATRIX_RESULTS, &values)) - { - resultLoadingSucess = false; - } - } - - if (!resultLoadingSucess) - { - // Error logging - CVF_ASSERT(false); - } - } - - return resultGridIndex; - -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -size_t RigReservoirCellResults::findOrLoadScalarResult(RimDefines::ResultCatType type, const QString& resultName) -{ - size_t resultGridIndex = cvf::UNDEFINED_SIZE_T; - - resultGridIndex = findScalarResultIndex(type, resultName); - - if (resultGridIndex == cvf::UNDEFINED_SIZE_T) return cvf::UNDEFINED_SIZE_T; - - if (cellScalarResults(resultGridIndex).size()) return resultGridIndex; - - if (type == RimDefines::GENERATED) - { - return cvf::UNDEFINED_SIZE_T; - } - - if (m_readerInterface.notNull()) - { - // Add one more result to result container - size_t timeStepCount = m_resultInfos[resultGridIndex].m_timeStepDates.size(); - - bool resultLoadingSucess = true; - - if (type == RimDefines::DYNAMIC_NATIVE && timeStepCount > 0) - { - m_cellScalarResults[resultGridIndex].resize(timeStepCount); - - size_t i; - for (i = 0; i < timeStepCount; i++) - { - std::vector& values = m_cellScalarResults[resultGridIndex][i]; - if (!m_readerInterface->dynamicResult(resultName, RifReaderInterface::MATRIX_RESULTS, i, &values)) - { - resultLoadingSucess = false; - } - } - } - else if (type == RimDefines::STATIC_NATIVE) - { - m_cellScalarResults[resultGridIndex].resize(1); - - std::vector& values = m_cellScalarResults[resultGridIndex][0]; - if (!m_readerInterface->staticResult(resultName, RifReaderInterface::MATRIX_RESULTS, &values)) - { - resultLoadingSucess = false; - } - } - - if (!resultLoadingSucess) - { - // Remove last scalar result because loading of result failed - m_cellScalarResults[resultGridIndex].clear(); - } - } - - return resultGridIndex; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigReservoirCellResults::setReaderInterface(RifReaderInterface* readerInterface) -{ - m_readerInterface = readerInterface; -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RifReaderInterface* RigReservoirCellResults::readerInterface() -{ - return m_readerInterface.p(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -464,234 +324,6 @@ size_t RigReservoirCellResults::findScalarResultIndex(const QString& resultName) return scalarResultIndex; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigReservoirCellResults::loadOrComputeSOIL() -{ - for (size_t timeStepIdx = 0; timeStepIdx < maxTimeStepCount(); timeStepIdx++) - { - loadOrComputeSOILForTimeStep(timeStepIdx); - } -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigReservoirCellResults::loadOrComputeSOILForTimeStep(size_t timeStepIndex) -{ - size_t scalarIndexSWAT = findOrLoadScalarResultForTimeStep(RimDefines::DYNAMIC_NATIVE, "SWAT", timeStepIndex); - size_t scalarIndexSGAS = findOrLoadScalarResultForTimeStep(RimDefines::DYNAMIC_NATIVE, "SGAS", timeStepIndex); - - // Early exit if none of SWAT or SGAS is present - if (scalarIndexSWAT == cvf::UNDEFINED_SIZE_T && scalarIndexSGAS == cvf::UNDEFINED_SIZE_T) - { - return; - } - - size_t soilResultValueCount = 0; - size_t soilTimeStepCount = 0; - - std::vector* swatForTimeStep = NULL; - std::vector* sgasForTimeStep = NULL; - if (scalarIndexSWAT != cvf::UNDEFINED_SIZE_T) - { - swatForTimeStep = &(cellScalarResults(scalarIndexSWAT, timeStepIndex)); - if (swatForTimeStep->size() == 0) - { - swatForTimeStep = NULL; - } - else - { - soilResultValueCount = swatForTimeStep->size(); - soilTimeStepCount = m_resultInfos[scalarIndexSWAT].m_timeStepDates.size(); - } - } - - if (scalarIndexSGAS != cvf::UNDEFINED_SIZE_T) - { - sgasForTimeStep = &(cellScalarResults(scalarIndexSGAS, timeStepIndex)); - if (sgasForTimeStep->size() == 0) - { - sgasForTimeStep = NULL; - } - else - { - soilResultValueCount = qMax(soilResultValueCount, sgasForTimeStep->size()); - - size_t sgasTimeStepCount = m_resultInfos[scalarIndexSGAS].m_timeStepDates.size(); - soilTimeStepCount = qMax(soilTimeStepCount, sgasTimeStepCount); - } - } - - size_t soilResultGridIndex = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL"); - if (soilResultGridIndex == cvf::UNDEFINED_SIZE_T) - { - soilResultGridIndex = addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL"); - CVF_ASSERT(soilResultGridIndex != cvf::UNDEFINED_SIZE_T); - - m_cellScalarResults[soilResultGridIndex].resize(soilTimeStepCount); - - for (size_t timeStepIdx = 0; timeStepIdx < soilTimeStepCount; timeStepIdx++) - { - m_cellScalarResults[soilResultGridIndex][timeStepIdx].resize(soilResultValueCount); - } - } - - std::vector& soilForTimeStep = cellScalarResults(soilResultGridIndex, timeStepIndex); - -#pragma omp parallel for - for (int idx = 0; idx < static_cast(soilResultValueCount); idx++) - { - double soilValue = 1.0; - if (sgasForTimeStep) - { - soilValue -= sgasForTimeStep->at(idx); - } - - if (swatForTimeStep) - { - soilValue -= swatForTimeStep->at(idx); - } - - soilForTimeStep[idx] = soilValue; - } -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigReservoirCellResults::computeDepthRelatedResults() -{ - size_t depthResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DEPTH"); - size_t dxResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DX"); - size_t dyResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DY"); - size_t dzResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DZ"); - size_t topsResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "TOPS"); - size_t bottomResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "BOTTOM"); - - bool computeDepth = false; - bool computeDx = false; - bool computeDy = false; - bool computeDz = false; - bool computeTops = false; - bool computeBottom = false; - - size_t resultValueCount = m_ownerMainGrid->cells().size(); - - if (depthResultGridIndex == cvf::UNDEFINED_SIZE_T) - { - depthResultGridIndex = addStaticScalarResult(RimDefines::STATIC_NATIVE, "DEPTH", resultValueCount); - computeDepth = true; - } - - if (dxResultGridIndex == cvf::UNDEFINED_SIZE_T) - { - dxResultGridIndex = addStaticScalarResult(RimDefines::STATIC_NATIVE, "DX", resultValueCount); - computeDx = true; - } - - if (dyResultGridIndex == cvf::UNDEFINED_SIZE_T) - { - dyResultGridIndex = addStaticScalarResult(RimDefines::STATIC_NATIVE, "DY", resultValueCount); - computeDy = true; - } - - if (dzResultGridIndex == cvf::UNDEFINED_SIZE_T) - { - dzResultGridIndex = addStaticScalarResult(RimDefines::STATIC_NATIVE, "DZ", resultValueCount); - computeDz = true; - } - - if (topsResultGridIndex == cvf::UNDEFINED_SIZE_T) - { - topsResultGridIndex = addStaticScalarResult(RimDefines::STATIC_NATIVE, "TOPS", resultValueCount); - computeTops = true; - } - - if (bottomResultGridIndex == cvf::UNDEFINED_SIZE_T) - { - bottomResultGridIndex = addStaticScalarResult(RimDefines::STATIC_NATIVE, "BOTTOM", resultValueCount); - computeBottom = true; - } - - std::vector< std::vector >& depth = cellScalarResults(depthResultGridIndex); - std::vector< std::vector >& dx = cellScalarResults(dxResultGridIndex); - std::vector< std::vector >& dy = cellScalarResults(dyResultGridIndex); - std::vector< std::vector >& dz = cellScalarResults(dzResultGridIndex); - std::vector< std::vector >& tops = cellScalarResults(topsResultGridIndex); - std::vector< std::vector >& bottom = cellScalarResults(bottomResultGridIndex); - - size_t cellIdx = 0; - for (cellIdx = 0; cellIdx < m_ownerMainGrid->cells().size(); cellIdx++) - { - const RigCell& cell = m_ownerMainGrid->cells()[cellIdx]; - - if (computeDepth) - { - depth[0][cellIdx] = cvf::Math::abs(cell.center().z()); - } - - if (computeDx) - { - cvf::Vec3d cellWidth = cell.faceCenter(cvf::StructGridInterface::NEG_I) - cell.faceCenter(cvf::StructGridInterface::POS_I); - dx[0][cellIdx] = cvf::Math::abs(cellWidth.x()); - } - - if (computeDy) - { - cvf::Vec3d cellWidth = cell.faceCenter(cvf::StructGridInterface::NEG_J) - cell.faceCenter(cvf::StructGridInterface::POS_J); - dy[0][cellIdx] = cvf::Math::abs(cellWidth.y()); - } - - if (computeDz) - { - cvf::Vec3d cellWidth = cell.faceCenter(cvf::StructGridInterface::NEG_K) - cell.faceCenter(cvf::StructGridInterface::POS_K); - dz[0][cellIdx] = cvf::Math::abs(cellWidth.z()); - } - - if (computeTops) - { - tops[0][cellIdx] = cvf::Math::abs(cell.faceCenter(cvf::StructGridInterface::NEG_K).z()); - } - - if (computeBottom) - { - bottom[0][cellIdx] = cvf::Math::abs(cell.faceCenter(cvf::StructGridInterface::POS_K).z()); - } - } -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -size_t RigReservoirCellResults::findOrLoadScalarResult(const QString& resultName) -{ - size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T; - - scalarResultIndex = this->findOrLoadScalarResult(RimDefines::STATIC_NATIVE, resultName); - - if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) - { - scalarResultIndex = this->findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, resultName); - } - - if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) - { - scalarResultIndex = this->findScalarResultIndex(RimDefines::GENERATED, resultName); - } - - if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) - { - scalarResultIndex = this->findScalarResultIndex(RimDefines::INPUT_PROPERTY, resultName); - } - - return scalarResultIndex; -} - //-------------------------------------------------------------------------------------------------- /// Adds an empty scalar set, and returns the scalarResultIndex to it. /// if resultName already exists, it returns the scalarResultIndex to the existing result. @@ -793,6 +425,10 @@ void RigReservoirCellResults::setTimeStepDates(size_t scalarResultIndex, const s CVF_ASSERT(scalarResultIndex < m_resultInfos.size() ); m_resultInfos[scalarResultIndex].m_timeStepDates = dates; + + // We need this. But not yet ... + //std::vector< std::vector >& dataValues = this->cellScalarResults(scalarResultIndex); + //dataValues.resize(dates.size()); } //-------------------------------------------------------------------------------------------------- @@ -800,7 +436,7 @@ void RigReservoirCellResults::setTimeStepDates(size_t scalarResultIndex, const s //-------------------------------------------------------------------------------------------------- size_t RigReservoirCellResults::maxTimeStepCount() const { - int maxTsCount = 0; + size_t maxTsCount = 0; std::vector::const_iterator it; for (it = m_resultInfos.begin(); it != m_resultInfos.end(); it++) diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h index b37c94d2d5..421e9d323f 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h +++ b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h @@ -35,49 +35,45 @@ class RigReservoirCellResults : public cvf::Object public: RigReservoirCellResults(RigMainGrid* ownerGrid); - void setReaderInterface(RifReaderInterface* readerInterface); - RifReaderInterface* readerInterface(); + //void setReaderInterface(RifReaderInterface* readerInterface); + //RifReaderInterface* readerInterface(); // Max and min values of the results - void recalculateMinMax(size_t scalarResultIndex); - void minMaxCellScalarValues(size_t scalarResultIndex, double& min, double& max); - void minMaxCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& min, double& max); - const std::vector& cellScalarValuesHistogram(size_t scalarResultIndex); - void p10p90CellScalarValues(size_t scalarResultIndex, double& p10, double& p90); - void meanCellScalarValues(size_t scalarResultIndex, double& meanValue); + void recalculateMinMax(size_t scalarResultIndex); + void minMaxCellScalarValues(size_t scalarResultIndex, double& min, double& max); + void minMaxCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& min, double& max); + const std::vector& cellScalarValuesHistogram(size_t scalarResultIndex); + void p10p90CellScalarValues(size_t scalarResultIndex, double& p10, double& p90); + void meanCellScalarValues(size_t scalarResultIndex, double& meanValue); // Access meta-information about the results - size_t resultCount() const; - size_t timeStepCount(size_t scalarResultIndex) const; - size_t maxTimeStepCount() const; - QStringList resultNames(RimDefines::ResultCatType type) const; - bool isUsingGlobalActiveIndex(size_t scalarResultIndex) const; + size_t resultCount() const; + size_t timeStepCount(size_t scalarResultIndex) const; + size_t maxTimeStepCount() const; + QStringList resultNames(RimDefines::ResultCatType type) const; + bool isUsingGlobalActiveIndex(size_t scalarResultIndex) const; - QDateTime timeStepDate(size_t scalarResultIndex, size_t timeStepIndex) const; - std::vector timeStepDates(size_t scalarResultIndex) const; - void setTimeStepDates(size_t scalarResultIndex, const std::vector& dates); + QDateTime timeStepDate(size_t scalarResultIndex, size_t timeStepIndex) const; + std::vector timeStepDates(size_t scalarResultIndex) const; + void setTimeStepDates(size_t scalarResultIndex, const std::vector& dates); // Find or create a slot for the results - size_t findOrLoadScalarResultForTimeStep(RimDefines::ResultCatType type, const QString& resultName, size_t timeStepIndex); - size_t findOrLoadScalarResult(RimDefines::ResultCatType type, const QString& resultName); - size_t findOrLoadScalarResult(const QString& resultName); ///< Simplified search. Assumes unique names across types. - size_t findScalarResultIndex(RimDefines::ResultCatType type, const QString& resultName) const; - size_t findScalarResultIndex(const QString& resultName) const; - size_t addEmptyScalarResult(RimDefines::ResultCatType type, const QString& resultName); - QString makeResultNameUnique(const QString& resultNameProposal) const; - void removeResult(const QString& resultName); - void clearAllResults(); + size_t findScalarResultIndex(RimDefines::ResultCatType type, const QString& resultName) const; + size_t findScalarResultIndex(const QString& resultName) const; + + size_t addEmptyScalarResult(RimDefines::ResultCatType type, const QString& resultName); + QString makeResultNameUnique(const QString& resultNameProposal) const; + + void removeResult(const QString& resultName); + void clearAllResults(); - void loadOrComputeSOIL(); - void loadOrComputeSOILForTimeStep(size_t timeStepIndex); - void computeDepthRelatedResults(); // Access the results data - const std::vector< std::vector > & cellScalarResults(size_t scalarResultIndex) const; - std::vector< std::vector > & cellScalarResults(size_t scalarResultIndex); - std::vector& cellScalarResults(size_t scalarResultIndex, size_t timeStepIndex); - double cellScalarResult(size_t scalarResultIndex, size_t timeStepIndex, size_t resultValueIndex); + const std::vector< std::vector > & cellScalarResults(size_t scalarResultIndex) const; + std::vector< std::vector > & cellScalarResults(size_t scalarResultIndex); + std::vector& cellScalarResults(size_t scalarResultIndex, size_t timeStepIndex); + double cellScalarResult(size_t scalarResultIndex, size_t timeStepIndex, size_t resultValueIndex); static RifReaderInterface::PorosityModelResultType convertFromProjectModelPorosityModel(RimDefines::PorosityModelType porosityModel); @@ -97,8 +93,10 @@ public: const std::vector& infoForEachResultIndex() { return m_resultInfos;} -private: - size_t addStaticScalarResult(RimDefines::ResultCatType type, const QString& resultName, size_t resultValueCount); +public: + size_t addStaticScalarResult(RimDefines::ResultCatType type, + const QString& resultName, + size_t resultValueCount); private: std::vector< std::vector< std::vector > > m_cellScalarResults; ///< Scalar results on the complete reservoir for each Result index (ResultVariable) and timestep @@ -113,7 +111,7 @@ private: private: std::vector m_resultInfos; - cvf::ref m_readerInterface; + RigMainGrid* m_ownerMainGrid; }; diff --git a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp index d9ec30b045..cb593a8050 100644 --- a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp +++ b/ApplicationCode/ReservoirDataModel/RigStatistics.cpp @@ -18,7 +18,11 @@ #include "RigStatistics.h" #include "RigReservoirCellResults.h" +#include "RimReservoirView.h" +#include "RimReservoir.h" +#include "RigEclipseCase.h" +//#include "RigEclipseCase.h" #include #include "cafProgressInfo.h" @@ -30,7 +34,8 @@ void RigStatistics::addNamedResult(RigReservoirCellResults* destinationCellResul // Use time step dates from first result in first source case CVF_ASSERT(m_sourceCases.size() > 0); - std::vector sourceTimeStepDates = m_sourceCases[0]->results(RifReaderInterface::MATRIX_RESULTS)->timeStepDates(0); + std::vector sourceTimeStepDates = m_sourceCases[0]->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->timeStepDates(0); + size_t destinationScalarResultIndex = destinationCellResults->addEmptyScalarResult(resultType, resultName); CVF_ASSERT(destinationScalarResultIndex != cvf::UNDEFINED_SIZE_T); @@ -38,6 +43,7 @@ void RigStatistics::addNamedResult(RigReservoirCellResults* destinationCellResul std::vector< std::vector >& dataValues = destinationCellResults->cellScalarResults(destinationScalarResultIndex); dataValues.resize(sourceTimeStepDates.size()); + // Initializes the size of the destination dataset to active union cell count for (int i = 0; i < sourceTimeStepDates.size(); i++) { @@ -58,7 +64,7 @@ void RigStatistics::computeActiveCellUnion() CVF_ASSERT(m_destinationCase); - RigMainGrid* mainGrid = m_sourceCases[0]->mainGrid(); + RigMainGrid* mainGrid = m_sourceCases[0]->reservoirData()->mainGrid(); CVF_ASSERT(mainGrid); m_destinationCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->setGlobalCellCount(mainGrid->cells().size()); @@ -84,7 +90,7 @@ void RigStatistics::computeActiveCellUnion() if (activeM[localGridCellIdx] == 0) { - if (m_sourceCases[caseIdx]->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->isActiveInMatrixModel(globalCellIdx)) + if (m_sourceCases[caseIdx]->reservoirData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->isActiveInMatrixModel(globalCellIdx)) { activeM[localGridCellIdx] = 1; } @@ -92,7 +98,7 @@ void RigStatistics::computeActiveCellUnion() if (activeF[localGridCellIdx] == 0) { - if (m_sourceCases[caseIdx]->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->isActiveInMatrixModel(globalCellIdx)) + if (m_sourceCases[caseIdx]->reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->isActiveInMatrixModel(globalCellIdx)) { activeF[localGridCellIdx] = 1; } @@ -143,20 +149,20 @@ void RigStatistics::buildSourceMetaData(RimDefines::ResultCatType resultType, co { if (m_sourceCases.size() == 0) return; - std::vector timeStepDates = m_sourceCases[0]->results(RifReaderInterface::MATRIX_RESULTS)->timeStepDates(0); + std::vector timeStepDates = m_sourceCases[0]->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->timeStepDates(0); for (size_t caseIdx = 1; caseIdx < m_sourceCases.size(); caseIdx++) { - RigEclipseCase* eclipseCase = m_sourceCases.at(caseIdx); + RigEclipseCase* eclipseCase = m_sourceCases.at(caseIdx)->reservoirData(); - RigReservoirCellResults* matrixResults = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS); + RimReservoirCellResultsCacher* matrixResults = m_sourceCases[caseIdx]->results(RifReaderInterface::MATRIX_RESULTS); size_t scalarResultIndex = matrixResults->findOrLoadScalarResult(resultType, resultName); if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) { - size_t scalarResultIndex = matrixResults->addEmptyScalarResult(resultType, resultName); - matrixResults->setTimeStepDates(scalarResultIndex, timeStepDates); + size_t scalarResultIndex = matrixResults->cellResults()->addEmptyScalarResult(resultType, resultName); + matrixResults->cellResults()->setTimeStepDates(scalarResultIndex, timeStepDates); - std::vector< std::vector >& dataValues = matrixResults->cellScalarResults(scalarResultIndex); + std::vector< std::vector >& dataValues = matrixResults->cellResults()->cellScalarResults(scalarResultIndex); dataValues.resize(timeStepDates.size()); } } @@ -183,13 +189,13 @@ void RigStatistics::evaluateStatistics(const QListresults(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(resultType, "SWAT"); + size_t swatIndex = m_sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->findScalarResultIndex(resultType, "SWAT"); if (swatIndex != cvf::UNDEFINED_SIZE_T) { buildSourceMetaData(resultType, "SWAT"); } - size_t sgasIndex = m_sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(resultType, "SGAS"); + size_t sgasIndex = m_sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->findScalarResultIndex(resultType, "SGAS"); if (sgasIndex != cvf::UNDEFINED_SIZE_T) { buildSourceMetaData(resultType, "SGAS"); @@ -248,11 +254,11 @@ void RigStatistics::evaluateStatistics(const QList dataAccesObjectList; for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++) { - RigEclipseCase* eclipseCase = m_sourceCases.at(caseIdx); + RimReservoir* eclipseCase = m_sourceCases.at(caseIdx); size_t scalarResultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->findOrLoadScalarResultForTimeStep(resultType, resultName, dataAccessTimeStepIndex); - cvf::ref dataAccessObject = eclipseCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, dataAccessTimeStepIndex, scalarResultIndex); + cvf::ref dataAccessObject = eclipseCase->reservoirData()->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, dataAccessTimeStepIndex, scalarResultIndex); if (dataAccessObject.notNull()) { dataAccesObjectList.push_back(dataAccessObject.p()); @@ -355,13 +361,13 @@ void RigStatistics::evaluateStatistics(const QListcloseReaderInterface(); + eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->readerInterface()->close(); } info.setProgress(timeIndicesIdx); @@ -378,7 +384,7 @@ void RigStatistics::debugOutput(RimDefines::ResultCatType resultType, const QStr qDebug() << resultName << "timeIdx : " << timeStepIdx; - size_t scalarResultIndex = m_destinationCase->results(RifReaderInterface::MATRIX_RESULTS)->findOrLoadScalarResult(resultType, resultName); + size_t scalarResultIndex = m_destinationCase->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(resultType, resultName); cvf::ref dataAccessObject = m_destinationCase->dataAccessObject(m_destinationCase->mainGrid(), RifReaderInterface::MATRIX_RESULTS, timeStepIdx, scalarResultIndex); if (dataAccessObject.isNull()) return; @@ -392,7 +398,8 @@ void RigStatistics::debugOutput(RimDefines::ResultCatType resultType, const QStr //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigStatistics::RigStatistics(cvf::Collection& sourceCases, const std::vector& timeStepIndices, const RigStatisticsConfig& statisticsConfig, RigEclipseCase* destinationCase) : m_sourceCases(sourceCases), +RigStatistics::RigStatistics(const std::vector& sourceCases, const std::vector& timeStepIndices, const RigStatisticsConfig& statisticsConfig, RigEclipseCase* destinationCase) + : m_sourceCases(sourceCases), m_statisticsConfig(statisticsConfig), m_destinationCase(destinationCase), m_globalCellCount(0), @@ -400,7 +407,7 @@ RigStatistics::RigStatistics(cvf::Collection& sourceCases, const { if (sourceCases.size() > 0) { - m_globalCellCount = sourceCases[0]->mainGrid()->cells().size(); + m_globalCellCount = sourceCases[0]->reservoirData()->mainGrid()->cells().size(); } CVF_ASSERT(m_destinationCase); diff --git a/ApplicationCode/ReservoirDataModel/RigStatistics.h b/ApplicationCode/ReservoirDataModel/RigStatistics.h index f0792129f8..5f0e42eb99 100644 --- a/ApplicationCode/ReservoirDataModel/RigStatistics.h +++ b/ApplicationCode/ReservoirDataModel/RigStatistics.h @@ -22,12 +22,17 @@ #include "cvfObject.h" #include "cvfCollection.h" -#include "RigEclipseCase.h" + #include #include #include +#include "RimDefines.h" + +class RimReservoir; +class RigEclipseCase; +class RigReservoirCellResults; class RigStatisticsEvaluator { @@ -124,7 +129,7 @@ public: class RigStatistics { public: - RigStatistics(cvf::Collection& sourceCases, + RigStatistics(const std::vector& sourceCases, const std::vector& timeStepIndices, const RigStatisticsConfig& statisticsConfig, RigEclipseCase* destinationCase); @@ -140,7 +145,7 @@ private: void buildSourceMetaData(RimDefines::ResultCatType resultType, const QString& resultName); private: - cvf::Collection m_sourceCases; + std::vector m_sourceCases; std::vector m_timeStepIndices; size_t m_globalCellCount; diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.cpp b/ApplicationCode/SocketInterface/RiaSocketServer.cpp index 8afa8aece5..04c123c1e1 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.cpp +++ b/ApplicationCode/SocketInterface/RiaSocketServer.cpp @@ -280,18 +280,18 @@ void RiaSocketServer::readCommandFromOctave() size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T; std::vector< std::vector >* scalarResultFrames = NULL; - if (reservoir && reservoir->reservoirData() && reservoir->reservoirData()->results(RifReaderInterface::MATRIX_RESULTS)) + if (reservoir && reservoir->results(RifReaderInterface::MATRIX_RESULTS)) { - scalarResultIndex = reservoir->reservoirData()->results(RifReaderInterface::MATRIX_RESULTS)->findOrLoadScalarResult(propertyName); + scalarResultIndex = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->findOrLoadScalarResult(propertyName); if (scalarResultIndex == cvf::UNDEFINED_SIZE_T && isSetProperty) { - scalarResultIndex = reservoir->reservoirData()->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::GENERATED, propertyName); + scalarResultIndex = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->addEmptyScalarResult(RimDefines::GENERATED, propertyName); } if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) { - scalarResultFrames = &(reservoir->reservoirData()->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(scalarResultIndex)); + scalarResultFrames = &(reservoir->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->cellScalarResults(scalarResultIndex)); m_currentScalarIndex = scalarResultIndex; m_currentPropertyName = propertyName; } diff --git a/ApplicationCode/UserInterface/RIMainWindow.cpp b/ApplicationCode/UserInterface/RIMainWindow.cpp index 24e12b144d..cf3860f9e7 100644 --- a/ApplicationCode/UserInterface/RIMainWindow.cpp +++ b/ApplicationCode/UserInterface/RIMainWindow.cpp @@ -546,7 +546,7 @@ void RIMainWindow::refreshAnimationActions() || app->activeReservoirView()->propertyFilterCollection()->hasActiveDynamicFilters() || app->activeReservoirView()->wellCollection()->hasVisibleWellPipes()) { - std::vector timeStepDates = app->activeReservoirView()->currentGridCellResults()->timeStepDates(0); + std::vector timeStepDates = app->activeReservoirView()->currentGridCellResults()->cellResults()->timeStepDates(0); bool showHoursAndMinutes = false; for (int i = 0; i < timeStepDates.size(); i++) { From 9da6b0a10b1a385a36b6d47c07b21cc76eec6d1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 18 Mar 2013 14:51:31 +0100 Subject: [PATCH 122/242] Results Storage: Fixed the Previous build error by moving the RigStatistics class. Cleaned up a bit in the ApplicationCode/CMakeList.txt p4#: 20946 --- ApplicationCode/CMakeLists.txt | 25 ++++++++++--------- .../RigStatistics.cpp | 1 + .../RigStatistics.h | 0 .../ReservoirDataModel/CMakeLists_files.cmake | 2 -- 4 files changed, 14 insertions(+), 14 deletions(-) rename ApplicationCode/{ReservoirDataModel => ProjectDataModel}/RigStatistics.cpp (99%) rename ApplicationCode/{ReservoirDataModel => ProjectDataModel}/RigStatistics.h (100%) diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index 5fd4c0cd30..92f37b4659 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -86,6 +86,7 @@ list( APPEND CPP_SOURCES ProjectDataModel/RimUiTreeModelPdm.cpp ProjectDataModel/RimUiTreeView.cpp ProjectDataModel/RimReservoirCellResultsCacher.cpp + ProjectDataModel/RigStatistics.cpp ) # Populate the filenames into variable lists @@ -153,20 +154,20 @@ qt4_add_resources( QRC_FILES_CPP ${QRC_FILES} ) ############################################################################# set( RAW_SOURCES ${CPP_SOURCES} ) -list( REMOVE_ITEM RAW_SOURCES RIStdInclude.cpp) -list( REMOVE_ITEM RAW_SOURCES ${CODE_SOURCE_FILES}) -list( REMOVE_ITEM RAW_SOURCES ModelVisualization/RivCellEdgeEffectGenerator.cpp) -list( REMOVE_ITEM RAW_SOURCES ModelVisualization/RivPipeGeometryGenerator.cpp) -list( REMOVE_ITEM RAW_SOURCES ModelVisualization/RivWellPipesPartMgr.cpp) -list( REMOVE_ITEM RAW_SOURCES ModelVisualization/RivWellHeadPartMgr.cpp) +list( REMOVE_ITEM RAW_SOURCES + RIStdInclude.cpp -list( REMOVE_ITEM RAW_SOURCES Application/RiaImageFileCompare.cpp) -list( REMOVE_ITEM RAW_SOURCES Application/RiaImageCompareReporter.cpp) + ${CODE_SOURCE_FILES} - - -list( REMOVE_ITEM RAW_SOURCES + ModelVisualization/RivCellEdgeEffectGenerator.cpp + ModelVisualization/RivPipeGeometryGenerator.cpp + ModelVisualization/RivWellPipesPartMgr.cpp + ModelVisualization/RivWellHeadPartMgr.cpp + + Application/RiaImageFileCompare.cpp + Application/RiaImageCompareReporter.cpp + FileInterface/RifEclipseInputFileTools.cpp FileInterface/RifEclipseOutputFileTools.cpp FileInterface/RifEclipseRestartFilesetAccess.cpp @@ -174,9 +175,9 @@ list( REMOVE_ITEM RAW_SOURCES FileInterface/RifEclipseUnifiedRestartFileAccess.cpp FileInterface/RifReaderEclipseInput.cpp FileInterface/RifReaderEclipseOutput.cpp + UserInterface/RiuSimpleHistogramWidget.cpp UserInterface/RiuMultiCaseImportDialog.cpp - ) include( CustomPCH.cmake ) diff --git a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp b/ApplicationCode/ProjectDataModel/RigStatistics.cpp similarity index 99% rename from ApplicationCode/ReservoirDataModel/RigStatistics.cpp rename to ApplicationCode/ProjectDataModel/RigStatistics.cpp index cb593a8050..fb5cb26129 100644 --- a/ApplicationCode/ReservoirDataModel/RigStatistics.cpp +++ b/ApplicationCode/ProjectDataModel/RigStatistics.cpp @@ -15,6 +15,7 @@ // for more details. // ///////////////////////////////////////////////////////////////////////////////// +#include "RIStdInclude.h" #include "RigStatistics.h" #include "RigReservoirCellResults.h" diff --git a/ApplicationCode/ReservoirDataModel/RigStatistics.h b/ApplicationCode/ProjectDataModel/RigStatistics.h similarity index 100% rename from ApplicationCode/ReservoirDataModel/RigStatistics.h rename to ApplicationCode/ProjectDataModel/RigStatistics.h diff --git a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake index 84b7d966db..5239d1e831 100644 --- a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake @@ -16,7 +16,6 @@ ${CEE_CURRENT_LIST_DIR}RigLocalGrid.h ${CEE_CURRENT_LIST_DIR}RigMainGrid.h ${CEE_CURRENT_LIST_DIR}RigReservoirBuilderMock.h ${CEE_CURRENT_LIST_DIR}RigReservoirCellResults.h -${CEE_CURRENT_LIST_DIR}RigStatistics.h ${CEE_CURRENT_LIST_DIR}RigWellResults.h ) @@ -31,7 +30,6 @@ ${CEE_CURRENT_LIST_DIR}RigLocalGrid.cpp ${CEE_CURRENT_LIST_DIR}RigMainGrid.cpp ${CEE_CURRENT_LIST_DIR}RigReservoirBuilderMock.cpp ${CEE_CURRENT_LIST_DIR}RigReservoirCellResults.cpp -${CEE_CURRENT_LIST_DIR}RigStatistics.cpp ${CEE_CURRENT_LIST_DIR}RigWellResults.cpp ) From 5db5c1423062c67f1edab2616b068c2be2683410 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 19 Mar 2013 08:14:35 +0100 Subject: [PATCH 123/242] Added possibility to read out scalar result index having most time steps p4#: 20952 --- .../RigReservoirCellResults.cpp | 21 +++++++++++++------ .../RigReservoirCellResults.h | 2 +- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp index 6bb393d684..9ce8805bd8 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp @@ -434,17 +434,26 @@ void RigReservoirCellResults::setTimeStepDates(size_t scalarResultIndex, const s //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -size_t RigReservoirCellResults::maxTimeStepCount() const +size_t RigReservoirCellResults::maxTimeStepCount(size_t* scalarResultIndexWithMostTimeSteps) const { size_t maxTsCount = 0; + size_t scalarResultIndexWithMaxTsCount = cvf::UNDEFINED_SIZE_T; - std::vector::const_iterator it; - for (it = m_resultInfos.begin(); it != m_resultInfos.end(); it++) + for (size_t i = 0; i < m_resultInfos.size(); i++) { - maxTsCount = it->m_timeStepDates.size() > maxTsCount ? it->m_timeStepDates.size() : maxTsCount; - } + if (m_resultInfos[i].m_timeStepDates.size() > maxTsCount) + { + maxTsCount = m_resultInfos[i].m_timeStepDates.size(); + scalarResultIndexWithMaxTsCount = i; + } + } - return static_cast(maxTsCount); + if (scalarResultIndexWithMostTimeSteps) + { + *scalarResultIndexWithMostTimeSteps = scalarResultIndexWithMaxTsCount; + } + + return maxTsCount; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h index 421e9d323f..a169e751e8 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h +++ b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h @@ -49,7 +49,7 @@ public: // Access meta-information about the results size_t resultCount() const; size_t timeStepCount(size_t scalarResultIndex) const; - size_t maxTimeStepCount() const; + size_t maxTimeStepCount(size_t* scalarResultIndex = NULL) const; QStringList resultNames(RimDefines::ResultCatType type) const; bool isUsingGlobalActiveIndex(size_t scalarResultIndex) const; From da3486f881d9b0751449b8f5da2d89d57af3d7b4 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 19 Mar 2013 08:15:27 +0100 Subject: [PATCH 124/242] Use size_t instead of int p4#: 20953 --- .../ProjectDataModel/RimReservoirCellResultsCacher.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp index 8213c8e107..62d47c4369 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp @@ -73,7 +73,7 @@ void RimReservoirCellResultsCacher::setupBeforeSave() stream << (quint32)0xCEECAC4E; // magic number stream << (qint32)1; // Version - for (int rIdx = 0; rIdx < resInfo.size(); ++rIdx) + for (size_t rIdx = 0; rIdx < resInfo.size(); ++rIdx) { size_t timestepCount = m_cellResults->cellScalarResults(resInfo[rIdx].m_gridScalarResultIndex).size(); if (timestepCount) @@ -87,7 +87,7 @@ void RimReservoirCellResultsCacher::setupBeforeSave() cacheEntry->m_filePosition = cacheFile.pos(); - for (int tsIdx = 0; tsIdx < resInfo[rIdx].m_timeStepDates.size() ; ++tsIdx) + for (size_t tsIdx = 0; tsIdx < resInfo[rIdx].m_timeStepDates.size() ; ++tsIdx) { const std::vector* data = NULL; if (tsIdx < timestepCount) From a411a8ae59b9dad65d2a7ec27389cddb4f5a8619 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 19 Mar 2013 08:21:55 +0100 Subject: [PATCH 125/242] Removed obsolete code from interface Use time steps from source case with largest time step count p4#: 20954 --- .../FileInterface/RifReaderInterface.h | 1 - .../ProjectDataModel/RimResultReservoir.cpp | 17 ++++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/FileInterface/RifReaderInterface.h b/ApplicationCode/FileInterface/RifReaderInterface.h index e313ca4bbd..0ad153db1f 100644 --- a/ApplicationCode/FileInterface/RifReaderInterface.h +++ b/ApplicationCode/FileInterface/RifReaderInterface.h @@ -48,7 +48,6 @@ public: virtual ~RifReaderInterface() {} virtual bool open(const QString& fileName, RigEclipseCase* eclipseCase) = 0; - virtual bool openAndReadActiveCellData(const QString& fileName, RigEclipseCase* mainEclipseCase, RigEclipseCase* eclipseCase) { return true; }; virtual void close() = 0; virtual bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector* values) = 0; diff --git a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp index 655a175c0c..b85640de6e 100644 --- a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp @@ -117,15 +117,26 @@ bool RimResultReservoir::openAndReadActiveCellData(RigEclipseCase* mainEclipseCa CVF_ASSERT(mainEclipseCase && mainEclipseCase->mainGrid()); eclipseCase->setMainGrid(mainEclipseCase->mainGrid()); - readerInterface = new RifReaderEclipseOutput; - if (!readerInterface->openAndReadActiveCellData(fname, mainEclipseCase, eclipseCase.p())) + size_t scalarIndexWithMaxTimeStepCount = cvf::UNDEFINED_SIZE_T; + mainEclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->maxTimeStepCount(&scalarIndexWithMaxTimeStepCount); + if (scalarIndexWithMaxTimeStepCount == cvf::UNDEFINED_SIZE_T) { return false; } - readerInterface->close(); + std::vector timeStepDates = mainEclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->timeStepDates(scalarIndexWithMaxTimeStepCount); + + cvf::ref readerEclipseOutput = new RifReaderEclipseOutput; + if (!readerEclipseOutput->openAndReadActiveCellData(fname, timeStepDates, eclipseCase.p())) + { + return false; + } + + readerEclipseOutput->close(); this->setReservoirData( eclipseCase.p() ); + + readerInterface = readerEclipseOutput; } results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p()); From f0fa445f7ae4d4ded086c7f335be0077a3ea95df Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 19 Mar 2013 08:28:25 +0100 Subject: [PATCH 126/242] Set main grid on eclipse case and cell results p4#: 20955 --- ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp | 3 +++ .../ReservoirDataModel/RigReservoirCellResults.cpp | 9 +++++++++ .../ReservoirDataModel/RigReservoirCellResults.h | 2 ++ 3 files changed, 14 insertions(+) diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp index 8724e9ff4c..5397ed8325 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp @@ -46,6 +46,9 @@ RigEclipseCase::~RigEclipseCase() void RigEclipseCase::setMainGrid(RigMainGrid* mainGrid) { m_mainGrid = mainGrid; + + m_matrixModelResults->setMainGrid(m_mainGrid.p()); + m_fractureModelResults->setMainGrid(m_mainGrid.p()); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp index 9ce8805bd8..c7b4cf0012 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp @@ -33,6 +33,15 @@ RigReservoirCellResults::RigReservoirCellResults(RigMainGrid* ownerGrid) m_ownerMainGrid = ownerGrid; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigReservoirCellResults::setMainGrid(RigMainGrid* ownerGrid) +{ + m_ownerMainGrid = ownerGrid; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h index a169e751e8..7e624b29bf 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h +++ b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h @@ -38,6 +38,8 @@ public: //void setReaderInterface(RifReaderInterface* readerInterface); //RifReaderInterface* readerInterface(); + void setMainGrid(RigMainGrid* ownerGrid); + // Max and min values of the results void recalculateMinMax(size_t scalarResultIndex); void minMaxCellScalarValues(size_t scalarResultIndex, double& min, double& max); From 516c642cc4e5b5da90e3f66a1a67a26ea43cc088 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 19 Mar 2013 09:08:37 +0100 Subject: [PATCH 127/242] Results Storage: Refined the output format. Think it is ok now p4#: 20956 --- .../RimReservoirCellResultsCacher.cpp | 15 +++++-- .../RimReservoirCellResultsCacher.h | 41 ++++++++++--------- .../ProjectDataModel/RimReservoirView.h | 1 - 3 files changed, 33 insertions(+), 24 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp index 62d47c4369..7c8afe989f 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp @@ -50,6 +50,10 @@ RimReservoirCellResultsCacher::~RimReservoirCellResultsCacher() } //-------------------------------------------------------------------------------------------------- +/// This override populates the metainfo regarding the cell results data in the RigReservoirCellResults +/// object. This metainfo will then be written to the project file when saving, and thus read on project file open. +/// This method then writes the actual double arrays to the data file in a simple format: +/// MagicNumber, Version, ResultVariables< Array < TimeStep< CellDataArraySize, CellData< Array > > > /// //-------------------------------------------------------------------------------------------------- void RimReservoirCellResultsCacher::setupBeforeSave() @@ -71,13 +75,15 @@ void RimReservoirCellResultsCacher::setupBeforeSave() QDataStream stream(&cacheFile); stream.setVersion(QDataStream::Qt_4_0); stream << (quint32)0xCEECAC4E; // magic number - stream << (qint32)1; // Version + stream << (quint32)1; // Version number. Increment if needing to extend the format in ways that can not be handled generically by the reader for (size_t rIdx = 0; rIdx < resInfo.size(); ++rIdx) { size_t timestepCount = m_cellResults->cellScalarResults(resInfo[rIdx].m_gridScalarResultIndex).size(); + if (timestepCount) { + // Create and setup the cache information for this result RimReservoirCellResultsCacheEntryInfo* cacheEntry = new RimReservoirCellResultsCacheEntryInfo; m_resultCacheMetaData.push_back(cacheEntry); @@ -85,8 +91,11 @@ void RimReservoirCellResultsCacher::setupBeforeSave() cacheEntry->m_resultName = resInfo[rIdx].m_resultName; cacheEntry->m_timeStepDates = resInfo[rIdx].m_timeStepDates; + // Take note of the file position for fast lookup later cacheEntry->m_filePosition = cacheFile.pos(); + // Write all the scalar values for each time step to the stream, + // starting with the number of values for (size_t tsIdx = 0; tsIdx < resInfo[rIdx].m_timeStepDates.size() ; ++tsIdx) { const std::vector* data = NULL; @@ -97,8 +106,8 @@ void RimReservoirCellResultsCacher::setupBeforeSave() if (data && data->size()) { - cacheEntry->m_timeStepHasData.v().push_back(1); + stream << (quint64)(data->size()); for (size_t cIdx = 0; cIdx < data->size(); ++cIdx) { stream << (*data)[cIdx]; @@ -106,7 +115,7 @@ void RimReservoirCellResultsCacher::setupBeforeSave() } else { - cacheEntry->m_timeStepHasData.v().push_back(0); + stream << (quint64)0; } } } diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h index fcf703e02d..1051429769 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h @@ -37,36 +37,37 @@ public: virtual ~RimReservoirCellResultsCacher(); // Fields - caf::PdmField m_resultCacheFileName; + caf::PdmField m_resultCacheFileName; caf::PdmPointersField - m_resultCacheMetaData; + m_resultCacheMetaData; - RigReservoirCellResults* cellResults() { return m_cellResults; } - const RigReservoirCellResults* cellResults() const { return m_cellResults; } + RigReservoirCellResults* cellResults() { return m_cellResults; } + const RigReservoirCellResults* cellResults() const { return m_cellResults; } - void setCellResults(RigReservoirCellResults* cellResults); - void setMainGrid(RigMainGrid* mainGrid); + void setCellResults(RigReservoirCellResults* cellResults); + void setMainGrid(RigMainGrid* mainGrid); - void setReaderInterface(RifReaderInterface* readerInterface); - RifReaderInterface* readerInterface(); + void setReaderInterface(RifReaderInterface* readerInterface); + RifReaderInterface* readerInterface(); - void loadOrComputeSOIL(); - void loadOrComputeSOILForTimeStep(size_t timeStepIndex); - void computeDepthRelatedResults(); + void loadOrComputeSOIL(); + void loadOrComputeSOILForTimeStep(size_t timeStepIndex); + void computeDepthRelatedResults(); - size_t findOrLoadScalarResultForTimeStep(RimDefines::ResultCatType type, const QString& resultName, size_t timeStepIndex); - size_t findOrLoadScalarResult(RimDefines::ResultCatType type, const QString& resultName); - size_t findOrLoadScalarResult(const QString& resultName); ///< Simplified search. Assumes unique names across types. + size_t findOrLoadScalarResultForTimeStep(RimDefines::ResultCatType type, const QString& resultName, size_t timeStepIndex); + size_t findOrLoadScalarResult(RimDefines::ResultCatType type, const QString& resultName); + size_t findOrLoadScalarResult(const QString& resultName); ///< Simplified search. Assumes unique names across types. // Overridden methods from PdmObject - virtual void setupBeforeSave(); + virtual void setupBeforeSave(); private: - QString getValidCacheFileName(); - QString getCacheDirectoryPath(); - cvf::ref m_readerInterface; - RigReservoirCellResults* m_cellResults; - RigMainGrid* m_ownerMainGrid; + QString getValidCacheFileName(); + QString getCacheDirectoryPath(); + + cvf::ref m_readerInterface; + RigReservoirCellResults* m_cellResults; + RigMainGrid* m_ownerMainGrid; }; class RimReservoirCellResultsCacheEntryInfo : public caf::PdmObject diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.h b/ApplicationCode/ProjectDataModel/RimReservoirView.h index a0cb0126e4..24c75fdaae 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.h +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.h @@ -51,7 +51,6 @@ namespace cvf class ModelBasicList; } - enum ViewState { GEOMETRY_ONLY, From 5860cb2e497721baf21ca1b6e663b0e97a62f1a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 19 Mar 2013 09:48:30 +0100 Subject: [PATCH 128/242] Results Storage: Removed obsolete field. Stored the filename. p4#: 20959 --- .../ProjectDataModel/RimReservoirCellResultsCacher.cpp | 8 +++++++- .../ProjectDataModel/RimReservoirCellResultsCacher.h | 1 - 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp index 7c8afe989f..5891016eb1 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp @@ -70,7 +70,13 @@ void RimReservoirCellResultsCacher::setupBeforeSave() QString newValidCacheFileName = getValidCacheFileName(); QFile cacheFile(newValidCacheFileName); - if (!cacheFile.open(QIODevice::WriteOnly)) qWarning() << "Saving project: Can't open the cache file : " + newValidCacheFileName; + if (!cacheFile.open(QIODevice::WriteOnly)) + { + qWarning() << "Saving project: Can't open the cache file : " + newValidCacheFileName; + return; + } + + m_resultCacheFileName = newValidCacheFileName; QDataStream stream(&cacheFile); stream.setVersion(QDataStream::Qt_4_0); diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h index 1051429769..e49637729e 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h @@ -80,7 +80,6 @@ public: caf::PdmField > m_resultType; caf::PdmField m_resultName; caf::PdmField< std::vector > m_timeStepDates; - caf::PdmField< std::vector > m_timeStepHasData; caf::PdmField m_filePosition; }; From 051710b82fb64ec5a36281eec528faa330719b13 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 19 Mar 2013 09:55:17 +0100 Subject: [PATCH 129/242] Prototype of copy/paste of reservoir case p4#: 20962 --- .../ProjectDataModel/RimProject.cpp | 121 ++++++++++++++---- ApplicationCode/ProjectDataModel/RimProject.h | 6 + .../ProjectDataModel/RimUiTreeView.cpp | 117 +++++++++++++++++ .../ProjectDataModel/RimUiTreeView.h | 13 +- cafProjectDataModel/cafPdmDocument.cpp | 51 ++++---- cafProjectDataModel/cafPdmDocument.h | 3 +- 6 files changed, 261 insertions(+), 50 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index b0d63ecee7..379f742e82 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -24,6 +24,7 @@ #include "RigGridCollection.h" #include "RigEclipseCase.h" +#include "RimResultReservoir.h" CAF_PDM_SOURCE_INIT(RimProject, "ResInsightProject"); @@ -134,31 +135,8 @@ void RimProject::moveEclipseCaseIntoCaseGroup(RimReservoir* rimReservoir) CVF_ASSERT(rimReservoir); RigEclipseCase* rigEclipseCase = rimReservoir->reservoirData(); - - RigMainGrid* equalGrid = m_gridCollection->findEqualGrid(rigEclipseCase->mainGrid()); - - if (equalGrid) - { - // Replace the grid with an already registered grid - rigEclipseCase->setMainGrid(equalGrid); - } - else - { - // This is the first insertion of this grid, compute cached data - rigEclipseCase->mainGrid()->computeCachedData(); - - std::vector grids; - rigEclipseCase->allGrids(&grids); - - size_t i; - for (i = 0; i < grids.size(); i++) - { - grids[i]->computeFaults(); - } - } - - m_gridCollection->addCase(rigEclipseCase); - + RigMainGrid* equalGrid = registerCaseInGridCollection(rigEclipseCase); + CVF_ASSERT(equalGrid); // Insert in identical grid group bool foundGroup = false; @@ -214,3 +192,96 @@ void RimProject::removeEclipseCaseFromAllGroups(RimReservoir* reservoir) reservoirs().removeChildObject(reservoir); } + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigMainGrid* RimProject::registerCaseInGridCollection(RigEclipseCase* rigEclipseCase) +{ + CVF_ASSERT(rigEclipseCase); + + RigMainGrid* equalGrid = m_gridCollection->findEqualGrid(rigEclipseCase->mainGrid()); + + if (equalGrid) + { + // Replace the grid with an already registered grid + rigEclipseCase->setMainGrid(equalGrid); + } + else + { + // This is the first insertion of this grid, compute cached data + rigEclipseCase->mainGrid()->computeCachedData(); + + std::vector grids; + rigEclipseCase->allGrids(&grids); + + size_t i; + for (i = 0; i < grids.size(); i++) + { + grids[i]->computeFaults(); + } + + equalGrid = rigEclipseCase->mainGrid(); + } + + m_gridCollection->addCase(rigEclipseCase); + + return equalGrid; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimProject::insertCaseInCaseGroup(RimReservoir* rimReservoir, RimIdenticalGridCaseGroup* caseGroup) +{ + CVF_ASSERT(rimReservoir); + + RigEclipseCase* rigEclipseCase = rimReservoir->reservoirData(); + registerCaseInGridCollection(rigEclipseCase); + + caseGroup->addCase(rimReservoir); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimProject::copyFromCaseList(RimIdenticalGridCaseGroup* caseGroup, const caf::PdmObjectGroup& caseList) +{ + std::vector > typedObjects; + caseList.createCopyByType(&typedObjects); + + if (typedObjects.size() == 0) return; + + RigEclipseCase* mainEclipseCase = NULL; + if (caseGroup->caseCollection()->reservoirs().size() > 0) + { + RimReservoir* mainReservoir = caseGroup->caseCollection()->reservoirs()[0];; + mainEclipseCase = mainReservoir->reservoirData(); + } + + for (size_t i = 0; i < typedObjects.size(); i++) + { + RimReservoir* rimReservoir = typedObjects[i]; + caf::PdmObjectGroup::initAfterReadTraversal(rimReservoir); + + RimResultReservoir* rimResultReservoir = dynamic_cast(rimReservoir); + if (rimResultReservoir) + { + if (caseGroup->mainGrid() == NULL) + { + rimResultReservoir->openEclipseGridFile(); + mainEclipseCase = rimResultReservoir->reservoirData(); + } + else + { + if (!rimResultReservoir->openAndReadActiveCellData(mainEclipseCase)) + { + CVF_ASSERT(false); + } + } + + insertCaseInCaseGroup(rimResultReservoir, caseGroup); + } + } +} diff --git a/ApplicationCode/ProjectDataModel/RimProject.h b/ApplicationCode/ProjectDataModel/RimProject.h index 2fde1ce4bc..12aa85dd09 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.h +++ b/ApplicationCode/ProjectDataModel/RimProject.h @@ -48,8 +48,14 @@ public: void close(); + void copyFromCaseList(RimIdenticalGridCaseGroup* caseGroup, const caf::PdmObjectGroup& caseList); + void insertCaseInCaseGroup(RimReservoir* rimReservoir, RimIdenticalGridCaseGroup* caseGroup); + void moveEclipseCaseIntoCaseGroup(RimReservoir* rimReservoir); void removeEclipseCaseFromAllGroups(RimReservoir* rimReservoir); + +private: + RigMainGrid* registerCaseInGridCollection(RigEclipseCase* rigEclipseCase); protected: // Overridden methods diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index efd22f5c22..63c372f0a3 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -40,6 +40,17 @@ RimUiTreeView::RimUiTreeView(QWidget *parent /*= 0*/) : QTreeView(parent) { setHeaderHidden(true); + + m_pdmObjectsFromClipboard = new caf::PdmObjectGroup; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimUiTreeView::~RimUiTreeView() +{ + delete m_pdmObjectsFromClipboard; + m_pdmObjectsFromClipboard = NULL; } //-------------------------------------------------------------------------------------------------- @@ -161,6 +172,7 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event) else if (dynamic_cast(uiItem->dataObject().p())) { QMenu menu; + menu.addAction(QString("Copy"), this, SLOT(slotCopyPdmObjectToClipboard())); menu.addAction(QString("Close"), this, SLOT(slotCloseCase())); menu.addAction(QString("New View"), this, SLOT(slotAddView())); menu.exec(event->globalPos()); @@ -169,6 +181,7 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event) { QMenu menu; menu.addAction(QString("New Case Group"), this, SLOT(slotAddCaseGroup())); + menu.addAction(QString("Paste"), this, SLOT(slotPasteEclipseCases())); menu.exec(event->globalPos()); } } @@ -816,3 +829,107 @@ void RimUiTreeView::slotAddCaseGroup() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUiTreeView::slotCopyPdmObjectToClipboard() +{ + QItemSelectionModel* m = selectionModel(); + + QModelIndexList mil = m->selectedRows(); + if (mil.size() == 0) + { + return; + } + + MimeDataWithIndexes* myObject = new MimeDataWithIndexes; + myObject->setIndexes(mil); + + QClipboard* clipboard = QApplication::clipboard(); + if (clipboard) + { + clipboard->setMimeData(myObject); + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUiTreeView::slotPasteEclipseCases() +{ + if (!currentIndex().isValid()) return; + + createPdmObjectsFromClipboard(); + if (m_pdmObjectsFromClipboard->objects().size() == 0) return; + + RimUiTreeModelPdm* myModel = dynamic_cast(model()); + caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex()); + + RimIdenticalGridCaseGroup* destinationGroup = dynamic_cast(uiItem->dataObject().p()); + if (!destinationGroup) return; + + + RimProject* proj = RIApplication::instance()->project(); + proj->copyFromCaseList(destinationGroup, *m_pdmObjectsFromClipboard); + + myModel->rebuildUiSubTree(destinationGroup); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUiTreeView::createPdmObjectsFromClipboard() +{ + m_pdmObjectsFromClipboard->objects().clear(); + + RimUiTreeModelPdm* myModel = dynamic_cast(model()); + if (!myModel) return; + + QClipboard* clipboard = QApplication::clipboard(); + if (!clipboard) return; + + const MimeDataWithIndexes* mdWithIndexes = dynamic_cast(clipboard->mimeData()); + if (!mdWithIndexes) return; + + QModelIndexList indexList = mdWithIndexes->indexes(); + for (int i = 0; i < indexList.size(); i++) + { + caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(indexList.at(i)); + m_pdmObjectsFromClipboard->addObject(uiItem->dataObject().p()); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUiTreeView::keyPressEvent(QKeyEvent* keyEvent) +{ + RimUiTreeModelPdm* myModel = dynamic_cast(model()); + caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex()); + + if (dynamic_cast(uiItem->dataObject().p())) + { + if (keyEvent->matches(QKeySequence::Copy)) + { + slotCopyPdmObjectToClipboard(); + keyEvent->setAccepted(true); + + return; + } + } + + if (dynamic_cast(uiItem->dataObject().p())) + { + if (keyEvent->matches(QKeySequence::Paste)) + { + slotPasteEclipseCases(); + keyEvent->setAccepted(true); + + return; + } + } + + QTreeView::keyPressEvent(keyEvent); +} + diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.h b/ApplicationCode/ProjectDataModel/RimUiTreeView.h index af2ba497bd..94af760a64 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.h @@ -23,6 +23,7 @@ #include class QItemSelection; +class PdmObjectGroup; //================================================================================================== /// @@ -34,6 +35,7 @@ class RimUiTreeView : public QTreeView public: RimUiTreeView(QWidget *parent = 0); + ~RimUiTreeView(); virtual void setModel(QAbstractItemModel* model); @@ -73,11 +75,20 @@ private slots: void slotComputeStatisticalCases(); void slotAddCaseGroup(); + void slotCopyPdmObjectToClipboard(); + void slotPasteEclipseCases(); + void slotSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected); signals: void selectedObjectChanged( caf::PdmObject* pdmObject ); + +private: + + void createPdmObjectsFromClipboard(); + + virtual void keyPressEvent(QKeyEvent* keyEvent); + caf::PdmObjectGroup* m_pdmObjectsFromClipboard; }; - diff --git a/cafProjectDataModel/cafPdmDocument.cpp b/cafProjectDataModel/cafPdmDocument.cpp index 0e16c8a468..133da9cac5 100644 --- a/cafProjectDataModel/cafPdmDocument.cpp +++ b/cafProjectDataModel/cafPdmDocument.cpp @@ -72,6 +72,34 @@ void PdmObjectGroup::addObject(PdmObject * obj) objects.push_back(obj); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmObjectGroup::initAfterReadTraversal(PdmObject* object) +{ + if (object == NULL) return; + + std::vector fields; + object->fields(fields); + + std::vector children; + size_t fIdx; + for (fIdx = 0; fIdx < fields.size(); ++fIdx) + { + if (fields[fIdx]) fields[fIdx]->childObjects(&children); + } + + size_t cIdx; + for (cIdx = 0; cIdx < children.size(); ++cIdx) + { + PdmObjectGroup::initAfterReadTraversal(children[cIdx]); + if (children[cIdx]) children[cIdx]->initAfterRead(); + } + + object->initAfterRead(); +} + + CAF_PDM_SOURCE_INIT(PdmDocument, "PdmDocument"); @@ -157,29 +185,6 @@ void PdmDocument::writeFile(QIODevice* xmlFile) xmlStream.writeEndDocument(); } -void PdmDocument::initAfterReadTraversal(PdmObject* object) -{ - if (object == NULL) return; - - std::vector fields; - object->fields(fields); - - std::vector children; - size_t fIdx; - for (fIdx = 0; fIdx < fields.size(); ++fIdx) - { - if (fields[fIdx]) fields[fIdx]->childObjects(&children); - } - - size_t cIdx; - for (cIdx = 0; cIdx < children.size(); ++cIdx) - { - PdmDocument::initAfterReadTraversal(children[cIdx]); - if (children[cIdx]) children[cIdx]->initAfterRead(); - } - - object->initAfterRead(); -} void PdmDocument::setupBeforeSaveTraversal(PdmObject * object) { diff --git a/cafProjectDataModel/cafPdmDocument.h b/cafProjectDataModel/cafPdmDocument.h index a620d539f6..db9f7036ec 100644 --- a/cafProjectDataModel/cafPdmDocument.h +++ b/cafProjectDataModel/cafPdmDocument.h @@ -44,6 +44,8 @@ public: void removeNullPtrs(); void addObject(PdmObject * obj); + static void initAfterReadTraversal(PdmObject * root); + template void objectsByType(std::vector >* typedObjects ) const { @@ -115,7 +117,6 @@ class PdmDocument: public PdmObjectGroup void writeFile(QIODevice* device); private: - static void initAfterReadTraversal(PdmObject * root); static void setupBeforeSaveTraversal(PdmObject * root); }; From 75fc89e67a035d65ffc91cbe282d6aa67587bf1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 19 Mar 2013 10:29:34 +0100 Subject: [PATCH 130/242] Rename of ...ResultsCacher to ...ResultsStorage. Hide Cacher from UI tree p4#: 20963 --- .../ProjectDataModel/RigStatistics.cpp | 2 +- .../RimCellPropertyFilter.cpp | 2 +- .../ProjectDataModel/RimInputReservoir.cpp | 4 +- .../ProjectDataModel/RimReservoir.cpp | 8 ++-- .../ProjectDataModel/RimReservoir.h | 6 +-- .../RimReservoirCellResultsCacher.cpp | 40 +++++++++---------- .../RimReservoirCellResultsCacher.h | 16 ++++---- .../ProjectDataModel/RimReservoirView.cpp | 4 +- .../ProjectDataModel/RimReservoirView.h | 2 +- .../ProjectDataModel/RimResultDefinition.cpp | 6 +-- 10 files changed, 46 insertions(+), 44 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RigStatistics.cpp b/ApplicationCode/ProjectDataModel/RigStatistics.cpp index fb5cb26129..45de3423fe 100644 --- a/ApplicationCode/ProjectDataModel/RigStatistics.cpp +++ b/ApplicationCode/ProjectDataModel/RigStatistics.cpp @@ -156,7 +156,7 @@ void RigStatistics::buildSourceMetaData(RimDefines::ResultCatType resultType, co { RigEclipseCase* eclipseCase = m_sourceCases.at(caseIdx)->reservoirData(); - RimReservoirCellResultsCacher* matrixResults = m_sourceCases[caseIdx]->results(RifReaderInterface::MATRIX_RESULTS); + RimReservoirCellResultsStorage* matrixResults = m_sourceCases[caseIdx]->results(RifReaderInterface::MATRIX_RESULTS); size_t scalarResultIndex = matrixResults->findOrLoadScalarResult(resultType, resultName); if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) { diff --git a/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.cpp b/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.cpp index ad47fc70c6..f1aad6768c 100644 --- a/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.cpp @@ -143,7 +143,7 @@ void RimCellPropertyFilter::setDefaultValues() size_t scalarIndex = resultDefinition->gridScalarIndex(); if (scalarIndex != cvf::UNDEFINED_SIZE_T) { - RimReservoirCellResultsCacher* results = m_parentContainer->reservoirView()->currentGridCellResults(); + RimReservoirCellResultsStorage* results = m_parentContainer->reservoirView()->currentGridCellResults(); if (results) { results->cellResults()->minMaxCellScalarValues(scalarIndex, min, max); diff --git a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp index c221244c7b..d1c55cafb7 100644 --- a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp @@ -191,8 +191,8 @@ bool RimInputReservoir::openEclipseGridFile() RIApplication* app = RIApplication::instance(); if (app->preferences()->autocomputeDepthRelatedProperties) { - RimReservoirCellResultsCacher* matrixResults = results(RifReaderInterface::MATRIX_RESULTS); - RimReservoirCellResultsCacher* fractureResults = results(RifReaderInterface::FRACTURE_RESULTS); + RimReservoirCellResultsStorage* matrixResults = results(RifReaderInterface::MATRIX_RESULTS); + RimReservoirCellResultsStorage* fractureResults = results(RifReaderInterface::FRACTURE_RESULTS); matrixResults->computeDepthRelatedResults(); fractureResults->computeDepthRelatedResults(); diff --git a/ApplicationCode/ProjectDataModel/RimReservoir.cpp b/ApplicationCode/ProjectDataModel/RimReservoir.cpp index 4078d2eeb1..dab4e7566d 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoir.cpp @@ -47,10 +47,12 @@ RimReservoir::RimReservoir() CAF_PDM_InitFieldNoDefault(&reservoirViews, "ReservoirViews", "", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_matrixModelResults, "MatrixModelResults", "", "", "", ""); + m_matrixModelResults.setUiHidden(true); CAF_PDM_InitFieldNoDefault(&m_fractureModelResults, "FractureModelResults", "", "", "", ""); + m_fractureModelResults.setUiHidden(true); - m_matrixModelResults = new RimReservoirCellResultsCacher; - m_fractureModelResults = new RimReservoirCellResultsCacher; + m_matrixModelResults = new RimReservoirCellResultsStorage; + m_fractureModelResults = new RimReservoirCellResultsStorage; this->setReservoirData( NULL ); } @@ -316,7 +318,7 @@ void RimReservoir::setReservoirData(RigEclipseCase* eclipseCase) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimReservoirCellResultsCacher* RimReservoir::results(RifReaderInterface::PorosityModelResultType porosityModel) +RimReservoirCellResultsStorage* RimReservoir::results(RifReaderInterface::PorosityModelResultType porosityModel) { if (porosityModel == RifReaderInterface::MATRIX_RESULTS) { diff --git a/ApplicationCode/ProjectDataModel/RimReservoir.h b/ApplicationCode/ProjectDataModel/RimReservoir.h index 05b634e706..5f6bc4ca30 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoir.h +++ b/ApplicationCode/ProjectDataModel/RimReservoir.h @@ -55,7 +55,7 @@ public: RigEclipseCase* reservoirData(); const RigEclipseCase* reservoirData() const; - RimReservoirCellResultsCacher* results(RifReaderInterface::PorosityModelResultType porosityModel); + RimReservoirCellResultsStorage* results(RifReaderInterface::PorosityModelResultType porosityModel); RimReservoirView* createAndAddReservoirView(); void removeReservoirView(RimReservoirView* reservoirView); @@ -83,7 +83,7 @@ private: cvf::ref m_rigEclipseCase; private: - caf::PdmField m_matrixModelResults; - caf::PdmField m_fractureModelResults; + caf::PdmField m_matrixModelResults; + caf::PdmField m_fractureModelResults; }; diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp index 5891016eb1..650da7597c 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp @@ -23,12 +23,12 @@ #include "RigMainGrid.h" #include "RigCell.h" -CAF_PDM_SOURCE_INIT(RimReservoirCellResultsCacher, "ReservoirCellResultCacher"); +CAF_PDM_SOURCE_INIT(RimReservoirCellResultsStorage, "ReservoirCellResultStorage"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimReservoirCellResultsCacher::RimReservoirCellResultsCacher() +RimReservoirCellResultsStorage::RimReservoirCellResultsStorage() : m_cellResults(NULL), m_ownerMainGrid(NULL) { @@ -44,7 +44,7 @@ RimReservoirCellResultsCacher::RimReservoirCellResultsCacher() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimReservoirCellResultsCacher::~RimReservoirCellResultsCacher() +RimReservoirCellResultsStorage::~RimReservoirCellResultsStorage() { m_resultCacheMetaData.deleteAllChildObjects(); } @@ -56,7 +56,7 @@ RimReservoirCellResultsCacher::~RimReservoirCellResultsCacher() /// MagicNumber, Version, ResultVariables< Array < TimeStep< CellDataArraySize, CellData< Array > > > /// //-------------------------------------------------------------------------------------------------- -void RimReservoirCellResultsCacher::setupBeforeSave() +void RimReservoirCellResultsStorage::setupBeforeSave() { if (!m_cellResults) return; @@ -90,7 +90,7 @@ void RimReservoirCellResultsCacher::setupBeforeSave() if (timestepCount) { // Create and setup the cache information for this result - RimReservoirCellResultsCacheEntryInfo* cacheEntry = new RimReservoirCellResultsCacheEntryInfo; + RimReservoirCellResultsStorageEntryInfo* cacheEntry = new RimReservoirCellResultsStorageEntryInfo; m_resultCacheMetaData.push_back(cacheEntry); cacheEntry->m_resultType = resInfo[rIdx].m_resultType; @@ -132,7 +132,7 @@ void RimReservoirCellResultsCacher::setupBeforeSave() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimReservoirCellResultsCacher::getValidCacheFileName() +QString RimReservoirCellResultsStorage::getValidCacheFileName() { QString cacheFileName; if (m_resultCacheFileName().isEmpty()) @@ -155,7 +155,7 @@ QString RimReservoirCellResultsCacher::getValidCacheFileName() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimReservoirCellResultsCacher::getCacheDirectoryPath() +QString RimReservoirCellResultsStorage::getCacheDirectoryPath() { QString cacheDirPath; QString projectFileName = RIApplication::instance()->project()->fileName(); @@ -168,7 +168,7 @@ QString RimReservoirCellResultsCacher::getCacheDirectoryPath() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoirCellResultsCacher::setReaderInterface(RifReaderInterface* readerInterface) +void RimReservoirCellResultsStorage::setReaderInterface(RifReaderInterface* readerInterface) { m_readerInterface = readerInterface; } @@ -177,7 +177,7 @@ void RimReservoirCellResultsCacher::setReaderInterface(RifReaderInterface* reade //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifReaderInterface* RimReservoirCellResultsCacher::readerInterface() +RifReaderInterface* RimReservoirCellResultsStorage::readerInterface() { return m_readerInterface.p(); } @@ -185,7 +185,7 @@ RifReaderInterface* RimReservoirCellResultsCacher::readerInterface() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -size_t RimReservoirCellResultsCacher::findOrLoadScalarResultForTimeStep(RimDefines::ResultCatType type, const QString& resultName, size_t timeStepIndex) +size_t RimReservoirCellResultsStorage::findOrLoadScalarResultForTimeStep(RimDefines::ResultCatType type, const QString& resultName, size_t timeStepIndex) { // Special handling for SOIL if (type == RimDefines::DYNAMIC_NATIVE && resultName.toUpper() == "SOIL") @@ -248,7 +248,7 @@ size_t RimReservoirCellResultsCacher::findOrLoadScalarResultForTimeStep(RimDefin //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -size_t RimReservoirCellResultsCacher::findOrLoadScalarResult(RimDefines::ResultCatType type, const QString& resultName) +size_t RimReservoirCellResultsStorage::findOrLoadScalarResult(RimDefines::ResultCatType type, const QString& resultName) { size_t resultGridIndex = cvf::UNDEFINED_SIZE_T; @@ -308,7 +308,7 @@ size_t RimReservoirCellResultsCacher::findOrLoadScalarResult(RimDefines::ResultC //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoirCellResultsCacher::loadOrComputeSOIL() +void RimReservoirCellResultsStorage::loadOrComputeSOIL() { for (size_t timeStepIdx = 0; timeStepIdx < m_cellResults->maxTimeStepCount(); timeStepIdx++) { @@ -320,7 +320,7 @@ void RimReservoirCellResultsCacher::loadOrComputeSOIL() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoirCellResultsCacher::loadOrComputeSOILForTimeStep(size_t timeStepIndex) +void RimReservoirCellResultsStorage::loadOrComputeSOILForTimeStep(size_t timeStepIndex) { size_t scalarIndexSWAT = findOrLoadScalarResultForTimeStep(RimDefines::DYNAMIC_NATIVE, "SWAT", timeStepIndex); size_t scalarIndexSGAS = findOrLoadScalarResultForTimeStep(RimDefines::DYNAMIC_NATIVE, "SGAS", timeStepIndex); @@ -404,7 +404,7 @@ void RimReservoirCellResultsCacher::loadOrComputeSOILForTimeStep(size_t timeStep //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoirCellResultsCacher::computeDepthRelatedResults() +void RimReservoirCellResultsStorage::computeDepthRelatedResults() { size_t depthResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DEPTH"); size_t dxResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DX"); @@ -509,7 +509,7 @@ void RimReservoirCellResultsCacher::computeDepthRelatedResults() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -size_t RimReservoirCellResultsCacher::findOrLoadScalarResult(const QString& resultName) +size_t RimReservoirCellResultsStorage::findOrLoadScalarResult(const QString& resultName) { size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T; @@ -536,7 +536,7 @@ size_t RimReservoirCellResultsCacher::findOrLoadScalarResult(const QString& resu //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoirCellResultsCacher::setCellResults(RigReservoirCellResults* cellResults) +void RimReservoirCellResultsStorage::setCellResults(RigReservoirCellResults* cellResults) { m_cellResults = cellResults; } @@ -544,18 +544,18 @@ void RimReservoirCellResultsCacher::setCellResults(RigReservoirCellResults* cell //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoirCellResultsCacher::setMainGrid(RigMainGrid* mainGrid) +void RimReservoirCellResultsStorage::setMainGrid(RigMainGrid* mainGrid) { m_ownerMainGrid = mainGrid; } -CAF_PDM_SOURCE_INIT(RimReservoirCellResultsCacheEntryInfo, "ResultCacheEntryInfo"); +CAF_PDM_SOURCE_INIT(RimReservoirCellResultsStorageEntryInfo, "ResultStorageEntryInfo"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimReservoirCellResultsCacheEntryInfo::RimReservoirCellResultsCacheEntryInfo() +RimReservoirCellResultsStorageEntryInfo::RimReservoirCellResultsStorageEntryInfo() { CAF_PDM_InitObject("Cache Entry", "", "", ""); @@ -569,7 +569,7 @@ RimReservoirCellResultsCacheEntryInfo::RimReservoirCellResultsCacheEntryInfo() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimReservoirCellResultsCacheEntryInfo::~RimReservoirCellResultsCacheEntryInfo() +RimReservoirCellResultsStorageEntryInfo::~RimReservoirCellResultsStorageEntryInfo() { } diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h index e49637729e..19141d7c6a 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h @@ -24,21 +24,21 @@ #include "cafAppEnum.h" #include "RimDefines.h" -class RimReservoirCellResultsCacheEntryInfo; +class RimReservoirCellResultsStorageEntryInfo; class RigReservoirCellResults; class RifReaderInterface; class RigMainGrid; -class RimReservoirCellResultsCacher : public caf::PdmObject +class RimReservoirCellResultsStorage : public caf::PdmObject { CAF_PDM_HEADER_INIT; public: - RimReservoirCellResultsCacher(); - virtual ~RimReservoirCellResultsCacher(); + RimReservoirCellResultsStorage(); + virtual ~RimReservoirCellResultsStorage(); // Fields caf::PdmField m_resultCacheFileName; - caf::PdmPointersField + caf::PdmPointersField m_resultCacheMetaData; RigReservoirCellResults* cellResults() { return m_cellResults; } @@ -70,12 +70,12 @@ private: RigMainGrid* m_ownerMainGrid; }; -class RimReservoirCellResultsCacheEntryInfo : public caf::PdmObject +class RimReservoirCellResultsStorageEntryInfo : public caf::PdmObject { CAF_PDM_HEADER_INIT; public: - RimReservoirCellResultsCacheEntryInfo(); - virtual ~RimReservoirCellResultsCacheEntryInfo(); + RimReservoirCellResultsStorageEntryInfo(); + virtual ~RimReservoirCellResultsStorageEntryInfo(); caf::PdmField > m_resultType; caf::PdmField m_resultName; diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp index 353698c7bd..93b19388da 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp @@ -711,7 +711,7 @@ void RimReservoirView::loadDataAndUpdate() RIApplication* app = RIApplication::instance(); if (app->preferences()->autocomputeSOIL) { - RimReservoirCellResultsCacher* results = currentGridCellResults(); + RimReservoirCellResultsStorage* results = currentGridCellResults(); CVF_ASSERT(results); results->loadOrComputeSOIL(); } @@ -970,7 +970,7 @@ void RimReservoirView::setupBeforeSave() //-------------------------------------------------------------------------------------------------- /// Convenience for quick access to results //-------------------------------------------------------------------------------------------------- -RimReservoirCellResultsCacher* RimReservoirView::currentGridCellResults() +RimReservoirCellResultsStorage* RimReservoirView::currentGridCellResults() { if (m_reservoir) { diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.h b/ApplicationCode/ProjectDataModel/RimReservoirView.h index 24c75fdaae..75cbae54d1 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.h +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.h @@ -117,7 +117,7 @@ public: caf::PdmField animationMode; // Access internal objects - RimReservoirCellResultsCacher* currentGridCellResults(); + RimReservoirCellResultsStorage* currentGridCellResults(); RigActiveCellInfo* currentActiveCellInfo(); void setEclipseCase(RimReservoir* reservoir); diff --git a/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp index c3fbd388eb..44826426bc 100644 --- a/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp @@ -119,7 +119,7 @@ size_t RimResultDefinition::gridScalarIndex() const { if (m_gridScalarResultIndex == cvf::UNDEFINED_SIZE_T) { - const RimReservoirCellResultsCacher* gridCellResults = m_reservoirView->currentGridCellResults(); + const RimReservoirCellResultsStorage* gridCellResults = m_reservoirView->currentGridCellResults(); if (gridCellResults) m_gridScalarResultIndex = gridCellResults->cellResults()->findScalarResultIndex(resultType(), resultVariable()); } return m_gridScalarResultIndex; @@ -130,7 +130,7 @@ size_t RimResultDefinition::gridScalarIndex() const //-------------------------------------------------------------------------------------------------- void RimResultDefinition::loadResult() { - RimReservoirCellResultsCacher* gridCellResults = m_reservoirView->currentGridCellResults(); + RimReservoirCellResultsStorage* gridCellResults = m_reservoirView->currentGridCellResults(); if (gridCellResults) { m_gridScalarResultIndex = gridCellResults->findOrLoadScalarResult(resultType(), resultVariable); @@ -148,7 +148,7 @@ void RimResultDefinition::loadResult() //-------------------------------------------------------------------------------------------------- bool RimResultDefinition::hasStaticResult() const { - const RimReservoirCellResultsCacher* gridCellResults = m_reservoirView->currentGridCellResults(); + const RimReservoirCellResultsStorage* gridCellResults = m_reservoirView->currentGridCellResults(); if (hasResult() && gridCellResults->cellResults()->timeStepCount(m_gridScalarResultIndex) == 1 ) { return true; From 414172cf78f454c66317234a23c73d50551f6b12 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 19 Mar 2013 11:14:32 +0100 Subject: [PATCH 131/242] Insert new case group before script item p4#: 20964 --- ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index cc06521933..0546998c08 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -513,7 +513,8 @@ RimIdenticalGridCaseGroup* RimUiTreeModelPdm::addCaseGroup(const QModelIndex& it QModelIndex rootIndex = itemIndex.parent(); caf::PdmUiTreeItem* rootTreeItem = currentItem->parent(); - int position = rootTreeItem->childCount(); + // New case group is inserted before the last item, the script item + int position = rootTreeItem->childCount() - 1; beginInsertRows(rootIndex, position, position); @@ -524,6 +525,8 @@ RimIdenticalGridCaseGroup* RimUiTreeModelPdm::addCaseGroup(const QModelIndex& it endInsertRows(); + rebuildUiSubTree(createdObject); + insertedModelIndex = index(position, 0, rootIndex); return createdObject; From 19e2adc1bf46b954be631cd398f6cf1c5ef2c438 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 19 Mar 2013 11:27:27 +0100 Subject: [PATCH 132/242] Do not delete objects in destructor p4#: 20965 --- cafProjectDataModel/cafPdmDocument.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/cafProjectDataModel/cafPdmDocument.cpp b/cafProjectDataModel/cafPdmDocument.cpp index 133da9cac5..5ac83e9272 100644 --- a/cafProjectDataModel/cafPdmDocument.cpp +++ b/cafProjectDataModel/cafPdmDocument.cpp @@ -40,7 +40,6 @@ PdmObjectGroup::PdmObjectGroup() //-------------------------------------------------------------------------------------------------- PdmObjectGroup::~PdmObjectGroup() { - deleteObjects(); } //-------------------------------------------------------------------------------------------------- From 4368a644bfb5355d83ef1a745599fe9b4bad1685 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 19 Mar 2013 11:32:30 +0100 Subject: [PATCH 133/242] No need to clear before exit as object no longer are deleted in destructor p4#: 20966 --- cafProjectDataModel/cafPdmDocument.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/cafProjectDataModel/cafPdmDocument.h b/cafProjectDataModel/cafPdmDocument.h index db9f7036ec..8c58fe950f 100644 --- a/cafProjectDataModel/cafPdmDocument.h +++ b/cafProjectDataModel/cafPdmDocument.h @@ -77,9 +77,6 @@ public: xmlStream.setAutoFormatting(true); typedObjectGroup.writeFields(xmlStream); - - // Call clear to avoid destruction of objects - typedObjectGroup.objects().clear(); } // Read back XML into object group, factory methods will be called that will create new objects @@ -92,9 +89,6 @@ public: T* obj = dynamic_cast(destinationObjectGroup.objects[it]); if (obj) copyOfTypedObjects->push_back(obj); } - - // Call clear to avoid destruction of objects - destinationObjectGroup.objects().clear(); } }; From 27dee4d4e2cbe97076b94cb217af612a7dceaf31 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 19 Mar 2013 12:47:38 +0100 Subject: [PATCH 134/242] Added paste on gridcollection, case collection and cases Moved creation of objects into rimUiTreeModelPdm p4#: 20968 --- .../ProjectDataModel/RimCaseCollection.cpp | 17 +++++++ .../ProjectDataModel/RimCaseCollection.h | 2 + .../ProjectDataModel/RimReservoir.h | 4 +- .../ProjectDataModel/RimUiTreeModelPdm.cpp | 47 +++++++++++++++++++ .../ProjectDataModel/RimUiTreeModelPdm.h | 1 + .../ProjectDataModel/RimUiTreeView.cpp | 39 ++++++++------- .../ProjectDataModel/RimUiTreeView.h | 3 +- 7 files changed, 89 insertions(+), 24 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimCaseCollection.cpp b/ApplicationCode/ProjectDataModel/RimCaseCollection.cpp index 9840dddd6a..15d3d92682 100644 --- a/ApplicationCode/ProjectDataModel/RimCaseCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimCaseCollection.cpp @@ -22,6 +22,7 @@ #include "RimCaseCollection.h" #include "RimReservoirView.h" +#include "RimIdenticalGridCaseGroup.h" CAF_PDM_SOURCE_INIT(RimCaseCollection, "RimCaseCollection"); @@ -42,3 +43,19 @@ RimCaseCollection::~RimCaseCollection() { reservoirs.deleteAllChildObjects(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimIdenticalGridCaseGroup* RimCaseCollection::parentCaseGroup() +{ + std::vector parentObjects; + this->parentObjectsOfType(parentObjects); + + if (parentObjects.size() > 0) + { + return parentObjects[0]; + } + + return NULL; +} diff --git a/ApplicationCode/ProjectDataModel/RimCaseCollection.h b/ApplicationCode/ProjectDataModel/RimCaseCollection.h index 49989fc9b3..ae94edef8a 100644 --- a/ApplicationCode/ProjectDataModel/RimCaseCollection.h +++ b/ApplicationCode/ProjectDataModel/RimCaseCollection.h @@ -41,6 +41,8 @@ public: caf::PdmPointersField reservoirs; + RimIdenticalGridCaseGroup* parentCaseGroup(); + private: }; diff --git a/ApplicationCode/ProjectDataModel/RimReservoir.h b/ApplicationCode/ProjectDataModel/RimReservoir.h index 5f6bc4ca30..e9c422a366 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoir.h +++ b/ApplicationCode/ProjectDataModel/RimReservoir.h @@ -63,6 +63,8 @@ public: void removeResult(const QString& resultName); virtual QString locationOnDisc() const { return QString(); } + + RimCaseCollection* parentCaseCollection(); // Overridden methods from PdmObject public: @@ -76,8 +78,6 @@ protected: void computeCachedData(); void setReservoirData(RigEclipseCase* eclipseCase); -private: - RimCaseCollection* parentCaseCollection(); private: cvf::ref m_rigEclipseCase; diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index 0546998c08..ee93854073 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -535,3 +535,50 @@ RimIdenticalGridCaseGroup* RimUiTreeModelPdm::addCaseGroup(const QModelIndex& it return NULL; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUiTreeModelPdm::addCases(const QModelIndex& itemIndex, caf::PdmObjectGroup& cases) +{ + RimProject* proj = RIApplication::instance()->project(); + CVF_ASSERT(proj); + + caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex); + + RimIdenticalGridCaseGroup* gridCaseGroup = NULL; + RimCaseCollection* caseCollection = NULL; + + if (dynamic_cast(currentItem->dataObject().p())) + { + gridCaseGroup = dynamic_cast(currentItem->dataObject().p()); + caseCollection = gridCaseGroup->caseCollection(); + } + else if (dynamic_cast(currentItem->dataObject().p())) + { + caseCollection = dynamic_cast(currentItem->dataObject().p()); + gridCaseGroup = caseCollection->parentCaseGroup(); + } + else if (dynamic_cast(currentItem->dataObject().p())) + { + RimReservoir* rimReservoir = dynamic_cast(currentItem->dataObject().p()); + caseCollection = rimReservoir->parentCaseCollection(); + gridCaseGroup = caseCollection->parentCaseGroup(); + } + else + { + return; + } + + CVF_ASSERT(caseCollection); + CVF_ASSERT(gridCaseGroup); + + //itemCount = caseCollection->reservoirs().size(); + + if (gridCaseGroup) + { + proj->copyFromCaseList(gridCaseGroup, cases); + + rebuildUiSubTree(caseCollection); + } +} + diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h index 6991b29bc0..8bda65e6b6 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h @@ -107,6 +107,7 @@ public: RimCellRangeFilter* addRangeFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); RimReservoirView* addReservoirView(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); void addInputProperty(const QModelIndex& itemIndex, const QStringList& fileNames); + void addCases(const QModelIndex& itemIndex, caf::PdmObjectGroup& cases); RimStatisticalCalculation* addStatisticalCalculation(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); RimIdenticalGridCaseGroup* addCaseGroup(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index 63c372f0a3..6e9db012f6 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -40,8 +40,6 @@ RimUiTreeView::RimUiTreeView(QWidget *parent /*= 0*/) : QTreeView(parent) { setHeaderHidden(true); - - m_pdmObjectsFromClipboard = new caf::PdmObjectGroup; } //-------------------------------------------------------------------------------------------------- @@ -49,8 +47,6 @@ RimUiTreeView::RimUiTreeView(QWidget *parent /*= 0*/) //-------------------------------------------------------------------------------------------------- RimUiTreeView::~RimUiTreeView() { - delete m_pdmObjectsFromClipboard; - m_pdmObjectsFromClipboard = NULL; } //-------------------------------------------------------------------------------------------------- @@ -173,6 +169,7 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event) { QMenu menu; menu.addAction(QString("Copy"), this, SLOT(slotCopyPdmObjectToClipboard())); + menu.addAction(QString("Paste"), this, SLOT(slotPasteEclipseCases())); menu.addAction(QString("Close"), this, SLOT(slotCloseCase())); menu.addAction(QString("New View"), this, SLOT(slotAddView())); menu.exec(event->globalPos()); @@ -184,6 +181,12 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event) menu.addAction(QString("Paste"), this, SLOT(slotPasteEclipseCases())); menu.exec(event->globalPos()); } + else if (dynamic_cast(uiItem->dataObject().p())) + { + QMenu menu; + menu.addAction(QString("Paste"), this, SLOT(slotPasteEclipseCases())); + menu.exec(event->globalPos()); + } } } } @@ -826,6 +829,8 @@ void RimUiTreeView::slotAddCaseGroup() QModelIndex insertedIndex; myModel->addCaseGroup(currentIndex(), insertedIndex); setCurrentIndex(insertedIndex); + + setExpanded(insertedIndex, true); } } @@ -860,29 +865,21 @@ void RimUiTreeView::slotPasteEclipseCases() { if (!currentIndex().isValid()) return; - createPdmObjectsFromClipboard(); - if (m_pdmObjectsFromClipboard->objects().size() == 0) return; - RimUiTreeModelPdm* myModel = dynamic_cast(model()); - caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex()); + if (!myModel) return; - RimIdenticalGridCaseGroup* destinationGroup = dynamic_cast(uiItem->dataObject().p()); - if (!destinationGroup) return; + caf::PdmObjectGroup objectGroup; + createPdmObjectsFromClipboard(&objectGroup); + if (objectGroup.objects().size() == 0) return; - - RimProject* proj = RIApplication::instance()->project(); - proj->copyFromCaseList(destinationGroup, *m_pdmObjectsFromClipboard); - - myModel->rebuildUiSubTree(destinationGroup); + myModel->addCases(currentIndex(), objectGroup); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimUiTreeView::createPdmObjectsFromClipboard() +void RimUiTreeView::createPdmObjectsFromClipboard(caf::PdmObjectGroup* objectGroup) { - m_pdmObjectsFromClipboard->objects().clear(); - RimUiTreeModelPdm* myModel = dynamic_cast(model()); if (!myModel) return; @@ -896,7 +893,7 @@ void RimUiTreeView::createPdmObjectsFromClipboard() for (int i = 0; i < indexList.size(); i++) { caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(indexList.at(i)); - m_pdmObjectsFromClipboard->addObject(uiItem->dataObject().p()); + objectGroup->addObject(uiItem->dataObject().p()); } } @@ -919,7 +916,9 @@ void RimUiTreeView::keyPressEvent(QKeyEvent* keyEvent) } } - if (dynamic_cast(uiItem->dataObject().p())) + if (dynamic_cast(uiItem->dataObject().p()) + || dynamic_cast(uiItem->dataObject().p()) + || dynamic_cast(uiItem->dataObject().p())) { if (keyEvent->matches(QKeySequence::Paste)) { diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.h b/ApplicationCode/ProjectDataModel/RimUiTreeView.h index 94af760a64..70279b3668 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.h @@ -85,10 +85,9 @@ signals: private: - void createPdmObjectsFromClipboard(); + void createPdmObjectsFromClipboard(caf::PdmObjectGroup* objectGroup); virtual void keyPressEvent(QKeyEvent* keyEvent); - caf::PdmObjectGroup* m_pdmObjectsFromClipboard; }; From 50206b9dc47a96f75e67658d8fdd23b19752e927 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 20 Mar 2013 06:11:45 +0100 Subject: [PATCH 135/242] Various linux fixes and missing includes p4#: 20976 --- ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp | 4 ++-- ApplicationCode/ProjectDataModel/RigStatistics.cpp | 2 +- ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h | 4 +++- ApplicationCode/ProjectDataModel/RimUiTreeView.cpp | 2 ++ ApplicationCode/ProjectDataModel/RimUiTreeView.h | 5 ++++- ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp | 2 +- ApplicationCode/ReservoirDataModel/RigWellResults.cpp | 4 ++-- ApplicationCode/UserInterface/RIMainWindow.cpp | 4 ++-- 8 files changed, 17 insertions(+), 10 deletions(-) diff --git a/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp b/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp index 8e3a4cbb8b..fa6c63bb75 100644 --- a/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp @@ -102,12 +102,12 @@ void RifEclipseOutputFileTools::timeSteps(ecl_file_type* ecl_file, std::vector(dayFraction * 24.0 * 60.0 * 60.0); QTime time(0, 0); time = time.addSecs(seconds); QDate reportDate = simulationStart; - reportDate = reportDate.addDays(floorDayValue); + reportDate = reportDate.addDays(static_cast(floorDayValue)); QDateTime reportDateTime(reportDate, time); if (std::find(timeStepsFound.begin(), timeStepsFound.end(), reportDateTime) == timeStepsFound.end()) diff --git a/ApplicationCode/ProjectDataModel/RigStatistics.cpp b/ApplicationCode/ProjectDataModel/RigStatistics.cpp index 45de3423fe..2f609c7938 100644 --- a/ApplicationCode/ProjectDataModel/RigStatistics.cpp +++ b/ApplicationCode/ProjectDataModel/RigStatistics.cpp @@ -46,7 +46,7 @@ void RigStatistics::addNamedResult(RigReservoirCellResults* destinationCellResul // Initializes the size of the destination dataset to active union cell count - for (int i = 0; i < sourceTimeStepDates.size(); i++) + for (size_t i = 0; i < sourceTimeStepDates.size(); i++) { dataValues[i].resize(activeUnionCellCount, HUGE_VAL); } diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h index 8bda65e6b6..ea28e897c9 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h @@ -20,6 +20,7 @@ #include "cafPdmObject.h" #include "cafPdmPointer.h" +#include "cafPdmDocument.h" #include "cafUiTreeModelPdm.h" #include @@ -45,7 +46,8 @@ public: { } - MimeDataWithIndexes(const MimeDataWithIndexes & other) + + MimeDataWithIndexes(const MimeDataWithIndexes & other) : QMimeData() { setIndexes(other.indexes()); } diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index 6e9db012f6..2034a8a277 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -18,6 +18,8 @@ #include "RIStdInclude.h" +#include "cafPdmDocument.h" + #include "RimUiTreeView.h" #include "RimUiTreeModelPdm.h" #include "RimReservoirView.h" diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.h b/ApplicationCode/ProjectDataModel/RimUiTreeView.h index 70279b3668..bc048157cf 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.h @@ -23,7 +23,10 @@ #include class QItemSelection; -class PdmObjectGroup; + +namespace caf { + class PdmObjectGroup; +} //================================================================================================== /// diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp index 5397ed8325..f72efdf255 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp @@ -441,4 +441,4 @@ void RigEclipseCase::closeReaderInterface() readerInterface->close(); } } -*/ \ No newline at end of file +*/ diff --git a/ApplicationCode/ReservoirDataModel/RigWellResults.cpp b/ApplicationCode/ReservoirDataModel/RigWellResults.cpp index 4a752ded4a..b1080e2bac 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellResults.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellResults.cpp @@ -54,7 +54,7 @@ void RigWellResults::computeMappingFromResultTimeIndicesToWellTimeIndices(const } qDebug() << "Result TimeStamps"; - for (int i = 0; i < resultTimes.size(); i++) + for (size_t i = 0; i < resultTimes.size(); i++) { qDebug() << resultTimes[i].toString(); } @@ -65,7 +65,7 @@ void RigWellResults::computeMappingFromResultTimeIndicesToWellTimeIndices(const size_t wellIdx = 0; size_t activeWellIdx = cvf::UNDEFINED_SIZE_T; - while (wellIdx <= m_wellCellsTimeSteps.size() && resultIdx < resultTimes.size()) + while (wellIdx <= m_wellCellsTimeSteps.size() && resultIdx < static_cast(resultTimes.size())) { if (wellIdx < m_wellCellsTimeSteps.size() && m_wellCellsTimeSteps[wellIdx].m_timestamp <= resultTimes[resultIdx]) { diff --git a/ApplicationCode/UserInterface/RIMainWindow.cpp b/ApplicationCode/UserInterface/RIMainWindow.cpp index cf3860f9e7..961eafb423 100644 --- a/ApplicationCode/UserInterface/RIMainWindow.cpp +++ b/ApplicationCode/UserInterface/RIMainWindow.cpp @@ -548,7 +548,7 @@ void RIMainWindow::refreshAnimationActions() { std::vector timeStepDates = app->activeReservoirView()->currentGridCellResults()->cellResults()->timeStepDates(0); bool showHoursAndMinutes = false; - for (int i = 0; i < timeStepDates.size(); i++) + for (size_t i = 0; i < timeStepDates.size(); i++) { if (timeStepDates[i].time().hour() != 0.0 || timeStepDates[i].time().minute() != 0.0) { @@ -562,7 +562,7 @@ void RIMainWindow::refreshAnimationActions() formatString += " - hh:mm"; } - for (int i = 0; i < timeStepDates.size(); i++) + for (size_t i = 0; i < timeStepDates.size(); i++) { timeStepStrings += timeStepDates[i].toString(formatString); } From c9b4376d8c46d3603c7109fd11bdab713a083a7d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 20 Mar 2013 07:04:34 +0100 Subject: [PATCH 136/242] Use -1 as argument when adding children, as they always must be appended to collection p4#: 20978 --- cafUserInterface/cafUiTreeModelPdm.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cafUserInterface/cafUiTreeModelPdm.cpp b/cafUserInterface/cafUiTreeModelPdm.cpp index f9bc0a315e..85a5112cb5 100644 --- a/cafUserInterface/cafUiTreeModelPdm.cpp +++ b/cafUserInterface/cafUiTreeModelPdm.cpp @@ -426,6 +426,7 @@ PdmUiTreeItem* UiTreeItemBuilderPdm::buildViewItems(PdmUiTreeItem* parentTreeIte return NULL; } + // NOTE: if position is -1, the item is appended to the parent tree item PdmUiTreeItem* objectTreeItem = new PdmUiTreeItem(parentTreeItem, position, object); std::vector fields; @@ -445,7 +446,8 @@ PdmUiTreeItem* UiTreeItemBuilderPdm::buildViewItems(PdmUiTreeItem* parentTreeIte caf::PdmObject* childObj = children[i]; assert(childObj); - UiTreeItemBuilderPdm::buildViewItems(objectTreeItem, position, childObj); + // NOTE: -1 as second argument indicates that child objects will be appended to collection + UiTreeItemBuilderPdm::buildViewItems(objectTreeItem, -1, childObj); } } From 45ce4097e12c3288581c1a2921659658ab5f730d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 20 Mar 2013 07:14:27 +0100 Subject: [PATCH 137/242] Use buildViewItems instead of rebuildUiSubTree p4#: 20979 --- .../ProjectDataModel/RimUiTreeModelPdm.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index ee93854073..832cf1a15a 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -346,14 +346,13 @@ RimReservoirView* RimUiTreeModelPdm::addReservoirView(const QModelIndex& itemInd int viewCount = rowCount(collectionIndex); beginInsertRows(collectionIndex, viewCount, viewCount); - caf::PdmUiTreeItem* childItem = new caf::PdmUiTreeItem(collectionItem, viewCount, insertedView); - + // NOTE: -1 as second argument indicates append + caf::PdmUiTreeItem* childItem = caf::UiTreeItemBuilderPdm::buildViewItems(collectionItem, -1, insertedView); + endInsertRows(); insertedView->loadDataAndUpdate(); - rebuildUiSubTree(insertedView); - return insertedView; } @@ -521,12 +520,9 @@ RimIdenticalGridCaseGroup* RimUiTreeModelPdm::addCaseGroup(const QModelIndex& it RimIdenticalGridCaseGroup* createdObject = new RimIdenticalGridCaseGroup; proj->caseGroups().push_back(createdObject); - caf::PdmUiTreeItem* childItem = new caf::PdmUiTreeItem(rootTreeItem, position, createdObject); - + caf::PdmUiTreeItem* childItem = caf::UiTreeItemBuilderPdm::buildViewItems(rootTreeItem, position, createdObject); endInsertRows(); - rebuildUiSubTree(createdObject); - insertedModelIndex = index(position, 0, rootIndex); return createdObject; From 22aee27333b42536d884689ad84fa56b7ccbdeab Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 20 Mar 2013 07:42:26 +0100 Subject: [PATCH 138/242] Improved paste of pdm objects p4#: 20980 --- .../ProjectDataModel/RimProject.cpp | 44 +---------------- ApplicationCode/ProjectDataModel/RimProject.h | 3 +- .../ProjectDataModel/RimUiTreeModelPdm.cpp | 49 ++++++++++++++++--- .../ProjectDataModel/RimUiTreeModelPdm.h | 2 +- .../ProjectDataModel/RimUiTreeView.cpp | 12 ++--- .../ProjectDataModel/RimUiTreeView.h | 2 +- 6 files changed, 53 insertions(+), 59 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 379f742e82..73b31d1fb9 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -233,7 +233,7 @@ RigMainGrid* RimProject::registerCaseInGridCollection(RigEclipseCase* rigEclipse //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimProject::insertCaseInCaseGroup(RimReservoir* rimReservoir, RimIdenticalGridCaseGroup* caseGroup) +void RimProject::insertCaseInCaseGroup(RimIdenticalGridCaseGroup* caseGroup, RimReservoir* rimReservoir) { CVF_ASSERT(rimReservoir); @@ -243,45 +243,3 @@ void RimProject::insertCaseInCaseGroup(RimReservoir* rimReservoir, RimIdenticalG caseGroup->addCase(rimReservoir); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimProject::copyFromCaseList(RimIdenticalGridCaseGroup* caseGroup, const caf::PdmObjectGroup& caseList) -{ - std::vector > typedObjects; - caseList.createCopyByType(&typedObjects); - - if (typedObjects.size() == 0) return; - - RigEclipseCase* mainEclipseCase = NULL; - if (caseGroup->caseCollection()->reservoirs().size() > 0) - { - RimReservoir* mainReservoir = caseGroup->caseCollection()->reservoirs()[0];; - mainEclipseCase = mainReservoir->reservoirData(); - } - - for (size_t i = 0; i < typedObjects.size(); i++) - { - RimReservoir* rimReservoir = typedObjects[i]; - caf::PdmObjectGroup::initAfterReadTraversal(rimReservoir); - - RimResultReservoir* rimResultReservoir = dynamic_cast(rimReservoir); - if (rimResultReservoir) - { - if (caseGroup->mainGrid() == NULL) - { - rimResultReservoir->openEclipseGridFile(); - mainEclipseCase = rimResultReservoir->reservoirData(); - } - else - { - if (!rimResultReservoir->openAndReadActiveCellData(mainEclipseCase)) - { - CVF_ASSERT(false); - } - } - - insertCaseInCaseGroup(rimResultReservoir, caseGroup); - } - } -} diff --git a/ApplicationCode/ProjectDataModel/RimProject.h b/ApplicationCode/ProjectDataModel/RimProject.h index 12aa85dd09..2d9f70c88c 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.h +++ b/ApplicationCode/ProjectDataModel/RimProject.h @@ -48,8 +48,7 @@ public: void close(); - void copyFromCaseList(RimIdenticalGridCaseGroup* caseGroup, const caf::PdmObjectGroup& caseList); - void insertCaseInCaseGroup(RimReservoir* rimReservoir, RimIdenticalGridCaseGroup* caseGroup); + void insertCaseInCaseGroup(RimIdenticalGridCaseGroup* caseGroup, RimReservoir* rimReservoir); void moveEclipseCaseIntoCaseGroup(RimReservoir* rimReservoir); void removeEclipseCaseFromAllGroups(RimReservoir* rimReservoir); diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index 832cf1a15a..28294365ec 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -36,6 +36,7 @@ #include "cafPdmField.h" #include "RimInputReservoir.h" #include "RimStatisticalCalculation.h" +#include "RimResultReservoir.h" //-------------------------------------------------------------------------------------------------- /// @@ -534,7 +535,7 @@ RimIdenticalGridCaseGroup* RimUiTreeModelPdm::addCaseGroup(const QModelIndex& it //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimUiTreeModelPdm::addCases(const QModelIndex& itemIndex, caf::PdmObjectGroup& cases) +void RimUiTreeModelPdm::addObjects(const QModelIndex& itemIndex, caf::PdmObjectGroup& pdmObjects) { RimProject* proj = RIApplication::instance()->project(); CVF_ASSERT(proj); @@ -568,13 +569,49 @@ void RimUiTreeModelPdm::addCases(const QModelIndex& itemIndex, caf::PdmObjectGro CVF_ASSERT(caseCollection); CVF_ASSERT(gridCaseGroup); - //itemCount = caseCollection->reservoirs().size(); - if (gridCaseGroup) { - proj->copyFromCaseList(gridCaseGroup, cases); - - rebuildUiSubTree(caseCollection); + std::vector > typedObjects; + pdmObjects.createCopyByType(&typedObjects); + + RigEclipseCase* mainEclipseCase = NULL; + if (gridCaseGroup->caseCollection()->reservoirs().size() > 0) + { + RimReservoir* mainReservoir = gridCaseGroup->caseCollection()->reservoirs()[0];; + mainEclipseCase = mainReservoir->reservoirData(); + } + + for (size_t i = 0; i < typedObjects.size(); i++) + { + RimResultReservoir* rimResultReservoir = typedObjects[i]; + + if (gridCaseGroup->mainGrid() == NULL) + { + rimResultReservoir->openEclipseGridFile(); + mainEclipseCase = rimResultReservoir->reservoirData(); + } + else + { + if (!rimResultReservoir->openAndReadActiveCellData(mainEclipseCase)) + { + CVF_ASSERT(false); + } + } + + proj->insertCaseInCaseGroup(gridCaseGroup, rimResultReservoir); + + caf::PdmObjectGroup::initAfterReadTraversal(rimResultReservoir); + + { + QModelIndex rootIndex = getModelIndexFromPdmObject(caseCollection); + caf::PdmUiTreeItem* caseCollectionUiItem = getTreeItemFromIndex(rootIndex); + + int position = rowCount(rootIndex); + beginInsertRows(rootIndex, position, position); + caf::PdmUiTreeItem* childItem = caf::UiTreeItemBuilderPdm::buildViewItems(caseCollectionUiItem, -1, rimResultReservoir); + endInsertRows(); + } + } } } diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h index ea28e897c9..362b0b27db 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h @@ -109,7 +109,7 @@ public: RimCellRangeFilter* addRangeFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); RimReservoirView* addReservoirView(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); void addInputProperty(const QModelIndex& itemIndex, const QStringList& fileNames); - void addCases(const QModelIndex& itemIndex, caf::PdmObjectGroup& cases); + void addObjects(const QModelIndex& itemIndex, caf::PdmObjectGroup& pdmObjects); RimStatisticalCalculation* addStatisticalCalculation(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); RimIdenticalGridCaseGroup* addCaseGroup(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index 2034a8a277..1e26f27e39 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -171,7 +171,7 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event) { QMenu menu; menu.addAction(QString("Copy"), this, SLOT(slotCopyPdmObjectToClipboard())); - menu.addAction(QString("Paste"), this, SLOT(slotPasteEclipseCases())); + menu.addAction(QString("Paste"), this, SLOT(slotPastePdmObjects())); menu.addAction(QString("Close"), this, SLOT(slotCloseCase())); menu.addAction(QString("New View"), this, SLOT(slotAddView())); menu.exec(event->globalPos()); @@ -180,13 +180,13 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event) { QMenu menu; menu.addAction(QString("New Case Group"), this, SLOT(slotAddCaseGroup())); - menu.addAction(QString("Paste"), this, SLOT(slotPasteEclipseCases())); + menu.addAction(QString("Paste"), this, SLOT(slotPastePdmObjects())); menu.exec(event->globalPos()); } else if (dynamic_cast(uiItem->dataObject().p())) { QMenu menu; - menu.addAction(QString("Paste"), this, SLOT(slotPasteEclipseCases())); + menu.addAction(QString("Paste"), this, SLOT(slotPastePdmObjects())); menu.exec(event->globalPos()); } } @@ -863,7 +863,7 @@ void RimUiTreeView::slotCopyPdmObjectToClipboard() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimUiTreeView::slotPasteEclipseCases() +void RimUiTreeView::slotPastePdmObjects() { if (!currentIndex().isValid()) return; @@ -874,7 +874,7 @@ void RimUiTreeView::slotPasteEclipseCases() createPdmObjectsFromClipboard(&objectGroup); if (objectGroup.objects().size() == 0) return; - myModel->addCases(currentIndex(), objectGroup); + myModel->addObjects(currentIndex(), objectGroup); } //-------------------------------------------------------------------------------------------------- @@ -924,7 +924,7 @@ void RimUiTreeView::keyPressEvent(QKeyEvent* keyEvent) { if (keyEvent->matches(QKeySequence::Paste)) { - slotPasteEclipseCases(); + slotPastePdmObjects(); keyEvent->setAccepted(true); return; diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.h b/ApplicationCode/ProjectDataModel/RimUiTreeView.h index bc048157cf..733ccd062c 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.h @@ -79,7 +79,7 @@ private slots: void slotAddCaseGroup(); void slotCopyPdmObjectToClipboard(); - void slotPasteEclipseCases(); + void slotPastePdmObjects(); void slotSelectionChanged(const QItemSelection & selected, const QItemSelection & deselected); From 9abe7a3b135e8a1cfd41d0568a16329f114cc5a0 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 20 Mar 2013 11:35:27 +0100 Subject: [PATCH 139/242] Improved handling when deleting all cases and adding new case to case group p4#: 20990 --- .../RimIdenticalGridCaseGroup.cpp | 13 +++++++++++++ .../ProjectDataModel/RimIdenticalGridCaseGroup.h | 1 + ApplicationCode/ProjectDataModel/RimProject.cpp | 16 ++-------------- ApplicationCode/ProjectDataModel/RimProject.h | 2 +- .../ProjectDataModel/RimUiTreeModelPdm.cpp | 2 +- 5 files changed, 18 insertions(+), 16 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index 22053140db..5f1d4d170c 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -90,6 +90,19 @@ void RimIdenticalGridCaseGroup::addCase(RimReservoir* reservoir) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIdenticalGridCaseGroup::removeCase(RimReservoir* reservoir) +{ + caseCollection()->reservoirs().removeChildObject(reservoir); + + if (caseCollection()->reservoirs().size() == 0) + { + m_mainGrid = NULL; + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h index 8ffacb62c4..81c7edfed2 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h @@ -45,6 +45,7 @@ public: caf::PdmField name; void addCase(RimReservoir* reservoir); + void removeCase(RimReservoir* reservoir); caf::PdmField caseCollection; caf::PdmField statisticalReservoirCollection; diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 73b31d1fb9..1395ec4e39 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -167,27 +167,15 @@ void RimProject::moveEclipseCaseIntoCaseGroup(RimReservoir* rimReservoir) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimProject::removeEclipseCaseFromAllGroups(RimReservoir* reservoir) +void RimProject::removeCaseFromAllGroups(RimReservoir* reservoir) { m_gridCollection->removeCase(reservoir->reservoirData()); - std::vector emptyCaseGroups; for (size_t i = 0; i < caseGroups.size(); i++) { RimIdenticalGridCaseGroup* cg = caseGroups()[i]; - cg->caseCollection()->reservoirs().removeChildObject(reservoir); - - if (cg->caseCollection()->reservoirs().size() == 0) - { - emptyCaseGroups.push_back(cg); - } - } - - for (size_t i = 0; i < emptyCaseGroups.size(); i++) - { - caseGroups().removeChildObject(emptyCaseGroups[i]); - delete emptyCaseGroups[i]; + cg->removeCase(reservoir); } reservoirs().removeChildObject(reservoir); diff --git a/ApplicationCode/ProjectDataModel/RimProject.h b/ApplicationCode/ProjectDataModel/RimProject.h index 2d9f70c88c..49e4d56ded 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.h +++ b/ApplicationCode/ProjectDataModel/RimProject.h @@ -51,7 +51,7 @@ public: void insertCaseInCaseGroup(RimIdenticalGridCaseGroup* caseGroup, RimReservoir* rimReservoir); void moveEclipseCaseIntoCaseGroup(RimReservoir* rimReservoir); - void removeEclipseCaseFromAllGroups(RimReservoir* rimReservoir); + void removeCaseFromAllGroups(RimReservoir* rimReservoir); private: RigMainGrid* registerCaseInGridCollection(RigEclipseCase* rigEclipseCase); diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index 28294365ec..e7c8aaa50f 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -220,7 +220,7 @@ void RimUiTreeModelPdm::deleteReservoir(const QModelIndex& itemIndex) removeRow(itemIndex.row(), itemIndex.parent()); RimProject* proj = RIApplication::instance()->project(); - proj->removeEclipseCaseFromAllGroups(reservoir); + proj->removeCaseFromAllGroups(reservoir); delete reservoir; } From 06a2f7e17ff9d4879b4b7d3846d29ce2a74dd721 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 20 Mar 2013 12:08:40 +0100 Subject: [PATCH 140/242] Added general function used to remove(and delete) pdmObject from pdmPointersField Used when closing a grid group p4#: 20992 --- .../ProjectDataModel/RimUiTreeModelPdm.cpp | 40 +++++++++++++++++++ .../ProjectDataModel/RimUiTreeModelPdm.h | 2 + .../ProjectDataModel/RimUiTreeView.cpp | 13 ++++++ .../ProjectDataModel/RimUiTreeView.h | 2 + 4 files changed, 57 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index e7c8aaa50f..2e27e41983 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -615,3 +615,43 @@ void RimUiTreeModelPdm::addObjects(const QModelIndex& itemIndex, caf::PdmObjectG } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimUiTreeModelPdm::deleteObjectFromPdmPointersField(const QModelIndex& itemIndex) +{ + if (!itemIndex.isValid()) + { + return false; + } + + caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex); + CVF_ASSERT(currentItem); + + caf::PdmObject* currentPdmObject = currentItem->dataObject().p(); + CVF_ASSERT(currentPdmObject); + + std::vector parentFields; + currentPdmObject->parentFields(parentFields); + + if (parentFields.size() == 1) + { + beginRemoveRows(itemIndex.parent(), itemIndex.row(), itemIndex.row()); + if (currentItem->parent()) + { + currentItem->parent()->removeChildren(itemIndex.row(), 1); + } + endRemoveRows(); + + caf::PdmPointersField* caseGroup = dynamic_cast *>(parentFields[0]); + if (caseGroup) + { + caseGroup->removeChildObject(currentPdmObject); + + delete currentPdmObject; + } + } + + return true; +} + diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h index 362b0b27db..4055cdc219 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h @@ -114,6 +114,8 @@ public: RimStatisticalCalculation* addStatisticalCalculation(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); RimIdenticalGridCaseGroup* addCaseGroup(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); + bool deleteObjectFromPdmPointersField(const QModelIndex& itemIndex); + void updateScriptPaths(); private slots: diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index 1e26f27e39..285eb90519 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -181,6 +181,7 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event) QMenu menu; menu.addAction(QString("New Case Group"), this, SLOT(slotAddCaseGroup())); menu.addAction(QString("Paste"), this, SLOT(slotPastePdmObjects())); + menu.addAction(QString("Close"), this, SLOT(slotDeleteObjectFromPdmPointersField())); menu.exec(event->globalPos()); } else if (dynamic_cast(uiItem->dataObject().p())) @@ -836,6 +837,18 @@ void RimUiTreeView::slotAddCaseGroup() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUiTreeView::slotDeleteObjectFromPdmPointersField() +{ + RimUiTreeModelPdm* myModel = dynamic_cast(model()); + if (myModel) + { + myModel->deleteObjectFromPdmPointersField(currentIndex()); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.h b/ApplicationCode/ProjectDataModel/RimUiTreeView.h index 733ccd062c..07dc53f5cb 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.h @@ -76,7 +76,9 @@ private slots: void slotNewStatisticalCase(); void slotComputeStatisticalCases(); + void slotAddCaseGroup(); + void slotDeleteObjectFromPdmPointersField(); void slotCopyPdmObjectToClipboard(); void slotPastePdmObjects(); From ddade8a6cfec71a7667b0f35e36de954385fd572 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 20 Mar 2013 13:40:26 +0100 Subject: [PATCH 141/242] Removed duplicate calls setupBeforeSave and initAfterRead p4#: 20998 --- cafProjectDataModel/cafPdmDocument.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/cafProjectDataModel/cafPdmDocument.cpp b/cafProjectDataModel/cafPdmDocument.cpp index 5ac83e9272..8bc3cac261 100644 --- a/cafProjectDataModel/cafPdmDocument.cpp +++ b/cafProjectDataModel/cafPdmDocument.cpp @@ -92,7 +92,6 @@ void PdmObjectGroup::initAfterReadTraversal(PdmObject* object) for (cIdx = 0; cIdx < children.size(); ++cIdx) { PdmObjectGroup::initAfterReadTraversal(children[cIdx]); - if (children[cIdx]) children[cIdx]->initAfterRead(); } object->initAfterRead(); @@ -203,7 +202,6 @@ void PdmDocument::setupBeforeSaveTraversal(PdmObject * object) for (cIdx = 0; cIdx < children.size(); ++cIdx) { PdmDocument::setupBeforeSaveTraversal(children[cIdx]); - if (children[cIdx]) children[cIdx]->setupBeforeSave(); } object->setupBeforeSave(); From d5b056b078669cbd5ef3424cfbe851bd33ff2172 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 20 Mar 2013 13:49:32 +0100 Subject: [PATCH 142/242] Load and update views after copy p4#: 21000 --- ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index 2e27e41983..7b09a61663 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -611,6 +611,12 @@ void RimUiTreeModelPdm::addObjects(const QModelIndex& itemIndex, caf::PdmObjectG caf::PdmUiTreeItem* childItem = caf::UiTreeItemBuilderPdm::buildViewItems(caseCollectionUiItem, -1, rimResultReservoir); endInsertRows(); } + + for (size_t i = 0; i < rimResultReservoir->reservoirViews.size(); i++) + { + RimReservoirView* riv = rimResultReservoir->reservoirViews()[i]; + riv->loadDataAndUpdate(); + } } } } From ad8cbfa6516c29bc3ea90558e5abdb036155e441 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 20 Mar 2013 13:56:17 +0100 Subject: [PATCH 143/242] Caf::Pdm: Added better Error messages and Recovery when encountering unknown field names and class types p4#: 21001 --- cafProjectDataModel/cafPdmField.inl | 94 ++++++++++++++++++++++------ cafProjectDataModel/cafPdmObject.cpp | 10 ++- 2 files changed, 83 insertions(+), 21 deletions(-) diff --git a/cafProjectDataModel/cafPdmField.inl b/cafProjectDataModel/cafPdmField.inl index d2654c8f2b..9d8c635f41 100644 --- a/cafProjectDataModel/cafPdmField.inl +++ b/cafProjectDataModel/cafPdmField.inl @@ -19,6 +19,7 @@ #include "cafPdmObject.h" #include +#include #include "cafPdmUiFieldEditorHandle.h" namespace caf @@ -226,26 +227,66 @@ template void caf::PdmField::readFieldData(QXmlStreamReader& xmlStream) { PdmFieldIOHelper::skipCharactersAndComments(xmlStream); - if (!xmlStream.isStartElement()) return; // Todo: Error handling - - QString className = xmlStream.name().toString(); - - if (m_fieldValue.isNull()) + if (!xmlStream.isStartElement()) { - m_fieldValue.setRawPtr(caf::PdmObjectFactory::instance()->create(className)); - if (m_fieldValue.notNull()) - { - m_fieldValue.rawPtr()->addParentField(this); - } + return; // This happens when the field is "shortcut" empty (written like: ) } - if (m_fieldValue.isNull()) return; // Warning: Unknown className read + QString className = xmlStream.name().toString(); + PdmObject* obj = NULL; - if (xmlStream.name() != m_fieldValue.rawPtr()->classKeyword()) return; // Error: Field contains different class type than on file + // Create an object if needed + if (m_fieldValue.isNull()) + { + obj = caf::PdmObjectFactory::instance()->create(className); - m_fieldValue.rawPtr()->readFields(xmlStream); + if (obj == NULL) + { + std::cout << "Line " << xmlStream.lineNumber() << ": Warning: Unknown object type with class name: " << className.toLatin1().data() << " found while reading the field : " << this->keyword().toLatin1().data() << std::endl; + + xmlStream.skipCurrentElement(); // Skip to the endelement of the object we was supposed to read + xmlStream.skipCurrentElement(); // Skip to the endelement of this field + return; + } + else + { + if (dynamic_cast(obj) == NULL) + { + assert(false); // Inconsistency in the factory. It creates objects of wrong type from the ClassKeyword + + xmlStream.skipCurrentElement(); // Skip to the endelement of the object we was supposed to read + xmlStream.skipCurrentElement(); // Skip to the endelement of this field + + return; + } + + m_fieldValue.setRawPtr(obj); + obj->addParentField(this); + } + } + else + { + obj = m_fieldValue.rawPtr(); + } + + if (className != obj->classKeyword()) + { + // Error: Field contains different class type than on file + std::cout << "Line " << xmlStream.lineNumber() << ": Warning: Unknown object type with class name: " << className.toLatin1().data() << " found while reading the field : " << this->keyword().toLatin1().data() << std::endl; + std::cout << " Expected class name: " << obj->classKeyword().toLatin1().data() << std::endl; + + xmlStream.skipCurrentElement(); // Skip to the endelement of the object we was supposed to read + xmlStream.skipCurrentElement(); // Skip to the endelement of this field + + return; + } + + // Everything seems ok, so read the contents of the object: + + obj->readFields(xmlStream); + + // Make stream point to endElement of this field - // Make stream point to end of element QXmlStreamReader::TokenType type; type = xmlStream.readNext(); PdmFieldIOHelper::skipCharactersAndComments(xmlStream); @@ -540,8 +581,17 @@ template { // Warning: Unknown className read // Skip to corresponding end element - xmlStream.skipCurrentElement(); + + std::cout << "Line " << xmlStream.lineNumber() << ": Warning: Unknown object type with class name: " << className.toLatin1().data() << " found while reading the field : " << this->keyword().toLatin1().data() << std::endl; + + // Skip to EndElement of the object + xmlStream.skipCurrentElement(); + + // Jump off the end element, and head for next start element (or the final EndElement of the field) + QXmlStreamReader::TokenType type; + type = xmlStream.readNext(); PdmFieldIOHelper::skipCharactersAndComments(xmlStream); + continue; } @@ -549,18 +599,24 @@ template if (currentObject == NULL) { - // Warning: Inconsistency in factory !! Assert ? - // Skip to corresponding end element + assert(false); // There is an inconsistency in the factory. It creates objects of type not matching the ClassKeyword + + // Skip to EndElement of the object xmlStream.skipCurrentElement(); + + // Jump off the end element, and head for next start element (or the final EndElement of the field) + QXmlStreamReader::TokenType type; + type = xmlStream.readNext(); PdmFieldIOHelper::skipCharactersAndComments(xmlStream); + continue; } currentObject->readFields(xmlStream); this->push_back(currentObject); - // Skip comments and for some reason: Characters. The last bit should not be correct, - // but Qt reports a character token between EndElement and StartElement + // Jump off the end element, and head for next start element (or the final EndElement of the field) + // Qt reports a character token between EndElements and StartElements so skip it QXmlStreamReader::TokenType type; type = xmlStream.readNext(); diff --git a/cafProjectDataModel/cafPdmObject.cpp b/cafProjectDataModel/cafPdmObject.cpp index 7d02f36a45..ed063420cd 100644 --- a/cafProjectDataModel/cafPdmObject.cpp +++ b/cafProjectDataModel/cafPdmObject.cpp @@ -30,10 +30,10 @@ namespace caf //-------------------------------------------------------------------------------------------------- /// Reads all the fields into this PdmObject -/// Assumes xmlStream points to the start element token of the containing object. +/// Assumes xmlStream points to the start element token of the PdmObject for which to read fields. /// ( and not first token of object content) /// This makes attribute based field storage possible. -/// Leaves the xmlStream pointing to the EndElement corresponding to the start element. +/// Leaves the xmlStream pointing to the EndElement of the PdmObject. //-------------------------------------------------------------------------------------------------- void PdmObject::readFields (QXmlStreamReader& xmlStream ) { @@ -48,6 +48,11 @@ void PdmObject::readFields (QXmlStreamReader& xmlStream ) case QXmlStreamReader::StartElement: { QString name = xmlStream.name().toString(); + if (name == QString("SimpleObjPtrField")) + { + int a; + a = 2 + 7; + } PdmFieldHandle* currentField = findField(name); if (currentField) { @@ -76,6 +81,7 @@ void PdmObject::readFields (QXmlStreamReader& xmlStream ) case QXmlStreamReader::EndElement: { // End of object. + QString name = xmlStream.name().toString(); // For debugging isObjectFinished = true; } break; From 1a113b83d3948d539ab951ae947332f49fd300e6 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 20 Mar 2013 15:04:28 +0100 Subject: [PATCH 144/242] As QModelIndex is stored on clipboard, clear after move/delete operations Added support for multiple delete of reservoir cases p4#: 21007 --- .../ProjectDataModel/RimUiTreeModelPdm.cpp | 52 +++++++++++++++---- .../ProjectDataModel/RimUiTreeModelPdm.h | 4 +- .../ProjectDataModel/RimUiTreeView.cpp | 22 +++++++- cafUserInterface/cafUiTreeModelPdm.h | 2 +- 4 files changed, 68 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index 7b09a61663..3385dc91a8 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -140,6 +140,9 @@ bool RimUiTreeModelPdm::deletePropertyFilter(const QModelIndex& itemIndex) { propertyFilterCollection->reservoirView()->createDisplayModelAndRedraw(); } + + clearClipboard(); + return true; } @@ -178,6 +181,8 @@ bool RimUiTreeModelPdm::deleteRangeFilter(const QModelIndex& itemIndex) rangeFilterCollection->reservoirView()->createDisplayModelAndRedraw(); } + clearClipboard(); + return true; } @@ -200,29 +205,36 @@ bool RimUiTreeModelPdm::deleteReservoirView(const QModelIndex& itemIndex) reservoirView->eclipseCase()->removeReservoirView(reservoirView); delete reservoirView; + clearClipboard(); + return true; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimUiTreeModelPdm::deleteReservoir(const QModelIndex& itemIndex) +void RimUiTreeModelPdm::deleteReservoir(RimReservoir* reservoir) { - CVF_ASSERT(itemIndex.isValid()); + RimCaseCollection* caseCollection = reservoir->parentCaseCollection(); + QModelIndex caseCollectionModelIndex = getModelIndexFromPdmObject(caseCollection); + if (!caseCollectionModelIndex.isValid()) return; - caf::PdmUiTreeItem* uiItem = getTreeItemFromIndex(itemIndex); - CVF_ASSERT(uiItem); + QModelIndex mi = getModelIndexFromPdmObjectRecursive(caseCollectionModelIndex, reservoir); + if (mi.isValid()) + { + caf::PdmUiTreeItem* uiItem = getTreeItemFromIndex(mi); + CVF_ASSERT(uiItem); - RimReservoir* reservoir = dynamic_cast(uiItem->dataObject().p()); - CVF_ASSERT(reservoir); - - // Remove Ui items pointing at the pdm object to delete - removeRow(itemIndex.row(), itemIndex.parent()); + // Remove Ui items pointing at the pdm object to delete + removeRow(mi.row(), mi.parent()); + } RimProject* proj = RIApplication::instance()->project(); proj->removeCaseFromAllGroups(reservoir); delete reservoir; + + clearClipboard(); } //-------------------------------------------------------------------------------------------------- @@ -456,6 +468,8 @@ void RimUiTreeModelPdm::deleteInputProperty(const QModelIndex& itemIndex) inputReservoir->removeProperty(inputProperty); delete inputProperty; + + clearClipboard(); } //-------------------------------------------------------------------------------------------------- @@ -658,6 +672,26 @@ bool RimUiTreeModelPdm::deleteObjectFromPdmPointersField(const QModelIndex& item } } + clearClipboard(); + return true; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUiTreeModelPdm::clearClipboard() +{ + // We use QModelIndex to identify a selection on the clipboard + // When we delete or move an entity, the clipboard data might be invalid + + QClipboard* clipboard = QApplication::clipboard(); + if (clipboard) + { + if (dynamic_cast(clipboard->mimeData())) + { + clipboard->clear(); + } + } +} + diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h index 4055cdc219..59aabbc789 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h @@ -29,6 +29,7 @@ class QFileSystemWatcher; class RimCellPropertyFilter; class RimCellRangeFilter; +class RimReservoir; class RimReservoirView; class RimInputProperty; class RimStatisticalCalculation; @@ -103,7 +104,7 @@ public: bool deletePropertyFilter(const QModelIndex& itemIndex); bool deleteReservoirView(const QModelIndex& itemIndex); void deleteInputProperty(const QModelIndex& itemIndex); - void deleteReservoir(const QModelIndex& itemIndex); + void deleteReservoir(RimReservoir* reservoir); RimCellPropertyFilter* addPropertyFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); RimCellRangeFilter* addRangeFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); @@ -120,6 +121,7 @@ public: private slots: void slotRefreshScriptTree(QString path); + void clearClipboard(); private: QFileSystemWatcher* m_scriptChangeDetector; diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index 285eb90519..ea6a245a1e 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -34,6 +34,7 @@ #include "RimBinaryExportSettings.h" #include "RigReservoirCellResults.h" #include "RimStatisticalCalculation.h" +#include "RimResultReservoir.h" //-------------------------------------------------------------------------------------------------- /// @@ -783,7 +784,26 @@ void RimUiTreeView::slotCloseCase() RimUiTreeModelPdm* myModel = dynamic_cast(model()); if (myModel) { - myModel->deleteReservoir(currentIndex()); + QItemSelectionModel* m = selectionModel(); + CVF_ASSERT(m); + + caf::PdmObjectGroup group; + + QModelIndexList mil = m->selectedRows(); + for (int i = 0; i < mil.size(); i++) + { + caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(mil.at(i)); + group.addObject(uiItem->dataObject().p()); + } + + std::vector > typedObjects; + group.objectsByType(&typedObjects); + + for (size_t i = 0; i < typedObjects.size(); i++) + { + RimReservoir* rimReservoir = typedObjects[i]; + myModel->deleteReservoir(rimReservoir); + } } } diff --git a/cafUserInterface/cafUiTreeModelPdm.h b/cafUserInterface/cafUiTreeModelPdm.h index 77fcf07bd6..0dfbf2593a 100644 --- a/cafUserInterface/cafUiTreeModelPdm.h +++ b/cafUserInterface/cafUiTreeModelPdm.h @@ -65,7 +65,7 @@ public: virtual bool insertRows(int position, int rows, const QModelIndex &parent = QModelIndex()); virtual bool removeRows(int position, int rows, const QModelIndex &parent = QModelIndex()); -private: +protected: QModelIndex getModelIndexFromPdmObjectRecursive(const QModelIndex& root, const PdmObject * object) const; private: From 53d7d62759129dd3087c6522ff35b4b868c514e1 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 20 Mar 2013 15:11:27 +0100 Subject: [PATCH 145/242] Made adding of objects more robust p4#: 21009 --- .../ProjectDataModel/RimUiTreeModelPdm.cpp | 12 ++++++++---- ApplicationCode/UserInterface/RIMainWindow.cpp | 11 +++++++++++ 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index 3385dc91a8..6516d59714 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -567,22 +567,26 @@ void RimUiTreeModelPdm::addObjects(const QModelIndex& itemIndex, caf::PdmObjectG else if (dynamic_cast(currentItem->dataObject().p())) { caseCollection = dynamic_cast(currentItem->dataObject().p()); + CVF_ASSERT(caseCollection); + gridCaseGroup = caseCollection->parentCaseGroup(); } else if (dynamic_cast(currentItem->dataObject().p())) { RimReservoir* rimReservoir = dynamic_cast(currentItem->dataObject().p()); + CVF_ASSERT(rimReservoir); + caseCollection = rimReservoir->parentCaseCollection(); - gridCaseGroup = caseCollection->parentCaseGroup(); + if (caseCollection) + { + gridCaseGroup = caseCollection->parentCaseGroup(); + } } else { return; } - CVF_ASSERT(caseCollection); - CVF_ASSERT(gridCaseGroup); - if (gridCaseGroup) { std::vector > typedObjects; diff --git a/ApplicationCode/UserInterface/RIMainWindow.cpp b/ApplicationCode/UserInterface/RIMainWindow.cpp index 961eafb423..486696f477 100644 --- a/ApplicationCode/UserInterface/RIMainWindow.cpp +++ b/ApplicationCode/UserInterface/RIMainWindow.cpp @@ -375,6 +375,17 @@ void RIMainWindow::createDockPanels() m_treeView = new RimUiTreeView(dockWidget); m_treeView->setModel(m_treeModelPdm); + m_treeView->setSelectionMode(QAbstractItemView::ExtendedSelection); + + // Must be enabled for drag and drop + /* + m_treeView->setSelectionMode(QAbstractItemView::SingleSelection); + m_treeView->setDragEnabled(true); + m_treeView->viewport()->setAcceptDrops(true); + m_treeView->setDropIndicatorShown(true); + m_treeView->setDragDropMode(QAbstractItemView::InternalMove); + */ + dockWidget->setWidget(m_treeView); From 92bd95d68328cf82839af31b8e8842d63b5727c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 20 Mar 2013 16:35:36 +0100 Subject: [PATCH 146/242] Added explicit load of data for StatisticsCases. Still trouble but this removed one obstacle p4#: 21014 --- ApplicationCode/Application/RIApplication.cpp | 29 ++++++++++++++++--- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/Application/RIApplication.cpp b/ApplicationCode/Application/RIApplication.cpp index 8e8998f376..fbc60f5473 100644 --- a/ApplicationCode/Application/RIApplication.cpp +++ b/ApplicationCode/Application/RIApplication.cpp @@ -250,11 +250,32 @@ bool RIApplication::loadProject(const QString& projectFileName) m_preferences->lastUsedProjectFileName = projectFileName; writePreferences(); - caf::ProgressInfo caseProgress(m_project->reservoirs().size() , "Reading Cases"); - size_t i; - for (i = 0; i < m_project->reservoirs().size(); ++i) + std::vector casesToLoad; + + // Add all "native" cases in the project + for (size_t cIdx = 0; cIdx < m_project->reservoirs().size(); ++cIdx) { - RimReservoir* ri = m_project->reservoirs()[i]; + casesToLoad.push_back(m_project->reservoirs()[cIdx]); + } + + // Add all statistics cases as well + for (size_t cgIdx = 0; cgIdx < m_project->caseGroups().size(); ++cgIdx) + { + if (m_project->caseGroups[cgIdx]->statisticalReservoirCollection()) + { + caf::PdmPointersField & statCases = m_project->caseGroups[cgIdx]->statisticalReservoirCollection()->reservoirs(); + for (size_t scIdx = 0; scIdx < statCases.size(); ++scIdx) + { + casesToLoad.push_back(statCases[scIdx]); + } + } + } + + caf::ProgressInfo caseProgress(casesToLoad.size() , "Reading Cases"); + + for (size_t cIdx = 0; cIdx < casesToLoad.size(); ++cIdx) + { + RimReservoir* ri = casesToLoad[cIdx]; CVF_ASSERT(ri); caseProgress.setProgressDescription(ri->caseName()); From a5fb1e17649dc2806a5e7db4e7174118e539ed95 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 21 Mar 2013 10:31:58 +0100 Subject: [PATCH 147/242] One shared active cell info for all statistical cases Invalidate existing statisticsCases when adding/removing source cases Moved computation of active cell union from RigStatistics to RimIdenticalGridCaseGroup Recompute active cell union when opening project file p4#: 21023 --- .../ProjectDataModel/RigStatistics.cpp | 86 --------- .../ProjectDataModel/RigStatistics.h | 1 - .../RimIdenticalGridCaseGroup.cpp | 179 +++++++++++++++++- .../RimIdenticalGridCaseGroup.h | 15 ++ .../RimStatisticalCalculation.cpp | 4 + .../RimStatisticalCollection.cpp | 20 -- .../RimStatisticalCollection.h | 2 - .../ProjectDataModel/RimUiTreeModelPdm.cpp | 7 +- .../ReservoirDataModel/RigActiveCellInfo.cpp | 4 +- .../ReservoirDataModel/RigActiveCellInfo.h | 2 +- .../ReservoirDataModel/RigEclipseCase.cpp | 45 +++-- .../ReservoirDataModel/RigEclipseCase.h | 5 +- .../RigReservoirBuilderMock.cpp | 1 + .../RigReservoirCellResults.cpp | 11 +- 14 files changed, 244 insertions(+), 138 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RigStatistics.cpp b/ApplicationCode/ProjectDataModel/RigStatistics.cpp index 2f609c7938..b3e9a6e549 100644 --- a/ApplicationCode/ProjectDataModel/RigStatistics.cpp +++ b/ApplicationCode/ProjectDataModel/RigStatistics.cpp @@ -52,90 +52,6 @@ void RigStatistics::addNamedResult(RigReservoirCellResults* destinationCellResul } } -//-------------------------------------------------------------------------------------------------- -/// -// See also RifReaderEclipseOutput::readActiveCellInfo() -//-------------------------------------------------------------------------------------------------- -void RigStatistics::computeActiveCellUnion() -{ - if (m_sourceCases.size() == 0) - { - return; - } - - CVF_ASSERT(m_destinationCase); - - RigMainGrid* mainGrid = m_sourceCases[0]->reservoirData()->mainGrid(); - CVF_ASSERT(mainGrid); - - m_destinationCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->setGlobalCellCount(mainGrid->cells().size()); - m_destinationCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->setGlobalCellCount(mainGrid->cells().size()); - m_destinationCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->setGridCount(mainGrid->gridCount()); - m_destinationCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->setGridCount(mainGrid->gridCount()); - - size_t globalActiveMatrixIndex = 0; - size_t globalActiveFractureIndex = 0; - - for (size_t gridIdx = 0; gridIdx < mainGrid->gridCount(); gridIdx++) - { - RigGridBase* grid = mainGrid->gridByIndex(gridIdx); - - std::vector activeM(grid->cellCount(), 0); - std::vector activeF(grid->cellCount(), 0); - - for (size_t localGridCellIdx = 0; localGridCellIdx < grid->cellCount(); localGridCellIdx++) - { - for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++) - { - size_t globalCellIdx = grid->globalGridCellIndex(localGridCellIdx); - - if (activeM[localGridCellIdx] == 0) - { - if (m_sourceCases[caseIdx]->reservoirData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->isActiveInMatrixModel(globalCellIdx)) - { - activeM[localGridCellIdx] = 1; - } - } - - if (activeF[localGridCellIdx] == 0) - { - if (m_sourceCases[caseIdx]->reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->isActiveInMatrixModel(globalCellIdx)) - { - activeF[localGridCellIdx] = 1; - } - } - } - } - - size_t activeMatrixIndex = 0; - size_t activeFractureIndex = 0; - - for (size_t localGridCellIdx = 0; localGridCellIdx < grid->cellCount(); localGridCellIdx++) - { - size_t globalCellIdx = grid->globalGridCellIndex(localGridCellIdx); - - if (activeM[localGridCellIdx] != 0) - { - m_destinationCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->setActiveIndexInMatrixModel(globalCellIdx, globalActiveMatrixIndex++); - activeMatrixIndex++; - } - - if (activeF[localGridCellIdx] != 0) - { - m_destinationCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->setActiveIndexInMatrixModel(globalCellIdx, globalActiveFractureIndex++); - activeFractureIndex++; - } - } - - m_destinationCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->setGridActiveCellCounts(gridIdx, activeMatrixIndex); - m_destinationCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->setGridActiveCellCounts(gridIdx, activeFractureIndex); - } - - m_destinationCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->computeDerivedData(); - m_destinationCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->computeDerivedData(); - - m_destinationCase->computeCachedData(); -} QString createResultNameMin(const QString& resultName) { return resultName + "_MIN"; } QString createResultNameMax(const QString& resultName) { return resultName + "_MAX"; } @@ -176,8 +92,6 @@ void RigStatistics::evaluateStatistics(const QListactiveCellInfo(RifReaderInterface::MATRIX_RESULTS)->globalMatrixModelActiveCellCount(); RigReservoirCellResults* matrixResults = m_destinationCase->results(RifReaderInterface::MATRIX_RESULTS); diff --git a/ApplicationCode/ProjectDataModel/RigStatistics.h b/ApplicationCode/ProjectDataModel/RigStatistics.h index 5f0e42eb99..3e67e93eb7 100644 --- a/ApplicationCode/ProjectDataModel/RigStatistics.h +++ b/ApplicationCode/ProjectDataModel/RigStatistics.h @@ -140,7 +140,6 @@ public: void debugOutput(RimDefines::ResultCatType resultType, const QString& resultName, size_t timeStepIdx); private: - void computeActiveCellUnion(); void addNamedResult(RigReservoirCellResults* cellResults, RimDefines::ResultCatType resultType, const QString& resultName, size_t activeCellCount); void buildSourceMetaData(RimDefines::ResultCatType resultType, const QString& resultName); diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index 5f1d4d170c..9be0877388 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -23,11 +23,13 @@ #include "RimReservoir.h" #include "RimReservoirView.h" #include "RigEclipseCase.h" +#include "RigReservoirCellResults.h" #include "RimStatisticalCalculation.h" #include "RimStatisticalCollection.h" #include "RimResultReservoir.h" #include "cafProgressInfo.h" +#include "RigActiveCellInfo.h" CAF_PDM_SOURCE_INIT(RimIdenticalGridCaseGroup, "RimIdenticalGridCaseGroup"); @@ -48,6 +50,8 @@ RimIdenticalGridCaseGroup::RimIdenticalGridCaseGroup() statisticalReservoirCollection = new RimStatisticalCollection; m_mainGrid = NULL; + + clearActiveCellUnions(); } //-------------------------------------------------------------------------------------------------- @@ -86,8 +90,12 @@ void RimIdenticalGridCaseGroup::addCase(RimReservoir* reservoir) if (statisticalReservoirCollection->reservoirs().size() == 0) { - statisticalReservoirCollection->createAndAppendStatisticalCalculation(); + createAndAppendStatisticalCalculation(); } + + clearActiveCellUnions(); + clearStatisticsResults(); + updateMainGridAndActiveCellsForStatisticsCases(); } //-------------------------------------------------------------------------------------------------- @@ -101,6 +109,10 @@ void RimIdenticalGridCaseGroup::removeCase(RimReservoir* reservoir) { m_mainGrid = NULL; } + + clearActiveCellUnions(); + clearStatisticsResults(); + updateMainGridAndActiveCellsForStatisticsCases(); } //-------------------------------------------------------------------------------------------------- @@ -161,15 +173,172 @@ void RimIdenticalGridCaseGroup::initAfterRead() } - // Set main grid for statistical calculations + bool foundResultsInCache = false; for (size_t i = 0; i < statisticalReservoirCollection()->reservoirs().size(); i++) { - RimStatisticalCalculation* rimReservoir = dynamic_cast(statisticalReservoirCollection()->reservoirs()[i]); - CVF_ASSERT(rimReservoir); + RimStatisticalCalculation* rimReservoir = statisticalReservoirCollection()->reservoirs()[i]; - rimReservoir->setMainGrid(mainEclipseCase->mainGrid()); + // Check if any results are stored in cache + if (rimReservoir->results(RifReaderInterface::MATRIX_RESULTS)->m_resultCacheMetaData.size() > 0 || + rimReservoir->results(RifReaderInterface::FRACTURE_RESULTS)->m_resultCacheMetaData.size() > 0) + { + foundResultsInCache = true; + break; + } + } + + if (foundResultsInCache) + { + computeUnionOfActiveCells(); } m_mainGrid = mainEclipseCase->mainGrid(); + + updateMainGridAndActiveCellsForStatisticsCases(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIdenticalGridCaseGroup::computeUnionOfActiveCells() +{ + if (m_unionOfMatrixActiveCells->globalMatrixModelActiveCellCount() > 0) + { + return; + } + + if (caseCollection->reservoirs.size() == 0 || !m_mainGrid) + { + m_unionOfMatrixActiveCells = new RigActiveCellInfo; + m_unionOfFractureActiveCells = new RigActiveCellInfo; + + return; + } + + + m_unionOfMatrixActiveCells->setGlobalCellCount(m_mainGrid->cells().size()); + m_unionOfFractureActiveCells->setGlobalCellCount(m_mainGrid->cells().size()); + m_unionOfMatrixActiveCells->setGridCount(m_mainGrid->gridCount()); + m_unionOfFractureActiveCells->setGridCount(m_mainGrid->gridCount()); + + size_t globalActiveMatrixIndex = 0; + size_t globalActiveFractureIndex = 0; + + for (size_t gridIdx = 0; gridIdx < m_mainGrid->gridCount(); gridIdx++) + { + RigGridBase* grid = m_mainGrid->gridByIndex(gridIdx); + + std::vector activeM(grid->cellCount(), 0); + std::vector activeF(grid->cellCount(), 0); + + for (size_t localGridCellIdx = 0; localGridCellIdx < grid->cellCount(); localGridCellIdx++) + { + for (size_t caseIdx = 0; caseIdx < caseCollection->reservoirs.size(); caseIdx++) + { + size_t globalCellIdx = grid->globalGridCellIndex(localGridCellIdx); + + if (activeM[localGridCellIdx] == 0) + { + if (caseCollection->reservoirs[caseIdx]->reservoirData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->isActiveInMatrixModel(globalCellIdx)) + { + activeM[localGridCellIdx] = 1; + } + } + + if (activeF[localGridCellIdx] == 0) + { + if (caseCollection->reservoirs[caseIdx]->reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->isActiveInMatrixModel(globalCellIdx)) + { + activeF[localGridCellIdx] = 1; + } + } + } + } + + size_t activeMatrixIndex = 0; + size_t activeFractureIndex = 0; + + for (size_t localGridCellIdx = 0; localGridCellIdx < grid->cellCount(); localGridCellIdx++) + { + size_t globalCellIdx = grid->globalGridCellIndex(localGridCellIdx); + + if (activeM[localGridCellIdx] != 0) + { + m_unionOfMatrixActiveCells->setActiveIndexInMatrixModel(globalCellIdx, globalActiveMatrixIndex++); + activeMatrixIndex++; + } + + if (activeF[localGridCellIdx] != 0) + { + m_unionOfFractureActiveCells->setActiveIndexInMatrixModel(globalCellIdx, globalActiveFractureIndex++); + activeFractureIndex++; + } + } + + m_unionOfMatrixActiveCells->setGridActiveCellCounts(gridIdx, activeMatrixIndex); + m_unionOfFractureActiveCells->setGridActiveCellCounts(gridIdx, activeFractureIndex); + } + + m_unionOfMatrixActiveCells->computeDerivedData(); + m_unionOfFractureActiveCells->computeDerivedData(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimStatisticalCalculation* RimIdenticalGridCaseGroup::createAndAppendStatisticalCalculation() +{ + RimStatisticalCalculation* newObject = new RimStatisticalCalculation; + + newObject->caseName = QString("Statistics ") + QString::number(statisticalReservoirCollection()->reservoirs.size()+1); + newObject->setMainGrid(this->mainGrid()); + newObject->reservoirData()->setActiveCellInfo(RifReaderInterface::MATRIX_RESULTS, m_unionOfMatrixActiveCells.p()); + newObject->reservoirData()->setActiveCellInfo(RifReaderInterface::FRACTURE_RESULTS, m_unionOfFractureActiveCells.p()); + + statisticalReservoirCollection()->reservoirs.push_back(newObject); + + return newObject; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIdenticalGridCaseGroup::updateMainGridAndActiveCellsForStatisticsCases() +{ + for (size_t i = 0; i < statisticalReservoirCollection->reservoirs().size(); i++) + { + RimStatisticalCalculation* rimStaticsCase = statisticalReservoirCollection->reservoirs[i]; + + rimStaticsCase->setMainGrid(this->mainGrid()); + rimStaticsCase->reservoirData()->setActiveCellInfo(RifReaderInterface::MATRIX_RESULTS, m_unionOfMatrixActiveCells.p()); + rimStaticsCase->reservoirData()->setActiveCellInfo(RifReaderInterface::FRACTURE_RESULTS, m_unionOfFractureActiveCells.p()); + + if (i == 0) + { + rimStaticsCase->reservoirData()->computeCachedData(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIdenticalGridCaseGroup::clearStatisticsResults() +{ + for (size_t i = 0; i < statisticalReservoirCollection->reservoirs().size(); i++) + { + RimStatisticalCalculation* rimStaticsCase = statisticalReservoirCollection->reservoirs[i]; + rimStaticsCase->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->clearAllResults(); + rimStaticsCase->results(RifReaderInterface::FRACTURE_RESULTS)->cellResults()->clearAllResults(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIdenticalGridCaseGroup::clearActiveCellUnions() +{ + m_unionOfMatrixActiveCells = new RigActiveCellInfo; + m_unionOfFractureActiveCells = new RigActiveCellInfo; } diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h index 81c7edfed2..a9a368ad75 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h @@ -28,6 +28,7 @@ class RimReservoir; class RigMainGrid; +class RigActiveCellInfo; //================================================================================================== // @@ -47,15 +48,29 @@ public: void addCase(RimReservoir* reservoir); void removeCase(RimReservoir* reservoir); + RimStatisticalCalculation* createAndAppendStatisticalCalculation(); + caf::PdmField caseCollection; caf::PdmField statisticalReservoirCollection; RigMainGrid* mainGrid(); + void computeUnionOfActiveCells(); + protected: virtual caf::PdmFieldHandle* userDescriptionField(); virtual void initAfterRead(); + +private: + void updateMainGridAndActiveCellsForStatisticsCases(); + void clearStatisticsResults(); + void clearActiveCellUnions(); + + private: RigMainGrid* m_mainGrid; + + cvf::ref m_unionOfMatrixActiveCells; + cvf::ref m_unionOfFractureActiveCells; }; diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp index 98a9381a3d..0212edbbdd 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp @@ -121,6 +121,10 @@ void RimStatisticalCalculation::computeStatistics() openEclipseGridFile(); } + RimIdenticalGridCaseGroup* gridCaseGroup = caseGroup(); + CVF_ASSERT(gridCaseGroup); + gridCaseGroup->computeUnionOfActiveCells(); + std::vector sourceCases; getSourceCases(sourceCases); diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCollection.cpp b/ApplicationCode/ProjectDataModel/RimStatisticalCollection.cpp index 79b63b400f..3f61974e36 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCollection.cpp @@ -45,26 +45,6 @@ RimStatisticalCollection::~RimStatisticalCollection() reservoirs.deleteAllChildObjects(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimStatisticalCalculation* RimStatisticalCollection::createAndAppendStatisticalCalculation() -{ - RimStatisticalCalculation* newObject = new RimStatisticalCalculation; - RimIdenticalGridCaseGroup* gridCaseGroup = parentCaseGroup(); - - CVF_ASSERT(gridCaseGroup); - CVF_ASSERT(gridCaseGroup->mainGrid()); - - newObject->setMainGrid(gridCaseGroup->mainGrid()); - - newObject->caseName = QString("Statistics ") + QString::number(reservoirs.size()+1); - - reservoirs.push_back(newObject); - - return newObject; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCollection.h b/ApplicationCode/ProjectDataModel/RimStatisticalCollection.h index 85d55996b4..c89522899e 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCollection.h +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCollection.h @@ -42,8 +42,6 @@ public: caf::PdmPointersField reservoirs; - RimStatisticalCalculation* createAndAppendStatisticalCalculation(); - RimIdenticalGridCaseGroup* parentCaseGroup(); private: diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index 6516d59714..8bf365099e 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -480,21 +480,22 @@ RimStatisticalCalculation* RimUiTreeModelPdm::addStatisticalCalculation(const QM caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex); QModelIndex collectionIndex; - RimStatisticalCollection* caseGroup = NULL; + RimIdenticalGridCaseGroup* caseGroup = NULL; caf::PdmUiTreeItem* parentCollectionItem = NULL; int position = 0; if (dynamic_cast(currentItem->dataObject().p())) { RimStatisticalCalculation* currentObject = dynamic_cast(currentItem->dataObject().p()); - caseGroup = currentObject->parentStatisticalCollection(); + caseGroup = currentObject->parentStatisticalCollection()->parentCaseGroup(); parentCollectionItem = currentItem->parent(); position = itemIndex.row(); collectionIndex = itemIndex.parent(); } else if (dynamic_cast(currentItem->dataObject().p())) { - caseGroup = dynamic_cast(currentItem->dataObject().p()); + RimStatisticalCollection* statColl = dynamic_cast(currentItem->dataObject().p()); + caseGroup = statColl->parentCaseGroup(); parentCollectionItem = currentItem; position = parentCollectionItem->childCount(); collectionIndex = itemIndex; diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp index bdf3305543..7591d27798 100644 --- a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp @@ -45,7 +45,7 @@ bool RigActiveCellInfo::isActiveInMatrixModel(size_t globalCellIndex) const { if (m_activeInMatrixModel.size() == 0) { - return false; + return true; } CVF_TIGHT_ASSERT(globalCellIndex < m_activeInMatrixModel.size()); @@ -60,7 +60,7 @@ size_t RigActiveCellInfo::activeIndexInMatrixModel(size_t globalCellIndex) const { if (m_activeInMatrixModel.size() == 0) { - return cvf::UNDEFINED_SIZE_T; + return globalCellIndex; } CVF_TIGHT_ASSERT(globalCellIndex < m_activeInMatrixModel.size()); diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h index a03b138f81..50ae9e1a34 100644 --- a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h @@ -27,7 +27,7 @@ -class RigActiveCellInfo +class RigActiveCellInfo : public cvf::Object { public: RigActiveCellInfo(); diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp index f72efdf255..dbfbdbdde8 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp @@ -30,6 +30,9 @@ RigEclipseCase::RigEclipseCase() m_matrixModelResults = new RigReservoirCellResults(m_mainGrid.p()); m_fractureModelResults = new RigReservoirCellResults(m_mainGrid.p()); + + m_activeCellInfo = new RigActiveCellInfo; + m_fractureActiveCellInfo = new RigActiveCellInfo; } //-------------------------------------------------------------------------------------------------- @@ -285,19 +288,19 @@ void RigEclipseCase::computeActiveCellData() size_t i, j, k; m_mainGrid->ijkFromCellIndex(idx, &i, &j, &k); - if (m_activeCellInfo.isActiveInMatrixModel(idx)) + if (m_activeCellInfo->isActiveInMatrixModel(idx)) { matrixModelActiveBB.add(i, j, k); } - if (m_fractureActiveCellInfo.isActiveInMatrixModel(idx)) + if (m_fractureActiveCellInfo->isActiveInMatrixModel(idx)) { fractureModelActiveBB.add(i, j, k); } } - m_activeCellInfo.setMatrixModelActiveCellsBoundingBox(matrixModelActiveBB.m_min, matrixModelActiveBB.m_max); - m_fractureActiveCellInfo.setMatrixModelActiveCellsBoundingBox(fractureModelActiveBB.m_min, fractureModelActiveBB.m_max); + m_activeCellInfo->setMatrixModelActiveCellsBoundingBox(matrixModelActiveBB.m_min, matrixModelActiveBB.m_max); + m_fractureActiveCellInfo->setMatrixModelActiveCellsBoundingBox(fractureModelActiveBB.m_min, fractureModelActiveBB.m_max); } //-------------------------------------------------------------------------------------------------- @@ -316,10 +319,10 @@ RigActiveCellInfo* RigEclipseCase::activeCellInfo(RifReaderInterface::PorosityMo { if (porosityModel == RifReaderInterface::MATRIX_RESULTS) { - return &m_activeCellInfo; + return m_activeCellInfo.p(); } - return &m_fractureActiveCellInfo; + return m_fractureActiveCellInfo.p(); } //-------------------------------------------------------------------------------------------------- @@ -329,12 +332,28 @@ const RigActiveCellInfo* RigEclipseCase::activeCellInfo(RifReaderInterface::Poro { if (porosityModel == RifReaderInterface::MATRIX_RESULTS) { - return &m_activeCellInfo; + return m_activeCellInfo.p(); } - return &m_fractureActiveCellInfo; + return m_fractureActiveCellInfo.p(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigEclipseCase::setActiveCellInfo(RifReaderInterface::PorosityModelResultType porosityModel, RigActiveCellInfo* activeCellInfo) +{ + if (porosityModel == RifReaderInterface::MATRIX_RESULTS) + { + m_activeCellInfo = activeCellInfo; + } + else + { + m_fractureActiveCellInfo = activeCellInfo; + } +} + + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -343,14 +362,14 @@ void RigEclipseCase::computeActiveCellsGeometryBoundingBox() if (m_mainGrid.isNull()) { cvf::BoundingBox bb; - m_activeCellInfo.setMatrixActiveCellsGeometryBoundingBox(bb); - m_fractureActiveCellInfo.setMatrixActiveCellsGeometryBoundingBox(bb); + m_activeCellInfo->setMatrixActiveCellsGeometryBoundingBox(bb); + m_fractureActiveCellInfo->setMatrixActiveCellsGeometryBoundingBox(bb); return; } RigActiveCellInfo* activeInfos[2]; - activeInfos[0] = &m_fractureActiveCellInfo; - activeInfos[1] = &m_activeCellInfo; // Last, to make this bb.min become display offset + activeInfos[0] = m_fractureActiveCellInfo.p(); + activeInfos[1] = m_activeCellInfo.p(); // Last, to make this bb.min become display offset cvf::BoundingBox bb; for (int acIdx = 0; acIdx < 2; ++acIdx) @@ -428,6 +447,8 @@ cvf::ref RigEclipseCase::dataAccessObject(const return NULL; } + + /* //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCase.h b/ApplicationCode/ReservoirDataModel/RigEclipseCase.h index 9deeedf3f0..04d23400ec 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCase.h +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCase.h @@ -51,6 +51,7 @@ public: RigActiveCellInfo* activeCellInfo(RifReaderInterface::PorosityModelResultType porosityModel); const RigActiveCellInfo* activeCellInfo(RifReaderInterface::PorosityModelResultType porosityModel) const; + void setActiveCellInfo(RifReaderInterface::PorosityModelResultType porosityModel, RigActiveCellInfo* activeCellInfo); cvf::ref dataAccessObject(const RigGridBase* grid, @@ -78,8 +79,8 @@ private: private: cvf::ref m_mainGrid; - RigActiveCellInfo m_activeCellInfo; - RigActiveCellInfo m_fractureActiveCellInfo; + cvf::ref m_activeCellInfo; + cvf::ref m_fractureActiveCellInfo; cvf::ref m_matrixModelResults; cvf::ref m_fractureModelResults; diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp index 6b8145a4aa..ef9831def6 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp @@ -18,6 +18,7 @@ #include "RigReservoirBuilderMock.h" #include "RigEclipseCase.h" +#include "RigActiveCellInfo.h" /* rand example: guess the number */ diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp index c7b4cf0012..7f5089a86d 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp @@ -505,10 +505,13 @@ void RigReservoirCellResults::removeResult(const QString& resultName) //-------------------------------------------------------------------------------------------------- void RigReservoirCellResults::clearAllResults() { - for (size_t i = 0; i < m_cellScalarResults.size(); i++) - { - m_cellScalarResults[i].clear(); - } + m_cellScalarResults.clear(); + m_maxMinValues.clear(); + m_histograms.clear(); + m_p10p90.clear(); + m_meanValues.clear(); + m_maxMinValuesPrTs.clear(); + m_resultInfos.clear(); } //-------------------------------------------------------------------------------------------------- From 359964092db9bb94f2454325d3cf32afb4098c44 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 21 Mar 2013 10:48:46 +0100 Subject: [PATCH 148/242] Added new grid case group on case context menu p4#: 21024 --- ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp | 3 ++- ApplicationCode/ProjectDataModel/RimUiTreeView.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index 8bf365099e..ccff2720e6 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -523,7 +523,8 @@ RimIdenticalGridCaseGroup* RimUiTreeModelPdm::addCaseGroup(const QModelIndex& it caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex); - if (dynamic_cast(currentItem->dataObject().p())) + if (dynamic_cast(currentItem->dataObject().p()) || + dynamic_cast(currentItem->dataObject().p())) { QModelIndex rootIndex = itemIndex.parent(); caf::PdmUiTreeItem* rootTreeItem = currentItem->parent(); diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index ea6a245a1e..59b7afd9ce 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -175,12 +175,13 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event) menu.addAction(QString("Paste"), this, SLOT(slotPastePdmObjects())); menu.addAction(QString("Close"), this, SLOT(slotCloseCase())); menu.addAction(QString("New View"), this, SLOT(slotAddView())); + menu.addAction(QString("New Grid Case Group"), this, SLOT(slotAddCaseGroup())); menu.exec(event->globalPos()); } else if (dynamic_cast(uiItem->dataObject().p())) { QMenu menu; - menu.addAction(QString("New Case Group"), this, SLOT(slotAddCaseGroup())); + menu.addAction(QString("New Grid Case Group"), this, SLOT(slotAddCaseGroup())); menu.addAction(QString("Paste"), this, SLOT(slotPastePdmObjects())); menu.addAction(QString("Close"), this, SLOT(slotDeleteObjectFromPdmPointersField())); menu.exec(event->globalPos()); From 1e8d5236d1661849deee54d7d2ea1e9325f54c0f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 21 Mar 2013 11:04:47 +0100 Subject: [PATCH 149/242] Disable paste if no available clipboard data p4#: 21025 --- .../ProjectDataModel/RimUiTreeView.cpp | 29 +++++++++++++++++-- .../ProjectDataModel/RimUiTreeView.h | 5 +++- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index 59b7afd9ce..72ae486ed8 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -43,6 +43,9 @@ RimUiTreeView::RimUiTreeView(QWidget *parent /*= 0*/) : QTreeView(parent) { setHeaderHidden(true); + + m_pasteAction = new QAction(QString("Paste"), this); + connect(m_pasteAction, SIGNAL(triggered()), SLOT(slotPastePdmObjects())); } //-------------------------------------------------------------------------------------------------- @@ -57,12 +60,15 @@ RimUiTreeView::~RimUiTreeView() //-------------------------------------------------------------------------------------------------- void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event) { + m_pasteAction->setEnabled(hasClipboardValidData()); + RimUiTreeModelPdm* myModel = dynamic_cast(model()); if (myModel) { caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex()); if (uiItem && uiItem->dataObject()) { + // Range filters if (dynamic_cast(uiItem->dataObject().p())) { @@ -172,7 +178,7 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event) { QMenu menu; menu.addAction(QString("Copy"), this, SLOT(slotCopyPdmObjectToClipboard())); - menu.addAction(QString("Paste"), this, SLOT(slotPastePdmObjects())); + menu.addAction(m_pasteAction); menu.addAction(QString("Close"), this, SLOT(slotCloseCase())); menu.addAction(QString("New View"), this, SLOT(slotAddView())); menu.addAction(QString("New Grid Case Group"), this, SLOT(slotAddCaseGroup())); @@ -182,14 +188,14 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event) { QMenu menu; menu.addAction(QString("New Grid Case Group"), this, SLOT(slotAddCaseGroup())); - menu.addAction(QString("Paste"), this, SLOT(slotPastePdmObjects())); + menu.addAction(m_pasteAction); menu.addAction(QString("Close"), this, SLOT(slotDeleteObjectFromPdmPointersField())); menu.exec(event->globalPos()); } else if (dynamic_cast(uiItem->dataObject().p())) { QMenu menu; - menu.addAction(QString("Paste"), this, SLOT(slotPastePdmObjects())); + menu.addAction(m_pasteAction); menu.exec(event->globalPos()); } } @@ -968,3 +974,20 @@ void RimUiTreeView::keyPressEvent(QKeyEvent* keyEvent) QTreeView::keyPressEvent(keyEvent); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimUiTreeView::hasClipboardValidData() +{ + QClipboard* clipboard = QApplication::clipboard(); + if (clipboard) + { + if (dynamic_cast(clipboard->mimeData())) + { + return true; + } + } + + return false; +} + diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.h b/ApplicationCode/ProjectDataModel/RimUiTreeView.h index 07dc53f5cb..db6f4b9ca4 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.h @@ -89,10 +89,13 @@ signals: void selectedObjectChanged( caf::PdmObject* pdmObject ); private: - void createPdmObjectsFromClipboard(caf::PdmObjectGroup* objectGroup); + bool hasClipboardValidData(); virtual void keyPressEvent(QKeyEvent* keyEvent); + +private: + QAction* m_pasteAction; }; From b0503cabba718a093290dc7ade68a0f8e7d14a90 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 21 Mar 2013 13:41:44 +0100 Subject: [PATCH 150/242] Added drag and drop support. Implemented our own insertRows/deleteRows to avoid bug caused by default drag and drop behaviour of Qt https://bugreports.qt-project.org/browse/QTBUG-26229 https://bugreports.qt-project.org/browse/QTBUG-6679 p4#: 21028 --- .../ProjectDataModel/RimUiTreeModelPdm.cpp | 112 ++++++++++++++++-- .../ProjectDataModel/RimUiTreeModelPdm.h | 11 +- .../UserInterface/RIMainWindow.cpp | 8 +- cafUserInterface/cafUiTreeModelPdm.cpp | 8 +- cafUserInterface/cafUiTreeModelPdm.h | 6 +- 5 files changed, 122 insertions(+), 23 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index ccff2720e6..35c24fc226 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -51,9 +51,9 @@ RimUiTreeModelPdm::RimUiTreeModelPdm(QObject* parent) } //-------------------------------------------------------------------------------------------------- -/// +/// TO BE DELETED //-------------------------------------------------------------------------------------------------- -bool RimUiTreeModelPdm::insertRows(int position, int rows, const QModelIndex &parent /*= QModelIndex()*/) +bool RimUiTreeModelPdm::insertRows_special(int position, int rows, const QModelIndex &parent /*= QModelIndex()*/) { caf::PdmUiTreeItem* parentItem = getTreeItemFromIndex(parent); @@ -126,7 +126,7 @@ bool RimUiTreeModelPdm::deletePropertyFilter(const QModelIndex& itemIndex) bool wasSomeFilterActive = propertyFilterCollection->hasActiveFilters(); // Remove Ui items pointing at the pdm object to delete - removeRow(itemIndex.row(), itemIndex.parent()); + removeRows_special(itemIndex.row(), 1, itemIndex.parent()); propertyFilterCollection->remove(propertyFilter); delete propertyFilter; @@ -166,7 +166,7 @@ bool RimUiTreeModelPdm::deleteRangeFilter(const QModelIndex& itemIndex) bool wasSomeFilterActive = rangeFilterCollection->hasActiveFilters(); // Remove Ui items pointing at the pdm object to delete - removeRow(itemIndex.row(), itemIndex.parent()); + removeRows_special(itemIndex.row(), 1, itemIndex.parent()); rangeFilterCollection->remove(rangeFilter); delete rangeFilter; @@ -200,7 +200,7 @@ bool RimUiTreeModelPdm::deleteReservoirView(const QModelIndex& itemIndex) CVF_ASSERT(reservoirView); // Remove Ui items pointing at the pdm object to delete - removeRow(itemIndex.row(), itemIndex.parent()); + removeRows_special(itemIndex.row(), 1, itemIndex.parent()); reservoirView->eclipseCase()->removeReservoirView(reservoirView); delete reservoirView; @@ -226,7 +226,7 @@ void RimUiTreeModelPdm::deleteReservoir(RimReservoir* reservoir) CVF_ASSERT(uiItem); // Remove Ui items pointing at the pdm object to delete - removeRow(mi.row(), mi.parent()); + removeRows_special(mi.row(), 1, mi.parent()); } RimProject* proj = RIApplication::instance()->project(); @@ -449,7 +449,7 @@ void RimUiTreeModelPdm::deleteInputProperty(const QModelIndex& itemIndex) if (!inputProperty) return; // Remove item from UI tree model before delete of project data structure - removeRow(itemIndex.row(), itemIndex.parent()); + removeRows_special(itemIndex.row(), 1, itemIndex.parent()); std::vector parentObjects; object->parentObjectsOfType(parentObjects); @@ -581,8 +581,8 @@ void RimUiTreeModelPdm::addObjects(const QModelIndex& itemIndex, caf::PdmObjectG caseCollection = rimReservoir->parentCaseCollection(); if (caseCollection) { - gridCaseGroup = caseCollection->parentCaseGroup(); - } + gridCaseGroup = caseCollection->parentCaseGroup(); + } } else { @@ -701,3 +701,97 @@ void RimUiTreeModelPdm::clearClipboard() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Qt::DropActions RimUiTreeModelPdm::supportedDropActions() const +{ + return Qt::CopyAction | Qt::MoveAction; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Qt::ItemFlags RimUiTreeModelPdm::flags(const QModelIndex &index) const +{ + Qt::ItemFlags defaultFlags = caf::UiTreeModelPdm::flags(index); + if (index.isValid()) + { + caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(index); + CVF_ASSERT(currentItem); + CVF_ASSERT(currentItem->dataObject().p()); + + if (dynamic_cast(currentItem->dataObject().p()) || + dynamic_cast(currentItem->dataObject().p())) + { + return Qt::ItemIsDropEnabled | defaultFlags; + } + else if (dynamic_cast(currentItem->dataObject().p())) + { + // TODO: Remember to handle reservoir holding the main grid + return Qt::ItemIsDragEnabled | defaultFlags; + } + } + + return defaultFlags; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimUiTreeModelPdm::dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent) +{ + const MimeDataWithIndexes* myMimeData = qobject_cast(data); + if (myMimeData && parent.isValid()) + { + caf::PdmObjectGroup pog; + + for (int i = 0; i < myMimeData->indexes().size(); i++) + { + QModelIndex mi = myMimeData->indexes().at(i); + caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(mi); + caf::PdmObject* pdmObj = currentItem->dataObject().p(); + + pog.objects().push_back(pdmObj); + } + + addObjects(parent, pog); + + if (action == Qt::MoveAction) + { + std::vector > typedObjects; + pog.objectsByType(&typedObjects); + + for (size_t i = 0; i < typedObjects.size(); i++) + { + RimReservoir* rimReservoir = typedObjects[i]; + deleteReservoir(rimReservoir); + } + } + + return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QMimeData* RimUiTreeModelPdm::mimeData(const QModelIndexList &indexes) const +{ + MimeDataWithIndexes* myObj = new MimeDataWithIndexes(); + myObj->setIndexes(indexes); + return myObj; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RimUiTreeModelPdm::mimeTypes() const +{ + QStringList types; + types << MimeDataWithIndexes::formatName(); + return types; +} + diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h index 59aabbc789..ece8c016dc 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h @@ -96,8 +96,9 @@ class RimUiTreeModelPdm : public caf::UiTreeModelPdm public: RimUiTreeModelPdm(QObject* parent); - // Overrides - virtual bool insertRows(int position, int rows, const QModelIndex &parent = QModelIndex()); + + // TO BE DELETED, NOT USED + virtual bool insertRows_special(int position, int rows, const QModelIndex &parent = QModelIndex()); // Special edit methods bool deleteRangeFilter(const QModelIndex& itemIndex); @@ -119,6 +120,12 @@ public: void updateScriptPaths(); + virtual Qt::DropActions supportedDropActions() const; + virtual Qt::ItemFlags flags(const QModelIndex &index) const; + virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent); + virtual QMimeData * mimeData(const QModelIndexList &indexes) const; + virtual QStringList mimeTypes() const; + private slots: void slotRefreshScriptTree(QString path); void clearClipboard(); diff --git a/ApplicationCode/UserInterface/RIMainWindow.cpp b/ApplicationCode/UserInterface/RIMainWindow.cpp index 486696f477..90e87996b5 100644 --- a/ApplicationCode/UserInterface/RIMainWindow.cpp +++ b/ApplicationCode/UserInterface/RIMainWindow.cpp @@ -377,15 +377,11 @@ void RIMainWindow::createDockPanels() m_treeView->setModel(m_treeModelPdm); m_treeView->setSelectionMode(QAbstractItemView::ExtendedSelection); - // Must be enabled for drag and drop - /* - m_treeView->setSelectionMode(QAbstractItemView::SingleSelection); + // Drag and drop configuration m_treeView->setDragEnabled(true); m_treeView->viewport()->setAcceptDrops(true); m_treeView->setDropIndicatorShown(true); - m_treeView->setDragDropMode(QAbstractItemView::InternalMove); - */ - + m_treeView->setDragDropMode(QAbstractItemView::DragDrop); dockWidget->setWidget(m_treeView); diff --git a/cafUserInterface/cafUiTreeModelPdm.cpp b/cafUserInterface/cafUiTreeModelPdm.cpp index 85a5112cb5..f1195d9478 100644 --- a/cafUserInterface/cafUiTreeModelPdm.cpp +++ b/cafUserInterface/cafUiTreeModelPdm.cpp @@ -293,9 +293,9 @@ Qt::ItemFlags UiTreeModelPdm::flags(const QModelIndex &index) const } //-------------------------------------------------------------------------------------------------- -/// +/// TO BE DELETED //-------------------------------------------------------------------------------------------------- -bool UiTreeModelPdm::insertRows(int position, int rows, const QModelIndex &parent /*= QModelIndex()*/) +bool UiTreeModelPdm::insertRows_special(int position, int rows, const QModelIndex &parent /*= QModelIndex()*/) { PdmUiTreeItem* parentItem = getTreeItemFromIndex(parent); @@ -311,7 +311,7 @@ bool UiTreeModelPdm::insertRows(int position, int rows, const QModelIndex &paren //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool UiTreeModelPdm::removeRows(int position, int rows, const QModelIndex &parent /*= QModelIndex()*/) +bool UiTreeModelPdm::removeRows_special(int position, int rows, const QModelIndex &parent /*= QModelIndex()*/) { if (rows <= 0) return true; @@ -344,7 +344,7 @@ void UiTreeModelPdm::rebuildUiSubTree(PdmObject* root) QModelIndex item = getModelIndexFromPdmObject(root); if (item.isValid()) { - this->removeRows(0, rowCount(item), item); + this->removeRows_special(0, rowCount(item), item); PdmUiTreeItem* treeItem = getTreeItemFromIndex(item); diff --git a/cafUserInterface/cafUiTreeModelPdm.h b/cafUserInterface/cafUiTreeModelPdm.h index 0dfbf2593a..b5f8f7de4e 100644 --- a/cafUserInterface/cafUiTreeModelPdm.h +++ b/cafUserInterface/cafUiTreeModelPdm.h @@ -62,8 +62,10 @@ public: virtual Qt::ItemFlags flags(const QModelIndex &index) const; virtual bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); - virtual bool insertRows(int position, int rows, const QModelIndex &parent = QModelIndex()); - virtual bool removeRows(int position, int rows, const QModelIndex &parent = QModelIndex()); + // TO BE DELETED, NOT USED + virtual bool insertRows_special(int position, int rows, const QModelIndex &parent = QModelIndex()); + + virtual bool removeRows_special(int position, int rows, const QModelIndex &parent = QModelIndex()); protected: QModelIndex getModelIndexFromPdmObjectRecursive(const QModelIndex& root, const PdmObject * object) const; From 7548e9c1bbf128e09736b12fb775dafc054434c0 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 21 Mar 2013 13:56:50 +0100 Subject: [PATCH 151/242] Do not add same case more than once in a grid case group p4#: 21030 --- .../RimIdenticalGridCaseGroup.cpp | 19 +++++++++++++++++++ .../RimIdenticalGridCaseGroup.h | 1 + .../ProjectDataModel/RimUiTreeModelPdm.cpp | 5 +++++ 3 files changed, 25 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index 9be0877388..0a10f4586e 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -342,3 +342,22 @@ void RimIdenticalGridCaseGroup::clearActiveCellUnions() m_unionOfFractureActiveCells = new RigActiveCellInfo; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimIdenticalGridCaseGroup::contains(RimReservoir* reservoir) const +{ + CVF_ASSERT(reservoir); + + for (size_t i = 0; i < caseCollection()->reservoirs().size(); i++) + { + RimReservoir* rimReservoir = caseCollection()->reservoirs()[i]; + if (reservoir->caseName == reservoir->caseName) + { + return true; + } + } + + return false; +} + diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h index a9a368ad75..6b05d6ec29 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h @@ -47,6 +47,7 @@ public: void addCase(RimReservoir* reservoir); void removeCase(RimReservoir* reservoir); + bool contains(RimReservoir* reservoir) const; RimStatisticalCalculation* createAndAppendStatisticalCalculation(); diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index 35c24fc226..a59e911928 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -605,6 +605,11 @@ void RimUiTreeModelPdm::addObjects(const QModelIndex& itemIndex, caf::PdmObjectG { RimResultReservoir* rimResultReservoir = typedObjects[i]; + if (gridCaseGroup->contains(rimResultReservoir)) + { + continue; + } + if (gridCaseGroup->mainGrid() == NULL) { rimResultReservoir->openEclipseGridFile(); From d0d96ba145d01381baf9ffdc6885f1795551f224 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 21 Mar 2013 14:03:37 +0100 Subject: [PATCH 152/242] Fixed layout p4#: 21031 --- .../ProjectDataModel/RimUiTreeModelPdm.h | 52 +++++++++---------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h index ece8c016dc..da9a6dcff9 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h @@ -98,43 +98,41 @@ public: // TO BE DELETED, NOT USED - virtual bool insertRows_special(int position, int rows, const QModelIndex &parent = QModelIndex()); + virtual bool insertRows_special(int position, int rows, const QModelIndex &parent = QModelIndex()); // Special edit methods - bool deleteRangeFilter(const QModelIndex& itemIndex); - bool deletePropertyFilter(const QModelIndex& itemIndex); - bool deleteReservoirView(const QModelIndex& itemIndex); - void deleteInputProperty(const QModelIndex& itemIndex); - void deleteReservoir(RimReservoir* reservoir); + bool deleteRangeFilter(const QModelIndex& itemIndex); + bool deletePropertyFilter(const QModelIndex& itemIndex); + bool deleteReservoirView(const QModelIndex& itemIndex); + void deleteInputProperty(const QModelIndex& itemIndex); + void deleteReservoir(RimReservoir* reservoir); - RimCellPropertyFilter* addPropertyFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); - RimCellRangeFilter* addRangeFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); - RimReservoirView* addReservoirView(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); - void addInputProperty(const QModelIndex& itemIndex, const QStringList& fileNames); - void addObjects(const QModelIndex& itemIndex, caf::PdmObjectGroup& pdmObjects); + RimCellPropertyFilter* addPropertyFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); + RimCellRangeFilter* addRangeFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); + RimReservoirView* addReservoirView(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); + void addInputProperty(const QModelIndex& itemIndex, const QStringList& fileNames); + void addObjects(const QModelIndex& itemIndex, caf::PdmObjectGroup& pdmObjects); - RimStatisticalCalculation* addStatisticalCalculation(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); - RimIdenticalGridCaseGroup* addCaseGroup(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); + RimStatisticalCalculation* addStatisticalCalculation(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); + RimIdenticalGridCaseGroup* addCaseGroup(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); - bool deleteObjectFromPdmPointersField(const QModelIndex& itemIndex); + bool deleteObjectFromPdmPointersField(const QModelIndex& itemIndex); - void updateScriptPaths(); + void updateScriptPaths(); - virtual Qt::DropActions supportedDropActions() const; - virtual Qt::ItemFlags flags(const QModelIndex &index) const; - virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent); - virtual QMimeData * mimeData(const QModelIndexList &indexes) const; - virtual QStringList mimeTypes() const; + virtual Qt::DropActions supportedDropActions() const; + virtual Qt::ItemFlags flags(const QModelIndex &index) const; + virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent); + virtual QMimeData* mimeData(const QModelIndexList &indexes) const; + virtual QStringList mimeTypes() const; private slots: - void slotRefreshScriptTree(QString path); - void clearClipboard(); + void slotRefreshScriptTree(QString path); private: - QFileSystemWatcher* m_scriptChangeDetector; + void clearClipboard(); + +private: + QFileSystemWatcher* m_scriptChangeDetector; }; - - - - From 326cd7975406920f2674bdbdbe8bc6317b27f6a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 21 Mar 2013 15:31:47 +0100 Subject: [PATCH 153/242] Result Storage: Finally things have come together, and seems to behave. Refactored the loadProject system to make loading of statistical cases work as they should. Got the update of references regarding grid and unionActive cells work Introduced a bool to keep track of what cell results to store. Introduced a clear method in ActiveCellInfo. Renamed a bit p4#: 21036 --- ApplicationCode/Application/RIApplication.cpp | 99 +++++++----- .../RifEclipseInputFileTools.cpp | 6 +- .../FileInterface/RifReaderEclipseOutput.cpp | 8 +- .../FileInterface/RifReaderMockModel.cpp | 6 +- .../RifReaderStatisticalCalculation.cpp | 8 +- .../ProjectDataModel/RigStatistics.cpp | 4 +- .../RimIdenticalGridCaseGroup.cpp | 88 +++++----- .../RimIdenticalGridCaseGroup.h | 6 +- .../ProjectDataModel/RimReservoir.cpp | 2 +- .../RimReservoirCellResultsCacher.cpp | 150 ++++++++++++++++-- .../RimReservoirCellResultsCacher.h | 18 ++- .../ProjectDataModel/RimResultReservoir.cpp | 2 +- .../RimStatisticalCalculation.cpp | 31 ++-- .../ReservoirDataModel/RigActiveCellInfo.cpp | 13 ++ .../ReservoirDataModel/RigActiveCellInfo.h | 2 + .../ReservoirDataModel/RigEclipseCase.cpp | 6 +- .../ReservoirDataModel/RigEclipseCase.h | 8 +- .../RigReservoirCellResults.cpp | 13 +- .../RigReservoirCellResults.h | 17 +- .../SocketInterface/RiaSocketServer.cpp | 2 +- 20 files changed, 334 insertions(+), 155 deletions(-) diff --git a/ApplicationCode/Application/RIApplication.cpp b/ApplicationCode/Application/RIApplication.cpp index fbc60f5473..127df8be08 100644 --- a/ApplicationCode/Application/RIApplication.cpp +++ b/ApplicationCode/Application/RIApplication.cpp @@ -223,14 +223,21 @@ const char* RIApplication::getVersionStringApp(bool includeCrtInfo) //-------------------------------------------------------------------------------------------------- bool RIApplication::loadProject(const QString& projectFileName) { + // First Close the current project + if (!closeProject(true)) return false; + // Open the project file and read the serialized data. + // Will initialize itself. + if (!QFile::exists(projectFileName)) return false; m_project->fileName = projectFileName; m_project->readFile(); m_project->fileName = projectFileName; // Make sure we overwrite the old filename read from the project file + // On error, delete everything, and bail out. + if (m_project->projectFileVersionString().isEmpty()) { closeProject(false); @@ -244,62 +251,78 @@ bool RIApplication::loadProject(const QString& projectFileName) // Delete all object possibly generated by readFile() delete m_project; m_project = new RimProject; + + onProjectOpenedOrClosed(); + + return true; } - else + + /////// + // Load the external data, and initialize stuff that needs specific ordering + + m_preferences->lastUsedProjectFileName = projectFileName; + writePreferences(); + + for (size_t cgIdx = 0; cgIdx < m_project->caseGroups.size(); ++cgIdx) { - m_preferences->lastUsedProjectFileName = projectFileName; - writePreferences(); + // Load the Main case of each IdenticalGridCaseGroup - std::vector casesToLoad; + RimIdenticalGridCaseGroup* igcg = m_project->caseGroups[cgIdx]; + igcg->loadMainCaseAndActiveCellInfo(); + } - // Add all "native" cases in the project - for (size_t cIdx = 0; cIdx < m_project->reservoirs().size(); ++cIdx) + // Now load the ReservoirViews for the cases + + std::vector casesToLoad; + + // Add all "native" cases in the project + for (size_t cIdx = 0; cIdx < m_project->reservoirs().size(); ++cIdx) + { + casesToLoad.push_back(m_project->reservoirs()[cIdx]); + } + + // Add all statistics cases as well + for (size_t cgIdx = 0; cgIdx < m_project->caseGroups().size(); ++cgIdx) + { + if (m_project->caseGroups[cgIdx]->statisticalReservoirCollection()) { - casesToLoad.push_back(m_project->reservoirs()[cIdx]); - } - - // Add all statistics cases as well - for (size_t cgIdx = 0; cgIdx < m_project->caseGroups().size(); ++cgIdx) - { - if (m_project->caseGroups[cgIdx]->statisticalReservoirCollection()) + caf::PdmPointersField & statCases = m_project->caseGroups[cgIdx]->statisticalReservoirCollection()->reservoirs(); + for (size_t scIdx = 0; scIdx < statCases.size(); ++scIdx) { - caf::PdmPointersField & statCases = m_project->caseGroups[cgIdx]->statisticalReservoirCollection()->reservoirs(); - for (size_t scIdx = 0; scIdx < statCases.size(); ++scIdx) - { - casesToLoad.push_back(statCases[scIdx]); - } + casesToLoad.push_back(statCases[scIdx]); } } + } - caf::ProgressInfo caseProgress(casesToLoad.size() , "Reading Cases"); + caf::ProgressInfo caseProgress(casesToLoad.size() , "Reading Cases"); - for (size_t cIdx = 0; cIdx < casesToLoad.size(); ++cIdx) + for (size_t cIdx = 0; cIdx < casesToLoad.size(); ++cIdx) + { + RimReservoir* ri = casesToLoad[cIdx]; + CVF_ASSERT(ri); + + caseProgress.setProgressDescription(ri->caseName()); + + caf::ProgressInfo viewProgress(ri->reservoirViews().size() , "Creating Views"); + + size_t j; + for (j = 0; j < ri->reservoirViews().size(); j++) { - RimReservoir* ri = casesToLoad[cIdx]; - CVF_ASSERT(ri); + RimReservoirView* riv = ri->reservoirViews[j]; + CVF_ASSERT(riv); - caseProgress.setProgressDescription(ri->caseName()); + viewProgress.setProgressDescription(riv->name()); - caf::ProgressInfo viewProgress(ri->reservoirViews().size() , "Creating Views"); + riv->loadDataAndUpdate(); - size_t j; - for (j = 0; j < ri->reservoirViews().size(); j++) - { - RimReservoirView* riv = ri->reservoirViews()[j]; - CVF_ASSERT(riv); - - viewProgress.setProgressDescription(riv->name()); - - riv->loadDataAndUpdate(); - viewProgress.incrementProgress(); - } - - caseProgress.incrementProgress(); + viewProgress.incrementProgress(); } + + caseProgress.incrementProgress(); } onProjectOpenedOrClosed(); - + return true; } diff --git a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp index 13182d8852..bcb4c98d57 100644 --- a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp @@ -214,7 +214,7 @@ std::map RifEclipseInputFileTools::readProperties(const QStri { QString newResultName = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->makeResultNameUnique(fileKeywords[i].keyword); - size_t resultIndex = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName); // Should really merge with inputProperty object information because we need to use PropertyName, and not keyword + size_t resultIndex = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName, false); // Should really merge with inputProperty object information because we need to use PropertyName, and not keyword std::vector< std::vector >& newPropertyData = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex); newPropertyData.push_back(std::vector()); @@ -297,7 +297,7 @@ bool RifEclipseInputFileTools::readProperty(const QString& fileName, RigEclipseC size_t resultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(newResultName); if (resultIndex == cvf::UNDEFINED_SIZE_T) { - resultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName); + resultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName, false); } std::vector< std::vector >& newPropertyData = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex); @@ -535,7 +535,7 @@ bool RifEclipseInputFileTools::readPropertyAtFilePosition(const QString& fileNam size_t resultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->findScalarResultIndex(newResultName); if (resultIndex == cvf::UNDEFINED_SIZE_T) { - resultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName); + resultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, newResultName, false); } std::vector< std::vector >& newPropertyData = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->cellScalarResults(resultIndex); diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index 584f731876..3d8e746183 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -564,7 +564,7 @@ bool RifReaderEclipseOutput::buildMetaData() for (int i = 0; i < matrixResultNames.size(); ++i) { - size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, matrixResultNames[i]); + size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, matrixResultNames[i], false); matrixModelResults->setTimeStepDates(resIndex, m_timeSteps); } } @@ -577,7 +577,7 @@ bool RifReaderEclipseOutput::buildMetaData() for (int i = 0; i < fractureResultNames.size(); ++i) { - size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, fractureResultNames[i]); + size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, fractureResultNames[i], false); fractureModelResults->setTimeStepDates(resIndex, m_timeSteps); } } @@ -610,7 +610,7 @@ bool RifReaderEclipseOutput::buildMetaData() for (int i = 0; i < matrixResultNames.size(); ++i) { - size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, matrixResultNames[i]); + size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, matrixResultNames[i], false); matrixModelResults->setTimeStepDates(resIndex, staticDate); } } @@ -629,7 +629,7 @@ bool RifReaderEclipseOutput::buildMetaData() for (int i = 0; i < fractureResultNames.size(); ++i) { - size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, fractureResultNames[i]); + size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, fractureResultNames[i], false); fractureModelResults->setTimeStepDates(resIndex, staticDate); } } diff --git a/ApplicationCode/FileInterface/RifReaderMockModel.cpp b/ApplicationCode/FileInterface/RifReaderMockModel.cpp index fc8257bcf7..49de1cb07b 100644 --- a/ApplicationCode/FileInterface/RifReaderMockModel.cpp +++ b/ApplicationCode/FileInterface/RifReaderMockModel.cpp @@ -43,7 +43,7 @@ bool RifReaderMockModel::open(const QString& fileName, RigEclipseCase* eclipseCa for (size_t i = 0; i < m_reservoirBuilder.resultCount(); i++) { - size_t resIdx = cellResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, QString("Dynamic_Result_%1").arg(i)); + size_t resIdx = cellResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, QString("Dynamic_Result_%1").arg(i), false); cellResults->setTimeStepDates(resIdx, dates); } @@ -59,7 +59,7 @@ bool RifReaderMockModel::open(const QString& fileName, RigEclipseCase* eclipseCa int resIndex = 0; if (i > 1) resIndex = i; - size_t resIdx = cellResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, QString("Static_Result_%1%2").arg(resIndex).arg(varEnd)); + size_t resIdx = cellResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, QString("Static_Result_%1%2").arg(resIndex).arg(varEnd), false); cellResults->setTimeStepDates(resIdx, staticDates); } @@ -68,7 +68,7 @@ bool RifReaderMockModel::open(const QString& fileName, RigEclipseCase* eclipseCa { \ size_t resIdx; \ QString resultName(Name); \ - resIdx = cellResults->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, resultName); \ + resIdx = cellResults->addEmptyScalarResult(RimDefines::INPUT_PROPERTY, resultName, false); \ cellResults->setTimeStepDates(resIdx, staticDates); \ cellResults->cellScalarResults(resIdx).resize(1); \ std::vector& values = cellResults->cellScalarResults(resIdx)[0]; \ diff --git a/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.cpp b/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.cpp index ca9d4cdc08..07bf2ab9db 100644 --- a/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.cpp +++ b/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.cpp @@ -60,13 +60,13 @@ void RifReaderStatisticalCalculation::buildMetaData(RigEclipseCase* eclipseCase) // Dynamic results for (int i = 0; i < m_matrixDynamicResultNames.size(); ++i) { - size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, m_matrixDynamicResultNames[i]); + size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, m_matrixDynamicResultNames[i], true); matrixModelResults->setTimeStepDates(resIndex, m_timeSteps); } for (int i = 0; i < m_fractureDynamicResultNames.size(); ++i) { - size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, m_fractureDynamicResultNames[i]); + size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, m_fractureDynamicResultNames[i], true); fractureModelResults->setTimeStepDates(resIndex, m_timeSteps); } @@ -79,13 +79,13 @@ void RifReaderStatisticalCalculation::buildMetaData(RigEclipseCase* eclipseCase) // Static results for (int i = 0; i < m_fractureStaticResultNames.size(); ++i) { - size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, m_fractureStaticResultNames[i]); + size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, m_fractureStaticResultNames[i], true); fractureModelResults->setTimeStepDates(resIndex, staticDate); } for (int i = 0; i < m_matrixStaticResultNames.size(); ++i) { - size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, m_matrixStaticResultNames[i]); + size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, m_matrixStaticResultNames[i], true); matrixModelResults->setTimeStepDates(resIndex, staticDate); } } diff --git a/ApplicationCode/ProjectDataModel/RigStatistics.cpp b/ApplicationCode/ProjectDataModel/RigStatistics.cpp index b3e9a6e549..3b6a173402 100644 --- a/ApplicationCode/ProjectDataModel/RigStatistics.cpp +++ b/ApplicationCode/ProjectDataModel/RigStatistics.cpp @@ -37,7 +37,7 @@ void RigStatistics::addNamedResult(RigReservoirCellResults* destinationCellResul std::vector sourceTimeStepDates = m_sourceCases[0]->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->timeStepDates(0); - size_t destinationScalarResultIndex = destinationCellResults->addEmptyScalarResult(resultType, resultName); + size_t destinationScalarResultIndex = destinationCellResults->addEmptyScalarResult(resultType, resultName, true); CVF_ASSERT(destinationScalarResultIndex != cvf::UNDEFINED_SIZE_T); destinationCellResults->setTimeStepDates(destinationScalarResultIndex, sourceTimeStepDates); @@ -76,7 +76,7 @@ void RigStatistics::buildSourceMetaData(RimDefines::ResultCatType resultType, co size_t scalarResultIndex = matrixResults->findOrLoadScalarResult(resultType, resultName); if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) { - size_t scalarResultIndex = matrixResults->cellResults()->addEmptyScalarResult(resultType, resultName); + size_t scalarResultIndex = matrixResults->cellResults()->addEmptyScalarResult(resultType, resultName, false); matrixResults->cellResults()->setTimeStepDates(scalarResultIndex, timeStepDates); std::vector< std::vector >& dataValues = matrixResults->cellResults()->cellScalarResults(scalarResultIndex); diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index 0a10f4586e..74f61921ca 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -51,7 +51,8 @@ RimIdenticalGridCaseGroup::RimIdenticalGridCaseGroup() m_mainGrid = NULL; - clearActiveCellUnions(); + m_unionOfMatrixActiveCells = new RigActiveCellInfo; + m_unionOfFractureActiveCells = new RigActiveCellInfo; } //-------------------------------------------------------------------------------------------------- @@ -136,51 +137,50 @@ caf::PdmFieldHandle* RimIdenticalGridCaseGroup::userDescriptionField() //-------------------------------------------------------------------------------------------------- /// Make sure changes in this functions is validated to RIApplication::addEclipseCases() //-------------------------------------------------------------------------------------------------- -void RimIdenticalGridCaseGroup::initAfterRead() +void RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo() { if (caseCollection()->reservoirs().size() == 0) { return; } - // First file is read completely including grid. - // The main grid from the first case is reused directly in for the other cases. + // Read the main case completely including grid. + // The mainGrid from the first case is reused directly in for the other cases. // When reading active cell info, only the total cell count is tested for consistency - RigEclipseCase* mainEclipseCase = NULL; - RimResultReservoir* rimReservoir = dynamic_cast(caseCollection()->reservoirs()[0]); - CVF_ASSERT(rimReservoir); - - rimReservoir->openEclipseGridFile(); - - mainEclipseCase = rimReservoir->reservoirData(); + RimReservoir* mainCase = caseCollection()->reservoirs[0]; + mainCase->openEclipseGridFile(); + RigEclipseCase* mainEclipseCase = mainCase->reservoirData(); CVF_ASSERT(mainEclipseCase); - // Read active cell info from all source cases - caf::ProgressInfo info(caseCollection()->reservoirs().size(), "Case group - Reading Active Cell data"); - for (size_t i = 1; i < caseCollection()->reservoirs().size(); i++) + + caf::ProgressInfo info(caseCollection()->reservoirs.size(), "Case group - Reading Active Cell data"); + for (size_t i = 1; i < caseCollection()->reservoirs.size(); i++) { - RimResultReservoir* rimReservoir = dynamic_cast(caseCollection()->reservoirs()[i]); - CVF_ASSERT(rimReservoir); + RimResultReservoir* rimReservoir = dynamic_cast(caseCollection()->reservoirs[i]); + if(!rimReservoir) continue; // Input reservoir if (!rimReservoir->openAndReadActiveCellData(mainEclipseCase)) { CVF_ASSERT(false); } - info.setProgress(i); + info.incrementProgress(); } + m_mainGrid = mainEclipseCase->mainGrid(); + + // Check if we need to calculate the union of the active cells bool foundResultsInCache = false; - for (size_t i = 0; i < statisticalReservoirCollection()->reservoirs().size(); i++) + for (size_t i = 0; i < statisticalReservoirCollection()->reservoirs.size(); i++) { - RimStatisticalCalculation* rimReservoir = statisticalReservoirCollection()->reservoirs()[i]; + RimStatisticalCalculation* rimReservoir = statisticalReservoirCollection()->reservoirs[i]; // Check if any results are stored in cache - if (rimReservoir->results(RifReaderInterface::MATRIX_RESULTS)->m_resultCacheMetaData.size() > 0 || - rimReservoir->results(RifReaderInterface::FRACTURE_RESULTS)->m_resultCacheMetaData.size() > 0) + if (rimReservoir->results(RifReaderInterface::MATRIX_RESULTS)->storedResultsCount() > 0 || + rimReservoir->results(RifReaderInterface::FRACTURE_RESULTS)->storedResultsCount() > 0) { foundResultsInCache = true; break; @@ -192,11 +192,22 @@ void RimIdenticalGridCaseGroup::initAfterRead() computeUnionOfActiveCells(); } - m_mainGrid = mainEclipseCase->mainGrid(); + // "Load" the statistical cases - updateMainGridAndActiveCellsForStatisticsCases(); + for (size_t i = 0; i < statisticalReservoirCollection()->reservoirs.size(); i++) + { + RimStatisticalCalculation* rimReservoir = statisticalReservoirCollection()->reservoirs[i]; + + rimReservoir->openEclipseGridFile(); + + if (i == 0) + { + rimReservoir->reservoirData()->computeActiveCellBoundingBoxes(); + } + } } + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -209,13 +220,11 @@ void RimIdenticalGridCaseGroup::computeUnionOfActiveCells() if (caseCollection->reservoirs.size() == 0 || !m_mainGrid) { - m_unionOfMatrixActiveCells = new RigActiveCellInfo; - m_unionOfFractureActiveCells = new RigActiveCellInfo; + this->clearActiveCellUnions(); return; } - m_unionOfMatrixActiveCells->setGlobalCellCount(m_mainGrid->cells().size()); m_unionOfFractureActiveCells->setGlobalCellCount(m_mainGrid->cells().size()); m_unionOfMatrixActiveCells->setGridCount(m_mainGrid->gridCount()); @@ -291,12 +300,10 @@ RimStatisticalCalculation* RimIdenticalGridCaseGroup::createAndAppendStatistical RimStatisticalCalculation* newObject = new RimStatisticalCalculation; newObject->caseName = QString("Statistics ") + QString::number(statisticalReservoirCollection()->reservoirs.size()+1); - newObject->setMainGrid(this->mainGrid()); - newObject->reservoirData()->setActiveCellInfo(RifReaderInterface::MATRIX_RESULTS, m_unionOfMatrixActiveCells.p()); - newObject->reservoirData()->setActiveCellInfo(RifReaderInterface::FRACTURE_RESULTS, m_unionOfFractureActiveCells.p()); - statisticalReservoirCollection()->reservoirs.push_back(newObject); + newObject->openEclipseGridFile(); + return newObject; } @@ -309,13 +316,11 @@ void RimIdenticalGridCaseGroup::updateMainGridAndActiveCellsForStatisticsCases() { RimStatisticalCalculation* rimStaticsCase = statisticalReservoirCollection->reservoirs[i]; - rimStaticsCase->setMainGrid(this->mainGrid()); - rimStaticsCase->reservoirData()->setActiveCellInfo(RifReaderInterface::MATRIX_RESULTS, m_unionOfMatrixActiveCells.p()); - rimStaticsCase->reservoirData()->setActiveCellInfo(RifReaderInterface::FRACTURE_RESULTS, m_unionOfFractureActiveCells.p()); + rimStaticsCase->reservoirData()->setMainGrid(this->mainGrid()); if (i == 0) { - rimStaticsCase->reservoirData()->computeCachedData(); + rimStaticsCase->reservoirData()->computeActiveCellBoundingBoxes(); } } } @@ -338,8 +343,8 @@ void RimIdenticalGridCaseGroup::clearStatisticsResults() //-------------------------------------------------------------------------------------------------- void RimIdenticalGridCaseGroup::clearActiveCellUnions() { - m_unionOfMatrixActiveCells = new RigActiveCellInfo; - m_unionOfFractureActiveCells = new RigActiveCellInfo; + m_unionOfMatrixActiveCells->clear(); + m_unionOfFractureActiveCells->clear(); } //-------------------------------------------------------------------------------------------------- @@ -361,3 +366,14 @@ bool RimIdenticalGridCaseGroup::contains(RimReservoir* reservoir) const return false; } +RigActiveCellInfo* RimIdenticalGridCaseGroup::unionOfActiveCells(RifReaderInterface::PorosityModelResultType porosityType) +{ + if (porosityType == RifReaderInterface::MATRIX_RESULTS) + { + return m_unionOfMatrixActiveCells.p(); + } + else + { + return m_unionOfFractureActiveCells.p(); + } +} diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h index 6b05d6ec29..06c0c2d077 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h @@ -54,21 +54,21 @@ public: caf::PdmField caseCollection; caf::PdmField statisticalReservoirCollection; + void loadMainCaseAndActiveCellInfo(); + RigMainGrid* mainGrid(); + RigActiveCellInfo* unionOfActiveCells(RifReaderInterface::PorosityModelResultType porosityType); void computeUnionOfActiveCells(); protected: virtual caf::PdmFieldHandle* userDescriptionField(); - virtual void initAfterRead(); - private: void updateMainGridAndActiveCellsForStatisticsCases(); void clearStatisticsResults(); void clearActiveCellUnions(); - private: RigMainGrid* m_mainGrid; diff --git a/ApplicationCode/ProjectDataModel/RimReservoir.cpp b/ApplicationCode/ProjectDataModel/RimReservoir.cpp index dab4e7566d..abd80217ef 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoir.cpp @@ -261,7 +261,7 @@ void RimReservoir::computeCachedData() RigEclipseCase* rigEclipseCase = reservoirData(); if (rigEclipseCase) { - rigEclipseCase->computeCachedData(); + rigEclipseCase->computeActiveCellBoundingBoxes(); rigEclipseCase->mainGrid()->computeCachedData(); diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp index 650da7597c..6cf8ec3a05 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp @@ -22,6 +22,7 @@ #include "RIApplication.h" #include "RigMainGrid.h" #include "RigCell.h" +#include "cafProgressInfo.h" CAF_PDM_SOURCE_INIT(RimReservoirCellResultsStorage, "ReservoirCellResultStorage"); @@ -58,16 +59,36 @@ RimReservoirCellResultsStorage::~RimReservoirCellResultsStorage() //-------------------------------------------------------------------------------------------------- void RimReservoirCellResultsStorage::setupBeforeSave() { + m_resultCacheMetaData.deleteAllChildObjects(); + QString newValidCacheFileName = getValidCacheFileName(); + + // Delete the storage file + + QFileInfo storageFileInfo(newValidCacheFileName); + if (storageFileInfo.exists()) + { + QDir storageDir = storageFileInfo.dir(); + storageDir.remove(storageFileInfo.fileName()); + } + if (!m_cellResults) return; const std::vector& resInfo = m_cellResults->infoForEachResultIndex(); - m_resultCacheMetaData.deleteAllChildObjects(); - if(resInfo.size()) + bool hasResultsToStore = false; + for (size_t rIdx = 0; rIdx < resInfo.size(); ++rIdx) + { + if (resInfo[rIdx].m_needsToBeStored) + { + hasResultsToStore = true; + break; + } + } + + if(resInfo.size() && hasResultsToStore) { QDir::root().mkpath(getCacheDirectoryPath()); - QString newValidCacheFileName = getValidCacheFileName(); QFile cacheFile(newValidCacheFileName); if (!cacheFile.open(QIODevice::WriteOnly)) @@ -79,16 +100,22 @@ void RimReservoirCellResultsStorage::setupBeforeSave() m_resultCacheFileName = newValidCacheFileName; QDataStream stream(&cacheFile); - stream.setVersion(QDataStream::Qt_4_0); + stream.setVersion(QDataStream::Qt_4_6); stream << (quint32)0xCEECAC4E; // magic number stream << (quint32)1; // Version number. Increment if needing to extend the format in ways that can not be handled generically by the reader + caf::ProgressInfo progInfo(resInfo.size(), "Saving generated and imported properties"); + for (size_t rIdx = 0; rIdx < resInfo.size(); ++rIdx) { + // If there is no data, we do not store anything for the current result variable + // (Even not the metadata, of cause) size_t timestepCount = m_cellResults->cellScalarResults(resInfo[rIdx].m_gridScalarResultIndex).size(); - if (timestepCount) + if (timestepCount && resInfo[rIdx].m_needsToBeStored) { + progInfo.setProgressDescription(resInfo[rIdx].m_resultName); + // Create and setup the cache information for this result RimReservoirCellResultsStorageEntryInfo* cacheEntry = new RimReservoirCellResultsStorageEntryInfo; m_resultCacheMetaData.push_back(cacheEntry); @@ -125,10 +152,13 @@ void RimReservoirCellResultsStorage::setupBeforeSave() } } } + + progInfo.incrementProgress(); } } } + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -256,7 +286,15 @@ size_t RimReservoirCellResultsStorage::findOrLoadScalarResult(RimDefines::Result if (resultGridIndex == cvf::UNDEFINED_SIZE_T) return cvf::UNDEFINED_SIZE_T; - if (m_cellResults->cellScalarResults(resultGridIndex).size()) return resultGridIndex; + // If we have any results on any timestep, assume we have loaded results already + + for (size_t tsIdx = 0; tsIdx < m_cellResults->timeStepCount(resultGridIndex); ++tsIdx) + { + if (m_cellResults->cellScalarResults(resultGridIndex, tsIdx).size()) + { + return resultGridIndex; + } + } if (type == RimDefines::GENERATED) { @@ -369,7 +407,7 @@ void RimReservoirCellResultsStorage::loadOrComputeSOILForTimeStep(size_t timeSte size_t soilResultGridIndex = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL"); if (soilResultGridIndex == cvf::UNDEFINED_SIZE_T) { - soilResultGridIndex = m_cellResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL"); + soilResultGridIndex = m_cellResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL", false); CVF_ASSERT(soilResultGridIndex != cvf::UNDEFINED_SIZE_T); m_cellResults->cellScalarResults(soilResultGridIndex).resize(soilTimeStepCount); @@ -424,37 +462,37 @@ void RimReservoirCellResultsStorage::computeDepthRelatedResults() if (depthResultGridIndex == cvf::UNDEFINED_SIZE_T) { - depthResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "DEPTH", resultValueCount); + depthResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "DEPTH", false, resultValueCount); computeDepth = true; } if (dxResultGridIndex == cvf::UNDEFINED_SIZE_T) { - dxResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "DX", resultValueCount); + dxResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "DX", false, resultValueCount); computeDx = true; } if (dyResultGridIndex == cvf::UNDEFINED_SIZE_T) { - dyResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "DY", resultValueCount); + dyResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "DY", false, resultValueCount); computeDy = true; } if (dzResultGridIndex == cvf::UNDEFINED_SIZE_T) { - dzResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "DZ", resultValueCount); + dzResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "DZ", false, resultValueCount); computeDz = true; } if (topsResultGridIndex == cvf::UNDEFINED_SIZE_T) { - topsResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "TOPS", resultValueCount); + topsResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "TOPS", false, resultValueCount); computeTops = true; } if (bottomResultGridIndex == cvf::UNDEFINED_SIZE_T) { - bottomResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "BOTTOM", resultValueCount); + bottomResultGridIndex = m_cellResults->addStaticScalarResult(RimDefines::STATIC_NATIVE, "BOTTOM", false, resultValueCount); computeBottom = true; } @@ -539,6 +577,84 @@ size_t RimReservoirCellResultsStorage::findOrLoadScalarResult(const QString& res void RimReservoirCellResultsStorage::setCellResults(RigReservoirCellResults* cellResults) { m_cellResults = cellResults; + + if (m_cellResults == NULL) + return; + + // Now that we have got the results container, we can finally + // Read data from the internal storage and populate it + + if (m_resultCacheFileName().isEmpty()) + return; + + // Get the name of the cache name relative to the current project file position + QString newValidCacheFileName = getValidCacheFileName(); + + QFile storageFile(newValidCacheFileName); + + // Warn if we thought we were to find some data on the storage file + + if (!storageFile.exists() && m_resultCacheMetaData.size()) + { + qWarning() << "Reading stored results: Missing the storage file : " + newValidCacheFileName; + return; + } + + if (!storageFile.open(QIODevice::ReadOnly)) + { + qWarning() << "Reading stored results: Can't open the file : " + newValidCacheFileName; + return; + } + + QDataStream stream(&storageFile); + stream.setVersion(QDataStream::Qt_4_6); + quint32 magicNumber = 0; + quint32 versionNumber = 0; + stream >> magicNumber; + + if (magicNumber != 0xCEECAC4E) + { + qWarning() << "Reading stored results: The storage file has wrong type "; + return; + } + + stream >> versionNumber; + if (versionNumber > 1 ) + { + qWarning() << "Reading stored results: The storage file has been written by a newer version of ResInsight"; + return; + } + + caf::ProgressInfo progress(m_resultCacheMetaData.size(), "Reading internally stored results"); + // Fill the object with data from the storage + + for (size_t rIdx = 0; rIdx < m_resultCacheMetaData.size(); ++rIdx) + { + RimReservoirCellResultsStorageEntryInfo* resInfo = m_resultCacheMetaData[rIdx]; + size_t resultIndex = m_cellResults->addEmptyScalarResult(resInfo->m_resultType(), resInfo->m_resultName(), true); + + m_cellResults->setTimeStepDates(resultIndex, resInfo->m_timeStepDates()); + + progress.setProgressDescription(resInfo->m_resultName); + + for (size_t tsIdx = 0; tsIdx < resInfo->m_timeStepDates().size(); ++tsIdx) + { + std::vector* data = NULL; + + data = &(m_cellResults->cellScalarResults(rIdx, tsIdx)); + + quint64 cellCount = 0; + stream >> cellCount; + data->resize(cellCount, HUGE_VAL); + + for (size_t cIdx = 0; cIdx < cellCount; ++cIdx) + { + stream >> (*data)[cIdx]; + } + } + + progress.incrementProgress(); + } } //-------------------------------------------------------------------------------------------------- @@ -549,6 +665,14 @@ void RimReservoirCellResultsStorage::setMainGrid(RigMainGrid* mainGrid) m_ownerMainGrid = mainGrid; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RimReservoirCellResultsStorage::storedResultsCount() +{ + return m_resultCacheMetaData.size(); +} + CAF_PDM_SOURCE_INIT(RimReservoirCellResultsStorageEntryInfo, "ResultStorageEntryInfo"); diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h index 19141d7c6a..2351e6c54d 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h @@ -36,35 +36,39 @@ public: RimReservoirCellResultsStorage(); virtual ~RimReservoirCellResultsStorage(); - // Fields - caf::PdmField m_resultCacheFileName; - caf::PdmPointersField - m_resultCacheMetaData; - + void setCellResults(RigReservoirCellResults* cellResults); RigReservoirCellResults* cellResults() { return m_cellResults; } const RigReservoirCellResults* cellResults() const { return m_cellResults; } - void setCellResults(RigReservoirCellResults* cellResults); + size_t storedResultsCount(); + void setMainGrid(RigMainGrid* mainGrid); void setReaderInterface(RifReaderInterface* readerInterface); RifReaderInterface* readerInterface(); void loadOrComputeSOIL(); - void loadOrComputeSOILForTimeStep(size_t timeStepIndex); void computeDepthRelatedResults(); size_t findOrLoadScalarResultForTimeStep(RimDefines::ResultCatType type, const QString& resultName, size_t timeStepIndex); size_t findOrLoadScalarResult(RimDefines::ResultCatType type, const QString& resultName); size_t findOrLoadScalarResult(const QString& resultName); ///< Simplified search. Assumes unique names across types. +protected: // Overridden methods from PdmObject virtual void setupBeforeSave(); private: + void loadOrComputeSOILForTimeStep(size_t timeStepIndex); + QString getValidCacheFileName(); QString getCacheDirectoryPath(); + // Fields + caf::PdmField m_resultCacheFileName; + caf::PdmPointersField + m_resultCacheMetaData; + cvf::ref m_readerInterface; RigReservoirCellResults* m_cellResults; RigMainGrid* m_ownerMainGrid; diff --git a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp index b85640de6e..f2e9620587 100644 --- a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp @@ -145,7 +145,7 @@ bool RimResultReservoir::openAndReadActiveCellData(RigEclipseCase* mainEclipseCa CVF_ASSERT(this->reservoirData()); CVF_ASSERT(readerInterface.notNull()); - reservoirData()->computeCachedData(); + reservoirData()->computeActiveCellBoundingBoxes(); return true; } diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp index 0212edbbdd..3a6827e17b 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp @@ -40,9 +40,6 @@ RimStatisticalCalculation::RimStatisticalCalculation() CAF_PDM_InitObject("Case Group Statistics", ":/Histogram16x16.png", "", ""); CAF_PDM_InitField(&m_resultName, "ResultName", QString("PRESSURE"), "ResultName", "", "", ""); - m_readerInterface = new RifReaderStatisticalCalculation; - - openEclipseGridFile(); } //-------------------------------------------------------------------------------------------------- @@ -74,16 +71,20 @@ bool RimStatisticalCalculation::openEclipseGridFile() cvf::ref eclipseCase = new RigEclipseCase; - if (!m_readerInterface->open("dummy", eclipseCase.p())) - { - return false; - } + CVF_ASSERT(parentStatisticalCollection()); + + RimIdenticalGridCaseGroup* gridCaseGroup = parentStatisticalCollection()->parentCaseGroup(); + CVF_ASSERT(gridCaseGroup); + + RigMainGrid* mainGrid = gridCaseGroup->mainGrid(); + + eclipseCase->setMainGrid(mainGrid); + + eclipseCase->setActiveCellInfo(RifReaderInterface::MATRIX_RESULTS, gridCaseGroup->unionOfActiveCells(RifReaderInterface::MATRIX_RESULTS)); + eclipseCase->setActiveCellInfo(RifReaderInterface::FRACTURE_RESULTS, gridCaseGroup->unionOfActiveCells(RifReaderInterface::FRACTURE_RESULTS)); this->setReservoirData( eclipseCase.p() ); - results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(m_readerInterface.p()); - results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(m_readerInterface.p()); - return true; } @@ -150,11 +151,11 @@ void RimStatisticalCalculation::computeStatistics() QList > resultSpecification; - resultSpecification.append(qMakePair(RimDefines::DYNAMIC_NATIVE, QString("PRESSURE"))); + //resultSpecification.append(qMakePair(RimDefines::DYNAMIC_NATIVE, QString("PRESSURE"))); - /* + { - QStringList resultNames = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->resultNames(RimDefines::DYNAMIC_NATIVE); + QStringList resultNames = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->resultNames(RimDefines::DYNAMIC_NATIVE); foreach(QString resultName, resultNames) { resultSpecification.append(qMakePair(RimDefines::DYNAMIC_NATIVE, resultName)); @@ -162,13 +163,13 @@ void RimStatisticalCalculation::computeStatistics() } { - QStringList resultNames = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->resultNames(RimDefines::STATIC_NATIVE); + QStringList resultNames = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->resultNames(RimDefines::STATIC_NATIVE); foreach(QString resultName, resultNames) { resultSpecification.append(qMakePair(RimDefines::STATIC_NATIVE, resultName)); } } - */ + RigStatistics stat(sourceCases, timeStepIndices, statisticsConfig, resultCase); stat.evaluateStatistics(resultSpecification); diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp index 7591d27798..545dc046fb 100644 --- a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp @@ -158,6 +158,19 @@ void RigActiveCellInfo::setMatrixActiveCellsGeometryBoundingBox(cvf::BoundingBox m_matrixActiveCellsBoundingBox = bb; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigActiveCellInfo::clear() +{ + m_perGridActiveCellInfo.clear(); + m_activeInMatrixModel.clear(); + m_globalMatrixModelActiveCellCount = 0; + m_activeCellPositionMin = cvf::Vec3st(0,0,0); + m_activeCellPositionMax = cvf::Vec3st(0,0,0); + m_matrixActiveCellsBoundingBox.reset(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h index 50ae9e1a34..abd01a5e76 100644 --- a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h @@ -51,6 +51,8 @@ public: cvf::BoundingBox matrixActiveCellsGeometryBoundingBox() const; void setMatrixActiveCellsGeometryBoundingBox(cvf::BoundingBox bb); + void clear(); + private: class GridActiveCellCounts { diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp index dbfbdbdde8..6cdb533792 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp @@ -277,7 +277,7 @@ public: //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigEclipseCase::computeActiveCellData() +void RigEclipseCase::computeActiveCellIJKBBox() { CellRangeBB matrixModelActiveBB; CellRangeBB fractureModelActiveBB; @@ -306,9 +306,9 @@ void RigEclipseCase::computeActiveCellData() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigEclipseCase::computeCachedData() +void RigEclipseCase::computeActiveCellBoundingBoxes() { - computeActiveCellData(); + computeActiveCellIJKBBox(); computeActiveCellsGeometryBoundingBox(); } diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCase.h b/ApplicationCode/ReservoirDataModel/RigEclipseCase.h index 04d23400ec..c4ed2a5b46 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCase.h +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCase.h @@ -59,20 +59,18 @@ public: size_t timeStepIndex, size_t scalarSetIndex); - void setWellResults(const cvf::Collection& data); + void setWellResults(const cvf::Collection& data); const cvf::Collection& wellResults() { return m_wellResults; } - cvf::UByteArray* wellCellsInGrid(size_t gridIndex); RigCell& cellFromWellResultCell(const RigWellResultCell& wellResultCell); bool findSharedSourceFace(cvf::StructGridInterface::FaceType& sharedSourceFace, const RigWellResultCell& sourceWellCellResult, const RigWellResultCell& otherWellCellResult) const; - void computeCachedData(); - //void closeReaderInterface(); + void computeActiveCellBoundingBoxes(); private: - void computeActiveCellData(); + void computeActiveCellIJKBBox(); void computeWellCellsPrGrid(); void computeActiveCellsGeometryBoundingBox(); diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp index 7f5089a86d..4ee9d29606 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp @@ -337,7 +337,7 @@ size_t RigReservoirCellResults::findScalarResultIndex(const QString& resultName) /// Adds an empty scalar set, and returns the scalarResultIndex to it. /// if resultName already exists, it returns the scalarResultIndex to the existing result. //-------------------------------------------------------------------------------------------------- -size_t RigReservoirCellResults::addEmptyScalarResult(RimDefines::ResultCatType type, const QString& resultName) +size_t RigReservoirCellResults::addEmptyScalarResult(RimDefines::ResultCatType type, const QString& resultName, bool needsToBeStored) { size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T; @@ -346,7 +346,7 @@ size_t RigReservoirCellResults::addEmptyScalarResult(RimDefines::ResultCatType t { scalarResultIndex = this->resultCount(); m_cellScalarResults.push_back(std::vector >()); - ResultInfo resInfo(type, resultName, scalarResultIndex); + ResultInfo resInfo(type, needsToBeStored, resultName, scalarResultIndex); m_resultInfos.push_back(resInfo); } @@ -435,9 +435,8 @@ void RigReservoirCellResults::setTimeStepDates(size_t scalarResultIndex, const s m_resultInfos[scalarResultIndex].m_timeStepDates = dates; - // We need this. But not yet ... - //std::vector< std::vector >& dataValues = this->cellScalarResults(scalarResultIndex); - //dataValues.resize(dates.size()); + std::vector< std::vector >& dataValues = this->cellScalarResults(scalarResultIndex); + dataValues.resize(dates.size()); } //-------------------------------------------------------------------------------------------------- @@ -517,9 +516,9 @@ void RigReservoirCellResults::clearAllResults() //-------------------------------------------------------------------------------------------------- /// Add a result with given type and name, and allocate one result vector for the static result values //-------------------------------------------------------------------------------------------------- -size_t RigReservoirCellResults::addStaticScalarResult(RimDefines::ResultCatType type, const QString& resultName, size_t resultValueCount) +size_t RigReservoirCellResults::addStaticScalarResult(RimDefines::ResultCatType type, const QString& resultName, bool needsToBeStored, size_t resultValueCount) { - size_t resultIdx = addEmptyScalarResult(type, resultName); + size_t resultIdx = addEmptyScalarResult(type, resultName, needsToBeStored); m_cellScalarResults[resultIdx].push_back(std::vector()); m_cellScalarResults[resultIdx][0].resize(resultValueCount, HUGE_VAL); diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h index 7e624b29bf..6fa3caca61 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h +++ b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h @@ -35,10 +35,7 @@ class RigReservoirCellResults : public cvf::Object public: RigReservoirCellResults(RigMainGrid* ownerGrid); - //void setReaderInterface(RifReaderInterface* readerInterface); - //RifReaderInterface* readerInterface(); - - void setMainGrid(RigMainGrid* ownerGrid); + void setMainGrid(RigMainGrid* ownerGrid); // Max and min values of the results void recalculateMinMax(size_t scalarResultIndex); @@ -64,14 +61,14 @@ public: size_t findScalarResultIndex(RimDefines::ResultCatType type, const QString& resultName) const; size_t findScalarResultIndex(const QString& resultName) const; - size_t addEmptyScalarResult(RimDefines::ResultCatType type, const QString& resultName); + size_t addEmptyScalarResult(RimDefines::ResultCatType type, const QString& resultName, bool needsToBeStored); QString makeResultNameUnique(const QString& resultNameProposal) const; void removeResult(const QString& resultName); void clearAllResults(); - // Access the results data + const std::vector< std::vector > & cellScalarResults(size_t scalarResultIndex) const; std::vector< std::vector > & cellScalarResults(size_t scalarResultIndex); std::vector& cellScalarResults(size_t scalarResultIndex, size_t timeStepIndex); @@ -83,14 +80,15 @@ public: class ResultInfo { public: - ResultInfo(RimDefines::ResultCatType resultType, QString resultName, size_t gridScalarResultIndex) - : m_resultType(resultType), m_resultName(resultName), m_gridScalarResultIndex(gridScalarResultIndex) { } + ResultInfo(RimDefines::ResultCatType resultType, bool needsToBeStored, QString resultName, size_t gridScalarResultIndex) + : m_resultType(resultType), m_needsToBeStored(needsToBeStored), m_resultName(resultName), m_gridScalarResultIndex(gridScalarResultIndex) { } public: RimDefines::ResultCatType m_resultType; + bool m_needsToBeStored; QString m_resultName; size_t m_gridScalarResultIndex; - std::vector m_timeStepDates; + std::vector m_timeStepDates; }; const std::vector& infoForEachResultIndex() { return m_resultInfos;} @@ -98,6 +96,7 @@ public: public: size_t addStaticScalarResult(RimDefines::ResultCatType type, const QString& resultName, + bool needsToBeStored, size_t resultValueCount); private: diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.cpp b/ApplicationCode/SocketInterface/RiaSocketServer.cpp index 04c123c1e1..e48ab7b3f5 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.cpp +++ b/ApplicationCode/SocketInterface/RiaSocketServer.cpp @@ -286,7 +286,7 @@ void RiaSocketServer::readCommandFromOctave() if (scalarResultIndex == cvf::UNDEFINED_SIZE_T && isSetProperty) { - scalarResultIndex = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->addEmptyScalarResult(RimDefines::GENERATED, propertyName); + scalarResultIndex = reservoir->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->addEmptyScalarResult(RimDefines::GENERATED, propertyName, true); } if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) From 0bb4d5ddc3beb7dee7f0d92f98422454e714d3f0 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 22 Mar 2013 09:16:50 +0100 Subject: [PATCH 154/242] Set selected results to None and rebuild display geometry p4#: 21043 --- .../ProjectDataModel/RimIdenticalGridCaseGroup.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index 74f61921ca..37a1a44fcc 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -335,6 +335,14 @@ void RimIdenticalGridCaseGroup::clearStatisticsResults() RimStatisticalCalculation* rimStaticsCase = statisticalReservoirCollection->reservoirs[i]; rimStaticsCase->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->clearAllResults(); rimStaticsCase->results(RifReaderInterface::FRACTURE_RESULTS)->cellResults()->clearAllResults(); + + for (size_t j = 0; j < rimStaticsCase->reservoirViews.size(); j++) + { + RimReservoirView* rimReservoirView = rimStaticsCase->reservoirViews[j]; + rimReservoirView->cellResult()->resultVariable = RimDefines::undefinedResultName(); + rimReservoirView->cellEdgeResult()->resultVariable = RimDefines::undefinedResultName(); + rimReservoirView->loadDataAndUpdate(); + } } } From 21065176f20badf04d278532e01255702353e1c7 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 22 Mar 2013 09:32:42 +0100 Subject: [PATCH 155/242] Rename of functions in RigActiveCellInfo p4#: 21045 --- .../FileInterface/RifReaderEclipseOutput.cpp | 22 +++--- .../RivReservoirViewPartMgr.cpp | 4 +- .../ProjectDataModel/RigStatistics.cpp | 4 +- .../Rim3dOverlayInfoConfig.cpp | 4 +- .../ProjectDataModel/RimCellRangeFilter.cpp | 4 +- .../RimIdenticalGridCaseGroup.cpp | 10 +-- .../ProjectDataModel/RimReservoirView.cpp | 4 +- .../ProjectDataModel/RimResultDefinition.cpp | 2 +- .../ReservoirDataModel/RigActiveCellInfo.cpp | 68 +++++++++---------- .../ReservoirDataModel/RigActiveCellInfo.h | 32 ++++----- .../ReservoirDataModel/RigEclipseCase.cpp | 16 ++--- .../RigGridScalarDataAccess.cpp | 4 +- .../RigReservoirBuilderMock.cpp | 2 +- .../SocketInterface/RiaSocketServer.cpp | 6 +- .../UserInterface/RIMainWindow.cpp | 23 +++++++ 15 files changed, 114 insertions(+), 91 deletions(-) diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index 3d8e746183..c15f589038 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -120,13 +120,13 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigActiveCellInfo* activeCellIn int matrixActiveIndex = ecl_grid_get_active_index1(localEclGrid, localCellIdx); if (matrixActiveIndex != -1) { - activeCellInfo->setActiveIndexInMatrixModel(cellStartIndex + localCellIdx, matrixActiveStartIndex + matrixActiveIndex); + activeCellInfo->setCellResultIndex(cellStartIndex + localCellIdx, matrixActiveStartIndex + matrixActiveIndex); } int fractureActiveIndex = ecl_grid_get_active_fracture_index1(localEclGrid, localCellIdx); if (fractureActiveIndex != -1) { - fractureActiveCellInfo->setActiveIndexInMatrixModel(cellStartIndex + localCellIdx, fractureActiveStartIndex + fractureActiveIndex); + fractureActiveCellInfo->setCellResultIndex(cellStartIndex + localCellIdx, fractureActiveStartIndex + fractureActiveIndex); } // Parent cell index @@ -490,13 +490,13 @@ bool RifReaderEclipseOutput::readActiveCellInfo() { if (actnumValues[i] == 1 || actnumValues[i] == 3) { - activeCellInfo->setActiveIndexInMatrixModel(cellIdx, globalActiveMatrixIndex++); + activeCellInfo->setCellResultIndex(cellIdx, globalActiveMatrixIndex++); activeMatrixIndex++; } if (actnumValues[i] == 2 || actnumValues[i] == 3) { - fractureActiveCellInfo->setActiveIndexInMatrixModel(cellIdx, globalActiveFractureIndex++); + fractureActiveCellInfo->setCellResultIndex(cellIdx, globalActiveFractureIndex++); activeFractureIndex++; } @@ -919,7 +919,7 @@ QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringL if (matrixOrFracture == RifReaderInterface::FRACTURE_RESULTS) { - if (fractureActiveCellInfo->globalMatrixModelActiveCellCount() == 0) + if (fractureActiveCellInfo->globalActiveCellCount() == 0) { return QStringList(); } @@ -932,13 +932,13 @@ QStringList RifReaderEclipseOutput::validKeywordsForPorosityModel(const QStringL QString keyword = keywords[i]; size_t keywordDataCount = keywordDataItemCounts[i]; - if (activeCellInfo->globalMatrixModelActiveCellCount() > 0) + if (activeCellInfo->globalActiveCellCount() > 0) { - size_t timeStepsMatrix = keywordDataItemCounts[i] / activeCellInfo->globalMatrixModelActiveCellCount(); - size_t timeStepsMatrixRest = keywordDataItemCounts[i] % activeCellInfo->globalMatrixModelActiveCellCount(); + size_t timeStepsMatrix = keywordDataItemCounts[i] / activeCellInfo->globalActiveCellCount(); + size_t timeStepsMatrixRest = keywordDataItemCounts[i] % activeCellInfo->globalActiveCellCount(); - size_t timeStepsMatrixAndFracture = keywordDataItemCounts[i] / (activeCellInfo->globalMatrixModelActiveCellCount() + fractureActiveCellInfo->globalMatrixModelActiveCellCount()); - size_t timeStepsMatrixAndFractureRest = keywordDataItemCounts[i] % (activeCellInfo->globalMatrixModelActiveCellCount() + fractureActiveCellInfo->globalMatrixModelActiveCellCount()); + size_t timeStepsMatrixAndFracture = keywordDataItemCounts[i] / (activeCellInfo->globalActiveCellCount() + fractureActiveCellInfo->globalActiveCellCount()); + size_t timeStepsMatrixAndFractureRest = keywordDataItemCounts[i] % (activeCellInfo->globalActiveCellCount() + fractureActiveCellInfo->globalActiveCellCount()); if (matrixOrFracture == RifReaderInterface::MATRIX_RESULTS) { @@ -976,7 +976,7 @@ void RifReaderEclipseOutput::extractResultValuesBasedOnPorosityModel(PorosityMod RigActiveCellInfo* fracActCellInfo = m_eclipseCase->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS); - if (matrixOrFracture == RifReaderInterface::MATRIX_RESULTS && fracActCellInfo->globalMatrixModelActiveCellCount() == 0) + if (matrixOrFracture == RifReaderInterface::MATRIX_RESULTS && fracActCellInfo->globalActiveCellCount() == 0) { destinationResultValues->insert(destinationResultValues->end(), sourceResultValues.begin(), sourceResultValues.end()); } diff --git a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp index 74a80eb3a2..a0ddb2ac74 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp @@ -487,8 +487,8 @@ void RivReservoirViewPartMgr::computeNativeVisibility(cvf::UByteArray* cellVisib size_t globalCellIndex = cell.mainGridCellIndex(); if ( !invalidCellsIsVisible && cell.isInvalid() - || !inactiveCellsIsVisible && !activeCellInfo->isActiveInMatrixModel(globalCellIndex) - || !activeCellsIsVisible && activeCellInfo->isActiveInMatrixModel(globalCellIndex) + || !inactiveCellsIsVisible && !activeCellInfo->isActive(globalCellIndex) + || !activeCellsIsVisible && activeCellInfo->isActive(globalCellIndex) || mainGridIsVisible && (cell.subGrid() != NULL) || (*cellIsInWellStatuses)[cellIndex] ) diff --git a/ApplicationCode/ProjectDataModel/RigStatistics.cpp b/ApplicationCode/ProjectDataModel/RigStatistics.cpp index 3b6a173402..52fac4283d 100644 --- a/ApplicationCode/ProjectDataModel/RigStatistics.cpp +++ b/ApplicationCode/ProjectDataModel/RigStatistics.cpp @@ -92,7 +92,7 @@ void RigStatistics::evaluateStatistics(const QListactiveCellInfo(RifReaderInterface::MATRIX_RESULTS)->globalMatrixModelActiveCellCount(); + size_t activeMatrixCellCount = m_destinationCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->globalActiveCellCount(); RigReservoirCellResults* matrixResults = m_destinationCase->results(RifReaderInterface::MATRIX_RESULTS); for (int i = 0; i < resultSpecification.size(); i++) @@ -225,7 +225,7 @@ void RigStatistics::evaluateStatistics(const QList values(dataAccesObjectList.size(), HUGE_VAL); size_t globalGridCellIdx = grid->globalGridCellIndex(cellIdx); - if (m_destinationCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->isActiveInMatrixModel(globalGridCellIdx)) + if (m_destinationCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->isActive(globalGridCellIdx)) { bool foundAnyValidValues = false; for (size_t caseIdx = 0; caseIdx < dataAccesObjectList.size(); caseIdx++) diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index 1e00f95e13..1ea0b6589b 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -91,8 +91,8 @@ void Rim3dOverlayInfoConfig::update3DInfo() { caseName = m_reservoirView->eclipseCase()->caseName(); totCellCount = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->cells().size()); - size_t mxActCellCount = m_reservoirView->eclipseCase()->reservoirData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->globalMatrixModelActiveCellCount(); - size_t frActCellCount = m_reservoirView->eclipseCase()->reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->globalMatrixModelActiveCellCount(); + size_t mxActCellCount = m_reservoirView->eclipseCase()->reservoirData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->globalActiveCellCount(); + size_t frActCellCount = m_reservoirView->eclipseCase()->reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->globalActiveCellCount(); if (frActCellCount > 0) activeCellCountText += "Matrix : "; activeCellCountText += QString::number(mxActCellCount); if (frActCellCount > 0) activeCellCountText += " Fracture : " + QString::number(frActCellCount); diff --git a/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp b/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp index ed23615d52..d8c087a462 100644 --- a/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp @@ -119,7 +119,7 @@ void RimCellRangeFilter::setDefaultValues() if (actCellInfo) { cvf::Vec3st min, max; - actCellInfo->matrixModelActiveCellsBoundingBox(min, max); + actCellInfo->IJKBoundingBox(min, max); // Adjust to Eclipse indexing min.x() = min.x() + 1; @@ -165,7 +165,7 @@ void RimCellRangeFilter::defineEditorAttribute(const caf::PdmFieldHandle* field, if (actCellInfo) { cvf::Vec3st min, max; - actCellInfo->matrixModelActiveCellsBoundingBox(min, max); + actCellInfo->IJKBoundingBox(min, max); // Adjust to Eclipse indexing min.x() = min.x() + 1; diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index 37a1a44fcc..89426d79b4 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -213,7 +213,7 @@ void RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo() //-------------------------------------------------------------------------------------------------- void RimIdenticalGridCaseGroup::computeUnionOfActiveCells() { - if (m_unionOfMatrixActiveCells->globalMatrixModelActiveCellCount() > 0) + if (m_unionOfMatrixActiveCells->globalActiveCellCount() > 0) { return; } @@ -248,7 +248,7 @@ void RimIdenticalGridCaseGroup::computeUnionOfActiveCells() if (activeM[localGridCellIdx] == 0) { - if (caseCollection->reservoirs[caseIdx]->reservoirData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->isActiveInMatrixModel(globalCellIdx)) + if (caseCollection->reservoirs[caseIdx]->reservoirData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->isActive(globalCellIdx)) { activeM[localGridCellIdx] = 1; } @@ -256,7 +256,7 @@ void RimIdenticalGridCaseGroup::computeUnionOfActiveCells() if (activeF[localGridCellIdx] == 0) { - if (caseCollection->reservoirs[caseIdx]->reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->isActiveInMatrixModel(globalCellIdx)) + if (caseCollection->reservoirs[caseIdx]->reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->isActive(globalCellIdx)) { activeF[localGridCellIdx] = 1; } @@ -273,13 +273,13 @@ void RimIdenticalGridCaseGroup::computeUnionOfActiveCells() if (activeM[localGridCellIdx] != 0) { - m_unionOfMatrixActiveCells->setActiveIndexInMatrixModel(globalCellIdx, globalActiveMatrixIndex++); + m_unionOfMatrixActiveCells->setCellResultIndex(globalCellIdx, globalActiveMatrixIndex++); activeMatrixIndex++; } if (activeF[localGridCellIdx] != 0) { - m_unionOfFractureActiveCells->setActiveIndexInMatrixModel(globalCellIdx, globalActiveFractureIndex++); + m_unionOfFractureActiveCells->setCellResultIndex(globalCellIdx, globalActiveFractureIndex++); activeFractureIndex++; } } diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp index 93b19388da..fedce7dfc8 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp @@ -721,7 +721,7 @@ void RimReservoirView::loadDataAndUpdate() CVF_ASSERT(this->cellResult() != NULL); this->cellResult()->loadResult(); - if (m_reservoir->reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->globalMatrixModelActiveCellCount() == 0) + if (m_reservoir->reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->globalActiveCellCount() == 0) { this->cellResult->porosityModel.setUiHidden(true); } @@ -1268,7 +1268,7 @@ void RimReservoirView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibl size_t fenceCellIndex = grid->cellIndexFromIJK(*pI,*pJ,*pK); size_t globalGridCellIndex = grid->globalGridCellIndex(fenceCellIndex); - if (activeCellInfo && activeCellInfo->isActiveInMatrixModel(globalGridCellIndex)) + if (activeCellInfo && activeCellInfo->isActive(globalGridCellIndex)) { (*visibleCells)[fenceCellIndex] = true; } diff --git a/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp index 44826426bc..98e081ea12 100644 --- a/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp @@ -65,7 +65,7 @@ void RimResultDefinition::setReservoirView(RimReservoirView* ownerReservoirView) m_reservoirView->eclipseCase()->reservoirData() && m_reservoirView->eclipseCase()->reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS) ) { - if (m_reservoirView->eclipseCase()->reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->globalMatrixModelActiveCellCount() == 0) + if (m_reservoirView->eclipseCase()->reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->globalActiveCellCount() == 0) { porosityModel.setUiHidden(true); } diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp index 545dc046fb..486470c849 100644 --- a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.cpp @@ -23,7 +23,7 @@ /// //-------------------------------------------------------------------------------------------------- RigActiveCellInfo::RigActiveCellInfo() - : m_globalMatrixModelActiveCellCount(0), + : m_globalActiveCellCount(0), m_activeCellPositionMin(cvf::Vec3d::ZERO), m_activeCellPositionMax(cvf::Vec3d::ZERO) { @@ -35,47 +35,47 @@ RigActiveCellInfo::RigActiveCellInfo() //-------------------------------------------------------------------------------------------------- void RigActiveCellInfo::setGlobalCellCount(size_t globalCellCount) { - m_activeInMatrixModel.resize(globalCellCount, cvf::UNDEFINED_SIZE_T); + m_cellIndexToResultIndex.resize(globalCellCount, cvf::UNDEFINED_SIZE_T); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RigActiveCellInfo::isActiveInMatrixModel(size_t globalCellIndex) const +bool RigActiveCellInfo::isActive(size_t globalCellIndex) const { - if (m_activeInMatrixModel.size() == 0) + if (m_cellIndexToResultIndex.size() == 0) { return true; } - CVF_TIGHT_ASSERT(globalCellIndex < m_activeInMatrixModel.size()); + CVF_TIGHT_ASSERT(globalCellIndex < m_cellIndexToResultIndex.size()); - return m_activeInMatrixModel[globalCellIndex] != cvf::UNDEFINED_SIZE_T; + return m_cellIndexToResultIndex[globalCellIndex] != cvf::UNDEFINED_SIZE_T; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -size_t RigActiveCellInfo::activeIndexInMatrixModel(size_t globalCellIndex) const +size_t RigActiveCellInfo::cellResultIndex(size_t globalCellIndex) const { - if (m_activeInMatrixModel.size() == 0) + if (m_cellIndexToResultIndex.size() == 0) { return globalCellIndex; } - CVF_TIGHT_ASSERT(globalCellIndex < m_activeInMatrixModel.size()); + CVF_TIGHT_ASSERT(globalCellIndex < m_cellIndexToResultIndex.size()); - return m_activeInMatrixModel[globalCellIndex]; + return m_cellIndexToResultIndex[globalCellIndex]; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigActiveCellInfo::setActiveIndexInMatrixModel(size_t globalCellIndex, size_t globalActiveCellIndex) +void RigActiveCellInfo::setCellResultIndex(size_t globalCellIndex, size_t globalActiveCellIndex) { - CVF_TIGHT_ASSERT(globalActiveCellIndex < m_activeInMatrixModel.size()); + CVF_TIGHT_ASSERT(globalActiveCellIndex < m_cellIndexToResultIndex.size()); - m_activeInMatrixModel[globalCellIndex] = globalActiveCellIndex; + m_cellIndexToResultIndex[globalCellIndex] = globalActiveCellIndex; } //-------------------------------------------------------------------------------------------------- @@ -89,11 +89,11 @@ void RigActiveCellInfo::setGridCount(size_t gridCount) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigActiveCellInfo::setGridActiveCellCounts(size_t gridIndex, size_t matrixActiveCellCount) +void RigActiveCellInfo::setGridActiveCellCounts(size_t gridIndex, size_t activeCellCount) { CVF_ASSERT(gridIndex < m_perGridActiveCellInfo.size()); - m_perGridActiveCellInfo[gridIndex].setMatrixModelActiveCellCount(matrixActiveCellCount); + m_perGridActiveCellInfo[gridIndex].setActiveCellCount(activeCellCount); } //-------------------------------------------------------------------------------------------------- @@ -101,26 +101,26 @@ void RigActiveCellInfo::setGridActiveCellCounts(size_t gridIndex, size_t matrixA //-------------------------------------------------------------------------------------------------- void RigActiveCellInfo::computeDerivedData() { - m_globalMatrixModelActiveCellCount = 0; + m_globalActiveCellCount = 0; for (size_t i = 0; i < m_perGridActiveCellInfo.size(); i++) { - m_globalMatrixModelActiveCellCount += m_perGridActiveCellInfo[i].matrixModelActiveCellCount(); + m_globalActiveCellCount += m_perGridActiveCellInfo[i].activeCellCount(); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -size_t RigActiveCellInfo::globalMatrixModelActiveCellCount() const +size_t RigActiveCellInfo::globalActiveCellCount() const { - return m_globalMatrixModelActiveCellCount; + return m_globalActiveCellCount; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigActiveCellInfo::setMatrixModelActiveCellsBoundingBox(const cvf::Vec3st& min, const cvf::Vec3st& max) +void RigActiveCellInfo::setIJKBoundingBox(const cvf::Vec3st& min, const cvf::Vec3st& max) { m_activeCellPositionMin = min; m_activeCellPositionMax = max; @@ -129,7 +129,7 @@ void RigActiveCellInfo::setMatrixModelActiveCellsBoundingBox(const cvf::Vec3st& //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigActiveCellInfo::matrixModelActiveCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const +void RigActiveCellInfo::IJKBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const { min = m_activeCellPositionMin; max = m_activeCellPositionMax; @@ -138,24 +138,24 @@ void RigActiveCellInfo::matrixModelActiveCellsBoundingBox(cvf::Vec3st& min, cvf: //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigActiveCellInfo::gridActiveCellCounts(size_t gridIndex, size_t& matrixActiveCellCount) +void RigActiveCellInfo::gridActiveCellCounts(size_t gridIndex, size_t& activeCellCount) { - matrixActiveCellCount = m_perGridActiveCellInfo[gridIndex].matrixModelActiveCellCount(); + activeCellCount = m_perGridActiveCellInfo[gridIndex].activeCellCount(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::BoundingBox RigActiveCellInfo::matrixActiveCellsGeometryBoundingBox() const +cvf::BoundingBox RigActiveCellInfo::geometryBoundingBox() const { - return m_matrixActiveCellsBoundingBox; + return m_activeCellsBoundingBox; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigActiveCellInfo::setMatrixActiveCellsGeometryBoundingBox(cvf::BoundingBox bb) +void RigActiveCellInfo::setGeometryBoundingBox(cvf::BoundingBox bb) { - m_matrixActiveCellsBoundingBox = bb; + m_activeCellsBoundingBox = bb; } //-------------------------------------------------------------------------------------------------- @@ -164,25 +164,25 @@ void RigActiveCellInfo::setMatrixActiveCellsGeometryBoundingBox(cvf::BoundingBox void RigActiveCellInfo::clear() { m_perGridActiveCellInfo.clear(); - m_activeInMatrixModel.clear(); - m_globalMatrixModelActiveCellCount = 0; + m_cellIndexToResultIndex.clear(); + m_globalActiveCellCount = 0; m_activeCellPositionMin = cvf::Vec3st(0,0,0); m_activeCellPositionMax = cvf::Vec3st(0,0,0); - m_matrixActiveCellsBoundingBox.reset(); + m_activeCellsBoundingBox.reset(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -size_t RigActiveCellInfo::GridActiveCellCounts::matrixModelActiveCellCount() const +size_t RigActiveCellInfo::GridActiveCellCounts::activeCellCount() const { - return m_matrixModelActiveCellCount; + return m_activeCellCount; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigActiveCellInfo::GridActiveCellCounts::setMatrixModelActiveCellCount(size_t activeMatrixModelCellCount) +void RigActiveCellInfo::GridActiveCellCounts::setActiveCellCount(size_t activeCellCount) { - m_matrixModelActiveCellCount = activeMatrixModelCellCount; + m_activeCellCount = activeCellCount; } diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h index abd01a5e76..7086b87d4f 100644 --- a/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellInfo.h @@ -34,22 +34,22 @@ public: void setGlobalCellCount(size_t globalCellCount); - bool isActiveInMatrixModel(size_t globalCellIndex) const; - size_t activeIndexInMatrixModel(size_t globalCellIndex) const; - void setActiveIndexInMatrixModel(size_t globalCellIndex, size_t globalActiveCellIndex); + bool isActive(size_t globalCellIndex) const; + size_t cellResultIndex(size_t globalCellIndex) const; + void setCellResultIndex(size_t globalCellIndex, size_t globalActiveCellIndex); void setGridCount(size_t gridCount); - void setGridActiveCellCounts(size_t gridIndex, size_t matrixActiveCellCount); - void gridActiveCellCounts(size_t gridIndex, size_t& matrixActiveCellCount); + void setGridActiveCellCounts(size_t gridIndex, size_t activeCellCount); + void gridActiveCellCounts(size_t gridIndex, size_t& activeCellCount); void computeDerivedData(); - size_t globalMatrixModelActiveCellCount() const; + size_t globalActiveCellCount() const; - void setMatrixModelActiveCellsBoundingBox(const cvf::Vec3st& min, const cvf::Vec3st& max); - void matrixModelActiveCellsBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const; + void setIJKBoundingBox(const cvf::Vec3st& min, const cvf::Vec3st& max); + void IJKBoundingBox(cvf::Vec3st& min, cvf::Vec3st& max) const; - cvf::BoundingBox matrixActiveCellsGeometryBoundingBox() const; - void setMatrixActiveCellsGeometryBoundingBox(cvf::BoundingBox bb); + cvf::BoundingBox geometryBoundingBox() const; + void setGeometryBoundingBox(cvf::BoundingBox bb); void clear(); @@ -57,23 +57,23 @@ private: class GridActiveCellCounts { public: - size_t matrixModelActiveCellCount() const; - void setMatrixModelActiveCellCount(size_t activeMatrixModelCellCount); + size_t activeCellCount() const; + void setActiveCellCount(size_t activeCellCount); private: - size_t m_matrixModelActiveCellCount; + size_t m_activeCellCount; }; private: std::vector m_perGridActiveCellInfo; - std::vector m_activeInMatrixModel; + std::vector m_cellIndexToResultIndex; - size_t m_globalMatrixModelActiveCellCount; + size_t m_globalActiveCellCount; cvf::Vec3st m_activeCellPositionMin; cvf::Vec3st m_activeCellPositionMax; - cvf::BoundingBox m_matrixActiveCellsBoundingBox; + cvf::BoundingBox m_activeCellsBoundingBox; }; diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp index 6cdb533792..b8cb1a310a 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp @@ -288,19 +288,19 @@ void RigEclipseCase::computeActiveCellIJKBBox() size_t i, j, k; m_mainGrid->ijkFromCellIndex(idx, &i, &j, &k); - if (m_activeCellInfo->isActiveInMatrixModel(idx)) + if (m_activeCellInfo->isActive(idx)) { matrixModelActiveBB.add(i, j, k); } - if (m_fractureActiveCellInfo->isActiveInMatrixModel(idx)) + if (m_fractureActiveCellInfo->isActive(idx)) { fractureModelActiveBB.add(i, j, k); } } - m_activeCellInfo->setMatrixModelActiveCellsBoundingBox(matrixModelActiveBB.m_min, matrixModelActiveBB.m_max); - m_fractureActiveCellInfo->setMatrixModelActiveCellsBoundingBox(fractureModelActiveBB.m_min, fractureModelActiveBB.m_max); + m_activeCellInfo->setIJKBoundingBox(matrixModelActiveBB.m_min, matrixModelActiveBB.m_max); + m_fractureActiveCellInfo->setIJKBoundingBox(fractureModelActiveBB.m_min, fractureModelActiveBB.m_max); } //-------------------------------------------------------------------------------------------------- @@ -362,8 +362,8 @@ void RigEclipseCase::computeActiveCellsGeometryBoundingBox() if (m_mainGrid.isNull()) { cvf::BoundingBox bb; - m_activeCellInfo->setMatrixActiveCellsGeometryBoundingBox(bb); - m_fractureActiveCellInfo->setMatrixActiveCellsGeometryBoundingBox(bb); + m_activeCellInfo->setGeometryBoundingBox(bb); + m_fractureActiveCellInfo->setGeometryBoundingBox(bb); return; } @@ -383,7 +383,7 @@ void RigEclipseCase::computeActiveCellsGeometryBoundingBox() { for (size_t i = 0; i < m_mainGrid->cellCount(); i++) { - if (activeInfos[acIdx]->isActiveInMatrixModel(i)) + if (activeInfos[acIdx]->isActive(i)) { const RigCell& c = m_mainGrid->cells()[i]; const caf::SizeTArray8& indices = c.cornerIndices(); @@ -397,7 +397,7 @@ void RigEclipseCase::computeActiveCellsGeometryBoundingBox() } } - activeInfos[acIdx]->setMatrixActiveCellsGeometryBoundingBox(bb); + activeInfos[acIdx]->setGeometryBoundingBox(bb); } m_mainGrid->setDisplayModelOffset(bb.min()); diff --git a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp index 931ef6fc4c..0cf3407102 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp @@ -102,7 +102,7 @@ public: if (m_reservoirResultValues->size() == 0 ) return HUGE_VAL; size_t globalGridCellIndex = m_grid->globalGridCellIndex(gridLocalCellIndex); - size_t resultValueIndex = m_activeCellInfo->activeIndexInMatrixModel(globalGridCellIndex); + size_t resultValueIndex = m_activeCellInfo->cellResultIndex(globalGridCellIndex); if (resultValueIndex == cvf::UNDEFINED_SIZE_T) return HUGE_VAL; CVF_TIGHT_ASSERT(resultValueIndex < m_reservoirResultValues->size()); @@ -116,7 +116,7 @@ public: virtual void setCellScalar(size_t gridLocalCellIndex, double scalarValue) { size_t globalGridCellIndex = m_grid->globalGridCellIndex(gridLocalCellIndex); - size_t resultValueIndex = m_activeCellInfo->activeIndexInMatrixModel(globalGridCellIndex); + size_t resultValueIndex = m_activeCellInfo->cellResultIndex(globalGridCellIndex); CVF_TIGHT_ASSERT(resultValueIndex < m_reservoirResultValues->size()); diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp index ef9831def6..0ad79539ee 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp @@ -252,7 +252,7 @@ void RigReservoirBuilderMock::populateReservoir(RigEclipseCase* eclipseCase) activeCellInfo->setGlobalCellCount(eclipseCase->mainGrid()->cells().size()); for (size_t i = 0; i < eclipseCase->mainGrid()->cells().size(); i++) { - activeCellInfo->setActiveIndexInMatrixModel(i, i); + activeCellInfo->setCellResultIndex(i, i); } } diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.cpp b/ApplicationCode/SocketInterface/RiaSocketServer.cpp index e48ab7b3f5..9a1aac8d00 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.cpp +++ b/ApplicationCode/SocketInterface/RiaSocketServer.cpp @@ -446,7 +446,7 @@ void RiaSocketServer::readPropertyDataFromOctave() size_t cellCountFromOctave = m_bytesPerTimeStepToRead / sizeof(double); - size_t gridActiveCellCount = m_currentReservoir->reservoirData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->globalMatrixModelActiveCellCount(); + size_t gridActiveCellCount = m_currentReservoir->reservoirData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->globalActiveCellCount(); size_t gridTotalCellCount = m_currentReservoir->reservoirData()->mainGrid()->cellCount(); if (cellCountFromOctave != gridActiveCellCount && cellCountFromOctave != gridTotalCellCount) @@ -635,7 +635,7 @@ void RiaSocketServer::calculateMatrixModelActiveCellInfo(std::vector& gr } RigActiveCellInfo* actCellInfo = m_currentReservoir->reservoirData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS); - size_t numMatrixModelActiveCells = actCellInfo->globalMatrixModelActiveCellCount(); + size_t numMatrixModelActiveCells = actCellInfo->globalActiveCellCount(); gridNumber.reserve(numMatrixModelActiveCells); cellI.reserve(numMatrixModelActiveCells); @@ -650,7 +650,7 @@ void RiaSocketServer::calculateMatrixModelActiveCellInfo(std::vector& gr for (size_t cIdx = 0; cIdx < globalCells.size(); ++cIdx) { - if (actCellInfo->isActiveInMatrixModel(cIdx)) + if (actCellInfo->isActive(cIdx)) { RigGridBase* grid = globalCells[cIdx].hostGrid(); CVF_ASSERT(grid != NULL); diff --git a/ApplicationCode/UserInterface/RIMainWindow.cpp b/ApplicationCode/UserInterface/RIMainWindow.cpp index 90e87996b5..d391e3e0dc 100644 --- a/ApplicationCode/UserInterface/RIMainWindow.cpp +++ b/ApplicationCode/UserInterface/RIMainWindow.cpp @@ -1271,6 +1271,7 @@ void RIMainWindow::slotOpenMultipleCases() { RIApplication* app = RIApplication::instance(); + /* RiuMultiCaseImportDialog dialog; int action = dialog.exec(); if (action == QDialog::Accepted) @@ -1278,4 +1279,26 @@ void RIMainWindow::slotOpenMultipleCases() QStringList gridFileNames = dialog.eclipseCaseFileNames(); app->addEclipseCases(gridFileNames); } + */ + + + QStringList gridFileNames; + + if (1) + { + gridFileNames += "Result Mock Debug Model With Results"; + gridFileNames += "Result Mock Debug Model With Results"; + gridFileNames += "Result Mock Debug Model With Results"; + } + else + { + gridFileNames += "d:/Models/Statoil/MultipleRealisations/Case_with_10_timesteps/Real0/BRUGGE_0000.EGRID"; + gridFileNames += "d:/Models/Statoil/MultipleRealisations/Case_with_10_timesteps/Real10/BRUGGE_0010.EGRID"; + gridFileNames += "d:/Models/Statoil/MultipleRealisations/Case_with_10_timesteps/Real30/BRUGGE_0030.EGRID"; + gridFileNames += "d:/Models/Statoil/MultipleRealisations/Case_with_10_timesteps/Real40/BRUGGE_0040.EGRID"; + } + + app->addEclipseCases(gridFileNames); + + } From 3cd92973afd0c6ef5f0da6f31d511dea57b7cf74 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 22 Mar 2013 09:44:41 +0100 Subject: [PATCH 156/242] Missed one file in previous rename p4#: 21046 --- .../RigActiveCellInfo-Test.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigActiveCellInfo-Test.cpp b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigActiveCellInfo-Test.cpp index a5349f3b95..57e99d4ec0 100644 --- a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigActiveCellInfo-Test.cpp +++ b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigActiveCellInfo-Test.cpp @@ -21,6 +21,9 @@ #include "RigActiveCellInfo.h" +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -33,12 +36,12 @@ TEST(RigActiveCellInfo, BasicTest) for (size_t i = 0; i < globalActiveCellCount; i++) { - EXPECT_TRUE(rigActiveCellInfo.activeIndexInMatrixModel(i) == cvf::UNDEFINED_SIZE_T); - EXPECT_FALSE(rigActiveCellInfo.isActiveInMatrixModel(i)); + EXPECT_TRUE(rigActiveCellInfo.cellResultIndex(i) == cvf::UNDEFINED_SIZE_T); + EXPECT_FALSE(rigActiveCellInfo.isActive(i)); } - rigActiveCellInfo.setActiveIndexInMatrixModel(3, 1); - EXPECT_TRUE(rigActiveCellInfo.activeIndexInMatrixModel(3) == 1); + rigActiveCellInfo.setCellResultIndex(3, 1); + EXPECT_TRUE(rigActiveCellInfo.cellResultIndex(3) == 1); } //-------------------------------------------------------------------------------------------------- @@ -54,7 +57,7 @@ TEST(RigActiveCellInfo, GridCellCounts) rigActiveCellInfo.setGridActiveCellCounts(2, 2); rigActiveCellInfo.computeDerivedData(); - EXPECT_TRUE(rigActiveCellInfo.globalMatrixModelActiveCellCount() == 3); + EXPECT_TRUE(rigActiveCellInfo.globalActiveCellCount() == 3); } { @@ -65,7 +68,6 @@ TEST(RigActiveCellInfo, GridCellCounts) rigActiveCellInfo.setGridActiveCellCounts(2, 5 ); rigActiveCellInfo.computeDerivedData(); - EXPECT_TRUE(rigActiveCellInfo.globalMatrixModelActiveCellCount() == 12); + EXPECT_TRUE(rigActiveCellInfo.globalActiveCellCount() == 12); } } - From 6c8d5ff631198858ad149e29a66dc82e7b92a9a9 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 22 Mar 2013 10:03:51 +0100 Subject: [PATCH 157/242] Rename of statistics related classes and method names p4#: 21047 --- ApplicationCode/Application/RIApplication.cpp | 4 +-- .../ProjectDataModel/RigStatistics.cpp | 12 +++---- .../ProjectDataModel/RigStatistics.h | 32 ++++++++--------- .../RimIdenticalGridCaseGroup.cpp | 36 +++++++++---------- .../RimIdenticalGridCaseGroup.h | 4 +-- .../RimStatisticalCalculation.cpp | 35 +++++++++--------- .../RimStatisticalCalculation.h | 14 +++----- .../RimStatisticalCollection.cpp | 12 +++---- .../RimStatisticalCollection.h | 8 ++--- .../ProjectDataModel/RimUiTreeModelPdm.cpp | 14 ++++---- .../ProjectDataModel/RimUiTreeModelPdm.h | 4 +-- .../ProjectDataModel/RimUiTreeView.cpp | 22 ++++++------ .../ProjectDataModel/RimUiTreeView.h | 4 +-- 13 files changed, 97 insertions(+), 104 deletions(-) diff --git a/ApplicationCode/Application/RIApplication.cpp b/ApplicationCode/Application/RIApplication.cpp index 127df8be08..1d3b5c5073 100644 --- a/ApplicationCode/Application/RIApplication.cpp +++ b/ApplicationCode/Application/RIApplication.cpp @@ -284,9 +284,9 @@ bool RIApplication::loadProject(const QString& projectFileName) // Add all statistics cases as well for (size_t cgIdx = 0; cgIdx < m_project->caseGroups().size(); ++cgIdx) { - if (m_project->caseGroups[cgIdx]->statisticalReservoirCollection()) + if (m_project->caseGroups[cgIdx]->statisticsCaseCollection()) { - caf::PdmPointersField & statCases = m_project->caseGroups[cgIdx]->statisticalReservoirCollection()->reservoirs(); + caf::PdmPointersField & statCases = m_project->caseGroups[cgIdx]->statisticsCaseCollection()->cases(); for (size_t scIdx = 0; scIdx < statCases.size(); ++scIdx) { casesToLoad.push_back(statCases[scIdx]); diff --git a/ApplicationCode/ProjectDataModel/RigStatistics.cpp b/ApplicationCode/ProjectDataModel/RigStatistics.cpp index 52fac4283d..0ff0bf3619 100644 --- a/ApplicationCode/ProjectDataModel/RigStatistics.cpp +++ b/ApplicationCode/ProjectDataModel/RigStatistics.cpp @@ -30,7 +30,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigStatistics::addNamedResult(RigReservoirCellResults* destinationCellResults, RimDefines::ResultCatType resultType, const QString& resultName, size_t activeUnionCellCount) +void RimStatisticsCaseEvaluator::addNamedResult(RigReservoirCellResults* destinationCellResults, RimDefines::ResultCatType resultType, const QString& resultName, size_t activeUnionCellCount) { // Use time step dates from first result in first source case CVF_ASSERT(m_sourceCases.size() > 0); @@ -62,7 +62,7 @@ QString createResultNameDev(const QString& resultName) { return resultName + "_ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigStatistics::buildSourceMetaData(RimDefines::ResultCatType resultType, const QString& resultName) +void RimStatisticsCaseEvaluator::buildSourceMetaData(RimDefines::ResultCatType resultType, const QString& resultName) { if (m_sourceCases.size() == 0) return; @@ -88,7 +88,7 @@ void RigStatistics::buildSourceMetaData(RimDefines::ResultCatType resultType, co //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigStatistics::evaluateStatistics(const QList >& resultSpecification) +void RimStatisticsCaseEvaluator::evaluateForResults(const QList >& resultSpecification) { CVF_ASSERT(m_destinationCase); @@ -246,7 +246,7 @@ void RigStatistics::evaluateStatistics(const QList& sourceCases, const std::vector& timeStepIndices, const RigStatisticsConfig& statisticsConfig, RigEclipseCase* destinationCase) +RimStatisticsCaseEvaluator::RimStatisticsCaseEvaluator(const std::vector& sourceCases, const std::vector& timeStepIndices, const RimStatisticsConfig& statisticsConfig, RigEclipseCase* destinationCase) : m_sourceCases(sourceCases), m_statisticsConfig(statisticsConfig), m_destinationCase(destinationCase), diff --git a/ApplicationCode/ProjectDataModel/RigStatistics.h b/ApplicationCode/ProjectDataModel/RigStatistics.h index 3e67e93eb7..de1b76764a 100644 --- a/ApplicationCode/ProjectDataModel/RigStatistics.h +++ b/ApplicationCode/ProjectDataModel/RigStatistics.h @@ -34,10 +34,10 @@ class RimReservoir; class RigEclipseCase; class RigReservoirCellResults; -class RigStatisticsEvaluator +class RimStatisticsEvaluator { public: - RigStatisticsEvaluator(const std::vector& values) + RimStatisticsEvaluator(const std::vector& values) : m_values(values), m_min(HUGE_VAL), m_max(-HUGE_VAL), @@ -107,10 +107,10 @@ private: -class RigStatisticsConfig +class RimStatisticsConfig { public: - RigStatisticsConfig() + RimStatisticsConfig() : m_min(true), m_max(true), m_mean(true), @@ -126,16 +126,16 @@ public: }; -class RigStatistics +class RimStatisticsCaseEvaluator { public: - RigStatistics(const std::vector& sourceCases, - const std::vector& timeStepIndices, - const RigStatisticsConfig& statisticsConfig, - RigEclipseCase* destinationCase); + RimStatisticsCaseEvaluator(const std::vector& sourceCases, + const std::vector& timeStepIndices, + const RimStatisticsConfig& statisticsConfig, + RigEclipseCase* destinationCase); - void evaluateStatistics(const QList >& resultSpecification); + void evaluateForResults(const QList >& resultSpecification); void debugOutput(RimDefines::ResultCatType resultType, const QString& resultName, size_t timeStepIdx); @@ -144,13 +144,11 @@ private: void buildSourceMetaData(RimDefines::ResultCatType resultType, const QString& resultName); private: - std::vector m_sourceCases; - std::vector m_timeStepIndices; + std::vector m_sourceCases; + std::vector m_timeStepIndices; - size_t m_globalCellCount; - - RigStatisticsConfig m_statisticsConfig; - - RigEclipseCase* m_destinationCase; + size_t m_globalCellCount; + RimStatisticsConfig m_statisticsConfig; + RigEclipseCase* m_destinationCase; }; diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index 89426d79b4..064b3a6c8f 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -43,11 +43,11 @@ RimIdenticalGridCaseGroup::RimIdenticalGridCaseGroup() CAF_PDM_InitField(&name, "UserDescription", QString("Grid Case Group"), "Name", "", "", ""); - CAF_PDM_InitFieldNoDefault(&statisticalReservoirCollection, "StatisticalReservoirCollection", "Derived Statistics", ":/Histograms16x16.png", "", ""); + CAF_PDM_InitFieldNoDefault(&statisticsCaseCollection, "StatisticsCaseCollection", "Derived Statistics", ":/Histograms16x16.png", "", ""); CAF_PDM_InitFieldNoDefault(&caseCollection, "CaseCollection", "Cases", ":/Cases16x16.png", "", ""); caseCollection = new RimCaseCollection; - statisticalReservoirCollection = new RimStatisticalCollection; + statisticsCaseCollection = new RimStatisticsCaseCollection; m_mainGrid = NULL; @@ -65,8 +65,8 @@ RimIdenticalGridCaseGroup::~RimIdenticalGridCaseGroup() delete caseCollection; caseCollection = NULL; - delete statisticalReservoirCollection; - statisticalReservoirCollection = NULL; + delete statisticsCaseCollection; + statisticsCaseCollection = NULL; } //-------------------------------------------------------------------------------------------------- @@ -89,9 +89,9 @@ void RimIdenticalGridCaseGroup::addCase(RimReservoir* reservoir) caseCollection()->reservoirs().push_back(reservoir); - if (statisticalReservoirCollection->reservoirs().size() == 0) + if (statisticsCaseCollection->cases().size() == 0) { - createAndAppendStatisticalCalculation(); + createAndAppendStatisticsCase(); } clearActiveCellUnions(); @@ -174,9 +174,9 @@ void RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo() // Check if we need to calculate the union of the active cells bool foundResultsInCache = false; - for (size_t i = 0; i < statisticalReservoirCollection()->reservoirs.size(); i++) + for (size_t i = 0; i < statisticsCaseCollection()->cases.size(); i++) { - RimStatisticalCalculation* rimReservoir = statisticalReservoirCollection()->reservoirs[i]; + RimStatisticsCase* rimReservoir = statisticsCaseCollection()->cases[i]; // Check if any results are stored in cache if (rimReservoir->results(RifReaderInterface::MATRIX_RESULTS)->storedResultsCount() > 0 || @@ -194,9 +194,9 @@ void RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo() // "Load" the statistical cases - for (size_t i = 0; i < statisticalReservoirCollection()->reservoirs.size(); i++) + for (size_t i = 0; i < statisticsCaseCollection()->cases.size(); i++) { - RimStatisticalCalculation* rimReservoir = statisticalReservoirCollection()->reservoirs[i]; + RimStatisticsCase* rimReservoir = statisticsCaseCollection()->cases[i]; rimReservoir->openEclipseGridFile(); @@ -295,12 +295,12 @@ void RimIdenticalGridCaseGroup::computeUnionOfActiveCells() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimStatisticalCalculation* RimIdenticalGridCaseGroup::createAndAppendStatisticalCalculation() +RimStatisticsCase* RimIdenticalGridCaseGroup::createAndAppendStatisticsCase() { - RimStatisticalCalculation* newObject = new RimStatisticalCalculation; + RimStatisticsCase* newObject = new RimStatisticsCase; - newObject->caseName = QString("Statistics ") + QString::number(statisticalReservoirCollection()->reservoirs.size()+1); - statisticalReservoirCollection()->reservoirs.push_back(newObject); + newObject->caseName = QString("Statistics ") + QString::number(statisticsCaseCollection()->cases.size()+1); + statisticsCaseCollection()->cases.push_back(newObject); newObject->openEclipseGridFile(); @@ -312,9 +312,9 @@ RimStatisticalCalculation* RimIdenticalGridCaseGroup::createAndAppendStatistical //-------------------------------------------------------------------------------------------------- void RimIdenticalGridCaseGroup::updateMainGridAndActiveCellsForStatisticsCases() { - for (size_t i = 0; i < statisticalReservoirCollection->reservoirs().size(); i++) + for (size_t i = 0; i < statisticsCaseCollection->cases().size(); i++) { - RimStatisticalCalculation* rimStaticsCase = statisticalReservoirCollection->reservoirs[i]; + RimStatisticsCase* rimStaticsCase = statisticsCaseCollection->cases[i]; rimStaticsCase->reservoirData()->setMainGrid(this->mainGrid()); @@ -330,9 +330,9 @@ void RimIdenticalGridCaseGroup::updateMainGridAndActiveCellsForStatisticsCases() //-------------------------------------------------------------------------------------------------- void RimIdenticalGridCaseGroup::clearStatisticsResults() { - for (size_t i = 0; i < statisticalReservoirCollection->reservoirs().size(); i++) + for (size_t i = 0; i < statisticsCaseCollection->cases().size(); i++) { - RimStatisticalCalculation* rimStaticsCase = statisticalReservoirCollection->reservoirs[i]; + RimStatisticsCase* rimStaticsCase = statisticsCaseCollection->cases[i]; rimStaticsCase->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->clearAllResults(); rimStaticsCase->results(RifReaderInterface::FRACTURE_RESULTS)->cellResults()->clearAllResults(); diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h index 06c0c2d077..4b5e1564f0 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h @@ -49,10 +49,10 @@ public: void removeCase(RimReservoir* reservoir); bool contains(RimReservoir* reservoir) const; - RimStatisticalCalculation* createAndAppendStatisticalCalculation(); + RimStatisticsCase* createAndAppendStatisticsCase(); caf::PdmField caseCollection; - caf::PdmField statisticalReservoirCollection; + caf::PdmField statisticsCaseCollection; void loadMainCaseAndActiveCellInfo(); diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp index 3a6827e17b..da0a4371a8 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp @@ -23,18 +23,17 @@ #include "cafPdmUiOrdering.h" #include "RimIdenticalGridCaseGroup.h" #include "RigEclipseCase.h" -#include "RifReaderStatisticalCalculation.h" #include "RigReservoirCellResults.h" #include "RigStatistics.h" #include "RigMainGrid.h" -CAF_PDM_SOURCE_INIT(RimStatisticalCalculation, "RimStatisticalCalculation"); +CAF_PDM_SOURCE_INIT(RimStatisticsCase, "RimStatisticalCalculation"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimStatisticalCalculation::RimStatisticalCalculation() +RimStatisticsCase::RimStatisticsCase() : RimReservoir() { CAF_PDM_InitObject("Case Group Statistics", ":/Histogram16x16.png", "", ""); @@ -45,7 +44,7 @@ RimStatisticalCalculation::RimStatisticalCalculation() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimStatisticalCalculation::~RimStatisticalCalculation() +RimStatisticsCase::~RimStatisticsCase() { } @@ -54,7 +53,7 @@ RimStatisticalCalculation::~RimStatisticalCalculation() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimStatisticalCalculation::setMainGrid(RigMainGrid* mainGrid) +void RimStatisticsCase::setMainGrid(RigMainGrid* mainGrid) { CVF_ASSERT(mainGrid); CVF_ASSERT(this->reservoirData()); @@ -65,15 +64,15 @@ void RimStatisticalCalculation::setMainGrid(RigMainGrid* mainGrid) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimStatisticalCalculation::openEclipseGridFile() +bool RimStatisticsCase::openEclipseGridFile() { if (this->reservoirData()) return true; cvf::ref eclipseCase = new RigEclipseCase; - CVF_ASSERT(parentStatisticalCollection()); + CVF_ASSERT(parentStatisticsCaseCollection()); - RimIdenticalGridCaseGroup* gridCaseGroup = parentStatisticalCollection()->parentCaseGroup(); + RimIdenticalGridCaseGroup* gridCaseGroup = parentStatisticsCaseCollection()->parentCaseGroup(); CVF_ASSERT(gridCaseGroup); RigMainGrid* mainGrid = gridCaseGroup->mainGrid(); @@ -91,7 +90,7 @@ bool RimStatisticalCalculation::openEclipseGridFile() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimStatisticalCalculation::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const +void RimStatisticsCase::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const { } @@ -99,9 +98,9 @@ void RimStatisticalCalculation::defineUiOrdering(QString uiConfigName, caf::PdmU //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimStatisticalCollection* RimStatisticalCalculation::parentStatisticalCollection() +RimStatisticsCaseCollection* RimStatisticsCase::parentStatisticsCaseCollection() { - std::vector parentObjects; + std::vector parentObjects; this->parentObjectsOfType(parentObjects); if (parentObjects.size() > 0) @@ -115,7 +114,7 @@ RimStatisticalCollection* RimStatisticalCalculation::parentStatisticalCollection //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimStatisticalCalculation::computeStatistics() +void RimStatisticsCase::computeStatistics() { if (this->reservoirData() == NULL) { @@ -139,7 +138,7 @@ void RimStatisticalCalculation::computeStatistics() // Use this information for all cases in the case group size_t timeStepCount = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->maxTimeStepCount(); - RigStatisticsConfig statisticsConfig; + RimStatisticsConfig statisticsConfig; std::vector timeStepIndices; for (size_t i = 0; i < timeStepCount; i++) @@ -171,8 +170,8 @@ void RimStatisticalCalculation::computeStatistics() } - RigStatistics stat(sourceCases, timeStepIndices, statisticsConfig, resultCase); - stat.evaluateStatistics(resultSpecification); + RimStatisticsCaseEvaluator stat(sourceCases, timeStepIndices, statisticsConfig, resultCase); + stat.evaluateForResults(resultSpecification); for (size_t i = 0; i < reservoirViews().size(); i++) { @@ -188,7 +187,7 @@ void RimStatisticalCalculation::computeStatistics() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimStatisticalCalculation::getSourceCases(std::vector& sourceCases) +void RimStatisticsCase::getSourceCases(std::vector& sourceCases) { RimIdenticalGridCaseGroup* gridCaseGroup = caseGroup(); if (gridCaseGroup) @@ -209,9 +208,9 @@ void RimStatisticalCalculation::getSourceCases(std::vector& sourc //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimIdenticalGridCaseGroup* RimStatisticalCalculation::caseGroup() +RimIdenticalGridCaseGroup* RimStatisticsCase::caseGroup() { - RimStatisticalCollection* parentCollection = parentStatisticalCollection(); + RimStatisticsCaseCollection* parentCollection = parentStatisticsCaseCollection(); if (parentCollection) { return parentCollection->parentCaseGroup(); diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h index d7b67ce785..5c828d4451 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h @@ -27,8 +27,7 @@ class RimIdenticalGridCaseGroup; class RimResultDefinition; -class RifReaderStatisticalCalculation; -class RimStatisticalCollection; +class RimStatisticsCaseCollection; class RigMainGrid; @@ -37,13 +36,13 @@ class RigMainGrid; // // //================================================================================================== -class RimStatisticalCalculation : public RimReservoir +class RimStatisticsCase : public RimReservoir { CAF_PDM_HEADER_INIT; public: - RimStatisticalCalculation(); - virtual ~RimStatisticalCalculation(); + RimStatisticsCase(); + virtual ~RimStatisticsCase(); void setMainGrid(RigMainGrid* mainGrid); @@ -51,7 +50,7 @@ public: caf::PdmField m_resultName; - RimStatisticalCollection* parentStatisticalCollection(); + RimStatisticsCaseCollection* parentStatisticsCaseCollection(); virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) const; void computeStatistics(); @@ -61,7 +60,4 @@ private: void getSourceCases(std::vector& sourceCases); -private: - cvf::ref m_readerInterface; - }; diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCollection.cpp b/ApplicationCode/ProjectDataModel/RimStatisticalCollection.cpp index 3f61974e36..c35bce456c 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCollection.cpp @@ -24,31 +24,31 @@ #include "RimIdenticalGridCaseGroup.h" -CAF_PDM_SOURCE_INIT(RimStatisticalCollection, "RimStatisticalCollection"); +CAF_PDM_SOURCE_INIT(RimStatisticsCaseCollection, "RimStatisticalCollection"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimStatisticalCollection::RimStatisticalCollection() +RimStatisticsCaseCollection::RimStatisticsCaseCollection() : PdmObject() { CAF_PDM_InitObject("Derived Statistics", "", "", ""); - CAF_PDM_InitFieldNoDefault(&reservoirs, "Reservoirs", "", "", "", ""); + CAF_PDM_InitFieldNoDefault(&cases, "Reservoirs", "", "", "", ""); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimStatisticalCollection::~RimStatisticalCollection() +RimStatisticsCaseCollection::~RimStatisticsCaseCollection() { - reservoirs.deleteAllChildObjects(); + cases.deleteAllChildObjects(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimIdenticalGridCaseGroup* RimStatisticalCollection::parentCaseGroup() +RimIdenticalGridCaseGroup* RimStatisticsCaseCollection::parentCaseGroup() { std::vector parentObjects; this->parentObjectsOfType(parentObjects); diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCollection.h b/ApplicationCode/ProjectDataModel/RimStatisticalCollection.h index c89522899e..d129ab1042 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCollection.h +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCollection.h @@ -32,15 +32,15 @@ // // //================================================================================================== -class RimStatisticalCollection : public caf::PdmObject +class RimStatisticsCaseCollection : public caf::PdmObject { CAF_PDM_HEADER_INIT; public: - RimStatisticalCollection(); - virtual ~RimStatisticalCollection(); + RimStatisticsCaseCollection(); + virtual ~RimStatisticsCaseCollection(); - caf::PdmPointersField reservoirs; + caf::PdmPointersField cases; RimIdenticalGridCaseGroup* parentCaseGroup(); diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index a59e911928..4d54ded8c5 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -475,7 +475,7 @@ void RimUiTreeModelPdm::deleteInputProperty(const QModelIndex& itemIndex) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimStatisticalCalculation* RimUiTreeModelPdm::addStatisticalCalculation(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex) +RimStatisticsCase* RimUiTreeModelPdm::addStatisticalCalculation(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex) { caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex); @@ -484,17 +484,17 @@ RimStatisticalCalculation* RimUiTreeModelPdm::addStatisticalCalculation(const QM caf::PdmUiTreeItem* parentCollectionItem = NULL; int position = 0; - if (dynamic_cast(currentItem->dataObject().p())) + if (dynamic_cast(currentItem->dataObject().p())) { - RimStatisticalCalculation* currentObject = dynamic_cast(currentItem->dataObject().p()); - caseGroup = currentObject->parentStatisticalCollection()->parentCaseGroup(); + RimStatisticsCase* currentObject = dynamic_cast(currentItem->dataObject().p()); + caseGroup = currentObject->parentStatisticsCaseCollection()->parentCaseGroup(); parentCollectionItem = currentItem->parent(); position = itemIndex.row(); collectionIndex = itemIndex.parent(); } - else if (dynamic_cast(currentItem->dataObject().p())) + else if (dynamic_cast(currentItem->dataObject().p())) { - RimStatisticalCollection* statColl = dynamic_cast(currentItem->dataObject().p()); + RimStatisticsCaseCollection* statColl = dynamic_cast(currentItem->dataObject().p()); caseGroup = statColl->parentCaseGroup(); parentCollectionItem = currentItem; position = parentCollectionItem->childCount(); @@ -503,7 +503,7 @@ RimStatisticalCalculation* RimUiTreeModelPdm::addStatisticalCalculation(const QM beginInsertRows(collectionIndex, position, position); - RimStatisticalCalculation* createdObject = caseGroup->createAndAppendStatisticalCalculation(); + RimStatisticsCase* createdObject = caseGroup->createAndAppendStatisticsCase(); caf::PdmUiTreeItem* childItem = new caf::PdmUiTreeItem(parentCollectionItem, position, createdObject); endInsertRows(); diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h index da9a6dcff9..2201c7e090 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h @@ -32,7 +32,7 @@ class RimCellRangeFilter; class RimReservoir; class RimReservoirView; class RimInputProperty; -class RimStatisticalCalculation; +class RimStatisticsCase; class RimIdenticalGridCaseGroup; //-------------------------------------------------------------------------------------------------- @@ -113,7 +113,7 @@ public: void addInputProperty(const QModelIndex& itemIndex, const QStringList& fileNames); void addObjects(const QModelIndex& itemIndex, caf::PdmObjectGroup& pdmObjects); - RimStatisticalCalculation* addStatisticalCalculation(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); + RimStatisticsCase* addStatisticalCalculation(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); RimIdenticalGridCaseGroup* addCaseGroup(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); bool deleteObjectFromPdmPointersField(const QModelIndex& itemIndex); diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index 72ae486ed8..9fe884f306 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -160,17 +160,17 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event) menu.addAction(QString("Save Property To File"), this, SLOT(slotWriteBinaryResultAsInputProperty())); menu.exec(event->globalPos()); } - else if (dynamic_cast(uiItem->dataObject().p())) + else if (dynamic_cast(uiItem->dataObject().p())) { QMenu menu; - menu.addAction(QString("New Statistical Case"), this, SLOT(slotNewStatisticalCase())); + menu.addAction(QString("New Statistcs Case"), this, SLOT(slotNewStatisticsCase())); menu.exec(event->globalPos()); } - else if (dynamic_cast(uiItem->dataObject().p())) + else if (dynamic_cast(uiItem->dataObject().p())) { QMenu menu; menu.addAction(QString("New View"), this, SLOT(slotAddView())); - menu.addAction(QString("Compute"), this, SLOT(slotComputeStatisticalCases())); + menu.addAction(QString("Compute"), this, SLOT(slotComputeStatistics())); menu.addAction(QString("Close"), this, SLOT(slotCloseCase())); menu.exec(event->globalPos()); } @@ -817,13 +817,13 @@ void RimUiTreeView::slotCloseCase() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimUiTreeView::slotNewStatisticalCase() +void RimUiTreeView::slotNewStatisticsCase() { RimUiTreeModelPdm* myModel = dynamic_cast(model()); if (myModel) { QModelIndex insertedIndex; - RimStatisticalCalculation* newObject = myModel->addStatisticalCalculation(currentIndex(), insertedIndex); + RimStatisticsCase* newObject = myModel->addStatisticalCalculation(currentIndex(), insertedIndex); setCurrentIndex(insertedIndex); } } @@ -831,18 +831,18 @@ void RimUiTreeView::slotNewStatisticalCase() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimUiTreeView::slotComputeStatisticalCases() +void RimUiTreeView::slotComputeStatistics() { QModelIndex index = currentIndex(); RimUiTreeModelPdm* myModel = dynamic_cast(model()); caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex()); - RimStatisticalCalculation* statisticalObject = dynamic_cast(uiItem->dataObject().p()); - if (!statisticalObject) return; + RimStatisticsCase* statisticsCase = dynamic_cast(uiItem->dataObject().p()); + if (!statisticsCase) return; - statisticalObject->computeStatistics(); + statisticsCase->computeStatistics(); - if (statisticalObject->reservoirViews.size() == 0) + if (statisticsCase->reservoirViews.size() == 0) { slotAddView(); } diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.h b/ApplicationCode/ProjectDataModel/RimUiTreeView.h index db6f4b9ca4..960000be44 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.h @@ -74,8 +74,8 @@ private slots: void slotCloseCase(); - void slotNewStatisticalCase(); - void slotComputeStatisticalCases(); + void slotNewStatisticsCase(); + void slotComputeStatistics(); void slotAddCaseGroup(); void slotDeleteObjectFromPdmPointersField(); From 4101c3cd8543bb0c0202435a60bc18227116327b Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 22 Mar 2013 10:10:34 +0100 Subject: [PATCH 158/242] Removed obsolete file p4#: 21048 --- .../FileInterface/CMakeLists_files.cmake | 2 - .../RifReaderStatisticalCalculation.cpp | 134 ------------------ .../RifReaderStatisticalCalculation.h | 55 ------- 3 files changed, 191 deletions(-) delete mode 100644 ApplicationCode/FileInterface/RifReaderStatisticalCalculation.cpp delete mode 100644 ApplicationCode/FileInterface/RifReaderStatisticalCalculation.h diff --git a/ApplicationCode/FileInterface/CMakeLists_files.cmake b/ApplicationCode/FileInterface/CMakeLists_files.cmake index 04b2938dc9..7e80dd49d8 100644 --- a/ApplicationCode/FileInterface/CMakeLists_files.cmake +++ b/ApplicationCode/FileInterface/CMakeLists_files.cmake @@ -15,7 +15,6 @@ ${CEE_CURRENT_LIST_DIR}RifReaderEclipseInput.h ${CEE_CURRENT_LIST_DIR}RifReaderEclipseOutput.h ${CEE_CURRENT_LIST_DIR}RifReaderInterface.h ${CEE_CURRENT_LIST_DIR}RifReaderMockModel.h -${CEE_CURRENT_LIST_DIR}RifReaderStatisticalCalculation.h ) list(APPEND CODE_SOURCE_FILES @@ -27,7 +26,6 @@ ${CEE_CURRENT_LIST_DIR}RifEclipseUnifiedRestartFileAccess.cpp ${CEE_CURRENT_LIST_DIR}RifReaderEclipseInput.cpp ${CEE_CURRENT_LIST_DIR}RifReaderEclipseOutput.cpp ${CEE_CURRENT_LIST_DIR}RifReaderMockModel.cpp -${CEE_CURRENT_LIST_DIR}RifReaderStatisticalCalculation.cpp ) diff --git a/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.cpp b/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.cpp deleted file mode 100644 index 07bf2ab9db..0000000000 --- a/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.cpp +++ /dev/null @@ -1,134 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 "cvfBase.h" - -#include "RigMainGrid.h" -#include "RigEclipseCase.h" -#include "RigReservoirCellResults.h" - -#include "RifReaderStatisticalCalculation.h" - - -//-------------------------------------------------------------------------------------------------- -/// Constructor -//-------------------------------------------------------------------------------------------------- -RifReaderStatisticalCalculation::RifReaderStatisticalCalculation() -{ -} - -//-------------------------------------------------------------------------------------------------- -/// Destructor -//-------------------------------------------------------------------------------------------------- -RifReaderStatisticalCalculation::~RifReaderStatisticalCalculation() -{ -} - -//-------------------------------------------------------------------------------------------------- -/// Open file and read geometry into given reservoir object -//-------------------------------------------------------------------------------------------------- -bool RifReaderStatisticalCalculation::open(const QString& fileName, RigEclipseCase* eclipseCase) -{ - buildMetaData(eclipseCase); - - return true; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RifReaderStatisticalCalculation::buildMetaData(RigEclipseCase* eclipseCase) -{ - RigReservoirCellResults* matrixModelResults = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS); - RigReservoirCellResults* fractureModelResults = eclipseCase->results(RifReaderInterface::FRACTURE_RESULTS); - - // Dynamic results - for (int i = 0; i < m_matrixDynamicResultNames.size(); ++i) - { - size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, m_matrixDynamicResultNames[i], true); - matrixModelResults->setTimeStepDates(resIndex, m_timeSteps); - } - - for (int i = 0; i < m_fractureDynamicResultNames.size(); ++i) - { - size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, m_fractureDynamicResultNames[i], true); - fractureModelResults->setTimeStepDates(resIndex, m_timeSteps); - } - - std::vector staticDate; - if (m_timeSteps.size() > 0) - { - staticDate.push_back(m_timeSteps.front()); - } - - // Static results - for (int i = 0; i < m_fractureStaticResultNames.size(); ++i) - { - size_t resIndex = fractureModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, m_fractureStaticResultNames[i], true); - fractureModelResults->setTimeStepDates(resIndex, staticDate); - } - - for (int i = 0; i < m_matrixStaticResultNames.size(); ++i) - { - size_t resIndex = matrixModelResults->addEmptyScalarResult(RimDefines::STATIC_NATIVE, m_matrixStaticResultNames[i], true); - matrixModelResults->setTimeStepDates(resIndex, staticDate); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RifReaderStatisticalCalculation::setMatrixResultNames(const QStringList& staticResultNames, const QStringList& dynamicResultNames) -{ - m_matrixStaticResultNames = staticResultNames; - m_matrixDynamicResultNames = dynamicResultNames; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RifReaderStatisticalCalculation::setFractureResultNames(const QStringList& staticResultNames, const QStringList& dynamicResultNames) -{ - m_fractureStaticResultNames = staticResultNames; - m_fractureDynamicResultNames = dynamicResultNames; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RifReaderStatisticalCalculation::setTimeSteps(const std::vector& timesteps) -{ - m_timeSteps = timesteps; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RifReaderStatisticalCalculation::staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector* values) -{ - return false; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RifReaderStatisticalCalculation::dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector* values) -{ - return false; -} - diff --git a/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.h b/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.h deleted file mode 100644 index 649fd08b74..0000000000 --- a/ApplicationCode/FileInterface/RifReaderStatisticalCalculation.h +++ /dev/null @@ -1,55 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 "RifReaderInterface.h" - - -class RifReaderStatisticalCalculation : public RifReaderInterface -{ -public: - RifReaderStatisticalCalculation(); - virtual ~RifReaderStatisticalCalculation(); - - // Virtual interface implementation - virtual bool open(const QString& fileName, RigEclipseCase* eclipseCase); - - virtual void close() {} - - virtual bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector* values ); - virtual bool dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector* values ); - - void setMatrixResultNames(const QStringList& staticResultNames, const QStringList& dynamicResultNames); - void setFractureResultNames(const QStringList& staticResultNames, const QStringList& dynamicResultNames); - - void setTimeSteps(const std::vector& timesteps); - -private: - void buildMetaData(RigEclipseCase* eclipseCase); - -private: - std::vector m_timeSteps; - - QStringList m_matrixDynamicResultNames; - QStringList m_fractureDynamicResultNames; - - QStringList m_matrixStaticResultNames; - QStringList m_fractureStaticResultNames; - -}; From d85b0d461922ea7f241335b61f6742d02a1744d6 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 22 Mar 2013 11:46:54 +0100 Subject: [PATCH 159/242] More checking on null pointers p4#: 21052 --- .../Rim3dOverlayInfoConfig.cpp | 2 +- .../ReservoirDataModel/RigEclipseCase.cpp | 53 +++++++++++++------ 2 files changed, 38 insertions(+), 17 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index 1ea0b6589b..005133ee9e 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -87,7 +87,7 @@ void Rim3dOverlayInfoConfig::update3DInfo() QString propName; QString cellEdgeName; - if (m_reservoirView->eclipseCase() && m_reservoirView->eclipseCase()->reservoirData()) + if (m_reservoirView->eclipseCase() && m_reservoirView->eclipseCase()->reservoirData() && m_reservoirView->eclipseCase()->reservoirData()->mainGrid()) { caseName = m_reservoirView->eclipseCase()->caseName(); totCellCount = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->cells().size()); diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp index b8cb1a310a..292d26fd9c 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp @@ -61,6 +61,11 @@ void RigEclipseCase::allGrids(std::vector* grids) { CVF_ASSERT(grids); + if (m_mainGrid.isNull()) + { + return; + } + size_t i; for (i = 0; i < m_mainGrid->gridCount(); i++) { @@ -74,6 +79,12 @@ void RigEclipseCase::allGrids(std::vector* grids) void RigEclipseCase::allGrids(std::vector* grids) const { CVF_ASSERT(grids); + + if (m_mainGrid.isNull()) + { + return; + } + size_t i; for (i = 0; i < m_mainGrid->gridCount(); i++) { @@ -86,6 +97,7 @@ void RigEclipseCase::allGrids(std::vector* grids) const //-------------------------------------------------------------------------------------------------- const RigGridBase* RigEclipseCase::grid(size_t index) const { + CVF_ASSERT(m_mainGrid.notNull()); return m_mainGrid->gridByIndex(index); } @@ -95,6 +107,7 @@ const RigGridBase* RigEclipseCase::grid(size_t index) const //-------------------------------------------------------------------------------------------------- RigGridBase* RigEclipseCase::grid(size_t index) { + CVF_ASSERT(m_mainGrid.notNull()); return m_mainGrid->gridByIndex(index); } @@ -103,6 +116,7 @@ RigGridBase* RigEclipseCase::grid(size_t index) //-------------------------------------------------------------------------------------------------- size_t RigEclipseCase::gridCount() const { + CVF_ASSERT(m_mainGrid.notNull()); return m_mainGrid->gridCount(); } @@ -279,28 +293,30 @@ public: //-------------------------------------------------------------------------------------------------- void RigEclipseCase::computeActiveCellIJKBBox() { - CellRangeBB matrixModelActiveBB; - CellRangeBB fractureModelActiveBB; - - size_t idx; - for (idx = 0; idx < m_mainGrid->cellCount(); idx++) + if (m_mainGrid.notNull() && m_activeCellInfo.notNull() && m_fractureActiveCellInfo.notNull()) { - size_t i, j, k; - m_mainGrid->ijkFromCellIndex(idx, &i, &j, &k); + CellRangeBB matrixModelActiveBB; + CellRangeBB fractureModelActiveBB; - if (m_activeCellInfo->isActive(idx)) + size_t idx; + for (idx = 0; idx < m_mainGrid->cellCount(); idx++) { - matrixModelActiveBB.add(i, j, k); - } + size_t i, j, k; + m_mainGrid->ijkFromCellIndex(idx, &i, &j, &k); - if (m_fractureActiveCellInfo->isActive(idx)) - { - fractureModelActiveBB.add(i, j, k); + if (m_activeCellInfo->isActive(idx)) + { + matrixModelActiveBB.add(i, j, k); + } + + if (m_fractureActiveCellInfo->isActive(idx)) + { + fractureModelActiveBB.add(i, j, k); + } } + m_activeCellInfo->setIJKBoundingBox(matrixModelActiveBB.m_min, matrixModelActiveBB.m_max); + m_fractureActiveCellInfo->setIJKBoundingBox(fractureModelActiveBB.m_min, fractureModelActiveBB.m_max); } - - m_activeCellInfo->setIJKBoundingBox(matrixModelActiveBB.m_min, matrixModelActiveBB.m_max); - m_fractureActiveCellInfo->setIJKBoundingBox(fractureModelActiveBB.m_min, fractureModelActiveBB.m_max); } //-------------------------------------------------------------------------------------------------- @@ -359,6 +375,11 @@ void RigEclipseCase::setActiveCellInfo(RifReaderInterface::PorosityModelResultTy //-------------------------------------------------------------------------------------------------- void RigEclipseCase::computeActiveCellsGeometryBoundingBox() { + if (m_activeCellInfo.notNull() || m_fractureActiveCellInfo.notNull()) + { + return; + } + if (m_mainGrid.isNull()) { cvf::BoundingBox bb; From d1cc48235523aac772f4395cef08ef945f7a9ee6 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 22 Mar 2013 11:47:46 +0100 Subject: [PATCH 160/242] Use same collection type for source cases and statistics cases in RimIdenticalGridCaseGroup p4#: 21053 --- ApplicationCode/Application/RIApplication.cpp | 2 +- .../ProjectDataModel/RigStatistics.cpp | 24 +++++++-- .../ProjectDataModel/RigStatistics.h | 4 +- .../RimIdenticalGridCaseGroup.cpp | 50 +++++++++++++------ .../RimIdenticalGridCaseGroup.h | 6 ++- .../RimStatisticalCalculation.cpp | 6 +-- .../RimStatisticalCalculation.h | 2 +- .../ProjectDataModel/RimUiTreeModelPdm.cpp | 37 ++++++++++---- .../ProjectDataModel/RimUiTreeView.cpp | 10 +++- 9 files changed, 104 insertions(+), 37 deletions(-) diff --git a/ApplicationCode/Application/RIApplication.cpp b/ApplicationCode/Application/RIApplication.cpp index 1d3b5c5073..dc2e5ba83a 100644 --- a/ApplicationCode/Application/RIApplication.cpp +++ b/ApplicationCode/Application/RIApplication.cpp @@ -286,7 +286,7 @@ bool RIApplication::loadProject(const QString& projectFileName) { if (m_project->caseGroups[cgIdx]->statisticsCaseCollection()) { - caf::PdmPointersField & statCases = m_project->caseGroups[cgIdx]->statisticsCaseCollection()->cases(); + caf::PdmPointersField & statCases = m_project->caseGroups[cgIdx]->statisticsCaseCollection()->reservoirs(); for (size_t scIdx = 0; scIdx < statCases.size(); ++scIdx) { casesToLoad.push_back(statCases[scIdx]); diff --git a/ApplicationCode/ProjectDataModel/RigStatistics.cpp b/ApplicationCode/ProjectDataModel/RigStatistics.cpp index 0ff0bf3619..781ae35874 100644 --- a/ApplicationCode/ProjectDataModel/RigStatistics.cpp +++ b/ApplicationCode/ProjectDataModel/RigStatistics.cpp @@ -57,6 +57,7 @@ QString createResultNameMin(const QString& resultName) { return resultName + "_ QString createResultNameMax(const QString& resultName) { return resultName + "_MAX"; } QString createResultNameMean(const QString& resultName) { return resultName + "_MEAN"; } QString createResultNameDev(const QString& resultName) { return resultName + "_DEV"; } +QString createResultNameRange(const QString& resultName) { return resultName + "_RANGE"; } //-------------------------------------------------------------------------------------------------- @@ -127,6 +128,7 @@ void RimStatisticsCaseEvaluator::evaluateForResults(const QList 0) { @@ -134,6 +136,7 @@ void RimStatisticsCaseEvaluator::evaluateForResults(const QList dataAccessObjectMax = NULL; cvf::ref dataAccessObjectMean = NULL; cvf::ref dataAccessObjectDev = NULL; + cvf::ref dataAccessObjectRange = NULL; { size_t scalarResultIndex = matrixResults->findScalarResultIndex(resultType, createResultNameMin(resultName)); @@ -219,13 +223,21 @@ void RimStatisticsCaseEvaluator::evaluateForResults(const QListfindScalarResultIndex(resultType, createResultNameRange(resultName)); + if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) + { + dataAccessObjectRange = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, dataAccessTimeStepIndex, scalarResultIndex); + } + } + + double min, max, mean, dev, range; for (size_t cellIdx = 0; cellIdx < grid->cellCount(); cellIdx++) { std::vector values(dataAccesObjectList.size(), HUGE_VAL); size_t globalGridCellIdx = grid->globalGridCellIndex(cellIdx); - if (m_destinationCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->isActive(globalGridCellIdx)) + if (m_destinationCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->isActive(globalGridCellIdx)) { bool foundAnyValidValues = false; for (size_t caseIdx = 0; caseIdx < dataAccesObjectList.size(); caseIdx++) @@ -243,11 +255,12 @@ void RimStatisticsCaseEvaluator::evaluateForResults(const QListsetCellScalar(cellIdx, dev); } + + if (dataAccessObjectRange.notNull()) + { + dataAccessObjectRange->setCellScalar(cellIdx, range); + } } } } diff --git a/ApplicationCode/ProjectDataModel/RigStatistics.h b/ApplicationCode/ProjectDataModel/RigStatistics.h index de1b76764a..8d885ac4ab 100644 --- a/ApplicationCode/ProjectDataModel/RigStatistics.h +++ b/ApplicationCode/ProjectDataModel/RigStatistics.h @@ -47,7 +47,7 @@ public: } - void getStatistics(double& min, double& max, double& mean, double& dev) + void getStatistics(double& min, double& max, double& mean, double& dev, double& range) { evaluate(); @@ -55,6 +55,8 @@ public: max = m_max; mean = m_mean; dev = m_dev; + + range = m_max - m_min; } private: diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index 064b3a6c8f..8d6b2efd98 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -47,7 +47,7 @@ RimIdenticalGridCaseGroup::RimIdenticalGridCaseGroup() CAF_PDM_InitFieldNoDefault(&caseCollection, "CaseCollection", "Cases", ":/Cases16x16.png", "", ""); caseCollection = new RimCaseCollection; - statisticsCaseCollection = new RimStatisticsCaseCollection; + statisticsCaseCollection = new RimCaseCollection; m_mainGrid = NULL; @@ -89,7 +89,7 @@ void RimIdenticalGridCaseGroup::addCase(RimReservoir* reservoir) caseCollection()->reservoirs().push_back(reservoir); - if (statisticsCaseCollection->cases().size() == 0) + if (statisticsCaseCollection->reservoirs().size() == 0) { createAndAppendStatisticsCase(); } @@ -174,9 +174,9 @@ void RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo() // Check if we need to calculate the union of the active cells bool foundResultsInCache = false; - for (size_t i = 0; i < statisticsCaseCollection()->cases.size(); i++) + for (size_t i = 0; i < statisticsCaseCollection()->reservoirs.size(); i++) { - RimStatisticsCase* rimReservoir = statisticsCaseCollection()->cases[i]; + RimReservoir* rimReservoir = statisticsCaseCollection()->reservoirs[i]; // Check if any results are stored in cache if (rimReservoir->results(RifReaderInterface::MATRIX_RESULTS)->storedResultsCount() > 0 || @@ -194,9 +194,9 @@ void RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo() // "Load" the statistical cases - for (size_t i = 0; i < statisticsCaseCollection()->cases.size(); i++) + for (size_t i = 0; i < statisticsCaseCollection()->reservoirs.size(); i++) { - RimStatisticsCase* rimReservoir = statisticsCaseCollection()->cases[i]; + RimReservoir* rimReservoir = statisticsCaseCollection()->reservoirs[i]; rimReservoir->openEclipseGridFile(); @@ -297,14 +297,14 @@ void RimIdenticalGridCaseGroup::computeUnionOfActiveCells() //-------------------------------------------------------------------------------------------------- RimStatisticsCase* RimIdenticalGridCaseGroup::createAndAppendStatisticsCase() { - RimStatisticsCase* newObject = new RimStatisticsCase; + RimStatisticsCase* newStatisticsCase = new RimStatisticsCase; - newObject->caseName = QString("Statistics ") + QString::number(statisticsCaseCollection()->cases.size()+1); - statisticsCaseCollection()->cases.push_back(newObject); + newStatisticsCase->caseName = QString("Statistics ") + QString::number(statisticsCaseCollection()->reservoirs.size()+1); + statisticsCaseCollection()->reservoirs.push_back(newStatisticsCase); - newObject->openEclipseGridFile(); + newStatisticsCase->openEclipseGridFile(); - return newObject; + return newStatisticsCase; } //-------------------------------------------------------------------------------------------------- @@ -312,9 +312,9 @@ RimStatisticsCase* RimIdenticalGridCaseGroup::createAndAppendStatisticsCase() //-------------------------------------------------------------------------------------------------- void RimIdenticalGridCaseGroup::updateMainGridAndActiveCellsForStatisticsCases() { - for (size_t i = 0; i < statisticsCaseCollection->cases().size(); i++) + for (size_t i = 0; i < statisticsCaseCollection->reservoirs().size(); i++) { - RimStatisticsCase* rimStaticsCase = statisticsCaseCollection->cases[i]; + RimReservoir* rimStaticsCase = statisticsCaseCollection->reservoirs[i]; rimStaticsCase->reservoirData()->setMainGrid(this->mainGrid()); @@ -330,9 +330,11 @@ void RimIdenticalGridCaseGroup::updateMainGridAndActiveCellsForStatisticsCases() //-------------------------------------------------------------------------------------------------- void RimIdenticalGridCaseGroup::clearStatisticsResults() { - for (size_t i = 0; i < statisticsCaseCollection->cases().size(); i++) + for (size_t i = 0; i < statisticsCaseCollection->reservoirs().size(); i++) { - RimStatisticsCase* rimStaticsCase = statisticsCaseCollection->cases[i]; + RimReservoir* rimStaticsCase = statisticsCaseCollection->reservoirs[i]; + if (!rimStaticsCase) continue; + rimStaticsCase->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->clearAllResults(); rimStaticsCase->results(RifReaderInterface::FRACTURE_RESULTS)->cellResults()->clearAllResults(); @@ -385,3 +387,21 @@ RigActiveCellInfo* RimIdenticalGridCaseGroup::unionOfActiveCells(RifReaderInterf return m_unionOfFractureActiveCells.p(); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimIdenticalGridCaseGroup::isStatisticsCaseCollection(RimCaseCollection* rimCaseCollection) +{ + std::vector fields; + rimCaseCollection->parentFields(fields); + if (fields.size() == 1) + { + if (fields[0]->keyword() == "StatisticsCaseCollection") + { + return true; + } + } + + return false; +} diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h index 4b5e1564f0..fb1218dade 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h @@ -51,8 +51,8 @@ public: RimStatisticsCase* createAndAppendStatisticsCase(); - caf::PdmField caseCollection; - caf::PdmField statisticsCaseCollection; + caf::PdmField caseCollection; + caf::PdmField statisticsCaseCollection; void loadMainCaseAndActiveCellInfo(); @@ -61,6 +61,8 @@ public: void computeUnionOfActiveCells(); + static bool isStatisticsCaseCollection(RimCaseCollection* rimCaseCollection); + protected: virtual caf::PdmFieldHandle* userDescriptionField(); diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp index da0a4371a8..5b75d52b78 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp @@ -98,9 +98,9 @@ void RimStatisticsCase::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderin //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimStatisticsCaseCollection* RimStatisticsCase::parentStatisticsCaseCollection() +RimCaseCollection* RimStatisticsCase::parentStatisticsCaseCollection() { - std::vector parentObjects; + std::vector parentObjects; this->parentObjectsOfType(parentObjects); if (parentObjects.size() > 0) @@ -210,7 +210,7 @@ void RimStatisticsCase::getSourceCases(std::vector& sourceCases) //-------------------------------------------------------------------------------------------------- RimIdenticalGridCaseGroup* RimStatisticsCase::caseGroup() { - RimStatisticsCaseCollection* parentCollection = parentStatisticsCaseCollection(); + RimCaseCollection* parentCollection = parentStatisticsCaseCollection(); if (parentCollection) { return parentCollection->parentCaseGroup(); diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h index 5c828d4451..df9dd0f022 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h +++ b/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h @@ -50,7 +50,7 @@ public: caf::PdmField m_resultName; - RimStatisticsCaseCollection* parentStatisticsCaseCollection(); + RimCaseCollection* parentStatisticsCaseCollection(); virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) const; void computeStatistics(); diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index 4d54ded8c5..cc3f59602a 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -229,8 +229,18 @@ void RimUiTreeModelPdm::deleteReservoir(RimReservoir* reservoir) removeRows_special(mi.row(), 1, mi.parent()); } - RimProject* proj = RIApplication::instance()->project(); - proj->removeCaseFromAllGroups(reservoir); + if (RimIdenticalGridCaseGroup::isStatisticsCaseCollection(caseCollection)) + { + RimIdenticalGridCaseGroup* caseGroup = caseCollection->parentCaseGroup(); + CVF_ASSERT(caseGroup); + + caseGroup->statisticsCaseCollection()->reservoirs.removeChildObject(reservoir); + } + else + { + RimProject* proj = RIApplication::instance()->project(); + proj->removeCaseFromAllGroups(reservoir); + } delete reservoir; @@ -492,25 +502,32 @@ RimStatisticsCase* RimUiTreeModelPdm::addStatisticalCalculation(const QModelInde position = itemIndex.row(); collectionIndex = itemIndex.parent(); } - else if (dynamic_cast(currentItem->dataObject().p())) + else if (dynamic_cast(currentItem->dataObject().p())) { - RimStatisticsCaseCollection* statColl = dynamic_cast(currentItem->dataObject().p()); + RimCaseCollection* statColl = dynamic_cast(currentItem->dataObject().p()); caseGroup = statColl->parentCaseGroup(); parentCollectionItem = currentItem; position = parentCollectionItem->childCount(); collectionIndex = itemIndex; } - beginInsertRows(collectionIndex, position, position); + if (parentCollectionItem && caseGroup) + { + beginInsertRows(collectionIndex, position, position); - RimStatisticsCase* createdObject = caseGroup->createAndAppendStatisticsCase(); - caf::PdmUiTreeItem* childItem = new caf::PdmUiTreeItem(parentCollectionItem, position, createdObject); + RimStatisticsCase* createdObject = caseGroup->createAndAppendStatisticsCase(); + caf::PdmUiTreeItem* childItem = new caf::PdmUiTreeItem(parentCollectionItem, position, createdObject); - endInsertRows(); + endInsertRows(); - insertedModelIndex = index(position, 0, collectionIndex); + insertedModelIndex = index(position, 0, collectionIndex); - return createdObject; + return createdObject; + } + else + { + return NULL; + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index 9fe884f306..9189928f68 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -196,6 +196,14 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event) { QMenu menu; menu.addAction(m_pasteAction); + + // Check if parent field is a StatisticsCaseCollection + RimCaseCollection* rimCaseCollection = dynamic_cast(uiItem->dataObject().p()); + if (RimIdenticalGridCaseGroup::isStatisticsCaseCollection(rimCaseCollection)) + { + menu.addAction(QString("New Statistics Case"), this, SLOT(slotNewStatisticsCase())); + } + menu.exec(event->globalPos()); } } @@ -803,7 +811,7 @@ void RimUiTreeView::slotCloseCase() group.addObject(uiItem->dataObject().p()); } - std::vector > typedObjects; + std::vector > typedObjects; group.objectsByType(&typedObjects); for (size_t i = 0; i < typedObjects.size(); i++) From 0d2ad04c3e3fea52047d7605ed9d67f1c608ce5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 22 Mar 2013 13:35:43 +0100 Subject: [PATCH 161/242] Moved "internal" class to cpp file p4#: 21057 --- .../ProjectDataModel/RigStatistics.cpp | 77 +++++++++++++++++++ .../ProjectDataModel/RigStatistics.h | 77 ------------------- 2 files changed, 77 insertions(+), 77 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RigStatistics.cpp b/ApplicationCode/ProjectDataModel/RigStatistics.cpp index 781ae35874..9f1244ddc2 100644 --- a/ApplicationCode/ProjectDataModel/RigStatistics.cpp +++ b/ApplicationCode/ProjectDataModel/RigStatistics.cpp @@ -27,6 +27,83 @@ #include #include "cafProgressInfo.h" +//-------------------------------------------------------------------------------------------------- +/// An internal class to do the actual computations +//-------------------------------------------------------------------------------------------------- +class RimStatisticsEvaluator +{ +public: + RimStatisticsEvaluator(const std::vector& values) + : m_values(values), + m_min(HUGE_VAL), + m_max(-HUGE_VAL), + m_mean(HUGE_VAL), + m_dev(HUGE_VAL) + { + } + + + void getStatistics(double& min, double& max, double& mean, double& dev, double& range) + { + evaluate(); + + min = m_min; + max = m_max; + mean = m_mean; + dev = m_dev; + + range = m_max - m_min; + } + +private: + void evaluate() + { + double sum = 0.0; + double sumSquared = 0.0; + + size_t validValueCount = 0; + + for (size_t i = 0; i < m_values.size(); i++) + { + double val = m_values[i]; + if (val == HUGE_VAL) continue; + + validValueCount++; + + if (val < m_min) m_min = val; + if (val > m_max) m_max = val; + + sum += val; + sumSquared += (val * val); + } + + if (validValueCount > 0) + { + m_mean = sum / validValueCount; + + + // http://en.wikipedia.org/wiki/Standard_deviation#Rapid_calculation_methods + // Running standard deviation + + double s0 = validValueCount; + double s1 = sum; + double s2 = sumSquared; + + m_dev = cvf::Math::sqrt( (s0 * s2) - (s1 * s1) ) / s0; + } + } + + +private: + const std::vector& m_values; + + double m_min; + double m_max; + double m_mean; + double m_dev; +}; + + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RigStatistics.h b/ApplicationCode/ProjectDataModel/RigStatistics.h index 8d885ac4ab..f34fd76bd8 100644 --- a/ApplicationCode/ProjectDataModel/RigStatistics.h +++ b/ApplicationCode/ProjectDataModel/RigStatistics.h @@ -21,9 +21,6 @@ #include "cvfBase.h" #include "cvfObject.h" #include "cvfCollection.h" - - - #include #include @@ -34,80 +31,6 @@ class RimReservoir; class RigEclipseCase; class RigReservoirCellResults; -class RimStatisticsEvaluator -{ -public: - RimStatisticsEvaluator(const std::vector& values) - : m_values(values), - m_min(HUGE_VAL), - m_max(-HUGE_VAL), - m_mean(HUGE_VAL), - m_dev(HUGE_VAL) - { - } - - - void getStatistics(double& min, double& max, double& mean, double& dev, double& range) - { - evaluate(); - - min = m_min; - max = m_max; - mean = m_mean; - dev = m_dev; - - range = m_max - m_min; - } - -private: - void evaluate() - { - double sum = 0.0; - double sumSquared = 0.0; - - size_t validValueCount = 0; - - for (size_t i = 0; i < m_values.size(); i++) - { - double val = m_values[i]; - if (val == HUGE_VAL) continue; - - validValueCount++; - - if (val < m_min) m_min = val; - if (val > m_max) m_max = val; - - sum += val; - sumSquared += (val * val); - } - - if (validValueCount > 0) - { - m_mean = sum / validValueCount; - - - // http://en.wikipedia.org/wiki/Standard_deviation#Rapid_calculation_methods - // Running standard deviation - - double s0 = validValueCount; - double s1 = sum; - double s2 = sumSquared; - - m_dev = cvf::Math::sqrt( (s0 * s2) - (s1 * s1) ) / s0; - } - } - - -private: - const std::vector& m_values; - - double m_min; - double m_max; - double m_mean; - double m_dev; -}; - - class RimStatisticsConfig { From 6d24c6b54142923b5f093962b3ec16bbcc1d25be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 22 Mar 2013 14:24:41 +0100 Subject: [PATCH 162/242] Renamed files corresponding to the already renamed statistics related classes p4#: 21060 --- ApplicationCode/CMakeLists.txt | 6 +++--- ApplicationCode/ProjectDataModel/RimCaseCollection.h | 2 +- .../ProjectDataModel/RimIdenticalGridCaseGroup.cpp | 4 ++-- .../ProjectDataModel/RimIdenticalGridCaseGroup.h | 2 +- ...{RimStatisticalCalculation.cpp => RimStatisticsCase.cpp} | 4 ++-- .../{RimStatisticalCalculation.h => RimStatisticsCase.h} | 0 ...sticalCollection.cpp => RimStatisticsCaseCollection.cpp} | 2 +- ...tatisticalCollection.h => RimStatisticsCaseCollection.h} | 2 +- .../{RigStatistics.cpp => RimStatisticsCaseEvaluator.cpp} | 2 +- .../{RigStatistics.h => RimStatisticsCaseEvaluator.h} | 0 ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp | 2 +- ApplicationCode/ProjectDataModel/RimUiTreeView.cpp | 2 +- 12 files changed, 14 insertions(+), 14 deletions(-) rename ApplicationCode/ProjectDataModel/{RimStatisticalCalculation.cpp => RimStatisticsCase.cpp} (99%) rename ApplicationCode/ProjectDataModel/{RimStatisticalCalculation.h => RimStatisticsCase.h} (100%) rename ApplicationCode/ProjectDataModel/{RimStatisticalCollection.cpp => RimStatisticsCaseCollection.cpp} (98%) rename ApplicationCode/ProjectDataModel/{RimStatisticalCollection.h => RimStatisticsCaseCollection.h} (97%) rename ApplicationCode/ProjectDataModel/{RigStatistics.cpp => RimStatisticsCaseEvaluator.cpp} (99%) rename ApplicationCode/ProjectDataModel/{RigStatistics.h => RimStatisticsCaseEvaluator.h} (100%) diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index 92f37b4659..23d6f03c15 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -77,8 +77,8 @@ list( APPEND CPP_SOURCES ProjectDataModel/RimWell.cpp ProjectDataModel/RimWellCollection.cpp ProjectDataModel/RimScriptCollection.cpp - ProjectDataModel/RimStatisticalCalculation.cpp - ProjectDataModel/RimStatisticalCollection.cpp + ProjectDataModel/RimStatisticsCase.cpp + ProjectDataModel/RimStatisticsCaseCollection.cpp ProjectDataModel/RimCalcScript.cpp ProjectDataModel/RimExportInputPropertySettings.cpp ProjectDataModel/RimBinaryExportSettings.cpp @@ -86,7 +86,7 @@ list( APPEND CPP_SOURCES ProjectDataModel/RimUiTreeModelPdm.cpp ProjectDataModel/RimUiTreeView.cpp ProjectDataModel/RimReservoirCellResultsCacher.cpp - ProjectDataModel/RigStatistics.cpp + ProjectDataModel/RimStatisticsCaseEvaluator.cpp ) # Populate the filenames into variable lists diff --git a/ApplicationCode/ProjectDataModel/RimCaseCollection.h b/ApplicationCode/ProjectDataModel/RimCaseCollection.h index ae94edef8a..814987a11f 100644 --- a/ApplicationCode/ProjectDataModel/RimCaseCollection.h +++ b/ApplicationCode/ProjectDataModel/RimCaseCollection.h @@ -23,7 +23,7 @@ #include "cafPdmField.h" #include "cafPdmObject.h" -#include "RimStatisticalCalculation.h" +#include "RimStatisticsCase.h" //================================================================================================== diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index 8d6b2efd98..0440dc1bd9 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -25,8 +25,8 @@ #include "RigEclipseCase.h" #include "RigReservoirCellResults.h" -#include "RimStatisticalCalculation.h" -#include "RimStatisticalCollection.h" +#include "RimStatisticsCase.h" +#include "RimStatisticsCaseCollection.h" #include "RimResultReservoir.h" #include "cafProgressInfo.h" #include "RigActiveCellInfo.h" diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h index fb1218dade..3147f8c6a6 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h @@ -23,7 +23,7 @@ #include "cafPdmField.h" #include "cafPdmObject.h" -#include "RimStatisticalCollection.h" +#include "RimStatisticsCaseCollection.h" #include "RimCaseCollection.h" class RimReservoir; diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp similarity index 99% rename from ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp rename to ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp index 5b75d52b78..8534a57a22 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp @@ -18,13 +18,13 @@ #include "RIStdInclude.h" -#include "RimStatisticalCalculation.h" +#include "RimStatisticsCase.h" #include "RimReservoirView.h" #include "cafPdmUiOrdering.h" #include "RimIdenticalGridCaseGroup.h" #include "RigEclipseCase.h" #include "RigReservoirCellResults.h" -#include "RigStatistics.h" +#include "RimStatisticsCaseEvaluator.h" #include "RigMainGrid.h" diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h b/ApplicationCode/ProjectDataModel/RimStatisticsCase.h similarity index 100% rename from ApplicationCode/ProjectDataModel/RimStatisticalCalculation.h rename to ApplicationCode/ProjectDataModel/RimStatisticsCase.h diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCollection.cpp b/ApplicationCode/ProjectDataModel/RimStatisticsCaseCollection.cpp similarity index 98% rename from ApplicationCode/ProjectDataModel/RimStatisticalCollection.cpp rename to ApplicationCode/ProjectDataModel/RimStatisticsCaseCollection.cpp index c35bce456c..59d5b11141 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCaseCollection.cpp @@ -20,7 +20,7 @@ #include "RimReservoirView.h" -#include "RimStatisticalCollection.h" +#include "RimStatisticsCaseCollection.h" #include "RimIdenticalGridCaseGroup.h" diff --git a/ApplicationCode/ProjectDataModel/RimStatisticalCollection.h b/ApplicationCode/ProjectDataModel/RimStatisticsCaseCollection.h similarity index 97% rename from ApplicationCode/ProjectDataModel/RimStatisticalCollection.h rename to ApplicationCode/ProjectDataModel/RimStatisticsCaseCollection.h index d129ab1042..e7c0059363 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticalCollection.h +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCaseCollection.h @@ -23,7 +23,7 @@ #include "cafPdmField.h" #include "cafPdmObject.h" -#include "RimStatisticalCalculation.h" +#include "RimStatisticsCase.h" diff --git a/ApplicationCode/ProjectDataModel/RigStatistics.cpp b/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.cpp similarity index 99% rename from ApplicationCode/ProjectDataModel/RigStatistics.cpp rename to ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.cpp index 9f1244ddc2..f170e30e4e 100644 --- a/ApplicationCode/ProjectDataModel/RigStatistics.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.cpp @@ -17,7 +17,7 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RIStdInclude.h" -#include "RigStatistics.h" +#include "RimStatisticsCaseEvaluator.h" #include "RigReservoirCellResults.h" #include "RimReservoirView.h" #include "RimReservoir.h" diff --git a/ApplicationCode/ProjectDataModel/RigStatistics.h b/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.h similarity index 100% rename from ApplicationCode/ProjectDataModel/RigStatistics.h rename to ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.h diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index cc3f59602a..6debf187d7 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -35,7 +35,7 @@ #include "RimInputPropertyCollection.h" #include "cafPdmField.h" #include "RimInputReservoir.h" -#include "RimStatisticalCalculation.h" +#include "RimStatisticsCase.h" #include "RimResultReservoir.h" //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index 9189928f68..65ae72d80a 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -33,7 +33,7 @@ #include "RimInputReservoir.h" #include "RimBinaryExportSettings.h" #include "RigReservoirCellResults.h" -#include "RimStatisticalCalculation.h" +#include "RimStatisticsCase.h" #include "RimResultReservoir.h" //-------------------------------------------------------------------------------------------------- From bd33a64e8468415b50e7fc2ed64bd134e137686b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 22 Mar 2013 15:22:50 +0100 Subject: [PATCH 163/242] Added a comment p4#: 21063 --- ApplicationCode/ReservoirDataModel/RigEclipseCase.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCase.h b/ApplicationCode/ReservoirDataModel/RigEclipseCase.h index c4ed2a5b46..5063111cb4 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCase.h +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCase.h @@ -83,6 +83,6 @@ private: cvf::ref m_matrixModelResults; cvf::ref m_fractureModelResults; - cvf::Collection m_wellResults; + cvf::Collection m_wellResults; //< A WellResults object for each well in the reservoir cvf::Collection m_wellCellsInGrid; //< A bool array pr grid with one bool pr cell telling wether the cell is a well cell or not }; From e493db37d08851c23aa98e563ea684ba212b0477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 22 Mar 2013 15:43:42 +0100 Subject: [PATCH 164/242] Major renaming of classes. Filenames not done yet. RimReservoir RimCase RimResultReservoir RimResultCase RimInputReservoir RimInputCase RigEclipseCase RigCaseData RigReservoirCellResults RigCaseCellResultsData RigWellResults RigSingleWellResultsData RigGridCollection RigGridManager p4#: 21064 --- ApplicationCode/Application/RIApplication.cpp | 18 +++--- ApplicationCode/Application/RIApplication.h | 4 +- .../RifReaderEclipseOutput-Test.cpp | 2 +- .../RifEclipseInputFileTools.cpp | 12 ++-- .../FileInterface/RifEclipseInputFileTools.h | 14 ++--- .../FileInterface/RifReaderEclipseInput.cpp | 2 +- .../FileInterface/RifReaderEclipseInput.h | 2 +- .../FileInterface/RifReaderEclipseOutput.cpp | 14 ++--- .../FileInterface/RifReaderEclipseOutput.h | 8 +-- .../FileInterface/RifReaderInterface.h | 4 +- .../FileInterface/RifReaderMockModel.cpp | 6 +- .../FileInterface/RifReaderMockModel.h | 6 +- .../RivCellEdgeEffectGenerator.cpp | 4 +- .../ModelVisualization/RivGridPartMgr.cpp | 4 +- .../RivReservoirPartMgr.cpp | 2 +- .../ModelVisualization/RivReservoirPartMgr.h | 4 +- .../RivReservoirViewPartMgr.cpp | 14 ++--- .../ModelVisualization/RivWellHeadPartMgr.cpp | 4 +- .../RivWellPipesPartMgr.cpp | 6 +- .../ProjectDataModel/RimCaseCollection.h | 2 +- .../ProjectDataModel/RimCellEdgeResultSlot.h | 2 +- .../ProjectDataModel/RimCellPropertyFilter.h | 2 +- .../RimIdenticalGridCaseGroup.cpp | 22 ++++---- .../RimIdenticalGridCaseGroup.h | 8 +-- .../ProjectDataModel/RimInputReservoir.cpp | 34 +++++------ .../ProjectDataModel/RimInputReservoir.h | 6 +- .../ProjectDataModel/RimProject.cpp | 14 ++--- ApplicationCode/ProjectDataModel/RimProject.h | 16 +++--- .../ProjectDataModel/RimReservoir.cpp | 34 +++++------ .../ProjectDataModel/RimReservoir.h | 16 +++--- .../RimReservoirCellResultsCacher.cpp | 4 +- .../RimReservoirCellResultsCacher.h | 10 ++-- .../ProjectDataModel/RimReservoirView.cpp | 28 +++++----- .../ProjectDataModel/RimReservoirView.h | 6 +- .../ProjectDataModel/RimResultDefinition.cpp | 4 +- .../ProjectDataModel/RimResultDefinition.h | 2 +- .../ProjectDataModel/RimResultReservoir.cpp | 24 ++++---- .../ProjectDataModel/RimResultReservoir.h | 8 +-- .../ProjectDataModel/RimStatisticsCase.cpp | 12 ++-- .../ProjectDataModel/RimStatisticsCase.h | 4 +- .../RimStatisticsCaseEvaluator.cpp | 12 ++-- .../RimStatisticsCaseEvaluator.h | 16 +++--- .../ProjectDataModel/RimUiTreeModelPdm.cpp | 34 +++++------ .../ProjectDataModel/RimUiTreeModelPdm.h | 4 +- .../ProjectDataModel/RimUiTreeView.cpp | 16 +++--- ApplicationCode/ProjectDataModel/RimWell.h | 6 +- .../RigReservoir-Test.cpp | 12 ++-- .../ReservoirDataModel/RigEclipseCase.cpp | 48 ++++++++-------- .../ReservoirDataModel/RigEclipseCase.h | 22 ++++---- .../ReservoirDataModel/RigGridCollection.cpp | 14 ++--- .../ReservoirDataModel/RigGridCollection.h | 12 ++-- .../RigGridScalarDataAccess.cpp | 2 +- .../RigGridScalarDataAccess.h | 2 +- .../RigReservoirBuilderMock.cpp | 14 ++--- .../RigReservoirBuilderMock.h | 10 ++-- .../RigReservoirCellResults.cpp | 56 +++++++++---------- .../RigReservoirCellResults.h | 4 +- .../ReservoirDataModel/RigWellResults.cpp | 10 ++-- .../ReservoirDataModel/RigWellResults.h | 2 +- .../SocketInterface/RiaSocketServer.cpp | 6 +- .../SocketInterface/RiaSocketServer.h | 6 +- .../UserInterface/RIMainWindow.cpp | 2 +- 62 files changed, 349 insertions(+), 349 deletions(-) diff --git a/ApplicationCode/Application/RIApplication.cpp b/ApplicationCode/Application/RIApplication.cpp index dc2e5ba83a..c3737622d2 100644 --- a/ApplicationCode/Application/RIApplication.cpp +++ b/ApplicationCode/Application/RIApplication.cpp @@ -273,7 +273,7 @@ bool RIApplication::loadProject(const QString& projectFileName) // Now load the ReservoirViews for the cases - std::vector casesToLoad; + std::vector casesToLoad; // Add all "native" cases in the project for (size_t cIdx = 0; cIdx < m_project->reservoirs().size(); ++cIdx) @@ -286,7 +286,7 @@ bool RIApplication::loadProject(const QString& projectFileName) { if (m_project->caseGroups[cgIdx]->statisticsCaseCollection()) { - caf::PdmPointersField & statCases = m_project->caseGroups[cgIdx]->statisticsCaseCollection()->reservoirs(); + caf::PdmPointersField & statCases = m_project->caseGroups[cgIdx]->statisticsCaseCollection()->reservoirs(); for (size_t scIdx = 0; scIdx < statCases.size(); ++scIdx) { casesToLoad.push_back(statCases[scIdx]); @@ -298,7 +298,7 @@ bool RIApplication::loadProject(const QString& projectFileName) for (size_t cIdx = 0; cIdx < casesToLoad.size(); ++cIdx) { - RimReservoir* ri = casesToLoad[cIdx]; + RimCase* ri = casesToLoad[cIdx]; CVF_ASSERT(ri); caseProgress.setProgressDescription(ri->caseName()); @@ -494,7 +494,7 @@ bool RIApplication::openEclipseCase(const QString& caseName, const QString& case QFileInfo gridFileName(caseFileName); QString casePath = gridFileName.absolutePath(); - RimResultReservoir* rimResultReservoir = new RimResultReservoir(); + RimResultCase* rimResultReservoir = new RimResultCase(); rimResultReservoir->caseName = caseName; rimResultReservoir->caseFileName = caseFileName; rimResultReservoir->caseDirectory = casePath; @@ -529,7 +529,7 @@ bool RIApplication::openEclipseCase(const QString& caseName, const QString& case //-------------------------------------------------------------------------------------------------- bool RIApplication::openInputEclipseCase(const QString& caseName, const QStringList& caseFileNames) { - RimInputReservoir* rimInputReservoir = new RimInputReservoir(); + RimInputCase* rimInputReservoir = new RimInputCase(); rimInputReservoir->caseName = caseName; rimInputReservoir->openDataFileSet(caseFileNames); @@ -1189,7 +1189,7 @@ void RIApplication::saveSnapshotForAllViews(const QString& snapshotFolderName) for (size_t i = 0; i < m_project->reservoirs().size(); ++i) { - RimReservoir* ri = m_project->reservoirs()[i]; + RimCase* ri = m_project->reservoirs()[i]; if (!ri) continue; for (size_t j = 0; j < ri->reservoirViews().size(); j++) @@ -1360,7 +1360,7 @@ bool RIApplication::addEclipseCases(const QStringList& fileNames) // First file is read completely including grid. // The main grid from the first case is reused directly in for the other cases. // When reading active cell info, only the total cell count is tested for consistency - RigEclipseCase* mainEclipseCase = NULL; + RigCaseData* mainEclipseCase = NULL; { QString firstFileName = fileNames[0]; @@ -1369,7 +1369,7 @@ bool RIApplication::addEclipseCases(const QStringList& fileNames) QString caseName = gridFileName.completeBaseName(); QString casePath = gridFileName.absolutePath(); - RimResultReservoir* rimResultReservoir = new RimResultReservoir(); + RimResultCase* rimResultReservoir = new RimResultCase(); rimResultReservoir->caseName = caseName; rimResultReservoir->caseFileName = firstFileName; rimResultReservoir->caseDirectory = casePath; @@ -1396,7 +1396,7 @@ bool RIApplication::addEclipseCases(const QStringList& fileNames) QString caseName = gridFileName.completeBaseName(); QString casePath = gridFileName.absolutePath(); - RimResultReservoir* rimResultReservoir = new RimResultReservoir(); + RimResultCase* rimResultReservoir = new RimResultCase(); rimResultReservoir->caseName = caseName; rimResultReservoir->caseFileName = fileName; rimResultReservoir->caseDirectory = casePath; diff --git a/ApplicationCode/Application/RIApplication.h b/ApplicationCode/Application/RIApplication.h index 4073593ad7..29992ec3d6 100644 --- a/ApplicationCode/Application/RIApplication.h +++ b/ApplicationCode/Application/RIApplication.h @@ -30,8 +30,8 @@ #include "RimProject.h" class RIProcess; -class RigEclipseCase; -class RimReservoir; +class RigCaseData; +class RimCase; class Drawable; class RiaSocketServer; class RIPreferences; diff --git a/ApplicationCode/FileInterface/FileInterface_UnitTests/RifReaderEclipseOutput-Test.cpp b/ApplicationCode/FileInterface/FileInterface_UnitTests/RifReaderEclipseOutput-Test.cpp index bb81b1f16d..797507e7af 100644 --- a/ApplicationCode/FileInterface/FileInterface_UnitTests/RifReaderEclipseOutput-Test.cpp +++ b/ApplicationCode/FileInterface/FileInterface_UnitTests/RifReaderEclipseOutput-Test.cpp @@ -247,7 +247,7 @@ TEST(RigReservoirTest, BasicTest) TEST(RigReservoirTest, WellTest) { cvf::ref readerInterfaceEcl = new RifReaderEclipseOutput; - cvf::ref reservoir = new RigEclipseCase; + cvf::ref reservoir = new RigCaseData; // Location of test dataset received from Håkon Høgstøl in July 2011 with 10k active cells #ifdef WIN32 diff --git a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp index bcb4c98d57..482f55456e 100644 --- a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp @@ -61,7 +61,7 @@ RifEclipseInputFileTools::~RifEclipseInputFileTools() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigEclipseCase* eclipseCase) +bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigCaseData* eclipseCase) { CVF_ASSERT(eclipseCase); @@ -176,7 +176,7 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigEclipseC //-------------------------------------------------------------------------------------------------- /// Read known properties from the input file //-------------------------------------------------------------------------------------------------- -std::map RifEclipseInputFileTools::readProperties(const QString &fileName, RigEclipseCase *reservoir) +std::map RifEclipseInputFileTools::readProperties(const QString &fileName, RigCaseData *reservoir) { CVF_ASSERT(reservoir); @@ -282,7 +282,7 @@ std::vector< RifKeywordAndFilePos > RifEclipseInputFileTools::findKeywordsOnFile /// Reads the property data requested into the \a reservoir, overwriting any previous /// propeties with the same name. //-------------------------------------------------------------------------------------------------- -bool RifEclipseInputFileTools::readProperty(const QString& fileName, RigEclipseCase* eclipseCase, const QString& eclipseKeyWord, const QString& resultName) +bool RifEclipseInputFileTools::readProperty(const QString& fileName, RigCaseData* eclipseCase, const QString& eclipseKeyWord, const QString& resultName) { CVF_ASSERT(eclipseCase); @@ -370,7 +370,7 @@ const std::vector& RifEclipseInputFileTools::knownPropertyKeywords() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifEclipseInputFileTools::writePropertyToTextFile(const QString& fileName, RigEclipseCase* eclipseCase, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord) +bool RifEclipseInputFileTools::writePropertyToTextFile(const QString& fileName, RigCaseData* eclipseCase, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord) { CVF_ASSERT(eclipseCase); @@ -402,7 +402,7 @@ bool RifEclipseInputFileTools::writePropertyToTextFile(const QString& fileName, /// Create and write a result vector with values for all cells. /// undefinedValue is used for cells with no result //-------------------------------------------------------------------------------------------------- -bool RifEclipseInputFileTools::writeBinaryResultToTextFile(const QString& fileName, RigEclipseCase* eclipseCase, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord, const double undefinedValue) +bool RifEclipseInputFileTools::writeBinaryResultToTextFile(const QString& fileName, RigCaseData* eclipseCase, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord, const double undefinedValue) { CVF_ASSERT(eclipseCase); @@ -519,7 +519,7 @@ void RifEclipseInputFileTools::findGridKeywordPositions(const QString& filename, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifEclipseInputFileTools::readPropertyAtFilePosition(const QString& fileName, RigEclipseCase* eclipseCase, const QString& eclipseKeyWord, qint64 filePos, const QString& resultName) +bool RifEclipseInputFileTools::readPropertyAtFilePosition(const QString& fileName, RigCaseData* eclipseCase, const QString& eclipseKeyWord, qint64 filePos, const QString& resultName) { CVF_ASSERT(eclipseCase); diff --git a/ApplicationCode/FileInterface/RifEclipseInputFileTools.h b/ApplicationCode/FileInterface/RifEclipseInputFileTools.h index f78c29c734..7d0116a29b 100644 --- a/ApplicationCode/FileInterface/RifEclipseInputFileTools.h +++ b/ApplicationCode/FileInterface/RifEclipseInputFileTools.h @@ -27,7 +27,7 @@ #include "RifReaderInterface.h" -class RigEclipseCase; +class RigCaseData; class QFile; @@ -52,19 +52,19 @@ public: RifEclipseInputFileTools(); virtual ~RifEclipseInputFileTools(); - static bool openGridFile(const QString& fileName, RigEclipseCase* eclipseCase); + static bool openGridFile(const QString& fileName, RigCaseData* eclipseCase); // Returns map of assigned resultName and Eclipse Keyword. - static std::map readProperties(const QString& fileName, RigEclipseCase* eclipseCase); - static bool readProperty (const QString& fileName, RigEclipseCase* eclipseCase, const QString& eclipseKeyWord, const QString& resultName ); - static bool readPropertyAtFilePosition (const QString& fileName, RigEclipseCase* eclipseCase, const QString& eclipseKeyWord, qint64 filePos, const QString& resultName ); + static std::map readProperties(const QString& fileName, RigCaseData* eclipseCase); + static bool readProperty (const QString& fileName, RigCaseData* eclipseCase, const QString& eclipseKeyWord, const QString& resultName ); + static bool readPropertyAtFilePosition (const QString& fileName, RigCaseData* eclipseCase, const QString& eclipseKeyWord, qint64 filePos, const QString& resultName ); static std::vector< RifKeywordAndFilePos > findKeywordsOnFile(const QString &fileName); static const std::vector& knownPropertyKeywords(); - static bool writePropertyToTextFile(const QString& fileName, RigEclipseCase* eclipseCase, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord); - static bool writeBinaryResultToTextFile(const QString& fileName, RigEclipseCase* eclipseCase, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord, const double undefinedValue); + static bool writePropertyToTextFile(const QString& fileName, RigCaseData* eclipseCase, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord); + static bool writeBinaryResultToTextFile(const QString& fileName, RigCaseData* eclipseCase, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStep, const QString& resultName, const QString& eclipseKeyWord, const double undefinedValue); private: static void writeDataToTextFile(QFile* file, const QString& eclipseKeyWord, const std::vector& resultData); diff --git a/ApplicationCode/FileInterface/RifReaderEclipseInput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseInput.cpp index 11fb5512e5..41cd834951 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseInput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseInput.cpp @@ -57,7 +57,7 @@ RifReaderEclipseInput::~RifReaderEclipseInput() //-------------------------------------------------------------------------------------------------- /// Open file and read geometry into given reservoir object //-------------------------------------------------------------------------------------------------- -bool RifReaderEclipseInput::open(const QString& fileName, RigEclipseCase* eclipseCase) +bool RifReaderEclipseInput::open(const QString& fileName, RigCaseData* eclipseCase) { CVF_ASSERT(eclipseCase); diff --git a/ApplicationCode/FileInterface/RifReaderEclipseInput.h b/ApplicationCode/FileInterface/RifReaderEclipseInput.h index 840dba0b96..32499507e4 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseInput.h +++ b/ApplicationCode/FileInterface/RifReaderEclipseInput.h @@ -32,7 +32,7 @@ public: virtual ~RifReaderEclipseInput(); // Virtual interface implementation - virtual bool open(const QString& fileName, RigEclipseCase* eclipseCase); + virtual bool open(const QString& fileName, RigCaseData* eclipseCase); diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index c15f589038..5f3153b794 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -231,7 +231,7 @@ void RifReaderEclipseOutput::close() //-------------------------------------------------------------------------------------------------- /// Read geometry from file given by name into given reservoir object //-------------------------------------------------------------------------------------------------- -bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid, RigEclipseCase* eclipseCase) +bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid, RigCaseData* eclipseCase) { CVF_ASSERT(eclipseCase); @@ -337,7 +337,7 @@ bool RifReaderEclipseOutput::transferGeometry(const ecl_grid_type* mainEclGrid, //-------------------------------------------------------------------------------------------------- /// Open file and read geometry into given reservoir object //-------------------------------------------------------------------------------------------------- -bool RifReaderEclipseOutput::open(const QString& fileName, RigEclipseCase* eclipseCase) +bool RifReaderEclipseOutput::open(const QString& fileName, RigCaseData* eclipseCase) { CVF_ASSERT(eclipseCase); caf::ProgressInfo progInfo(100, ""); @@ -394,7 +394,7 @@ bool RifReaderEclipseOutput::open(const QString& fileName, RigEclipseCase* eclip //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifReaderEclipseOutput::openAndReadActiveCellData(const QString& fileName, const std::vector& mainCaseTimeSteps, RigEclipseCase* eclipseCase) +bool RifReaderEclipseOutput::openAndReadActiveCellData(const QString& fileName, const std::vector& mainCaseTimeSteps, RigCaseData* eclipseCase) { CVF_ASSERT(eclipseCase); @@ -544,8 +544,8 @@ bool RifReaderEclipseOutput::buildMetaData() progInfo.incrementProgress(); - RigReservoirCellResults* matrixModelResults = m_eclipseCase->results(RifReaderInterface::MATRIX_RESULTS); - RigReservoirCellResults* fractureModelResults = m_eclipseCase->results(RifReaderInterface::FRACTURE_RESULTS); + RigCaseCellResultsData* matrixModelResults = m_eclipseCase->results(RifReaderInterface::MATRIX_RESULTS); + RigCaseCellResultsData* fractureModelResults = m_eclipseCase->results(RifReaderInterface::FRACTURE_RESULTS); if (m_dynamicResultsAccess.notNull()) { @@ -741,7 +741,7 @@ void RifReaderEclipseOutput::readWellCells() std::vector grids; m_eclipseCase->allGrids(&grids); - cvf::Collection wells; + cvf::Collection wells; caf::ProgressInfo progress(well_info_get_num_wells(ert_well_info), ""); int wellIdx; @@ -750,7 +750,7 @@ void RifReaderEclipseOutput::readWellCells() const char* wellName = well_info_iget_well_name(ert_well_info, wellIdx); CVF_ASSERT(wellName); - cvf::ref wellResults = new RigWellResults; + cvf::ref wellResults = new RigSingleWellResultsData; wellResults->m_wellName = wellName; well_ts_type* ert_well_time_series = well_info_get_ts(ert_well_info , wellName); diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.h b/ApplicationCode/FileInterface/RifReaderEclipseOutput.h index d902795935..8217b58ca5 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.h +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.h @@ -43,14 +43,14 @@ public: RifReaderEclipseOutput(); virtual ~RifReaderEclipseOutput(); - bool open(const QString& fileName, RigEclipseCase* eclipseCase); - virtual bool openAndReadActiveCellData(const QString& fileName, const std::vector& mainCaseTimeSteps, RigEclipseCase* eclipseCase); + bool open(const QString& fileName, RigCaseData* eclipseCase); + virtual bool openAndReadActiveCellData(const QString& fileName, const std::vector& mainCaseTimeSteps, RigCaseData* eclipseCase); void close(); bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector* values); bool dynamicResult(const QString& result, PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector* values); - static bool transferGeometry(const ecl_grid_type* mainEclGrid, RigEclipseCase* eclipseCase); + static bool transferGeometry(const ecl_grid_type* mainEclGrid, RigCaseData* eclipseCase); private: bool readActiveCellInfo(); @@ -71,7 +71,7 @@ private: QString m_fileName; // Name of file used to start accessing Eclipse output files QStringList m_fileSet; // Set of files in filename's path with same base name as filename - RigEclipseCase* m_eclipseCase; + RigCaseData* m_eclipseCase; std::vector m_timeSteps; diff --git a/ApplicationCode/FileInterface/RifReaderInterface.h b/ApplicationCode/FileInterface/RifReaderInterface.h index 0ad153db1f..7b947f9468 100644 --- a/ApplicationCode/FileInterface/RifReaderInterface.h +++ b/ApplicationCode/FileInterface/RifReaderInterface.h @@ -27,7 +27,7 @@ #include -class RigEclipseCase; +class RigCaseData; //================================================================================================== // @@ -47,7 +47,7 @@ public: RifReaderInterface() {} virtual ~RifReaderInterface() {} - virtual bool open(const QString& fileName, RigEclipseCase* eclipseCase) = 0; + virtual bool open(const QString& fileName, RigCaseData* eclipseCase) = 0; virtual void close() = 0; virtual bool staticResult(const QString& result, PorosityModelResultType matrixOrFracture, std::vector* values) = 0; diff --git a/ApplicationCode/FileInterface/RifReaderMockModel.cpp b/ApplicationCode/FileInterface/RifReaderMockModel.cpp index 49de1cb07b..1fe0b2d44b 100644 --- a/ApplicationCode/FileInterface/RifReaderMockModel.cpp +++ b/ApplicationCode/FileInterface/RifReaderMockModel.cpp @@ -25,13 +25,13 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifReaderMockModel::open(const QString& fileName, RigEclipseCase* eclipseCase) +bool RifReaderMockModel::open(const QString& fileName, RigCaseData* eclipseCase) { m_reservoirBuilder.populateReservoir(eclipseCase); m_reservoir = eclipseCase; - RigReservoirCellResults* cellResults = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS); + RigCaseCellResultsData* cellResults = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS); std::vector dates; @@ -170,7 +170,7 @@ void RifReaderMockModel::addLocalGridRefinement(const cvf::Vec3st& minCellPositi //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RifReaderMockModel::populateReservoir(RigEclipseCase* eclipseCase) +void RifReaderMockModel::populateReservoir(RigCaseData* eclipseCase) { m_reservoirBuilder.populateReservoir(eclipseCase); } diff --git a/ApplicationCode/FileInterface/RifReaderMockModel.h b/ApplicationCode/FileInterface/RifReaderMockModel.h index b2e4f1cbd4..0237381bbe 100644 --- a/ApplicationCode/FileInterface/RifReaderMockModel.h +++ b/ApplicationCode/FileInterface/RifReaderMockModel.h @@ -33,17 +33,17 @@ public: void addLocalGridRefinement(const cvf::Vec3st& minCellPosition, const cvf::Vec3st& maxCellPosition, const cvf::Vec3st& singleCellRefinementFactors); - virtual bool open( const QString& fileName, RigEclipseCase* eclipseCase ); + virtual bool open( const QString& fileName, RigCaseData* eclipseCase ); virtual void close(); virtual bool staticResult( const QString& result, RifReaderInterface::PorosityModelResultType matrixOrFracture, std::vector* values ); virtual bool dynamicResult( const QString& result, RifReaderInterface::PorosityModelResultType matrixOrFracture, size_t stepIndex, std::vector* values ); private: - void populateReservoir(RigEclipseCase* eclipseCase); + void populateReservoir(RigCaseData* eclipseCase); bool inputProperty( const QString& propertyName, std::vector* values ); RigReservoirBuilderMock m_reservoirBuilder; - RigEclipseCase* m_reservoir; + RigCaseData* m_reservoir; }; diff --git a/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp b/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp index fc640b69ab..3ffce80792 100644 --- a/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp @@ -96,7 +96,7 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo( const RigGridBase* grid = dynamic_cast(generator->activeGrid()); CVF_ASSERT(grid != NULL); - RigEclipseCase* eclipseCase = cellResultSlot->reservoirView()->eclipseCase()->reservoirData(); + RigCaseData* eclipseCase = cellResultSlot->reservoirView()->eclipseCase()->reservoirData(); CVF_ASSERT(eclipseCase != NULL); cvf::ref cellCenterDataAccessObject = NULL; @@ -108,7 +108,7 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo( timeStepIndex = 0; } - RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel()); + RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel()); cellCenterDataAccessObject = eclipseCase->dataAccessObject(grid, porosityModel, timeStepIndex, cellResultSlot->gridScalarIndex()); } diff --git a/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp b/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp index bed02b5a73..52fc9a050f 100644 --- a/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp @@ -221,9 +221,9 @@ void RivGridPartMgr::updateCellResultColor(size_t timeStepIndex, RimResultSlot* size_t resTimeStepIdx = timeStepIndex; if (cellResultSlot->hasStaticResult()) resTimeStepIdx = 0; - RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel()); + RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResultSlot->porosityModel()); - RigEclipseCase* eclipseCase = cellResultSlot->reservoirView()->eclipseCase()->reservoirData(); + RigCaseData* eclipseCase = cellResultSlot->reservoirView()->eclipseCase()->reservoirData(); cvf::ref dataAccessObject = eclipseCase->dataAccessObject(m_grid.p(), porosityModel, resTimeStepIdx, scalarSetIndex); if (dataAccessObject.isNull()) return; diff --git a/ApplicationCode/ModelVisualization/RivReservoirPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirPartMgr.cpp index 9d6be7e290..a7c48f705b 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirPartMgr.cpp @@ -26,7 +26,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivReservoirPartMgr::clearAndSetReservoir(const RigEclipseCase* eclipseCase) +void RivReservoirPartMgr::clearAndSetReservoir(const RigCaseData* eclipseCase) { m_allGrids.clear(); if (eclipseCase) diff --git a/ApplicationCode/ModelVisualization/RivReservoirPartMgr.h b/ApplicationCode/ModelVisualization/RivReservoirPartMgr.h index 601558216f..58d4dc08f6 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivReservoirPartMgr.h @@ -30,7 +30,7 @@ namespace cvf class RimResultSlot; class RimCellEdgeResultSlot; class RivGridPartMgr; -class RigEclipseCase; +class RigCaseData; //================================================================================================== @@ -43,7 +43,7 @@ class RigEclipseCase; class RivReservoirPartMgr: public cvf::Object { public: - void clearAndSetReservoir(const RigEclipseCase* eclipseCase); + void clearAndSetReservoir(const RigCaseData* eclipseCase); void setTransform(cvf::Transform* scaleTransform); void setCellVisibility(size_t gridIndex, cvf::UByteArray* cellVisibilities ); diff --git a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp index a0ddb2ac74..95020a38bd 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp @@ -125,7 +125,7 @@ void RivReservoirViewPartMgr::scheduleGeometryRegen(ReservoirGeometryCacheType g //-------------------------------------------------------------------------------------------------- void RivReservoirViewPartMgr::clearGeometryCache(ReservoirGeometryCacheType geomType) { - RigEclipseCase* eclipseCase = NULL; + RigCaseData* eclipseCase = NULL; if (m_reservoirView != NULL && m_reservoirView->eclipseCase()) { eclipseCase = m_reservoirView->eclipseCase()->reservoirData(); @@ -224,7 +224,7 @@ void RivReservoirViewPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicL //-------------------------------------------------------------------------------------------------- void RivReservoirViewPartMgr::createGeometry(ReservoirGeometryCacheType geometryType) { - RigEclipseCase* res = m_reservoirView->eclipseCase()->reservoirData(); + RigCaseData* res = m_reservoirView->eclipseCase()->reservoirData(); m_geometries[geometryType].clearAndSetReservoir(res); m_geometries[geometryType].setTransform(m_scaleTransform.p()); std::vector grids; @@ -246,7 +246,7 @@ void RivReservoirViewPartMgr::createGeometry(ReservoirGeometryCacheType geometry //-------------------------------------------------------------------------------------------------- void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility, ReservoirGeometryCacheType geometryType, RigGridBase* grid, size_t gridIdx) { - RigEclipseCase* eclipseCase = m_reservoirView->eclipseCase()->reservoirData(); + RigCaseData* eclipseCase = m_reservoirView->eclipseCase()->reservoirData(); RigActiveCellInfo* activeCellInfo = m_reservoirView->currentActiveCellInfo(); switch (geometryType) @@ -370,7 +370,7 @@ void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility, //-------------------------------------------------------------------------------------------------- void RivReservoirViewPartMgr::createPropertyFilteredGeometry(size_t frameIndex) { - RigEclipseCase* res = m_reservoirView->eclipseCase()->reservoirData(); + RigCaseData* res = m_reservoirView->eclipseCase()->reservoirData(); if ( frameIndex >= m_propFilteredGeometryFrames.size()) { @@ -418,7 +418,7 @@ void RivReservoirViewPartMgr::createPropertyFilteredGeometry(size_t frameIndex) //-------------------------------------------------------------------------------------------------- void RivReservoirViewPartMgr::createPropertyFilteredWellGeometry(size_t frameIndex) { - RigEclipseCase* res = m_reservoirView->eclipseCase()->reservoirData(); + RigCaseData* res = m_reservoirView->eclipseCase()->reservoirData(); if ( frameIndex >= m_propFilteredWellGeometryFrames.size()) { @@ -606,8 +606,8 @@ void RivReservoirViewPartMgr::computePropertyVisibility(cvf::UByteArray* cellVis const RimCellFilter::FilterModeType filterType = (*pfIt)->filterMode(); - RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel((*pfIt)->resultDefinition()->porosityModel()); - RigEclipseCase* eclipseCase = propFilterColl->reservoirView()->eclipseCase()->reservoirData(); + RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel((*pfIt)->resultDefinition()->porosityModel()); + RigCaseData* eclipseCase = propFilterColl->reservoirView()->eclipseCase()->reservoirData(); cvf::ref dataAccessObject = eclipseCase->dataAccessObject(grid, porosityModel, timeStepIndex, scalarResultIndex); CVF_ASSERT(dataAccessObject.notNull()); diff --git a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp index a78833582f..1d721e24e7 100644 --- a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp @@ -72,11 +72,11 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex) if (m_rimReservoirView.isNull()) return; - RigEclipseCase* rigReservoir = m_rimReservoirView->eclipseCase()->reservoirData(); + RigCaseData* rigReservoir = m_rimReservoirView->eclipseCase()->reservoirData(); RimWell* well = m_rimWell; - RigWellResults* wellResults = well->wellResults(); + RigSingleWellResultsData* wellResults = well->wellResults(); if (wellResults->m_staticWellCells.m_wellResultBranches.size() == 0) { diff --git a/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp index c091f1a4a2..f45e79a32b 100644 --- a/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp @@ -158,8 +158,8 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector bool isAutoDetectBranches = m_rimReservoirView->wellCollection()->isAutoDetectingBranches(); - RigEclipseCase* rigReservoir = m_rimReservoirView->eclipseCase()->reservoirData(); - RigWellResults* wellResults = m_rimWell->wellResults(); + RigCaseData* rigReservoir = m_rimReservoirView->eclipseCase()->reservoirData(); + RigSingleWellResultsData* wellResults = m_rimWell->wellResults(); const RigWellResultFrame& staticWellFrame = m_rimWell->wellResults()->m_staticWellCells; @@ -357,7 +357,7 @@ void RivWellPipesPartMgr::updatePipeResultColor(size_t frameIndex) { if (m_rimWell == NULL) return; - RigWellResults* wRes = m_rimWell->wellResults(); + RigSingleWellResultsData* wRes = m_rimWell->wellResults(); if (wRes == NULL) return; if (frameIndex < wRes->firstResultTimeStep()) return; // Or reset colors or something diff --git a/ApplicationCode/ProjectDataModel/RimCaseCollection.h b/ApplicationCode/ProjectDataModel/RimCaseCollection.h index 814987a11f..bd1e1a48b2 100644 --- a/ApplicationCode/ProjectDataModel/RimCaseCollection.h +++ b/ApplicationCode/ProjectDataModel/RimCaseCollection.h @@ -39,7 +39,7 @@ public: RimCaseCollection(); virtual ~RimCaseCollection(); - caf::PdmPointersField reservoirs; + caf::PdmPointersField reservoirs; RimIdenticalGridCaseGroup* parentCaseGroup(); diff --git a/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.h b/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.h index c37bc7577d..8f4eb1eba9 100644 --- a/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.h +++ b/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.h @@ -23,7 +23,7 @@ #include "cafAppEnum.h" #include "RimDefines.h" -class RigReservoirCellResults; +class RigCaseCellResultsData; namespace caf { diff --git a/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.h b/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.h index 228826cb6b..344c2c5eb2 100644 --- a/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.h +++ b/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.h @@ -32,7 +32,7 @@ class RimCellPropertyFilterCollection; class RimResultDefinition; class RigGridBase; -class RigReservoirCellResults; +class RigCaseCellResultsData; namespace cvf { diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index 0440dc1bd9..2a52911820 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -72,7 +72,7 @@ RimIdenticalGridCaseGroup::~RimIdenticalGridCaseGroup() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimIdenticalGridCaseGroup::addCase(RimReservoir* reservoir) +void RimIdenticalGridCaseGroup::addCase(RimCase* reservoir) { CVF_ASSERT(reservoir); @@ -102,7 +102,7 @@ void RimIdenticalGridCaseGroup::addCase(RimReservoir* reservoir) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimIdenticalGridCaseGroup::removeCase(RimReservoir* reservoir) +void RimIdenticalGridCaseGroup::removeCase(RimCase* reservoir) { caseCollection()->reservoirs().removeChildObject(reservoir); @@ -148,9 +148,9 @@ void RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo() // The mainGrid from the first case is reused directly in for the other cases. // When reading active cell info, only the total cell count is tested for consistency - RimReservoir* mainCase = caseCollection()->reservoirs[0]; + RimCase* mainCase = caseCollection()->reservoirs[0]; mainCase->openEclipseGridFile(); - RigEclipseCase* mainEclipseCase = mainCase->reservoirData(); + RigCaseData* mainEclipseCase = mainCase->reservoirData(); CVF_ASSERT(mainEclipseCase); // Read active cell info from all source cases @@ -158,7 +158,7 @@ void RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo() caf::ProgressInfo info(caseCollection()->reservoirs.size(), "Case group - Reading Active Cell data"); for (size_t i = 1; i < caseCollection()->reservoirs.size(); i++) { - RimResultReservoir* rimReservoir = dynamic_cast(caseCollection()->reservoirs[i]); + RimResultCase* rimReservoir = dynamic_cast(caseCollection()->reservoirs[i]); if(!rimReservoir) continue; // Input reservoir if (!rimReservoir->openAndReadActiveCellData(mainEclipseCase)) @@ -176,7 +176,7 @@ void RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo() bool foundResultsInCache = false; for (size_t i = 0; i < statisticsCaseCollection()->reservoirs.size(); i++) { - RimReservoir* rimReservoir = statisticsCaseCollection()->reservoirs[i]; + RimCase* rimReservoir = statisticsCaseCollection()->reservoirs[i]; // Check if any results are stored in cache if (rimReservoir->results(RifReaderInterface::MATRIX_RESULTS)->storedResultsCount() > 0 || @@ -196,7 +196,7 @@ void RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo() for (size_t i = 0; i < statisticsCaseCollection()->reservoirs.size(); i++) { - RimReservoir* rimReservoir = statisticsCaseCollection()->reservoirs[i]; + RimCase* rimReservoir = statisticsCaseCollection()->reservoirs[i]; rimReservoir->openEclipseGridFile(); @@ -314,7 +314,7 @@ void RimIdenticalGridCaseGroup::updateMainGridAndActiveCellsForStatisticsCases() { for (size_t i = 0; i < statisticsCaseCollection->reservoirs().size(); i++) { - RimReservoir* rimStaticsCase = statisticsCaseCollection->reservoirs[i]; + RimCase* rimStaticsCase = statisticsCaseCollection->reservoirs[i]; rimStaticsCase->reservoirData()->setMainGrid(this->mainGrid()); @@ -332,7 +332,7 @@ void RimIdenticalGridCaseGroup::clearStatisticsResults() { for (size_t i = 0; i < statisticsCaseCollection->reservoirs().size(); i++) { - RimReservoir* rimStaticsCase = statisticsCaseCollection->reservoirs[i]; + RimCase* rimStaticsCase = statisticsCaseCollection->reservoirs[i]; if (!rimStaticsCase) continue; rimStaticsCase->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->clearAllResults(); @@ -360,13 +360,13 @@ void RimIdenticalGridCaseGroup::clearActiveCellUnions() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimIdenticalGridCaseGroup::contains(RimReservoir* reservoir) const +bool RimIdenticalGridCaseGroup::contains(RimCase* reservoir) const { CVF_ASSERT(reservoir); for (size_t i = 0; i < caseCollection()->reservoirs().size(); i++) { - RimReservoir* rimReservoir = caseCollection()->reservoirs()[i]; + RimCase* rimReservoir = caseCollection()->reservoirs()[i]; if (reservoir->caseName == reservoir->caseName) { return true; diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h index 3147f8c6a6..7e379b4a10 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h @@ -26,7 +26,7 @@ #include "RimStatisticsCaseCollection.h" #include "RimCaseCollection.h" -class RimReservoir; +class RimCase; class RigMainGrid; class RigActiveCellInfo; @@ -45,9 +45,9 @@ public: caf::PdmField name; - void addCase(RimReservoir* reservoir); - void removeCase(RimReservoir* reservoir); - bool contains(RimReservoir* reservoir) const; + void addCase(RimCase* reservoir); + void removeCase(RimCase* reservoir); + bool contains(RimCase* reservoir) const; RimStatisticsCase* createAndAppendStatisticsCase(); diff --git a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp index d1c55cafb7..4237879b55 100644 --- a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp @@ -38,12 +38,12 @@ #include "RIPreferences.h" -CAF_PDM_SOURCE_INIT(RimInputReservoir, "RimInputReservoir"); +CAF_PDM_SOURCE_INIT(RimInputCase, "RimInputReservoir"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimInputReservoir::RimInputReservoir() - : RimReservoir() +RimInputCase::RimInputCase() + : RimCase() { CAF_PDM_InitObject("RimInputReservoir", ":/EclipseInput48x48.png", "", ""); CAF_PDM_InitField(&m_gridFileName, "GridFileName", QString(), "Case grid filename", "", "" ,""); @@ -58,7 +58,7 @@ RimInputReservoir::RimInputReservoir() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimInputReservoir::~RimInputReservoir() +RimInputCase::~RimInputCase() { delete m_inputPropertyCollection; } @@ -67,7 +67,7 @@ RimInputReservoir::~RimInputReservoir() /// Open the supplied file set. If no grid data has been read, it will first find the possible /// grid data among the files then read all supported properties from the files matching the grid //-------------------------------------------------------------------------------------------------- -void RimInputReservoir::openDataFileSet(const QStringList& filenames) +void RimInputCase::openDataFileSet(const QStringList& filenames) { if (caseName().contains("Input Mock Debug Model")) { @@ -83,7 +83,7 @@ void RimInputReservoir::openDataFileSet(const QStringList& filenames) if (this->reservoirData() == NULL) { - this->setReservoirData(new RigEclipseCase); + this->setReservoirData(new RigCaseData); } // First find and read the grid data @@ -154,7 +154,7 @@ void RimInputReservoir::openDataFileSet(const QStringList& filenames) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimInputReservoir::openEclipseGridFile() +bool RimInputCase::openEclipseGridFile() { // Early exit if reservoir data is created if (this->reservoirData() == NULL) @@ -167,7 +167,7 @@ bool RimInputReservoir::openEclipseGridFile() } else { - cvf::ref eclipseCase = new RigEclipseCase; + cvf::ref eclipseCase = new RigCaseData; readerInterface = new RifReaderEclipseInput; if (!readerInterface->open(m_gridFileName, eclipseCase.p())) { @@ -206,7 +206,7 @@ bool RimInputReservoir::openEclipseGridFile() /// Loads input property data from the gridFile and additional files /// Creates new InputProperties if necessary, and flags the unused ones as obsolete //-------------------------------------------------------------------------------------------------- -void RimInputReservoir::loadAndSyncronizeInputProperties() +void RimInputCase::loadAndSyncronizeInputProperties() { // Make sure we actually have reservoir data @@ -313,7 +313,7 @@ void RimInputReservoir::loadAndSyncronizeInputProperties() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimInputReservoir::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +void RimInputCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { } @@ -321,7 +321,7 @@ void RimInputReservoir::fieldChangedByUi(const caf::PdmFieldHandle* changedField //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimInputReservoir::addFiles(const QStringList& newFileNames) +void RimInputCase::addFiles(const QStringList& newFileNames) { } @@ -330,7 +330,7 @@ void RimInputReservoir::addFiles(const QStringList& newFileNames) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimInputReservoir::removeFiles(const QStringList& obsoleteFileNames) +void RimInputCase::removeFiles(const QStringList& obsoleteFileNames) { } @@ -338,7 +338,7 @@ void RimInputReservoir::removeFiles(const QStringList& obsoleteFileNames) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimInputReservoir::removeProperty(RimInputProperty* inputProperty) +void RimInputCase::removeProperty(RimInputProperty* inputProperty) { bool isPropertyFileReferencedByOthers = false; @@ -359,7 +359,7 @@ void RimInputReservoir::removeProperty(RimInputProperty* inputProperty) } // Remove the results pointed to by this input property - RigReservoirCellResults* results = reservoirData()->results(RifReaderInterface::MATRIX_RESULTS); + RigCaseCellResultsData* results = reservoirData()->results(RifReaderInterface::MATRIX_RESULTS); results->removeResult(inputProperty->resultName); this->removeResult(inputProperty->resultName); @@ -368,9 +368,9 @@ void RimInputReservoir::removeProperty(RimInputProperty* inputProperty) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RimInputReservoir::createMockModel(QString modelName) +cvf::ref RimInputCase::createMockModel(QString modelName) { - cvf::ref reservoir = new RigEclipseCase; + cvf::ref reservoir = new RigCaseData; cvf::ref mockFileInterface = new RifReaderMockModel; if (modelName == "Input Mock Debug Model Simple") @@ -412,7 +412,7 @@ cvf::ref RimInputReservoir::createMockModel(QString modelNam //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimInputReservoir::locationOnDisc() const +QString RimInputCase::locationOnDisc() const { if (m_gridFileName().isEmpty()) return QString(); diff --git a/ApplicationCode/ProjectDataModel/RimInputReservoir.h b/ApplicationCode/ProjectDataModel/RimInputReservoir.h index 45f06d8c7c..9e0a573b51 100644 --- a/ApplicationCode/ProjectDataModel/RimInputReservoir.h +++ b/ApplicationCode/ProjectDataModel/RimInputReservoir.h @@ -36,13 +36,13 @@ class RifReaderInterface; // // //================================================================================================== -class RimInputReservoir : public RimReservoir +class RimInputCase : public RimCase { CAF_PDM_HEADER_INIT; public: - RimInputReservoir(); - virtual ~RimInputReservoir(); + RimInputCase(); + virtual ~RimInputCase(); // Fields caf::PdmField > m_additionalFileNames; diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 1395ec4e39..212978843f 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -44,7 +44,7 @@ RimProject::RimProject(void) scriptCollection = new RimScriptCollection(); scriptCollection->directory.setUiHidden(true); - m_gridCollection = new RigGridCollection; + m_gridCollection = new RigGridManager; initAfterRead(); } @@ -130,11 +130,11 @@ QString RimProject::projectFileVersionString() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimProject::moveEclipseCaseIntoCaseGroup(RimReservoir* rimReservoir) +void RimProject::moveEclipseCaseIntoCaseGroup(RimCase* rimReservoir) { CVF_ASSERT(rimReservoir); - RigEclipseCase* rigEclipseCase = rimReservoir->reservoirData(); + RigCaseData* rigEclipseCase = rimReservoir->reservoirData(); RigMainGrid* equalGrid = registerCaseInGridCollection(rigEclipseCase); CVF_ASSERT(equalGrid); @@ -167,7 +167,7 @@ void RimProject::moveEclipseCaseIntoCaseGroup(RimReservoir* rimReservoir) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimProject::removeCaseFromAllGroups(RimReservoir* reservoir) +void RimProject::removeCaseFromAllGroups(RimCase* reservoir) { m_gridCollection->removeCase(reservoir->reservoirData()); @@ -185,7 +185,7 @@ void RimProject::removeCaseFromAllGroups(RimReservoir* reservoir) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigMainGrid* RimProject::registerCaseInGridCollection(RigEclipseCase* rigEclipseCase) +RigMainGrid* RimProject::registerCaseInGridCollection(RigCaseData* rigEclipseCase) { CVF_ASSERT(rigEclipseCase); @@ -221,11 +221,11 @@ RigMainGrid* RimProject::registerCaseInGridCollection(RigEclipseCase* rigEclipse //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimProject::insertCaseInCaseGroup(RimIdenticalGridCaseGroup* caseGroup, RimReservoir* rimReservoir) +void RimProject::insertCaseInCaseGroup(RimIdenticalGridCaseGroup* caseGroup, RimCase* rimReservoir) { CVF_ASSERT(rimReservoir); - RigEclipseCase* rigEclipseCase = rimReservoir->reservoirData(); + RigCaseData* rigEclipseCase = rimReservoir->reservoirData(); registerCaseInGridCollection(rigEclipseCase); caseGroup->addCase(rimReservoir); diff --git a/ApplicationCode/ProjectDataModel/RimProject.h b/ApplicationCode/ProjectDataModel/RimProject.h index 49e4d56ded..084e92dff2 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.h +++ b/ApplicationCode/ProjectDataModel/RimProject.h @@ -22,8 +22,8 @@ #include "RimScriptCollection.h" #include "RimIdenticalGridCaseGroup.h" -class RimReservoir; -class RigGridCollection; +class RimCase; +class RigGridManager; //================================================================================================== /// @@ -34,7 +34,7 @@ class RimProject : public caf::PdmDocument CAF_PDM_HEADER_INIT; public: - caf::PdmPointersField reservoirs; + caf::PdmPointersField reservoirs; caf::PdmPointersField caseGroups; caf::PdmField scriptCollection; @@ -48,13 +48,13 @@ public: void close(); - void insertCaseInCaseGroup(RimIdenticalGridCaseGroup* caseGroup, RimReservoir* rimReservoir); + void insertCaseInCaseGroup(RimIdenticalGridCaseGroup* caseGroup, RimCase* rimReservoir); - void moveEclipseCaseIntoCaseGroup(RimReservoir* rimReservoir); - void removeCaseFromAllGroups(RimReservoir* rimReservoir); + void moveEclipseCaseIntoCaseGroup(RimCase* rimReservoir); + void removeCaseFromAllGroups(RimCase* rimReservoir); private: - RigMainGrid* registerCaseInGridCollection(RigEclipseCase* rigEclipseCase); + RigMainGrid* registerCaseInGridCollection(RigCaseData* rigEclipseCase); protected: // Overridden methods @@ -64,5 +64,5 @@ protected: private: caf::PdmField m_projectFileVersionString; - cvf::ref m_gridCollection; + cvf::ref m_gridCollection; }; diff --git a/ApplicationCode/ProjectDataModel/RimReservoir.cpp b/ApplicationCode/ProjectDataModel/RimReservoir.cpp index abd80217ef..6492c47818 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoir.cpp @@ -36,12 +36,12 @@ #include "RimProject.h" #include "RimReservoirCellResultsCacher.h" -CAF_PDM_SOURCE_INIT(RimReservoir, "RimReservoir"); +CAF_PDM_SOURCE_INIT(RimCase, "RimReservoir"); //------------------------------------------------------------------------------------------------ /// //-------------------------------------------------------------------------------------------------- -RimReservoir::RimReservoir() +RimCase::RimCase() { CAF_PDM_InitField(&caseName, "CaseName", QString(), "Case name", "", "" ,""); CAF_PDM_InitFieldNoDefault(&reservoirViews, "ReservoirViews", "", "", "", ""); @@ -60,7 +60,7 @@ RimReservoir::RimReservoir() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimReservoir::~RimReservoir() +RimCase::~RimCase() { reservoirViews.deleteAllChildObjects(); @@ -77,7 +77,7 @@ RimReservoir::~RimReservoir() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigEclipseCase* RimReservoir::reservoirData() +RigCaseData* RimCase::reservoirData() { return m_rigEclipseCase.p(); } @@ -85,7 +85,7 @@ RigEclipseCase* RimReservoir::reservoirData() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const RigEclipseCase* RimReservoir::reservoirData() const +const RigCaseData* RimCase::reservoirData() const { return m_rigEclipseCase.p(); } @@ -93,7 +93,7 @@ const RigEclipseCase* RimReservoir::reservoirData() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoir::initAfterRead() +void RimCase::initAfterRead() { size_t j; for (j = 0; j < reservoirViews().size(); j++) @@ -108,7 +108,7 @@ void RimReservoir::initAfterRead() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimReservoirView* RimReservoir::createAndAddReservoirView() +RimReservoirView* RimCase::createAndAddReservoirView() { // If parent is collection, and number of views is zero, make sure rig is set to NULL to initiate normal case loading if (parentCaseCollection() != NULL && reservoirViews().size() == 0) @@ -135,7 +135,7 @@ RimReservoirView* RimReservoir::createAndAddReservoirView() //-------------------------------------------------------------------------------------------------- /// TODO: Move this functionality to PdmPointersField //-------------------------------------------------------------------------------------------------- -void RimReservoir::removeReservoirView(RimReservoirView* reservoirView) +void RimCase::removeReservoirView(RimReservoirView* reservoirView) { std::vector indices; @@ -159,7 +159,7 @@ void RimReservoir::removeReservoirView(RimReservoirView* reservoirView) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoir::removeResult(const QString& resultName) +void RimCase::removeResult(const QString& resultName) { size_t i; for (i = 0; i < reservoirViews().size(); i++) @@ -210,7 +210,7 @@ void RimReservoir::removeResult(const QString& resultName) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoir::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +void RimCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { if (changedField == &releaseResultMemory) { @@ -236,13 +236,13 @@ void RimReservoir::fieldChangedByUi(const caf::PdmFieldHandle* changedField, con reservoirView->createDisplayModelAndRedraw(); } - RigReservoirCellResults* matrixModelResults = reservoirData()->results(RifReaderInterface::MATRIX_RESULTS); + RigCaseCellResultsData* matrixModelResults = reservoirData()->results(RifReaderInterface::MATRIX_RESULTS); if (matrixModelResults) { matrixModelResults->clearAllResults(); } - RigReservoirCellResults* fractureModelResults = reservoirData()->results(RifReaderInterface::FRACTURE_RESULTS); + RigCaseCellResultsData* fractureModelResults = reservoirData()->results(RifReaderInterface::FRACTURE_RESULTS); if (fractureModelResults) { fractureModelResults->clearAllResults(); @@ -256,9 +256,9 @@ void RimReservoir::fieldChangedByUi(const caf::PdmFieldHandle* changedField, con //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoir::computeCachedData() +void RimCase::computeCachedData() { - RigEclipseCase* rigEclipseCase = reservoirData(); + RigCaseData* rigEclipseCase = reservoirData(); if (rigEclipseCase) { rigEclipseCase->computeActiveCellBoundingBoxes(); @@ -280,7 +280,7 @@ void RimReservoir::computeCachedData() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimCaseCollection* RimReservoir::parentCaseCollection() +RimCaseCollection* RimCase::parentCaseCollection() { std::vector parentObjects; this->parentObjectsOfType(parentObjects); @@ -296,7 +296,7 @@ RimCaseCollection* RimReservoir::parentCaseCollection() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoir::setReservoirData(RigEclipseCase* eclipseCase) +void RimCase::setReservoirData(RigCaseData* eclipseCase) { m_rigEclipseCase = eclipseCase; if (this->reservoirData()) @@ -318,7 +318,7 @@ void RimReservoir::setReservoirData(RigEclipseCase* eclipseCase) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimReservoirCellResultsStorage* RimReservoir::results(RifReaderInterface::PorosityModelResultType porosityModel) +RimReservoirCellResultsStorage* RimCase::results(RifReaderInterface::PorosityModelResultType porosityModel) { if (porosityModel == RifReaderInterface::MATRIX_RESULTS) { diff --git a/ApplicationCode/ProjectDataModel/RimReservoir.h b/ApplicationCode/ProjectDataModel/RimReservoir.h index e9c422a366..12b1b6aaff 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoir.h +++ b/ApplicationCode/ProjectDataModel/RimReservoir.h @@ -27,7 +27,7 @@ class QString; -class RigEclipseCase; +class RigCaseData; class RigGridBase; class RimReservoirView; class RimCaseCollection; @@ -38,12 +38,12 @@ class RimCaseCollection; // Interface for reservoirs. // //================================================================================================== -class RimReservoir : public caf::PdmObject +class RimCase : public caf::PdmObject { CAF_PDM_HEADER_INIT; public: - RimReservoir(); - virtual ~RimReservoir(); + RimCase(); + virtual ~RimCase(); // Fields: caf::PdmField caseName; @@ -52,8 +52,8 @@ public: virtual bool openEclipseGridFile() { return false;}; // Should be pure virtual but PDM does not allow that. - RigEclipseCase* reservoirData(); - const RigEclipseCase* reservoirData() const; + RigCaseData* reservoirData(); + const RigCaseData* reservoirData() const; RimReservoirCellResultsStorage* results(RifReaderInterface::PorosityModelResultType porosityModel); @@ -76,11 +76,11 @@ protected: // Internal methods protected: void computeCachedData(); - void setReservoirData(RigEclipseCase* eclipseCase); + void setReservoirData(RigCaseData* eclipseCase); private: - cvf::ref m_rigEclipseCase; + cvf::ref m_rigEclipseCase; private: caf::PdmField m_matrixModelResults; diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp index 6cf8ec3a05..07e7ea5942 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp @@ -73,7 +73,7 @@ void RimReservoirCellResultsStorage::setupBeforeSave() if (!m_cellResults) return; - const std::vector& resInfo = m_cellResults->infoForEachResultIndex(); + const std::vector& resInfo = m_cellResults->infoForEachResultIndex(); bool hasResultsToStore = false; for (size_t rIdx = 0; rIdx < resInfo.size(); ++rIdx) @@ -574,7 +574,7 @@ size_t RimReservoirCellResultsStorage::findOrLoadScalarResult(const QString& res //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoirCellResultsStorage::setCellResults(RigReservoirCellResults* cellResults) +void RimReservoirCellResultsStorage::setCellResults(RigCaseCellResultsData* cellResults) { m_cellResults = cellResults; diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h index 2351e6c54d..dd0e154388 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h @@ -25,7 +25,7 @@ #include "RimDefines.h" class RimReservoirCellResultsStorageEntryInfo; -class RigReservoirCellResults; +class RigCaseCellResultsData; class RifReaderInterface; class RigMainGrid; @@ -36,9 +36,9 @@ public: RimReservoirCellResultsStorage(); virtual ~RimReservoirCellResultsStorage(); - void setCellResults(RigReservoirCellResults* cellResults); - RigReservoirCellResults* cellResults() { return m_cellResults; } - const RigReservoirCellResults* cellResults() const { return m_cellResults; } + void setCellResults(RigCaseCellResultsData* cellResults); + RigCaseCellResultsData* cellResults() { return m_cellResults; } + const RigCaseCellResultsData* cellResults() const { return m_cellResults; } size_t storedResultsCount(); @@ -70,7 +70,7 @@ private: m_resultCacheMetaData; cvf::ref m_readerInterface; - RigReservoirCellResults* m_cellResults; + RigCaseCellResultsData* m_cellResults; RigMainGrid* m_ownerMainGrid; }; diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp index fedce7dfc8..8cb8eea24a 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp @@ -847,7 +847,7 @@ bool RimReservoirView::pickInfo(size_t gridIndex, size_t cellIndex, const cvf::V if (m_reservoir) { - const RigEclipseCase* eclipseCase = m_reservoir->reservoirData(); + const RigCaseData* eclipseCase = m_reservoir->reservoirData(); if (eclipseCase) { size_t i = 0; @@ -880,12 +880,12 @@ void RimReservoirView::appendCellResultInfo(size_t gridIndex, size_t cellIndex, if (m_reservoir && m_reservoir->reservoirData()) { - RigEclipseCase* eclipseCase = m_reservoir->reservoirData(); + RigCaseData* eclipseCase = m_reservoir->reservoirData(); RigGridBase* grid = eclipseCase->grid(gridIndex); if (this->cellResult()->hasResult()) { - RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResult()->porosityModel()); + RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResult()->porosityModel()); cvf::ref dataAccessObject = eclipseCase->dataAccessObject(grid, porosityModel, m_currentTimeStep, this->cellResult()->gridScalarIndex()); if (dataAccessObject.notNull()) { @@ -906,7 +906,7 @@ void RimReservoirView::appendCellResultInfo(size_t gridIndex, size_t cellIndex, if (resultIndices[idx] == cvf::UNDEFINED_SIZE_T) continue; // Cell edge results are static, results are loaded for first time step only - RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResult()->porosityModel()); + RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResult()->porosityModel()); cvf::ref dataAccessObject = eclipseCase->dataAccessObject(grid, porosityModel, 0, resultIndices[idx]); if (dataAccessObject.notNull()) { @@ -974,7 +974,7 @@ RimReservoirCellResultsStorage* RimReservoirView::currentGridCellResults() { if (m_reservoir) { - RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResult->porosityModel()); + RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResult->porosityModel()); return m_reservoir->results(porosityModel); } @@ -991,7 +991,7 @@ RigActiveCellInfo* RimReservoirView::currentActiveCellInfo() m_reservoir->reservoirData() ) { - RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResult->porosityModel()); + RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResult->porosityModel()); return m_reservoir->reservoirData()->activeCellInfo(porosityModel); } @@ -1059,11 +1059,11 @@ void RimReservoirView::updateLegends() return; } - RigEclipseCase* eclipseCase = m_reservoir->reservoirData(); + RigCaseData* eclipseCase = m_reservoir->reservoirData(); CVF_ASSERT(eclipseCase); - RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(cellResult()->porosityModel()); - RigReservoirCellResults* results = eclipseCase->results(porosityModel); + RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(cellResult()->porosityModel()); + RigCaseCellResultsData* results = eclipseCase->results(porosityModel); CVF_ASSERT(results); if (this->cellResult()->hasResult()) @@ -1112,7 +1112,7 @@ void RimReservoirView::updateLegends() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoirView::setEclipseCase(RimReservoir* reservoir) +void RimReservoirView::setEclipseCase(RimCase* reservoir) { m_reservoir = reservoir; } @@ -1120,7 +1120,7 @@ void RimReservoirView::setEclipseCase(RimReservoir* reservoir) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimReservoir* RimReservoirView::eclipseCase() +RimCase* RimReservoirView::eclipseCase() { return m_reservoir; } @@ -1142,7 +1142,7 @@ void RimReservoirView::syncronizeWellsWithResults() { if (!(m_reservoir && m_reservoir->reservoirData()) ) return; - cvf::Collection wellResults = m_reservoir->reservoirData()->wellResults(); + cvf::Collection wellResults = m_reservoir->reservoirData()->wellResults(); // Find corresponding well from well result, or create a new size_t wIdx; @@ -1164,7 +1164,7 @@ void RimReservoirView::syncronizeWellsWithResults() for (wIdx = 0; wIdx < this->wellCollection()->wells().size(); ++wIdx) { RimWell* well = this->wellCollection()->wells()[wIdx]; - RigWellResults* wellRes = well->wellResults(); + RigSingleWellResultsData* wellRes = well->wellResults(); if (wellRes == NULL) { delete well; @@ -1208,7 +1208,7 @@ void RimReservoirView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibl RimWell* well = this->wellCollection()->wells()[wIdx]; if (this->wellCollection()->wellCellVisibility() == RimWellCollection::FORCE_ALL_ON || well->showWellCells()) { - RigWellResults* wres = well->wellResults(); + RigSingleWellResultsData* wres = well->wellResults(); if (!wres) continue; const std::vector< RigWellResultFrame >& wellResFrames = wres->m_wellCellsTimeSteps; diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.h b/ApplicationCode/ProjectDataModel/RimReservoirView.h index 75cbae54d1..c1125d47cf 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.h +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.h @@ -120,8 +120,8 @@ public: RimReservoirCellResultsStorage* currentGridCellResults(); RigActiveCellInfo* currentActiveCellInfo(); - void setEclipseCase(RimReservoir* reservoir); - RimReservoir* eclipseCase(); + void setEclipseCase(RimCase* reservoir); + RimCase* eclipseCase(); // Animation int currentTimeStep() { return m_currentTimeStep;} @@ -179,7 +179,7 @@ private: private: caf::PdmField m_currentTimeStep; QPointer m_viewer; - caf::PdmPointer m_reservoir; + caf::PdmPointer m_reservoir; }; diff --git a/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp index 98e081ea12..cf741cd8a1 100644 --- a/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp @@ -166,7 +166,7 @@ bool RimResultDefinition::hasResult() const { if (m_gridScalarResultIndex != cvf::UNDEFINED_SIZE_T) return true; - const RigReservoirCellResults* gridCellResults = m_reservoirView->currentGridCellResults()->cellResults(); + const RigCaseCellResultsData* gridCellResults = m_reservoirView->currentGridCellResults()->cellResults(); if (gridCellResults) { m_gridScalarResultIndex = gridCellResults->findScalarResultIndex(resultType(), resultVariable()); @@ -182,7 +182,7 @@ bool RimResultDefinition::hasResult() const //-------------------------------------------------------------------------------------------------- bool RimResultDefinition::hasDynamicResult() const { - const RigReservoirCellResults* gridCellResults = m_reservoirView->currentGridCellResults()->cellResults(); + const RigCaseCellResultsData* gridCellResults = m_reservoirView->currentGridCellResults()->cellResults(); if (hasResult() && gridCellResults->timeStepCount(m_gridScalarResultIndex) > 1 ) return true; else diff --git a/ApplicationCode/ProjectDataModel/RimResultDefinition.h b/ApplicationCode/ProjectDataModel/RimResultDefinition.h index a9a159935b..138ce0a5ab 100644 --- a/ApplicationCode/ProjectDataModel/RimResultDefinition.h +++ b/ApplicationCode/ProjectDataModel/RimResultDefinition.h @@ -26,7 +26,7 @@ class RimReservoirView; -class RigReservoirCellResults; +class RigCaseCellResultsData; //================================================================================================== /// diff --git a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp index f2e9620587..5cffbd67f6 100644 --- a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp @@ -28,12 +28,12 @@ #include "RimProject.h" -CAF_PDM_SOURCE_INIT(RimResultReservoir, "EclipseCase"); +CAF_PDM_SOURCE_INIT(RimResultCase, "EclipseCase"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimResultReservoir::RimResultReservoir() - : RimReservoir() +RimResultCase::RimResultCase() + : RimCase() { CAF_PDM_InitObject("Eclipse Case", ":/AppLogo48x48.png", "", ""); @@ -45,7 +45,7 @@ RimResultReservoir::RimResultReservoir() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimResultReservoir::openEclipseGridFile() +bool RimResultCase::openEclipseGridFile() { caf::ProgressInfo progInfo(50, "Reading Eclipse Grid File"); @@ -69,7 +69,7 @@ bool RimResultReservoir::openEclipseGridFile() return false; } - cvf::ref eclipseCase = new RigEclipseCase; + cvf::ref eclipseCase = new RigCaseData; readerInterface = new RifReaderEclipseOutput; if (!readerInterface->open(fname, eclipseCase.p())) { @@ -96,7 +96,7 @@ bool RimResultReservoir::openEclipseGridFile() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimResultReservoir::openAndReadActiveCellData(RigEclipseCase* mainEclipseCase) +bool RimResultCase::openAndReadActiveCellData(RigCaseData* mainEclipseCase) { cvf::ref readerInterface; @@ -112,7 +112,7 @@ bool RimResultReservoir::openAndReadActiveCellData(RigEclipseCase* mainEclipseCa return false; } - cvf::ref eclipseCase = new RigEclipseCase; + cvf::ref eclipseCase = new RigCaseData; CVF_ASSERT(mainEclipseCase && mainEclipseCase->mainGrid()); eclipseCase->setMainGrid(mainEclipseCase->mainGrid()); @@ -155,10 +155,10 @@ bool RimResultReservoir::openAndReadActiveCellData(RigEclipseCase* mainEclipseCa //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RimResultReservoir::createMockModel(QString modelName) +cvf::ref RimResultCase::createMockModel(QString modelName) { cvf::ref mockFileInterface = new RifReaderMockModel; - cvf::ref reservoir = new RigEclipseCase; + cvf::ref reservoir = new RigCaseData; if (modelName == "Result Mock Debug Model Simple") { @@ -233,7 +233,7 @@ cvf::ref RimResultReservoir::createMockModel(QString modelNa //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimResultReservoir::~RimResultReservoir() +RimResultCase::~RimResultCase() { reservoirViews.deleteAllChildObjects(); } @@ -241,7 +241,7 @@ RimResultReservoir::~RimResultReservoir() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimResultReservoir::locationOnDisc() const +QString RimResultCase::locationOnDisc() const { return caseDirectory; } @@ -249,7 +249,7 @@ QString RimResultReservoir::locationOnDisc() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimResultReservoir::createAbsoluteFilenameFromCase(const QString& caseName) +QString RimResultCase::createAbsoluteFilenameFromCase(const QString& caseName) { QString candidate; diff --git a/ApplicationCode/ProjectDataModel/RimResultReservoir.h b/ApplicationCode/ProjectDataModel/RimResultReservoir.h index a97f141e11..7824be7f63 100644 --- a/ApplicationCode/ProjectDataModel/RimResultReservoir.h +++ b/ApplicationCode/ProjectDataModel/RimResultReservoir.h @@ -32,13 +32,13 @@ class RigMainGrid; // // //================================================================================================== -class RimResultReservoir : public RimReservoir +class RimResultCase : public RimCase { CAF_PDM_HEADER_INIT; public: - RimResultReservoir(); - virtual ~RimResultReservoir(); + RimResultCase(); + virtual ~RimResultCase(); // Fields: @@ -46,7 +46,7 @@ public: caf::PdmField caseDirectory; virtual bool openEclipseGridFile(); - bool openAndReadActiveCellData(RigEclipseCase* mainEclipseCase); + bool openAndReadActiveCellData(RigCaseData* mainEclipseCase); //virtual caf::PdmFieldHandle* userDescriptionField() { return &caseName;} diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp index 8534a57a22..8ccc043e15 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp @@ -34,7 +34,7 @@ CAF_PDM_SOURCE_INIT(RimStatisticsCase, "RimStatisticalCalculation"); /// //-------------------------------------------------------------------------------------------------- RimStatisticsCase::RimStatisticsCase() - : RimReservoir() + : RimCase() { CAF_PDM_InitObject("Case Group Statistics", ":/Histogram16x16.png", "", ""); CAF_PDM_InitField(&m_resultName, "ResultName", QString("PRESSURE"), "ResultName", "", "", ""); @@ -68,7 +68,7 @@ bool RimStatisticsCase::openEclipseGridFile() { if (this->reservoirData()) return true; - cvf::ref eclipseCase = new RigEclipseCase; + cvf::ref eclipseCase = new RigCaseData; CVF_ASSERT(parentStatisticsCaseCollection()); @@ -125,7 +125,7 @@ void RimStatisticsCase::computeStatistics() CVF_ASSERT(gridCaseGroup); gridCaseGroup->computeUnionOfActiveCells(); - std::vector sourceCases; + std::vector sourceCases; getSourceCases(sourceCases); @@ -146,7 +146,7 @@ void RimStatisticsCase::computeStatistics() timeStepIndices.push_back(i); } - RigEclipseCase* resultCase = reservoirData(); + RigCaseData* resultCase = reservoirData(); QList > resultSpecification; @@ -187,7 +187,7 @@ void RimStatisticsCase::computeStatistics() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimStatisticsCase::getSourceCases(std::vector& sourceCases) +void RimStatisticsCase::getSourceCases(std::vector& sourceCases) { RimIdenticalGridCaseGroup* gridCaseGroup = caseGroup(); if (gridCaseGroup) @@ -199,7 +199,7 @@ void RimStatisticsCase::getSourceCases(std::vector& sourceCases) CVF_ASSERT(gridCaseGroup->caseCollection->reservoirs[i]); CVF_ASSERT(gridCaseGroup->caseCollection->reservoirs[i]->reservoirData()); - RimReservoir* sourceCase = gridCaseGroup->caseCollection->reservoirs[i]; + RimCase* sourceCase = gridCaseGroup->caseCollection->reservoirs[i]; sourceCases.push_back(sourceCase); } } diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCase.h b/ApplicationCode/ProjectDataModel/RimStatisticsCase.h index df9dd0f022..86d424b02d 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCase.h +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCase.h @@ -36,7 +36,7 @@ class RigMainGrid; // // //================================================================================================== -class RimStatisticsCase : public RimReservoir +class RimStatisticsCase : public RimCase { CAF_PDM_HEADER_INIT; @@ -58,6 +58,6 @@ public: private: RimIdenticalGridCaseGroup* caseGroup(); - void getSourceCases(std::vector& sourceCases); + void getSourceCases(std::vector& sourceCases); }; diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.cpp b/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.cpp index f170e30e4e..b42379e4b4 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.cpp @@ -107,7 +107,7 @@ private: //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimStatisticsCaseEvaluator::addNamedResult(RigReservoirCellResults* destinationCellResults, RimDefines::ResultCatType resultType, const QString& resultName, size_t activeUnionCellCount) +void RimStatisticsCaseEvaluator::addNamedResult(RigCaseCellResultsData* destinationCellResults, RimDefines::ResultCatType resultType, const QString& resultName, size_t activeUnionCellCount) { // Use time step dates from first result in first source case CVF_ASSERT(m_sourceCases.size() > 0); @@ -148,7 +148,7 @@ void RimStatisticsCaseEvaluator::buildSourceMetaData(RimDefines::ResultCatType r for (size_t caseIdx = 1; caseIdx < m_sourceCases.size(); caseIdx++) { - RigEclipseCase* eclipseCase = m_sourceCases.at(caseIdx)->reservoirData(); + RigCaseData* eclipseCase = m_sourceCases.at(caseIdx)->reservoirData(); RimReservoirCellResultsStorage* matrixResults = m_sourceCases[caseIdx]->results(RifReaderInterface::MATRIX_RESULTS); size_t scalarResultIndex = matrixResults->findOrLoadScalarResult(resultType, resultName); @@ -171,7 +171,7 @@ void RimStatisticsCaseEvaluator::evaluateForResults(const QListactiveCellInfo(RifReaderInterface::MATRIX_RESULTS)->globalActiveCellCount(); - RigReservoirCellResults* matrixResults = m_destinationCase->results(RifReaderInterface::MATRIX_RESULTS); + RigCaseCellResultsData* matrixResults = m_destinationCase->results(RifReaderInterface::MATRIX_RESULTS); for (int i = 0; i < resultSpecification.size(); i++) { @@ -249,7 +249,7 @@ void RimStatisticsCaseEvaluator::evaluateForResults(const QList dataAccesObjectList; for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++) { - RimReservoir* eclipseCase = m_sourceCases.at(caseIdx); + RimCase* eclipseCase = m_sourceCases.at(caseIdx); size_t scalarResultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->findOrLoadScalarResultForTimeStep(resultType, resultName, dataAccessTimeStepIndex); @@ -371,7 +371,7 @@ void RimStatisticsCaseEvaluator::evaluateForResults(const QList& sourceCases, const std::vector& timeStepIndices, const RimStatisticsConfig& statisticsConfig, RigEclipseCase* destinationCase) +RimStatisticsCaseEvaluator::RimStatisticsCaseEvaluator(const std::vector& sourceCases, const std::vector& timeStepIndices, const RimStatisticsConfig& statisticsConfig, RigCaseData* destinationCase) : m_sourceCases(sourceCases), m_statisticsConfig(statisticsConfig), m_destinationCase(destinationCase), diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.h b/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.h index f34fd76bd8..14a80a6b0d 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.h +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.h @@ -27,9 +27,9 @@ #include #include "RimDefines.h" -class RimReservoir; -class RigEclipseCase; -class RigReservoirCellResults; +class RimCase; +class RigCaseData; +class RigCaseCellResultsData; class RimStatisticsConfig @@ -54,10 +54,10 @@ public: class RimStatisticsCaseEvaluator { public: - RimStatisticsCaseEvaluator(const std::vector& sourceCases, + RimStatisticsCaseEvaluator(const std::vector& sourceCases, const std::vector& timeStepIndices, const RimStatisticsConfig& statisticsConfig, - RigEclipseCase* destinationCase); + RigCaseData* destinationCase); void evaluateForResults(const QList >& resultSpecification); @@ -65,15 +65,15 @@ public: void debugOutput(RimDefines::ResultCatType resultType, const QString& resultName, size_t timeStepIdx); private: - void addNamedResult(RigReservoirCellResults* cellResults, RimDefines::ResultCatType resultType, const QString& resultName, size_t activeCellCount); + void addNamedResult(RigCaseCellResultsData* cellResults, RimDefines::ResultCatType resultType, const QString& resultName, size_t activeCellCount); void buildSourceMetaData(RimDefines::ResultCatType resultType, const QString& resultName); private: - std::vector m_sourceCases; + std::vector m_sourceCases; std::vector m_timeStepIndices; size_t m_globalCellCount; RimStatisticsConfig m_statisticsConfig; - RigEclipseCase* m_destinationCase; + RigCaseData* m_destinationCase; }; diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index 6debf187d7..a1395c0234 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -213,7 +213,7 @@ bool RimUiTreeModelPdm::deleteReservoirView(const QModelIndex& itemIndex) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimUiTreeModelPdm::deleteReservoir(RimReservoir* reservoir) +void RimUiTreeModelPdm::deleteReservoir(RimCase* reservoir) { RimCaseCollection* caseCollection = reservoir->parentCaseCollection(); QModelIndex caseCollectionModelIndex = getModelIndexFromPdmObject(caseCollection); @@ -355,7 +355,7 @@ RimReservoirView* RimUiTreeModelPdm::addReservoirView(const QModelIndex& itemInd collectionItem = currentItem->parent(); collectionIndex = itemIndex.parent(); } - else if (dynamic_cast(currentItem->dataObject().p())) + else if (dynamic_cast(currentItem->dataObject().p())) { collectionItem = currentItem; collectionIndex = itemIndex; @@ -363,7 +363,7 @@ RimReservoirView* RimUiTreeModelPdm::addReservoirView(const QModelIndex& itemInd if (collectionItem) { - RimReservoir* rimReservoir = dynamic_cast(collectionItem->dataObject().p()); + RimCase* rimReservoir = dynamic_cast(collectionItem->dataObject().p()); RimReservoirView* insertedView = rimReservoir->createAndAddReservoirView(); int viewCount = rowCount(collectionIndex); @@ -430,11 +430,11 @@ void RimUiTreeModelPdm::addInputProperty(const QModelIndex& itemIndex, const QSt RimInputPropertyCollection* inputPropertyCollection = dynamic_cast(currentItem->dataObject().p()); CVF_ASSERT(inputPropertyCollection); - std::vector parentObjects; + std::vector parentObjects; inputPropertyCollection->parentObjectsOfType(parentObjects); CVF_ASSERT(parentObjects.size() == 1); - RimInputReservoir* inputReservoir = parentObjects[0]; + RimInputCase* inputReservoir = parentObjects[0]; CVF_ASSERT(inputReservoir); if (inputReservoir) { @@ -468,11 +468,11 @@ void RimUiTreeModelPdm::deleteInputProperty(const QModelIndex& itemIndex) RimInputPropertyCollection* inputPropertyCollection = parentObjects[0]; if (!inputPropertyCollection) return; - std::vector parentObjects2; + std::vector parentObjects2; inputPropertyCollection->parentObjectsOfType(parentObjects2); CVF_ASSERT(parentObjects2.size() == 1); - RimInputReservoir* inputReservoir = parentObjects2[0]; + RimInputCase* inputReservoir = parentObjects2[0]; if (!inputReservoir) return; inputReservoir->removeProperty(inputProperty); @@ -541,7 +541,7 @@ RimIdenticalGridCaseGroup* RimUiTreeModelPdm::addCaseGroup(const QModelIndex& it caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex); if (dynamic_cast(currentItem->dataObject().p()) || - dynamic_cast(currentItem->dataObject().p())) + dynamic_cast(currentItem->dataObject().p())) { QModelIndex rootIndex = itemIndex.parent(); caf::PdmUiTreeItem* rootTreeItem = currentItem->parent(); @@ -590,9 +590,9 @@ void RimUiTreeModelPdm::addObjects(const QModelIndex& itemIndex, caf::PdmObjectG gridCaseGroup = caseCollection->parentCaseGroup(); } - else if (dynamic_cast(currentItem->dataObject().p())) + else if (dynamic_cast(currentItem->dataObject().p())) { - RimReservoir* rimReservoir = dynamic_cast(currentItem->dataObject().p()); + RimCase* rimReservoir = dynamic_cast(currentItem->dataObject().p()); CVF_ASSERT(rimReservoir); caseCollection = rimReservoir->parentCaseCollection(); @@ -608,19 +608,19 @@ void RimUiTreeModelPdm::addObjects(const QModelIndex& itemIndex, caf::PdmObjectG if (gridCaseGroup) { - std::vector > typedObjects; + std::vector > typedObjects; pdmObjects.createCopyByType(&typedObjects); - RigEclipseCase* mainEclipseCase = NULL; + RigCaseData* mainEclipseCase = NULL; if (gridCaseGroup->caseCollection()->reservoirs().size() > 0) { - RimReservoir* mainReservoir = gridCaseGroup->caseCollection()->reservoirs()[0];; + RimCase* mainReservoir = gridCaseGroup->caseCollection()->reservoirs()[0];; mainEclipseCase = mainReservoir->reservoirData(); } for (size_t i = 0; i < typedObjects.size(); i++) { - RimResultReservoir* rimResultReservoir = typedObjects[i]; + RimResultCase* rimResultReservoir = typedObjects[i]; if (gridCaseGroup->contains(rimResultReservoir)) { @@ -748,7 +748,7 @@ Qt::ItemFlags RimUiTreeModelPdm::flags(const QModelIndex &index) const { return Qt::ItemIsDropEnabled | defaultFlags; } - else if (dynamic_cast(currentItem->dataObject().p())) + else if (dynamic_cast(currentItem->dataObject().p())) { // TODO: Remember to handle reservoir holding the main grid return Qt::ItemIsDragEnabled | defaultFlags; @@ -781,12 +781,12 @@ bool RimUiTreeModelPdm::dropMimeData(const QMimeData *data, Qt::DropAction actio if (action == Qt::MoveAction) { - std::vector > typedObjects; + std::vector > typedObjects; pog.objectsByType(&typedObjects); for (size_t i = 0; i < typedObjects.size(); i++) { - RimReservoir* rimReservoir = typedObjects[i]; + RimCase* rimReservoir = typedObjects[i]; deleteReservoir(rimReservoir); } } diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h index 2201c7e090..af0372e21f 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h @@ -29,7 +29,7 @@ class QFileSystemWatcher; class RimCellPropertyFilter; class RimCellRangeFilter; -class RimReservoir; +class RimCase; class RimReservoirView; class RimInputProperty; class RimStatisticsCase; @@ -105,7 +105,7 @@ public: bool deletePropertyFilter(const QModelIndex& itemIndex); bool deleteReservoirView(const QModelIndex& itemIndex); void deleteInputProperty(const QModelIndex& itemIndex); - void deleteReservoir(RimReservoir* reservoir); + void deleteReservoir(RimCase* reservoir); RimCellPropertyFilter* addPropertyFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); RimCellRangeFilter* addRangeFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index 65ae72d80a..db0db569b6 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -174,7 +174,7 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event) menu.addAction(QString("Close"), this, SLOT(slotCloseCase())); menu.exec(event->globalPos()); } - else if (dynamic_cast(uiItem->dataObject().p())) + else if (dynamic_cast(uiItem->dataObject().p())) { QMenu menu; menu.addAction(QString("Copy"), this, SLOT(slotCopyPdmObjectToClipboard())); @@ -686,7 +686,7 @@ void RimUiTreeView::slotWriteInputProperty() exportSettings.eclipseKeyword = inputProperty->eclipseKeyword; // Find input reservoir for this property - RimInputReservoir* inputReservoir = NULL; + RimInputCase* inputReservoir = NULL; { std::vector parentObjects; inputProperty->parentObjectsOfType(parentObjects); @@ -695,7 +695,7 @@ void RimUiTreeView::slotWriteInputProperty() RimInputPropertyCollection* inputPropertyCollection = parentObjects[0]; if (!inputPropertyCollection) return; - std::vector parentObjects2; + std::vector parentObjects2; inputPropertyCollection->parentObjectsOfType(parentObjects2); CVF_ASSERT(parentObjects2.size() == 1); @@ -781,7 +781,7 @@ void RimUiTreeView::slotWriteBinaryResultAsInputProperty() if (preferencesDialog.exec() == QDialog::Accepted) { size_t timeStep = resultSlot->reservoirView()->currentTimeStep(); - RifReaderInterface::PorosityModelResultType porosityModel = RigReservoirCellResults::convertFromProjectModelPorosityModel(resultSlot->porosityModel()); + RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(resultSlot->porosityModel()); bool isOk = RifEclipseInputFileTools::writeBinaryResultToTextFile(exportSettings.fileName, resultSlot->reservoirView()->eclipseCase()->reservoirData(), porosityModel, timeStep, resultSlot->resultVariable, exportSettings.eclipseKeyword, exportSettings.undefinedValue); if (!isOk) @@ -811,12 +811,12 @@ void RimUiTreeView::slotCloseCase() group.addObject(uiItem->dataObject().p()); } - std::vector > typedObjects; + std::vector > typedObjects; group.objectsByType(&typedObjects); for (size_t i = 0; i < typedObjects.size(); i++) { - RimReservoir* rimReservoir = typedObjects[i]; + RimCase* rimReservoir = typedObjects[i]; myModel->deleteReservoir(rimReservoir); } } @@ -955,7 +955,7 @@ void RimUiTreeView::keyPressEvent(QKeyEvent* keyEvent) RimUiTreeModelPdm* myModel = dynamic_cast(model()); caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(currentIndex()); - if (dynamic_cast(uiItem->dataObject().p())) + if (dynamic_cast(uiItem->dataObject().p())) { if (keyEvent->matches(QKeySequence::Copy)) { @@ -968,7 +968,7 @@ void RimUiTreeView::keyPressEvent(QKeyEvent* keyEvent) if (dynamic_cast(uiItem->dataObject().p()) || dynamic_cast(uiItem->dataObject().p()) - || dynamic_cast(uiItem->dataObject().p())) + || dynamic_cast(uiItem->dataObject().p())) { if (keyEvent->matches(QKeySequence::Paste)) { diff --git a/ApplicationCode/ProjectDataModel/RimWell.h b/ApplicationCode/ProjectDataModel/RimWell.h index 56e405fe77..d2b136cff4 100644 --- a/ApplicationCode/ProjectDataModel/RimWell.h +++ b/ApplicationCode/ProjectDataModel/RimWell.h @@ -41,8 +41,8 @@ public: void setReservoirView(RimReservoirView* ownerReservoirView); - void setWellResults(RigWellResults* wellResults) { m_wellResults = wellResults;} - RigWellResults* wellResults() { return m_wellResults.p();} + void setWellResults(RigSingleWellResultsData* wellResults) { m_wellResults = wellResults;} + RigSingleWellResultsData* wellResults() { return m_wellResults.p();} virtual caf::PdmFieldHandle* userDescriptionField(); @@ -61,7 +61,7 @@ public: caf::PdmField pipeRadiusScaleFactor; private: - cvf::ref m_wellResults; + cvf::ref m_wellResults; RimReservoirView* m_reservoirView; }; diff --git a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp index 80689eb35f..b6abc6c47e 100644 --- a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp +++ b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp @@ -28,17 +28,17 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -TEST(RigGridCollection, BasicTest) +TEST(RigGridManager, BasicTest) { cvf::ref mainGridA = new RigMainGrid; - cvf::ref eclipseCase = new RigEclipseCase; + cvf::ref eclipseCase = new RigCaseData; eclipseCase->setMainGrid(mainGridA.p()); int count = mainGridA->refCount(); EXPECT_EQ(mainGridA->refCount(), 2); - RigGridCollection gridCollection; + RigGridManager gridCollection; gridCollection.addCase(eclipseCase.p()); EXPECT_EQ(mainGridA->refCount(), 2); @@ -52,18 +52,18 @@ TEST(RigGridCollection, BasicTest) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -TEST(RigGridCollection, EqualTests) +TEST(RigGridManager, EqualTests) { cvf::ref mainGridA = new RigMainGrid; mainGridA->nodes().push_back(cvf::Vec3d(0, 0, 0)); mainGridA->nodes().push_back(cvf::Vec3d(0, 0, 1)); mainGridA->nodes().push_back(cvf::Vec3d(0, 0, 2)); - cvf::ref eclipseCase = new RigEclipseCase; + cvf::ref eclipseCase = new RigCaseData; eclipseCase->setMainGrid(mainGridA.p()); - RigGridCollection gridCollection; + RigGridManager gridCollection; gridCollection.addCase(eclipseCase.p()); diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp index 292d26fd9c..76b3617dd0 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp @@ -24,12 +24,12 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigEclipseCase::RigEclipseCase() +RigCaseData::RigCaseData() { m_mainGrid = new RigMainGrid(); - m_matrixModelResults = new RigReservoirCellResults(m_mainGrid.p()); - m_fractureModelResults = new RigReservoirCellResults(m_mainGrid.p()); + m_matrixModelResults = new RigCaseCellResultsData(m_mainGrid.p()); + m_fractureModelResults = new RigCaseCellResultsData(m_mainGrid.p()); m_activeCellInfo = new RigActiveCellInfo; m_fractureActiveCellInfo = new RigActiveCellInfo; @@ -38,7 +38,7 @@ RigEclipseCase::RigEclipseCase() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigEclipseCase::~RigEclipseCase() +RigCaseData::~RigCaseData() { } @@ -46,7 +46,7 @@ RigEclipseCase::~RigEclipseCase() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigEclipseCase::setMainGrid(RigMainGrid* mainGrid) +void RigCaseData::setMainGrid(RigMainGrid* mainGrid) { m_mainGrid = mainGrid; @@ -57,7 +57,7 @@ void RigEclipseCase::setMainGrid(RigMainGrid* mainGrid) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigEclipseCase::allGrids(std::vector* grids) +void RigCaseData::allGrids(std::vector* grids) { CVF_ASSERT(grids); @@ -76,7 +76,7 @@ void RigEclipseCase::allGrids(std::vector* grids) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigEclipseCase::allGrids(std::vector* grids) const +void RigCaseData::allGrids(std::vector* grids) const { CVF_ASSERT(grids); @@ -95,7 +95,7 @@ void RigEclipseCase::allGrids(std::vector* grids) const //-------------------------------------------------------------------------------------------------- /// Get grid by index. The main grid has index 0, so the first lgr has index 1 //-------------------------------------------------------------------------------------------------- -const RigGridBase* RigEclipseCase::grid(size_t index) const +const RigGridBase* RigCaseData::grid(size_t index) const { CVF_ASSERT(m_mainGrid.notNull()); return m_mainGrid->gridByIndex(index); @@ -105,7 +105,7 @@ const RigGridBase* RigEclipseCase::grid(size_t index) const //-------------------------------------------------------------------------------------------------- /// Get grid by index. The main grid has index 0, so the first lgr has index 1 //-------------------------------------------------------------------------------------------------- -RigGridBase* RigEclipseCase::grid(size_t index) +RigGridBase* RigCaseData::grid(size_t index) { CVF_ASSERT(m_mainGrid.notNull()); return m_mainGrid->gridByIndex(index); @@ -114,7 +114,7 @@ RigGridBase* RigEclipseCase::grid(size_t index) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -size_t RigEclipseCase::gridCount() const +size_t RigCaseData::gridCount() const { CVF_ASSERT(m_mainGrid.notNull()); return m_mainGrid->gridCount(); @@ -124,7 +124,7 @@ size_t RigEclipseCase::gridCount() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigEclipseCase::computeWellCellsPrGrid() +void RigCaseData::computeWellCellsPrGrid() { // If we have computed this already, return if (m_wellCellsInGrid.size()) return; @@ -185,7 +185,7 @@ void RigEclipseCase::computeWellCellsPrGrid() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigEclipseCase::setWellResults(const cvf::Collection& data) +void RigCaseData::setWellResults(const cvf::Collection& data) { m_wellResults = data; m_wellCellsInGrid.clear(); @@ -195,7 +195,7 @@ void RigEclipseCase::setWellResults(const cvf::Collection& data) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::UByteArray* RigEclipseCase::wellCellsInGrid(size_t gridIndex) +cvf::UByteArray* RigCaseData::wellCellsInGrid(size_t gridIndex) { computeWellCellsPrGrid(); CVF_ASSERT(gridIndex < m_wellCellsInGrid.size()); @@ -206,7 +206,7 @@ cvf::UByteArray* RigEclipseCase::wellCellsInGrid(size_t gridIndex) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigCell& RigEclipseCase::cellFromWellResultCell(const RigWellResultCell& wellResultCell) +RigCell& RigCaseData::cellFromWellResultCell(const RigWellResultCell& wellResultCell) { size_t gridIndex = wellResultCell.m_gridIndex; size_t gridCellIndex = wellResultCell.m_gridCellIndex; @@ -220,7 +220,7 @@ RigCell& RigEclipseCase::cellFromWellResultCell(const RigWellResultCell& wellRes //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RigEclipseCase::findSharedSourceFace(cvf::StructGridInterface::FaceType& sharedSourceFace,const RigWellResultCell& sourceWellCellResult, const RigWellResultCell& otherWellCellResult) const +bool RigCaseData::findSharedSourceFace(cvf::StructGridInterface::FaceType& sharedSourceFace,const RigWellResultCell& sourceWellCellResult, const RigWellResultCell& otherWellCellResult) const { size_t gridIndex = sourceWellCellResult.m_gridIndex; size_t gridCellIndex = sourceWellCellResult.m_gridCellIndex; @@ -291,7 +291,7 @@ public: //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigEclipseCase::computeActiveCellIJKBBox() +void RigCaseData::computeActiveCellIJKBBox() { if (m_mainGrid.notNull() && m_activeCellInfo.notNull() && m_fractureActiveCellInfo.notNull()) { @@ -322,7 +322,7 @@ void RigEclipseCase::computeActiveCellIJKBBox() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigEclipseCase::computeActiveCellBoundingBoxes() +void RigCaseData::computeActiveCellBoundingBoxes() { computeActiveCellIJKBBox(); computeActiveCellsGeometryBoundingBox(); @@ -331,7 +331,7 @@ void RigEclipseCase::computeActiveCellBoundingBoxes() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigActiveCellInfo* RigEclipseCase::activeCellInfo(RifReaderInterface::PorosityModelResultType porosityModel) +RigActiveCellInfo* RigCaseData::activeCellInfo(RifReaderInterface::PorosityModelResultType porosityModel) { if (porosityModel == RifReaderInterface::MATRIX_RESULTS) { @@ -344,7 +344,7 @@ RigActiveCellInfo* RigEclipseCase::activeCellInfo(RifReaderInterface::PorosityMo //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const RigActiveCellInfo* RigEclipseCase::activeCellInfo(RifReaderInterface::PorosityModelResultType porosityModel) const +const RigActiveCellInfo* RigCaseData::activeCellInfo(RifReaderInterface::PorosityModelResultType porosityModel) const { if (porosityModel == RifReaderInterface::MATRIX_RESULTS) { @@ -357,7 +357,7 @@ const RigActiveCellInfo* RigEclipseCase::activeCellInfo(RifReaderInterface::Poro //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigEclipseCase::setActiveCellInfo(RifReaderInterface::PorosityModelResultType porosityModel, RigActiveCellInfo* activeCellInfo) +void RigCaseData::setActiveCellInfo(RifReaderInterface::PorosityModelResultType porosityModel, RigActiveCellInfo* activeCellInfo) { if (porosityModel == RifReaderInterface::MATRIX_RESULTS) { @@ -373,7 +373,7 @@ void RigEclipseCase::setActiveCellInfo(RifReaderInterface::PorosityModelResultTy //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigEclipseCase::computeActiveCellsGeometryBoundingBox() +void RigCaseData::computeActiveCellsGeometryBoundingBox() { if (m_activeCellInfo.notNull() || m_fractureActiveCellInfo.notNull()) { @@ -427,7 +427,7 @@ void RigEclipseCase::computeActiveCellsGeometryBoundingBox() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigReservoirCellResults* RigEclipseCase::results(RifReaderInterface::PorosityModelResultType porosityModel) +RigCaseCellResultsData* RigCaseData::results(RifReaderInterface::PorosityModelResultType porosityModel) { if (porosityModel == RifReaderInterface::MATRIX_RESULTS) { @@ -440,7 +440,7 @@ RigReservoirCellResults* RigEclipseCase::results(RifReaderInterface::PorosityMod //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const RigReservoirCellResults* RigEclipseCase::results(RifReaderInterface::PorosityModelResultType porosityModel) const +const RigCaseCellResultsData* RigCaseData::results(RifReaderInterface::PorosityModelResultType porosityModel) const { if (porosityModel == RifReaderInterface::MATRIX_RESULTS) { @@ -453,7 +453,7 @@ const RigReservoirCellResults* RigEclipseCase::results(RifReaderInterface::Poros //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RigEclipseCase::dataAccessObject(const RigGridBase* grid, +cvf::ref RigCaseData::dataAccessObject(const RigGridBase* grid, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStepIndex, size_t scalarSetIndex) diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCase.h b/ApplicationCode/ReservoirDataModel/RigEclipseCase.h index 5063111cb4..04900460a8 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCase.h +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCase.h @@ -27,14 +27,14 @@ #include "RigWellResults.h" #include "RigActiveCellInfo.h" -class RigReservoirCellResults; +class RigCaseCellResultsData; -class RigEclipseCase: public cvf::Object +class RigCaseData: public cvf::Object { public: - RigEclipseCase(); - ~RigEclipseCase(); + RigCaseData(); + ~RigCaseData(); RigMainGrid* mainGrid() { return m_mainGrid.p(); } const RigMainGrid* mainGrid() const { return m_mainGrid.p(); } @@ -46,8 +46,8 @@ public: RigGridBase* grid(size_t index); size_t gridCount() const; - RigReservoirCellResults* results(RifReaderInterface::PorosityModelResultType porosityModel); - const RigReservoirCellResults* results(RifReaderInterface::PorosityModelResultType porosityModel) const; + RigCaseCellResultsData* results(RifReaderInterface::PorosityModelResultType porosityModel); + const RigCaseCellResultsData* results(RifReaderInterface::PorosityModelResultType porosityModel) const; RigActiveCellInfo* activeCellInfo(RifReaderInterface::PorosityModelResultType porosityModel); const RigActiveCellInfo* activeCellInfo(RifReaderInterface::PorosityModelResultType porosityModel) const; @@ -59,8 +59,8 @@ public: size_t timeStepIndex, size_t scalarSetIndex); - void setWellResults(const cvf::Collection& data); - const cvf::Collection& wellResults() { return m_wellResults; } + void setWellResults(const cvf::Collection& data); + const cvf::Collection& wellResults() { return m_wellResults; } cvf::UByteArray* wellCellsInGrid(size_t gridIndex); @@ -80,9 +80,9 @@ private: cvf::ref m_activeCellInfo; cvf::ref m_fractureActiveCellInfo; - cvf::ref m_matrixModelResults; - cvf::ref m_fractureModelResults; + cvf::ref m_matrixModelResults; + cvf::ref m_fractureModelResults; - cvf::Collection m_wellResults; //< A WellResults object for each well in the reservoir + cvf::Collection m_wellResults; //< A WellResults object for each well in the reservoir cvf::Collection m_wellCellsInGrid; //< A bool array pr grid with one bool pr cell telling wether the cell is a well cell or not }; diff --git a/ApplicationCode/ReservoirDataModel/RigGridCollection.cpp b/ApplicationCode/ReservoirDataModel/RigGridCollection.cpp index 0bd0a98a6b..61812211a6 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridCollection.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridCollection.cpp @@ -24,7 +24,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigGridCollection::addCase(RigEclipseCase* eclipseCase) +void RigGridManager::addCase(RigCaseData* eclipseCase) { cvf::ref caseAndGrid = new CaseToGridMap(eclipseCase, eclipseCase->mainGrid()); m_caseToGrid.push_back(caseAndGrid.p()); @@ -33,7 +33,7 @@ void RigGridCollection::addCase(RigEclipseCase* eclipseCase) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigGridCollection::removeCase(RigEclipseCase* eclipseCase) +void RigGridManager::removeCase(RigCaseData* eclipseCase) { size_t indexToErase = cvf::UNDEFINED_SIZE_T; @@ -50,12 +50,12 @@ void RigGridCollection::removeCase(RigEclipseCase* eclipseCase) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigMainGrid* RigGridCollection::findEqualGrid(RigMainGrid* candidateGrid) +RigMainGrid* RigGridManager::findEqualGrid(RigMainGrid* candidateGrid) { for (size_t i = 0; i < m_caseToGrid.size(); i++) { RigMainGrid* mainGrid = m_caseToGrid.at(i)->m_mainGrid; - if (RigGridCollection::isEqual(mainGrid, candidateGrid)) + if (RigGridManager::isEqual(mainGrid, candidateGrid)) { return mainGrid; } @@ -67,7 +67,7 @@ RigMainGrid* RigGridCollection::findEqualGrid(RigMainGrid* candidateGrid) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RigGridCollection::isEqual(RigMainGrid* gridA, RigMainGrid* gridB) +bool RigGridManager::isEqual(RigMainGrid* gridA, RigMainGrid* gridB) { if (gridA == NULL || gridB == NULL) return false; @@ -91,7 +91,7 @@ bool RigGridCollection::isEqual(RigMainGrid* gridA, RigMainGrid* gridB) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigGridCollection::clear() +void RigGridManager::clear() { m_caseToGrid.clear(); } @@ -99,7 +99,7 @@ void RigGridCollection::clear() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigGridCollection::CaseToGridMap::CaseToGridMap(RigEclipseCase* eclipseCase, RigMainGrid* mainGrid) : +RigGridManager::CaseToGridMap::CaseToGridMap(RigCaseData* eclipseCase, RigMainGrid* mainGrid) : m_eclipseCase(eclipseCase), m_mainGrid(mainGrid) { diff --git a/ApplicationCode/ReservoirDataModel/RigGridCollection.h b/ApplicationCode/ReservoirDataModel/RigGridCollection.h index caa6476703..3d6dada127 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridCollection.h +++ b/ApplicationCode/ReservoirDataModel/RigGridCollection.h @@ -25,14 +25,14 @@ #include class RigMainGrid; -class RigEclipseCase; +class RigCaseData; -class RigGridCollection : public cvf::Object +class RigGridManager : public cvf::Object { public: - void addCase(RigEclipseCase* eclipseCase); + void addCase(RigCaseData* eclipseCase); - void removeCase(RigEclipseCase* eclipseCase); + void removeCase(RigCaseData* eclipseCase); RigMainGrid* findEqualGrid(RigMainGrid* candidateGrid); @@ -45,9 +45,9 @@ private: class CaseToGridMap : public cvf::Object { public: - CaseToGridMap(RigEclipseCase* eclipseCase, RigMainGrid* mainGrid); + CaseToGridMap(RigCaseData* eclipseCase, RigMainGrid* mainGrid); - RigEclipseCase* m_eclipseCase; + RigCaseData* m_eclipseCase; RigMainGrid* m_mainGrid; }; diff --git a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp index 0cf3407102..8377a35c67 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp @@ -133,7 +133,7 @@ private: //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RigGridScalarDataAccessFactory::createPerGridDataAccessObject(RigEclipseCase* eclipseCase, +cvf::ref RigGridScalarDataAccessFactory::createPerGridDataAccessObject(RigCaseData* eclipseCase, size_t gridIndex, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStepIndex, diff --git a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.h b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.h index ce0bd96b0b..4757bf5d39 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.h +++ b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.h @@ -30,7 +30,7 @@ class RigGridScalarDataAccessFactory { public: static cvf::ref - createPerGridDataAccessObject(RigEclipseCase* eclipseCase, + createPerGridDataAccessObject(RigCaseData* eclipseCase, size_t gridIndex, RifReaderInterface::PorosityModelResultType porosityModel, size_t timeStepIndex, diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp index 0ad79539ee..6f2dfccfb5 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp @@ -172,7 +172,7 @@ void RigReservoirBuilderMock::appendCells(size_t nodeStartIndex, size_t cellCoun //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigReservoirBuilderMock::populateReservoir(RigEclipseCase* eclipseCase) +void RigReservoirBuilderMock::populateReservoir(RigCaseData* eclipseCase) { std::vector& mainGridNodes = eclipseCase->mainGrid()->nodes(); appendNodes(m_minWorldCoordinate, m_maxWorldCoordinate, cellDimension(), mainGridNodes); @@ -278,7 +278,7 @@ void RigReservoirBuilderMock::setWorldCoordinates(cvf::Vec3d minWorldCoordinate, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RigReservoirBuilderMock::inputProperty(RigEclipseCase* eclipseCase, const QString& propertyName, std::vector* values) +bool RigReservoirBuilderMock::inputProperty(RigCaseData* eclipseCase, const QString& propertyName, std::vector* values) { size_t k; @@ -299,7 +299,7 @@ bool RigReservoirBuilderMock::inputProperty(RigEclipseCase* eclipseCase, const Q //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RigReservoirBuilderMock::staticResult(RigEclipseCase* eclipseCase, const QString& result, std::vector* values) +bool RigReservoirBuilderMock::staticResult(RigCaseData* eclipseCase, const QString& result, std::vector* values) { size_t k; @@ -316,7 +316,7 @@ bool RigReservoirBuilderMock::staticResult(RigEclipseCase* eclipseCase, const QS //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RigReservoirBuilderMock::dynamicResult(RigEclipseCase* eclipseCase, const QString& result, size_t stepIndex, std::vector* values) +bool RigReservoirBuilderMock::dynamicResult(RigCaseData* eclipseCase, const QString& result, size_t stepIndex, std::vector* values) { int resultIndex = 1; @@ -352,19 +352,19 @@ bool RigReservoirBuilderMock::dynamicResult(RigEclipseCase* eclipseCase, const Q //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigReservoirBuilderMock::addWellData(RigEclipseCase* eclipseCase, RigGridBase* grid) +void RigReservoirBuilderMock::addWellData(RigCaseData* eclipseCase, RigGridBase* grid) { CVF_ASSERT(eclipseCase); CVF_ASSERT(grid); cvf::Vec3st dim = grid->gridPointDimensions(); - cvf::Collection wells; + cvf::Collection wells; int wellIdx; for (wellIdx = 0; wellIdx < 1; wellIdx++) { - cvf::ref wellCellsTimeHistory = new RigWellResults; + cvf::ref wellCellsTimeHistory = new RigSingleWellResultsData; wellCellsTimeHistory->m_wellName = QString("Well %1").arg(wellIdx); wellCellsTimeHistory->m_wellCellsTimeSteps.resize(m_timeStepCount); diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.h b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.h index 9ea0149b1d..c22bfbd926 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.h +++ b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.h @@ -55,14 +55,14 @@ public: void addLocalGridRefinement(const cvf::Vec3st& minCellPosition, const cvf::Vec3st& maxCellPosition, const cvf::Vec3st& singleCellRefinementFactors); - void populateReservoir(RigEclipseCase* eclipseCase); + void populateReservoir(RigCaseData* eclipseCase); - bool inputProperty(RigEclipseCase* eclipseCase, const QString& propertyName, std::vector* values ); - bool staticResult(RigEclipseCase* eclipseCase, const QString& result, std::vector* values ); - bool dynamicResult(RigEclipseCase* eclipseCase, const QString& result, size_t stepIndex, std::vector* values ); + bool inputProperty(RigCaseData* eclipseCase, const QString& propertyName, std::vector* values ); + bool staticResult(RigCaseData* eclipseCase, const QString& result, std::vector* values ); + bool dynamicResult(RigCaseData* eclipseCase, const QString& result, size_t stepIndex, std::vector* values ); private: - void addWellData(RigEclipseCase* eclipseCase, RigGridBase* grid); + void addWellData(RigCaseData* eclipseCase, RigGridBase* grid); static void appendCells(size_t nodeStartIndex, size_t cellCount, RigGridBase* hostGrid, std::vector& cells); static void appendNodes(const cvf::Vec3d& min, const cvf::Vec3d& max, const cvf::Vec3st& cubeDimension, std::vector& nodes); diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp index 4ee9d29606..115ad0a66a 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp @@ -27,7 +27,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigReservoirCellResults::RigReservoirCellResults(RigMainGrid* ownerGrid) +RigCaseCellResultsData::RigCaseCellResultsData(RigMainGrid* ownerGrid) { CVF_ASSERT(ownerGrid != NULL); m_ownerMainGrid = ownerGrid; @@ -37,7 +37,7 @@ RigReservoirCellResults::RigReservoirCellResults(RigMainGrid* ownerGrid) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigReservoirCellResults::setMainGrid(RigMainGrid* ownerGrid) +void RigCaseCellResultsData::setMainGrid(RigMainGrid* ownerGrid) { m_ownerMainGrid = ownerGrid; } @@ -45,7 +45,7 @@ void RigReservoirCellResults::setMainGrid(RigMainGrid* ownerGrid) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigReservoirCellResults::minMaxCellScalarValues( size_t scalarResultIndex, double& min, double& max ) +void RigCaseCellResultsData::minMaxCellScalarValues( size_t scalarResultIndex, double& min, double& max ) { min = HUGE_VAL; max = -HUGE_VAL; @@ -83,7 +83,7 @@ void RigReservoirCellResults::minMaxCellScalarValues( size_t scalarResultIndex, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigReservoirCellResults::minMaxCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& min, double& max) +void RigCaseCellResultsData::minMaxCellScalarValues(size_t scalarResultIndex, size_t timeStepIndex, double& min, double& max) { min = HUGE_VAL; max = -HUGE_VAL; @@ -137,7 +137,7 @@ void RigReservoirCellResults::minMaxCellScalarValues(size_t scalarResultIndex, s //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const std::vector& RigReservoirCellResults::cellScalarValuesHistogram(size_t scalarResultIndex) +const std::vector& RigCaseCellResultsData::cellScalarValuesHistogram(size_t scalarResultIndex) { CVF_ASSERT(scalarResultIndex < resultCount()); @@ -178,7 +178,7 @@ const std::vector& RigReservoirCellResults::cellScalarValuesHistogram(si //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigReservoirCellResults::p10p90CellScalarValues(size_t scalarResultIndex, double& p10, double& p90) +void RigCaseCellResultsData::p10p90CellScalarValues(size_t scalarResultIndex, double& p10, double& p90) { const std::vector& histogr = cellScalarValuesHistogram( scalarResultIndex); p10 = m_p10p90[scalarResultIndex].first; @@ -188,7 +188,7 @@ void RigReservoirCellResults::p10p90CellScalarValues(size_t scalarResultIndex, d //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigReservoirCellResults::meanCellScalarValues(size_t scalarResultIndex, double& meanValue) +void RigCaseCellResultsData::meanCellScalarValues(size_t scalarResultIndex, double& meanValue) { CVF_ASSERT(scalarResultIndex < resultCount()); @@ -224,7 +224,7 @@ void RigReservoirCellResults::meanCellScalarValues(size_t scalarResultIndex, dou //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -size_t RigReservoirCellResults::resultCount() const +size_t RigCaseCellResultsData::resultCount() const { return m_cellScalarResults.size(); } @@ -232,7 +232,7 @@ size_t RigReservoirCellResults::resultCount() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -size_t RigReservoirCellResults::timeStepCount(size_t scalarResultIndex) const +size_t RigCaseCellResultsData::timeStepCount(size_t scalarResultIndex) const { CVF_TIGHT_ASSERT(scalarResultIndex < resultCount()); @@ -242,7 +242,7 @@ size_t RigReservoirCellResults::timeStepCount(size_t scalarResultIndex) const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const std::vector< std::vector > & RigReservoirCellResults::cellScalarResults( size_t scalarResultIndex ) const +const std::vector< std::vector > & RigCaseCellResultsData::cellScalarResults( size_t scalarResultIndex ) const { CVF_TIGHT_ASSERT(scalarResultIndex < resultCount()); @@ -252,7 +252,7 @@ const std::vector< std::vector > & RigReservoirCellResults::cellScalarRe //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector< std::vector > & RigReservoirCellResults::cellScalarResults( size_t scalarResultIndex ) +std::vector< std::vector > & RigCaseCellResultsData::cellScalarResults( size_t scalarResultIndex ) { CVF_TIGHT_ASSERT(scalarResultIndex < resultCount()); @@ -262,7 +262,7 @@ std::vector< std::vector > & RigReservoirCellResults::cellScalarResults( //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector& RigReservoirCellResults::cellScalarResults(size_t scalarResultIndex, size_t timeStepIndex) +std::vector& RigCaseCellResultsData::cellScalarResults(size_t scalarResultIndex, size_t timeStepIndex) { CVF_TIGHT_ASSERT(scalarResultIndex < resultCount()); CVF_TIGHT_ASSERT(timeStepIndex < m_cellScalarResults[scalarResultIndex].size()); @@ -273,7 +273,7 @@ std::vector& RigReservoirCellResults::cellScalarResults(size_t scalarRes //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double RigReservoirCellResults::cellScalarResult( size_t scalarResultIndex, size_t timeStepIndex, size_t resultValueIndex) +double RigCaseCellResultsData::cellScalarResult( size_t scalarResultIndex, size_t timeStepIndex, size_t resultValueIndex) { if (scalarResultIndex < resultCount() && timeStepIndex < m_cellScalarResults[scalarResultIndex].size() && @@ -292,7 +292,7 @@ double RigReservoirCellResults::cellScalarResult( size_t scalarResultIndex, size //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -size_t RigReservoirCellResults::findScalarResultIndex(RimDefines::ResultCatType type, const QString& resultName) const +size_t RigCaseCellResultsData::findScalarResultIndex(RimDefines::ResultCatType type, const QString& resultName) const { std::vector::const_iterator it; for (it = m_resultInfos.begin(); it != m_resultInfos.end(); it++) @@ -309,7 +309,7 @@ size_t RigReservoirCellResults::findScalarResultIndex(RimDefines::ResultCatType //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -size_t RigReservoirCellResults::findScalarResultIndex(const QString& resultName) const +size_t RigCaseCellResultsData::findScalarResultIndex(const QString& resultName) const { size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T; @@ -337,7 +337,7 @@ size_t RigReservoirCellResults::findScalarResultIndex(const QString& resultName) /// Adds an empty scalar set, and returns the scalarResultIndex to it. /// if resultName already exists, it returns the scalarResultIndex to the existing result. //-------------------------------------------------------------------------------------------------- -size_t RigReservoirCellResults::addEmptyScalarResult(RimDefines::ResultCatType type, const QString& resultName, bool needsToBeStored) +size_t RigCaseCellResultsData::addEmptyScalarResult(RimDefines::ResultCatType type, const QString& resultName, bool needsToBeStored) { size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T; @@ -356,7 +356,7 @@ size_t RigReservoirCellResults::addEmptyScalarResult(RimDefines::ResultCatType t //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QStringList RigReservoirCellResults::resultNames(RimDefines::ResultCatType resType) const +QStringList RigCaseCellResultsData::resultNames(RimDefines::ResultCatType resType) const { QStringList varList; std::vector::const_iterator it; @@ -373,7 +373,7 @@ QStringList RigReservoirCellResults::resultNames(RimDefines::ResultCatType resTy //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigReservoirCellResults::recalculateMinMax(size_t scalarResultIndex) +void RigCaseCellResultsData::recalculateMinMax(size_t scalarResultIndex) { // Make sure cached max min values are recalculated next time asked for, since // the data could be changed. @@ -392,7 +392,7 @@ void RigReservoirCellResults::recalculateMinMax(size_t scalarResultIndex) //-------------------------------------------------------------------------------------------------- /// Returns whether the result data in question is addressed by Active Cell Index //-------------------------------------------------------------------------------------------------- -bool RigReservoirCellResults::isUsingGlobalActiveIndex(size_t scalarResultIndex) const +bool RigCaseCellResultsData::isUsingGlobalActiveIndex(size_t scalarResultIndex) const { CVF_TIGHT_ASSERT(scalarResultIndex < m_cellScalarResults.size()); @@ -407,7 +407,7 @@ bool RigReservoirCellResults::isUsingGlobalActiveIndex(size_t scalarResultIndex) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QDateTime RigReservoirCellResults::timeStepDate(size_t scalarResultIndex, size_t timeStepIndex) const +QDateTime RigCaseCellResultsData::timeStepDate(size_t scalarResultIndex, size_t timeStepIndex) const { if (scalarResultIndex < m_resultInfos.size() && (size_t)(m_resultInfos[scalarResultIndex].m_timeStepDates.size()) > timeStepIndex) return m_resultInfos[scalarResultIndex].m_timeStepDates[static_cast(timeStepIndex)]; @@ -418,7 +418,7 @@ QDateTime RigReservoirCellResults::timeStepDate(size_t scalarResultIndex, size_t //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RigReservoirCellResults::timeStepDates(size_t scalarResultIndex) const +std::vector RigCaseCellResultsData::timeStepDates(size_t scalarResultIndex) const { if (scalarResultIndex < m_resultInfos.size() ) return m_resultInfos[scalarResultIndex].m_timeStepDates; @@ -429,7 +429,7 @@ std::vector RigReservoirCellResults::timeStepDates(size_t scalarResul //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigReservoirCellResults::setTimeStepDates(size_t scalarResultIndex, const std::vector& dates) +void RigCaseCellResultsData::setTimeStepDates(size_t scalarResultIndex, const std::vector& dates) { CVF_ASSERT(scalarResultIndex < m_resultInfos.size() ); @@ -442,7 +442,7 @@ void RigReservoirCellResults::setTimeStepDates(size_t scalarResultIndex, const s //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -size_t RigReservoirCellResults::maxTimeStepCount(size_t* scalarResultIndexWithMostTimeSteps) const +size_t RigCaseCellResultsData::maxTimeStepCount(size_t* scalarResultIndexWithMostTimeSteps) const { size_t maxTsCount = 0; size_t scalarResultIndexWithMaxTsCount = cvf::UNDEFINED_SIZE_T; @@ -467,7 +467,7 @@ size_t RigReservoirCellResults::maxTimeStepCount(size_t* scalarResultIndexWithMo //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RigReservoirCellResults::makeResultNameUnique(const QString& resultNameProposal) const +QString RigCaseCellResultsData::makeResultNameUnique(const QString& resultNameProposal) const { QString newResultName = resultNameProposal; size_t resultIndex = cvf::UNDEFINED_SIZE_T; @@ -489,7 +489,7 @@ QString RigReservoirCellResults::makeResultNameUnique(const QString& resultNameP //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigReservoirCellResults::removeResult(const QString& resultName) +void RigCaseCellResultsData::removeResult(const QString& resultName) { size_t resultIdx = findScalarResultIndex(resultName); if (resultIdx == cvf::UNDEFINED_SIZE_T) return; @@ -502,7 +502,7 @@ void RigReservoirCellResults::removeResult(const QString& resultName) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigReservoirCellResults::clearAllResults() +void RigCaseCellResultsData::clearAllResults() { m_cellScalarResults.clear(); m_maxMinValues.clear(); @@ -516,7 +516,7 @@ void RigReservoirCellResults::clearAllResults() //-------------------------------------------------------------------------------------------------- /// Add a result with given type and name, and allocate one result vector for the static result values //-------------------------------------------------------------------------------------------------- -size_t RigReservoirCellResults::addStaticScalarResult(RimDefines::ResultCatType type, const QString& resultName, bool needsToBeStored, size_t resultValueCount) +size_t RigCaseCellResultsData::addStaticScalarResult(RimDefines::ResultCatType type, const QString& resultName, bool needsToBeStored, size_t resultValueCount) { size_t resultIdx = addEmptyScalarResult(type, resultName, needsToBeStored); @@ -529,7 +529,7 @@ size_t RigReservoirCellResults::addStaticScalarResult(RimDefines::ResultCatType //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifReaderInterface::PorosityModelResultType RigReservoirCellResults::convertFromProjectModelPorosityModel(RimDefines::PorosityModelType porosityModel) +RifReaderInterface::PorosityModelResultType RigCaseCellResultsData::convertFromProjectModelPorosityModel(RimDefines::PorosityModelType porosityModel) { if (porosityModel == RimDefines::MATRIX_MODEL) return RifReaderInterface::MATRIX_RESULTS; diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h index 6fa3caca61..31ec57dae4 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h +++ b/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h @@ -30,10 +30,10 @@ class RigMainGrid; //================================================================================================== /// Class containing the results for the complete number of active cells. Both main grid and LGR's //================================================================================================== -class RigReservoirCellResults : public cvf::Object +class RigCaseCellResultsData : public cvf::Object { public: - RigReservoirCellResults(RigMainGrid* ownerGrid); + RigCaseCellResultsData(RigMainGrid* ownerGrid); void setMainGrid(RigMainGrid* ownerGrid); diff --git a/ApplicationCode/ReservoirDataModel/RigWellResults.cpp b/ApplicationCode/ReservoirDataModel/RigWellResults.cpp index b1080e2bac..a52fea4430 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellResults.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellResults.cpp @@ -24,7 +24,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const RigWellResultFrame& RigWellResults::wellResultFrame(size_t resultTimeStepIndex) const +const RigWellResultFrame& RigSingleWellResultsData::wellResultFrame(size_t resultTimeStepIndex) const { CVF_ASSERT(resultTimeStepIndex < m_resultTimeStepIndexToWellTimeStepIndex.size()); @@ -37,7 +37,7 @@ const RigWellResultFrame& RigWellResults::wellResultFrame(size_t resultTimeStepI //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigWellResults::computeMappingFromResultTimeIndicesToWellTimeIndices(const std::vector& resultTimes) +void RigSingleWellResultsData::computeMappingFromResultTimeIndicesToWellTimeIndices(const std::vector& resultTimes) { m_resultTimeStepIndexToWellTimeStepIndex.clear(); if (m_wellCellsTimeSteps.size() == 0) return; @@ -83,7 +83,7 @@ void RigWellResults::computeMappingFromResultTimeIndicesToWellTimeIndices(const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RigWellResults::hasWellResult(size_t resultTimeStepIndex) const +bool RigSingleWellResultsData::hasWellResult(size_t resultTimeStepIndex) const { size_t wellTimeStepIndex = m_resultTimeStepIndexToWellTimeStepIndex[resultTimeStepIndex]; @@ -93,7 +93,7 @@ bool RigWellResults::hasWellResult(size_t resultTimeStepIndex) const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -size_t RigWellResults::firstResultTimeStep() const +size_t RigSingleWellResultsData::firstResultTimeStep() const { size_t i = 0; for(i = 0; i < m_resultTimeStepIndexToWellTimeStepIndex.size(); ++i) @@ -108,7 +108,7 @@ size_t RigWellResults::firstResultTimeStep() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigWellResults::computeStaticWellCellPath() +void RigSingleWellResultsData::computeStaticWellCellPath() { if (m_wellCellsTimeSteps.size() == 0) return; diff --git a/ApplicationCode/ReservoirDataModel/RigWellResults.h b/ApplicationCode/ReservoirDataModel/RigWellResults.h index dce4c4c7ec..7e27f23073 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellResults.h +++ b/ApplicationCode/ReservoirDataModel/RigWellResults.h @@ -99,7 +99,7 @@ public: //================================================================================================== /// //================================================================================================== -class RigWellResults : public cvf::Object +class RigSingleWellResultsData : public cvf::Object { public: bool hasWellResult(size_t resultTimeStepIndex) const; diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.cpp b/ApplicationCode/SocketInterface/RiaSocketServer.cpp index 9a1aac8d00..092aece862 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.cpp +++ b/ApplicationCode/SocketInterface/RiaSocketServer.cpp @@ -151,7 +151,7 @@ void RiaSocketServer::handleClientConnection(QTcpSocket* clientToHandle) //-------------------------------------------------------------------------------------------------- /// Find the requested reservoir: Current, by index or by name //-------------------------------------------------------------------------------------------------- -RimReservoir* RiaSocketServer::findReservoir(const QString& caseName) +RimCase* RiaSocketServer::findReservoir(const QString& caseName) { if (caseName.isEmpty()) { @@ -241,7 +241,7 @@ void RiaSocketServer::readCommandFromOctave() QString caseName; QString propertyName; - RimReservoir* reservoir = NULL; + RimCase* reservoir = NULL; // Find the correct arguments @@ -502,7 +502,7 @@ void RiaSocketServer::readPropertyDataFromOctave() if (m_currentReservoir != NULL) { // Create a new input property if we have an input reservoir - RimInputReservoir* inputRes = dynamic_cast(m_currentReservoir); + RimInputCase* inputRes = dynamic_cast(m_currentReservoir); if (inputRes) { RimInputProperty* inputProperty = NULL; diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.h b/ApplicationCode/SocketInterface/RiaSocketServer.h index 8a6f2e7e4e..6e19a1bb74 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.h +++ b/ApplicationCode/SocketInterface/RiaSocketServer.h @@ -27,7 +27,7 @@ class QTcpServer; class QTcpSocket; class QNetworkSession; class QErrorMessage; -class RimReservoir; +class RimCase; class RiaSocketServer : public QObject @@ -53,7 +53,7 @@ private: void handleClientConnection( QTcpSocket* clientToHandle); - RimReservoir* findReservoir(const QString &casename); + RimCase* findReservoir(const QString &casename); void terminateCurrentConnection(); void calculateMatrixModelActiveCellInfo(std::vector& gridNumber, @@ -80,7 +80,7 @@ private: quint64 m_bytesPerTimeStepToRead; size_t m_currentTimeStepToRead; std::vector< std::vector >* m_scalarResultsToAdd; - RimReservoir* m_currentReservoir; + RimCase* m_currentReservoir; size_t m_currentScalarIndex; QString m_currentPropertyName; bool m_invalidActiveCellCountDetected; diff --git a/ApplicationCode/UserInterface/RIMainWindow.cpp b/ApplicationCode/UserInterface/RIMainWindow.cpp index d391e3e0dc..5073f1b446 100644 --- a/ApplicationCode/UserInterface/RIMainWindow.cpp +++ b/ApplicationCode/UserInterface/RIMainWindow.cpp @@ -976,7 +976,7 @@ void RIMainWindow::slotSubWindowActivated(QMdiSubWindow* subWindow) size_t i; for (i = 0; i < proj->reservoirs().size(); ++i) { - RimReservoir* ri = proj->reservoirs()[i]; + RimCase* ri = proj->reservoirs()[i]; if (!ri) continue; size_t j; From 949084784ec286d0a21493929f31629904536b04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 22 Mar 2013 15:50:44 +0100 Subject: [PATCH 165/242] More class renaming. File names not done yet. RIApplication RiaApplication RIPreferences RiaPreferences p4#: 21065 --- ApplicationCode/Application/RIApplication.cpp | 112 +++++++++--------- ApplicationCode/Application/RIApplication.h | 14 +-- ApplicationCode/Application/RIPreferences.cpp | 12 +- ApplicationCode/Application/RIPreferences.h | 8 +- .../ProjectDataModel/RimInputReservoir.cpp | 2 +- .../ProjectDataModel/RimProject.cpp | 2 +- .../RimReservoirCellResultsCacher.cpp | 2 +- .../ProjectDataModel/RimReservoirView.cpp | 12 +- .../ProjectDataModel/RimUiTreeModelPdm.cpp | 10 +- .../ProjectDataModel/RimUiTreeView.cpp | 18 +-- ApplicationCode/RIMain.cpp | 2 +- .../SocketInterface/RiaSocketServer.cpp | 6 +- .../UserInterface/RIMainWindow.cpp | 102 ++++++++-------- .../UserInterface/RIProcessMonitor.cpp | 2 +- ApplicationCode/UserInterface/RIViewer.cpp | 4 +- .../RiuMultiCaseImportDialog.cpp | 4 +- 16 files changed, 156 insertions(+), 156 deletions(-) diff --git a/ApplicationCode/Application/RIApplication.cpp b/ApplicationCode/Application/RIApplication.cpp index c3737622d2..c901516b03 100644 --- a/ApplicationCode/Application/RIApplication.cpp +++ b/ApplicationCode/Application/RIApplication.cpp @@ -60,11 +60,11 @@ namespace caf { template<> -void AppEnum< RIApplication::RINavigationPolicy >::setUp() +void AppEnum< RiaApplication::RINavigationPolicy >::setUp() { - addItem(RIApplication::NAVIGATION_POLICY_CEETRON, "NAVIGATION_POLICY_CEETRON", "Ceetron"); - addItem(RIApplication::NAVIGATION_POLICY_CAD, "NAVIGATION_POLICY_CAD", "CAD"); - setDefault(RIApplication::NAVIGATION_POLICY_CAD); + addItem(RiaApplication::NAVIGATION_POLICY_CEETRON, "NAVIGATION_POLICY_CEETRON", "Ceetron"); + addItem(RiaApplication::NAVIGATION_POLICY_CAD, "NAVIGATION_POLICY_CAD", "CAD"); + setDefault(RiaApplication::NAVIGATION_POLICY_CAD); } } @@ -93,7 +93,7 @@ namespace RegTestNames //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RIApplication::RIApplication(int& argc, char** argv) +RiaApplication::RiaApplication(int& argc, char** argv) : QApplication(argc, argv) { // USed to get registry settings in the right place @@ -106,7 +106,7 @@ RIApplication::RIApplication(int& argc, char** argv) //cvf::Trace::enable(false); - m_preferences = new RIPreferences; + m_preferences = new RiaPreferences; readPreferences(); applyPreferences(); @@ -140,7 +140,7 @@ RIApplication::RIApplication(int& argc, char** argv) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RIApplication::~RIApplication() +RiaApplication::~RiaApplication() { delete m_preferences; } @@ -149,16 +149,16 @@ RIApplication::~RIApplication() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RIApplication* RIApplication::instance() +RiaApplication* RiaApplication::instance() { - return static_castqApp; + return static_castqApp; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIApplication::setWindowCaptionFromAppState() +void RiaApplication::setWindowCaptionFromAppState() { RIMainWindow* mainWnd = RIMainWindow::instance(); if (!mainWnd) return; @@ -186,7 +186,7 @@ void RIApplication::setWindowCaptionFromAppState() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIApplication::processNonGuiEvents() +void RiaApplication::processNonGuiEvents() { processEvents(QEventLoop::ExcludeUserInputEvents); } @@ -195,7 +195,7 @@ void RIApplication::processNonGuiEvents() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const char* RIApplication::getVersionStringApp(bool includeCrtInfo) +const char* RiaApplication::getVersionStringApp(bool includeCrtInfo) { // Use static buf so we can return ptr static char szBuf[1024]; @@ -221,7 +221,7 @@ const char* RIApplication::getVersionStringApp(bool includeCrtInfo) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RIApplication::loadProject(const QString& projectFileName) +bool RiaApplication::loadProject(const QString& projectFileName) { // First Close the current project @@ -330,7 +330,7 @@ bool RIApplication::loadProject(const QString& projectFileName) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RIApplication::loadLastUsedProject() +bool RiaApplication::loadLastUsedProject() { return loadProject(m_preferences->lastUsedProjectFileName); } @@ -339,7 +339,7 @@ bool RIApplication::loadLastUsedProject() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RIApplication::saveProject() +bool RiaApplication::saveProject() { CVF_ASSERT(m_project.notNull()); @@ -357,11 +357,11 @@ bool RIApplication::saveProject() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RIApplication::saveProjectPromptForFileName() +bool RiaApplication::saveProjectPromptForFileName() { //if (m_project.isNull()) return true; - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); QString startPath; if (!m_project->fileName().isEmpty()) @@ -396,7 +396,7 @@ bool RIApplication::saveProjectPromptForFileName() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RIApplication::saveProjectAs(const QString& fileName) +bool RiaApplication::saveProjectAs(const QString& fileName) { m_project->fileName = fileName; m_project->writeFile(); @@ -411,7 +411,7 @@ bool RIApplication::saveProjectAs(const QString& fileName) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RIApplication::closeProject(bool askToSaveIfDirty) +bool RiaApplication::closeProject(bool askToSaveIfDirty) { RIMainWindow* mainWnd = RIMainWindow::instance(); @@ -451,7 +451,7 @@ bool RIApplication::closeProject(bool askToSaveIfDirty) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIApplication::onProjectOpenedOrClosed() +void RiaApplication::onProjectOpenedOrClosed() { RIMainWindow* mainWnd = RIMainWindow::instance(); if (!mainWnd) return; @@ -466,7 +466,7 @@ void RIApplication::onProjectOpenedOrClosed() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RIApplication::currentProjectFileName() const +QString RiaApplication::currentProjectFileName() const { return m_project->fileName(); } @@ -475,7 +475,7 @@ QString RIApplication::currentProjectFileName() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RIApplication::openEclipseCaseFromFile(const QString& fileName) +bool RiaApplication::openEclipseCaseFromFile(const QString& fileName) { if (!QFile::exists(fileName)) return false; @@ -489,7 +489,7 @@ bool RIApplication::openEclipseCaseFromFile(const QString& fileName) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RIApplication::openEclipseCase(const QString& caseName, const QString& caseFileName) +bool RiaApplication::openEclipseCase(const QString& caseName, const QString& caseFileName) { QFileInfo gridFileName(caseFileName); QString casePath = gridFileName.absolutePath(); @@ -527,7 +527,7 @@ bool RIApplication::openEclipseCase(const QString& caseName, const QString& case //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RIApplication::openInputEclipseCase(const QString& caseName, const QStringList& caseFileNames) +bool RiaApplication::openInputEclipseCase(const QString& caseName, const QStringList& caseFileNames) { RimInputCase* rimInputReservoir = new RimInputCase(); rimInputReservoir->caseName = caseName; @@ -557,7 +557,7 @@ bool RIApplication::openInputEclipseCase(const QString& caseName, const QStringL //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIApplication::createMockModel() +void RiaApplication::createMockModel() { openEclipseCase("Result Mock Debug Model Simple", "Result Mock Debug Model Simple"); } @@ -565,7 +565,7 @@ void RIApplication::createMockModel() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIApplication::createResultsMockModel() +void RiaApplication::createResultsMockModel() { openEclipseCase("Result Mock Debug Model With Results", "Result Mock Debug Model With Results"); } @@ -574,7 +574,7 @@ void RIApplication::createResultsMockModel() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIApplication::createLargeResultsMockModel() +void RiaApplication::createLargeResultsMockModel() { openEclipseCase("Result Mock Debug Model Large With Results", "Result Mock Debug Model Large With Results"); } @@ -582,7 +582,7 @@ void RIApplication::createLargeResultsMockModel() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIApplication::createInputMockModel() +void RiaApplication::createInputMockModel() { openInputEclipseCase("Input Mock Debug Model Simple", QStringList("Input Mock Debug Model Simple")); } @@ -590,7 +590,7 @@ void RIApplication::createInputMockModel() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const RimReservoirView* RIApplication::activeReservoirView() const +const RimReservoirView* RiaApplication::activeReservoirView() const { return m_activeReservoirView; } @@ -598,7 +598,7 @@ const RimReservoirView* RIApplication::activeReservoirView() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimReservoirView* RIApplication::activeReservoirView() +RimReservoirView* RiaApplication::activeReservoirView() { return m_activeReservoirView; } @@ -606,7 +606,7 @@ RimReservoirView* RIApplication::activeReservoirView() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIApplication::setActiveReservoirView(RimReservoirView* rv) +void RiaApplication::setActiveReservoirView(RimReservoirView* rv) { m_activeReservoirView = rv; } @@ -614,7 +614,7 @@ void RIApplication::setActiveReservoirView(RimReservoirView* rv) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIApplication::setUseShaders(bool enable) +void RiaApplication::setUseShaders(bool enable) { m_preferences->useShaders = enable; writePreferences(); @@ -623,7 +623,7 @@ void RIApplication::setUseShaders(bool enable) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RIApplication::useShaders() const +bool RiaApplication::useShaders() const { if (!m_preferences->useShaders) return false; @@ -637,7 +637,7 @@ bool RIApplication::useShaders() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RIApplication::RINavigationPolicy RIApplication::navigationPolicy() const +RiaApplication::RINavigationPolicy RiaApplication::navigationPolicy() const { return m_preferences->navigationPolicy(); } @@ -646,7 +646,7 @@ RIApplication::RINavigationPolicy RIApplication::navigationPolicy() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIApplication::setShowPerformanceInfo(bool enable) +void RiaApplication::setShowPerformanceInfo(bool enable) { m_preferences->showHud = enable; writePreferences(); @@ -656,7 +656,7 @@ void RIApplication::setShowPerformanceInfo(bool enable) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RIApplication::showPerformanceInfo() const +bool RiaApplication::showPerformanceInfo() const { return m_preferences->showHud; } @@ -665,7 +665,7 @@ bool RIApplication::showPerformanceInfo() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RIApplication::parseArguments() +bool RiaApplication::parseArguments() { QStringList arguments = QCoreApplication::arguments(); @@ -885,7 +885,7 @@ bool RIApplication::parseArguments() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RIApplication::scriptDirectory() const +QString RiaApplication::scriptDirectory() const { return m_preferences->scriptDirectory(); } @@ -893,7 +893,7 @@ QString RIApplication::scriptDirectory() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RIApplication::scriptEditorPath() const +QString RiaApplication::scriptEditorPath() const { return m_preferences->scriptEditorExecutable(); } @@ -901,7 +901,7 @@ QString RIApplication::scriptEditorPath() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RIApplication::octavePath() const +QString RiaApplication::octavePath() const { return m_preferences->octaveExecutable(); } @@ -909,7 +909,7 @@ QString RIApplication::octavePath() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIApplication::slotWorkerProcessFinished(int exitCode, QProcess::ExitStatus exitStatus) +void RiaApplication::slotWorkerProcessFinished(int exitCode, QProcess::ExitStatus exitStatus) { RIMainWindow::instance()->processMonitor()->stopMonitorWorkProcess(); @@ -943,7 +943,7 @@ void RIApplication::slotWorkerProcessFinished(int exitCode, QProcess::ExitStatus //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RIApplication::launchProcess(const QString& program, const QStringList& arguments) +bool RiaApplication::launchProcess(const QString& program, const QStringList& arguments) { if (m_workerProcess == NULL) { @@ -977,7 +977,7 @@ bool RIApplication::launchProcess(const QString& program, const QStringList& arg //-------------------------------------------------------------------------------------------------- /// Read fields of a Pdm object using QSettings //-------------------------------------------------------------------------------------------------- -void RIApplication::readPreferences() +void RiaApplication::readPreferences() { QSettings settings; std::vector fields; @@ -999,7 +999,7 @@ void RIApplication::readPreferences() //-------------------------------------------------------------------------------------------------- /// Write fields of a Pdm object using QSettings //-------------------------------------------------------------------------------------------------- -void RIApplication::writePreferences() +void RiaApplication::writePreferences() { QSettings settings; @@ -1018,7 +1018,7 @@ void RIApplication::writePreferences() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RIPreferences* RIApplication::preferences() +RiaPreferences* RiaApplication::preferences() { return m_preferences; } @@ -1026,7 +1026,7 @@ RIPreferences* RIApplication::preferences() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIApplication::applyPreferences() +void RiaApplication::applyPreferences() { if (m_activeReservoirView && m_activeReservoirView->viewer()) { @@ -1063,7 +1063,7 @@ void RIApplication::applyPreferences() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIApplication::terminateProcess() +void RiaApplication::terminateProcess() { if (m_workerProcess) { @@ -1076,7 +1076,7 @@ void RIApplication::terminateProcess() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RIApplication::defaultFileDialogDirectory(const QString& dialogName) +QString RiaApplication::defaultFileDialogDirectory(const QString& dialogName) { QString defaultDirectory = m_startupDefaultDirectory; std::map::iterator it; @@ -1093,7 +1093,7 @@ QString RIApplication::defaultFileDialogDirectory(const QString& dialogName) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIApplication::setDefaultFileDialogDirectory(const QString& dialogName, const QString& defaultDirectory) +void RiaApplication::setDefaultFileDialogDirectory(const QString& dialogName, const QString& defaultDirectory) { m_fileDialogDefaultDirectories[dialogName] = defaultDirectory; } @@ -1101,7 +1101,7 @@ void RIApplication::setDefaultFileDialogDirectory(const QString& dialogName, con //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIApplication::saveSnapshotPromtpForFilename() +void RiaApplication::saveSnapshotPromtpForFilename() { QString startPath; if (!m_project->fileName().isEmpty()) @@ -1131,7 +1131,7 @@ void RIApplication::saveSnapshotPromtpForFilename() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIApplication::saveSnapshotAs(const QString& fileName) +void RiaApplication::saveSnapshotAs(const QString& fileName) { if (m_activeReservoirView && m_activeReservoirView->viewer()) { @@ -1150,7 +1150,7 @@ void RIApplication::saveSnapshotAs(const QString& fileName) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIApplication::copySnapshotToClipboard() +void RiaApplication::copySnapshotToClipboard() { if (m_activeReservoirView && m_activeReservoirView->viewer()) { @@ -1167,7 +1167,7 @@ void RIApplication::copySnapshotToClipboard() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIApplication::saveSnapshotForAllViews(const QString& snapshotFolderName) +void RiaApplication::saveSnapshotForAllViews(const QString& snapshotFolderName) { RIMainWindow* mainWnd = RIMainWindow::instance(); if (!mainWnd) return; @@ -1229,7 +1229,7 @@ void removeDirectoryWithContent(QDir dirToDelete ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIApplication::runRegressionTest(const QString& testRootPath) +void RiaApplication::runRegressionTest(const QString& testRootPath) { QString generatedFolderName = RegTestNames::generatedFolderName; QString diffFolderName = RegTestNames::diffFolderName; @@ -1317,7 +1317,7 @@ void RIApplication::runRegressionTest(const QString& testRootPath) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIApplication::updateRegressionTest(const QString& testRootPath) +void RiaApplication::updateRegressionTest(const QString& testRootPath) { // Find all sub folders @@ -1352,7 +1352,7 @@ void RIApplication::updateRegressionTest(const QString& testRootPath) //-------------------------------------------------------------------------------------------------- /// Make sure changes in this functions is validated to RimIdenticalGridCaseGroup::initAfterRead() //-------------------------------------------------------------------------------------------------- -bool RIApplication::addEclipseCases(const QStringList& fileNames) +bool RiaApplication::addEclipseCases(const QStringList& fileNames) { if (fileNames.size() == 0) return true; diff --git a/ApplicationCode/Application/RIApplication.h b/ApplicationCode/Application/RIApplication.h index 29992ec3d6..00b984a186 100644 --- a/ApplicationCode/Application/RIApplication.h +++ b/ApplicationCode/Application/RIApplication.h @@ -34,7 +34,7 @@ class RigCaseData; class RimCase; class Drawable; class RiaSocketServer; -class RIPreferences; +class RiaPreferences; namespace caf { @@ -46,7 +46,7 @@ namespace caf // // //================================================================================================== -class RIApplication : public QApplication +class RiaApplication : public QApplication { Q_OBJECT @@ -58,9 +58,9 @@ public: }; public: - RIApplication(int& argc, char** argv); - ~RIApplication(); - static RIApplication* instance(); + RiaApplication(int& argc, char** argv); + ~RiaApplication(); + static RiaApplication* instance(); bool parseArguments(); @@ -116,7 +116,7 @@ public: bool launchProcess(const QString& program, const QStringList& arguments); void terminateProcess(); - RIPreferences* preferences(); + RiaPreferences* preferences(); void readPreferences(); void writePreferences(); void applyPreferences(); @@ -139,7 +139,7 @@ private: caf::UiProcess* m_workerProcess; - RIPreferences* m_preferences; + RiaPreferences* m_preferences; std::map m_fileDialogDefaultDirectories; QString m_startupDefaultDirectory; diff --git a/ApplicationCode/Application/RIPreferences.cpp b/ApplicationCode/Application/RIPreferences.cpp index 57aeee9a06..9d016682e5 100644 --- a/ApplicationCode/Application/RIPreferences.cpp +++ b/ApplicationCode/Application/RIPreferences.cpp @@ -20,13 +20,13 @@ #include "RIPreferences.h" #include "cafPdmUiFilePathEditor.h" -CAF_PDM_SOURCE_INIT(RIPreferences, "RIPreferences"); +CAF_PDM_SOURCE_INIT(RiaPreferences, "RIPreferences"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RIPreferences::RIPreferences(void) +RiaPreferences::RiaPreferences(void) { - CAF_PDM_InitField(&navigationPolicy, "navigationPolicy", caf::AppEnum(RIApplication::NAVIGATION_POLICY_CAD), "Navigation mode", "", "", ""); + CAF_PDM_InitField(&navigationPolicy, "navigationPolicy", caf::AppEnum(RiaApplication::NAVIGATION_POLICY_CAD), "Navigation mode", "", "", ""); CAF_PDM_InitFieldNoDefault(&scriptDirectory, "scriptDirectory", "Shared Script Folder", "", "", ""); scriptDirectory.setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName()); @@ -53,7 +53,7 @@ RIPreferences::RIPreferences(void) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RIPreferences::~RIPreferences(void) +RiaPreferences::~RiaPreferences(void) { } @@ -61,7 +61,7 @@ RIPreferences::~RIPreferences(void) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIPreferences::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute) +void RiaPreferences::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute) { if (field == &scriptDirectory) { @@ -76,7 +76,7 @@ void RIPreferences::defineEditorAttribute(const caf::PdmFieldHandle* field, QStr //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIPreferences::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const +void RiaPreferences::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const { uiOrdering.add(&navigationPolicy); diff --git a/ApplicationCode/Application/RIPreferences.h b/ApplicationCode/Application/RIPreferences.h index a35ba41997..4bad994edc 100644 --- a/ApplicationCode/Application/RIPreferences.h +++ b/ApplicationCode/Application/RIPreferences.h @@ -21,16 +21,16 @@ #include "cafPdmObject.h" #include "RIApplication.h" -class RIPreferences : public caf::PdmObject +class RiaPreferences : public caf::PdmObject { CAF_PDM_HEADER_INIT; public: - RIPreferences(void); - virtual ~RIPreferences(void); + RiaPreferences(void); + virtual ~RiaPreferences(void); public: // Pdm Fields - caf::PdmField > navigationPolicy; + caf::PdmField > navigationPolicy; caf::PdmField scriptDirectory; caf::PdmField scriptEditorExecutable; diff --git a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp index 4237879b55..b7467f4010 100644 --- a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp @@ -188,7 +188,7 @@ bool RimInputCase::openEclipseGridFile() } - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); if (app->preferences()->autocomputeDepthRelatedProperties) { RimReservoirCellResultsStorage* matrixResults = results(RifReaderInterface::MATRIX_RESULTS); diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 212978843f..c815de5054 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -82,7 +82,7 @@ void RimProject::initAfterRead() // // TODO : Must store content of scripts in project file and notify user if stored content is different from disk on execute and edit // - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); QString scriptDirectory = app->scriptDirectory(); this->setUserScriptPath(scriptDirectory); diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp index 07e7ea5942..7c08fa8084 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp @@ -188,7 +188,7 @@ QString RimReservoirCellResultsStorage::getValidCacheFileName() QString RimReservoirCellResultsStorage::getCacheDirectoryPath() { QString cacheDirPath; - QString projectFileName = RIApplication::instance()->project()->fileName(); + QString projectFileName = RiaApplication::instance()->project()->fileName(); QFileInfo fileInfo(projectFileName); cacheDirPath = fileInfo.canonicalPath(); cacheDirPath += "/" + fileInfo.completeBaseName() + "_cache"; diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp index 8cb8eea24a..dd25274ef8 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp @@ -82,8 +82,8 @@ CAF_PDM_SOURCE_INIT(RimReservoirView, "ReservoirView"); //-------------------------------------------------------------------------------------------------- RimReservoirView::RimReservoirView() { - RIApplication* app = RIApplication::instance(); - RIPreferences* preferences = app->preferences(); + RiaApplication* app = RiaApplication::instance(); + RiaPreferences* preferences = app->preferences(); CVF_ASSERT(preferences); CAF_PDM_InitObject("Reservoir View", ":/ReservoirView.png", "", ""); @@ -192,7 +192,7 @@ void RimReservoirView::updateViewerWidget() if (!m_viewer) { QGLFormat glFormat; - glFormat.setDirectRendering(RIApplication::instance()->useShaders()); + glFormat.setDirectRendering(RiaApplication::instance()->useShaders()); m_viewer = new RIViewer(glFormat, NULL); m_viewer->setOwnerReservoirView(this); @@ -204,7 +204,7 @@ void RimReservoirView::updateViewerWidget() m_viewer->setColorLegend1(this->cellResult()->legendConfig->legend()); m_viewer->setColorLegend2(this->cellEdgeResult()->legendConfig->legend()); - if (RIApplication::instance()->navigationPolicy() == RIApplication::NAVIGATION_POLICY_CEETRON) + if (RiaApplication::instance()->navigationPolicy() == RiaApplication::NAVIGATION_POLICY_CEETRON) { m_viewer->setNavigationPolicy(new caf::CeetronNavigation); } @@ -213,7 +213,7 @@ void RimReservoirView::updateViewerWidget() m_viewer->setNavigationPolicy(new caf::CadNavigation); } - m_viewer->enablePerfInfoHud(RIApplication::instance()->showPerformanceInfo()); + m_viewer->enablePerfInfoHud(RiaApplication::instance()->showPerformanceInfo()); //m_viewer->layoutWidget()->showMaximized(); @@ -708,7 +708,7 @@ void RimReservoirView::loadDataAndUpdate() } else { - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); if (app->preferences()->autocomputeSOIL) { RimReservoirCellResultsStorage* results = currentGridCellResults(); diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index a1395c0234..fa67077eb4 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -238,7 +238,7 @@ void RimUiTreeModelPdm::deleteReservoir(RimCase* reservoir) } else { - RimProject* proj = RIApplication::instance()->project(); + RimProject* proj = RiaApplication::instance()->project(); proj->removeCaseFromAllGroups(reservoir); } @@ -388,7 +388,7 @@ RimReservoirView* RimUiTreeModelPdm::addReservoirView(const QModelIndex& itemInd //-------------------------------------------------------------------------------------------------- void RimUiTreeModelPdm::updateScriptPaths() { - RimProject* proj = RIApplication::instance()->project(); + RimProject* proj = RiaApplication::instance()->project(); if (!proj || !proj->scriptCollection()) return; @@ -408,7 +408,7 @@ void RimUiTreeModelPdm::updateScriptPaths() //-------------------------------------------------------------------------------------------------- void RimUiTreeModelPdm::slotRefreshScriptTree(QString path) { - RimProject* proj = RIApplication::instance()->project(); + RimProject* proj = RiaApplication::instance()->project(); if (!proj || !proj->scriptCollection()) return; @@ -535,7 +535,7 @@ RimStatisticsCase* RimUiTreeModelPdm::addStatisticalCalculation(const QModelInde //-------------------------------------------------------------------------------------------------- RimIdenticalGridCaseGroup* RimUiTreeModelPdm::addCaseGroup(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex) { - RimProject* proj = RIApplication::instance()->project(); + RimProject* proj = RiaApplication::instance()->project(); CVF_ASSERT(proj); caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex); @@ -570,7 +570,7 @@ RimIdenticalGridCaseGroup* RimUiTreeModelPdm::addCaseGroup(const QModelIndex& it //-------------------------------------------------------------------------------------------------- void RimUiTreeModelPdm::addObjects(const QModelIndex& itemIndex, caf::PdmObjectGroup& pdmObjects) { - RimProject* proj = RIApplication::instance()->project(); + RimProject* proj = RiaApplication::instance()->project(); CVF_ASSERT(proj); caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex); diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index db0db569b6..512ce8eb6f 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -117,7 +117,7 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event) } else if (dynamic_cast(uiItem->dataObject().p())) { - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); QMenu menu; { @@ -425,7 +425,7 @@ void RimUiTreeView::slotEditScript() { RimCalcScript* calcScript = dynamic_cast(uiItem->dataObject().p()); - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); QString scriptEditor = app->scriptEditorPath(); if (!scriptEditor.isEmpty()) { @@ -482,7 +482,7 @@ void RimUiTreeView::slotNewScript() num++; } - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); QString scriptEditor = app->scriptEditorPath(); if (!scriptEditor.isEmpty()) { @@ -512,7 +512,7 @@ void RimUiTreeView::slotExecuteScript() { RimCalcScript* calcScript = dynamic_cast(uiItem->dataObject().p()); - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); QString octavePath = app->octavePath(); if (!octavePath.isEmpty()) { @@ -539,7 +539,7 @@ void RimUiTreeView::slotExecuteScript() arguments.append("-q"); arguments << calcScript->absolutePath(); - RIApplication::instance()->launchProcess(octavePath, arguments); + RiaApplication::instance()->launchProcess(octavePath, arguments); } } } @@ -568,7 +568,7 @@ void RimUiTreeView::slotDeleteView() { myModel->deleteReservoirView(currentIndex()); - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); app->setActiveReservoirView(NULL); } } @@ -618,7 +618,7 @@ void RimUiTreeView::setModel(QAbstractItemModel* model) //-------------------------------------------------------------------------------------------------- void RimUiTreeView::slotAddInputProperty() { - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->defaultFileDialogDirectory("INPUT_FILES"); QStringList fileNames = QFileDialog::getOpenFileNames(this, "Select Eclipse Input Property Files", defaultDir, "All Files (*.* *)"); @@ -707,7 +707,7 @@ void RimUiTreeView::slotWriteInputProperty() { QString projectFolder; - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); QString projectFileName = app->currentProjectFileName(); if (!projectFileName.isEmpty()) { @@ -760,7 +760,7 @@ void RimUiTreeView::slotWriteBinaryResultAsInputProperty() { QString projectFolder; - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); QString projectFileName = app->currentProjectFileName(); if (!projectFileName.isEmpty()) { diff --git a/ApplicationCode/RIMain.cpp b/ApplicationCode/RIMain.cpp index 1c877ae238..97f82a642f 100644 --- a/ApplicationCode/RIMain.cpp +++ b/ApplicationCode/RIMain.cpp @@ -23,7 +23,7 @@ int main(int argc, char *argv[]) { - RIApplication app(argc, argv); + RiaApplication app(argc, argv); QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates)); diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.cpp b/ApplicationCode/SocketInterface/RiaSocketServer.cpp index 092aece862..4fd4768d08 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.cpp +++ b/ApplicationCode/SocketInterface/RiaSocketServer.cpp @@ -155,14 +155,14 @@ RimCase* RiaSocketServer::findReservoir(const QString& caseName) { if (caseName.isEmpty()) { - if (RIApplication::instance()->activeReservoirView()) + if (RiaApplication::instance()->activeReservoirView()) { - return RIApplication::instance()->activeReservoirView()->eclipseCase(); + return RiaApplication::instance()->activeReservoirView()->eclipseCase(); } } else { - RimProject* project = RIApplication::instance()->project(); + RimProject* project = RiaApplication::instance()->project(); if (!project) return NULL; bool isInt = false; diff --git a/ApplicationCode/UserInterface/RIMainWindow.cpp b/ApplicationCode/UserInterface/RIMainWindow.cpp index 5073f1b446..742f939ec2 100644 --- a/ApplicationCode/UserInterface/RIMainWindow.cpp +++ b/ApplicationCode/UserInterface/RIMainWindow.cpp @@ -96,7 +96,7 @@ RIMainWindow::RIMainWindow() slotRefreshEditActions(); // Set pdm root so scripts are displayed - setPdmRoot(RIApplication::instance()->project()); + setPdmRoot(RiaApplication::instance()->project()); } @@ -116,7 +116,7 @@ void RIMainWindow::initializeGuiNewProjectLoaded() slotRefreshFileActions(); slotRefreshEditActions(); refreshAnimationActions(); - setPdmRoot(RIApplication::instance()->project()); + setPdmRoot(RiaApplication::instance()->project()); } //-------------------------------------------------------------------------------------------------- @@ -157,7 +157,7 @@ void RIMainWindow::refreshToolbars() //-------------------------------------------------------------------------------------------------- void RIMainWindow::closeEvent(QCloseEvent* event) { - if (!RIApplication::instance()->closeProject(true)) + if (!RiaApplication::instance()->closeProject(true)) { event->ignore(); return; @@ -486,7 +486,7 @@ void RIMainWindow::setResultInfo(const QString& info) const //-------------------------------------------------------------------------------------------------- void RIMainWindow::slotRefreshFileActions() { - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); bool projectExists = true; m_saveProjectAction->setEnabled(projectExists); @@ -528,9 +528,9 @@ void RIMainWindow::slotRefreshViewActions() void RIMainWindow::refreshAnimationActions() { caf::FrameAnimationControl* ac = NULL; - if (RIApplication::instance()->activeReservoirView() && RIApplication::instance()->activeReservoirView()->viewer()) + if (RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer()) { - ac = RIApplication::instance()->activeReservoirView()->viewer()->animationControl(); + ac = RiaApplication::instance()->activeReservoirView()->viewer()->animationControl(); } m_animationToolBar->connectAnimationControl(ac); @@ -538,7 +538,7 @@ void RIMainWindow::refreshAnimationActions() QStringList timeStepStrings; int currentTimeStepIndex = 0; - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); bool enableAnimControls = false; if (app->activeReservoirView() && @@ -573,7 +573,7 @@ void RIMainWindow::refreshAnimationActions() { timeStepStrings += timeStepDates[i].toString(formatString); } - currentTimeStepIndex = RIApplication::instance()->activeReservoirView()->currentTimeStep(); + currentTimeStepIndex = RiaApplication::instance()->activeReservoirView()->currentTimeStep(); } else { @@ -598,7 +598,7 @@ void RIMainWindow::slotAbout() cvfqt::BasicAboutDialog dlg(this); dlg.setApplicationName(RI_APPLICATION_NAME); - dlg.setApplicationVersion(RIApplication::getVersionStringApp(true)); + dlg.setApplicationVersion(RiaApplication::getVersionStringApp(true)); dlg.setCopyright("Copyright 2012 Statoil ASA, Ceetron AS"); dlg.showCeeVizVersion(false); @@ -630,7 +630,7 @@ void RIMainWindow::slotOpenBinaryGridFiles() { if (checkForDocumentModifications()) { - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->defaultFileDialogDirectory("BINARY_GRID"); QStringList fileNames = QFileDialog::getOpenFileNames(this, "Open Eclipse File", defaultDir, "Eclipse Grid Files (*.GRID *.EGRID)"); @@ -658,7 +658,7 @@ void RIMainWindow::slotOpenInputFiles() { if (checkForDocumentModifications()) { - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->defaultFileDialogDirectory("INPUT_FILES"); QStringList fileNames = QFileDialog::getOpenFileNames(this, "Open Eclipse Input Files", defaultDir, "Eclipse Input Files and Input Properties (*.GRDECL *)"); @@ -679,7 +679,7 @@ void RIMainWindow::slotOpenProject() { if (checkForDocumentModifications()) { - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->defaultFileDialogDirectory("BINARY_GRID"); QString fileName = QFileDialog::getOpenFileName(this, "Open ResInsight Project", defaultDir, "ResInsight project (*.rip)"); @@ -699,7 +699,7 @@ void RIMainWindow::slotOpenProject() //-------------------------------------------------------------------------------------------------- void RIMainWindow::slotOpenLastUsedProject() { - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); app->loadLastUsedProject(); } @@ -708,7 +708,7 @@ void RIMainWindow::slotOpenLastUsedProject() //-------------------------------------------------------------------------------------------------- void RIMainWindow::slotMockModel() { - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); app->createMockModel(); //m_mainViewer->setDefaultView(); @@ -719,7 +719,7 @@ void RIMainWindow::slotMockModel() //-------------------------------------------------------------------------------------------------- void RIMainWindow::slotMockResultsModel() { - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); app->createResultsMockModel(); //m_mainViewer->setDefaultView(); @@ -731,7 +731,7 @@ void RIMainWindow::slotMockResultsModel() //-------------------------------------------------------------------------------------------------- void RIMainWindow::slotMockLargeResultsModel() { - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); app->createLargeResultsMockModel(); } @@ -741,7 +741,7 @@ void RIMainWindow::slotMockLargeResultsModel() //-------------------------------------------------------------------------------------------------- void RIMainWindow::slotInputMockModel() { - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); app->createInputMockModel(); } @@ -751,7 +751,7 @@ void RIMainWindow::slotInputMockModel() //-------------------------------------------------------------------------------------------------- void RIMainWindow::slotSetCurrentFrame(int frameIndex) { - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); // app->setTimeStep(frameIndex); } @@ -760,7 +760,7 @@ void RIMainWindow::slotSetCurrentFrame(int frameIndex) //-------------------------------------------------------------------------------------------------- bool RIMainWindow::checkForDocumentModifications() { - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); // RISceneManager* project = app->sceneManager(); // if (project && project->isModified()) // { @@ -790,7 +790,7 @@ bool RIMainWindow::checkForDocumentModifications() //-------------------------------------------------------------------------------------------------- void RIMainWindow::slotCloseProject() { - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); bool ret = app->closeProject(true); } @@ -854,7 +854,7 @@ void RIMainWindow::addViewer(RIViewer* viewer) //-------------------------------------------------------------------------------------------------- void RIMainWindow::slotSaveProject() { - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); app->saveProject(); } @@ -864,7 +864,7 @@ void RIMainWindow::slotSaveProject() //-------------------------------------------------------------------------------------------------- void RIMainWindow::slotSaveProjectAs() { - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); app->saveProjectPromptForFileName(); } @@ -893,9 +893,9 @@ void RIMainWindow::setPdmRoot(caf::PdmObject* pdmRoot) //-------------------------------------------------------------------------------------------------- void RIMainWindow::slotViewFromNorth() { - if (RIApplication::instance()->activeReservoirView() && RIApplication::instance()->activeReservoirView()->viewer()) + if (RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer()) { - RIApplication::instance()->activeReservoirView()->viewer()->setView(cvf::Vec3d(0,-1,0), cvf::Vec3d(0,0,1)); + RiaApplication::instance()->activeReservoirView()->viewer()->setView(cvf::Vec3d(0,-1,0), cvf::Vec3d(0,0,1)); } } @@ -904,9 +904,9 @@ void RIMainWindow::slotViewFromNorth() //-------------------------------------------------------------------------------------------------- void RIMainWindow::slotViewFromSouth() { - if (RIApplication::instance()->activeReservoirView() && RIApplication::instance()->activeReservoirView()->viewer()) + if (RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer()) { - RIApplication::instance()->activeReservoirView()->viewer()->setView(cvf::Vec3d(0,1,0), cvf::Vec3d(0,0,1)); + RiaApplication::instance()->activeReservoirView()->viewer()->setView(cvf::Vec3d(0,1,0), cvf::Vec3d(0,0,1)); } } @@ -915,9 +915,9 @@ void RIMainWindow::slotViewFromSouth() //-------------------------------------------------------------------------------------------------- void RIMainWindow::slotViewFromEast() { - if (RIApplication::instance()->activeReservoirView() && RIApplication::instance()->activeReservoirView()->viewer()) + if (RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer()) { - RIApplication::instance()->activeReservoirView()->viewer()->setView(cvf::Vec3d(-1,0,0), cvf::Vec3d(0,0,1)); + RiaApplication::instance()->activeReservoirView()->viewer()->setView(cvf::Vec3d(-1,0,0), cvf::Vec3d(0,0,1)); } } @@ -926,9 +926,9 @@ void RIMainWindow::slotViewFromEast() //-------------------------------------------------------------------------------------------------- void RIMainWindow::slotViewFromWest() { - if (RIApplication::instance()->activeReservoirView() && RIApplication::instance()->activeReservoirView()->viewer()) + if (RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer()) { - RIApplication::instance()->activeReservoirView()->viewer()->setView(cvf::Vec3d(1,0,0), cvf::Vec3d(0,0,1)); + RiaApplication::instance()->activeReservoirView()->viewer()->setView(cvf::Vec3d(1,0,0), cvf::Vec3d(0,0,1)); } } @@ -937,9 +937,9 @@ void RIMainWindow::slotViewFromWest() //-------------------------------------------------------------------------------------------------- void RIMainWindow::slotViewFromAbove() { - if (RIApplication::instance()->activeReservoirView() && RIApplication::instance()->activeReservoirView()->viewer()) + if (RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer()) { - RIApplication::instance()->activeReservoirView()->viewer()->setView(cvf::Vec3d(0,0,-1), cvf::Vec3d(0,1,0)); + RiaApplication::instance()->activeReservoirView()->viewer()->setView(cvf::Vec3d(0,0,-1), cvf::Vec3d(0,1,0)); } } @@ -948,9 +948,9 @@ void RIMainWindow::slotViewFromAbove() //-------------------------------------------------------------------------------------------------- void RIMainWindow::slotViewFromBelow() { - if (RIApplication::instance()->activeReservoirView() && RIApplication::instance()->activeReservoirView()->viewer()) + if (RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer()) { - RIApplication::instance()->activeReservoirView()->viewer()->setView(cvf::Vec3d(0,0,1), cvf::Vec3d(0,1,0)); + RiaApplication::instance()->activeReservoirView()->viewer()->setView(cvf::Vec3d(0,0,1), cvf::Vec3d(0,1,0)); } } @@ -959,9 +959,9 @@ void RIMainWindow::slotViewFromBelow() //-------------------------------------------------------------------------------------------------- void RIMainWindow::slotZoomAll() { - if (RIApplication::instance()->activeReservoirView() && RIApplication::instance()->activeReservoirView()->viewer()) + if (RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer()) { - RIApplication::instance()->activeReservoirView()->viewer()->zoomAll(); + RiaApplication::instance()->activeReservoirView()->viewer()->zoomAll(); } } @@ -970,7 +970,7 @@ void RIMainWindow::slotZoomAll() //-------------------------------------------------------------------------------------------------- void RIMainWindow::slotSubWindowActivated(QMdiSubWindow* subWindow) { - RimProject * proj = RIApplication::instance()->project(); + RimProject * proj = RiaApplication::instance()->project(); if (!proj) return; size_t i; @@ -989,8 +989,8 @@ void RIMainWindow::slotSubWindowActivated(QMdiSubWindow* subWindow) riv->viewer()->layoutWidget() && riv->viewer()->layoutWidget()->parent() == subWindow) { - RimReservoirView* previousActiveReservoirView = RIApplication::instance()->activeReservoirView(); - RIApplication::instance()->setActiveReservoirView(riv); + RimReservoirView* previousActiveReservoirView = RiaApplication::instance()->activeReservoirView(); + RiaApplication::instance()->setActiveReservoirView(riv); if (previousActiveReservoirView && previousActiveReservoirView != riv) { QModelIndex previousViewModelIndex = m_treeModelPdm->getModelIndexFromPdmObject(previousActiveReservoirView); @@ -1052,7 +1052,7 @@ void RIMainWindow::slotSubWindowActivated(QMdiSubWindow* subWindow) //-------------------------------------------------------------------------------------------------- void RIMainWindow::slotUseShaders(bool enable) { - RIApplication::instance()->setUseShaders(enable); + RiaApplication::instance()->setUseShaders(enable); } //-------------------------------------------------------------------------------------------------- @@ -1060,7 +1060,7 @@ void RIMainWindow::slotUseShaders(bool enable) //-------------------------------------------------------------------------------------------------- void RIMainWindow::slotShowPerformanceInfo(bool enable) { - RIApplication::instance()->setShowPerformanceInfo(enable); + RiaApplication::instance()->setShowPerformanceInfo(enable); } //-------------------------------------------------------------------------------------------------- @@ -1068,7 +1068,7 @@ void RIMainWindow::slotShowPerformanceInfo(bool enable) //-------------------------------------------------------------------------------------------------- void RIMainWindow::slotRefreshDebugActions() { - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); } //-------------------------------------------------------------------------------------------------- @@ -1076,7 +1076,7 @@ void RIMainWindow::slotRefreshDebugActions() //-------------------------------------------------------------------------------------------------- void RIMainWindow::slotEditPreferences() { - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); RIPreferencesDialog preferencesDialog(this, app->preferences(), "Preferences"); if (preferencesDialog.exec() == QDialog::Accepted) { @@ -1105,9 +1105,9 @@ void RIMainWindow::setActiveViewer(RIViewer* viewer) //-------------------------------------------------------------------------------------------------- void RIMainWindow::slotFramerateChanged(double frameRate) { - if (RIApplication::instance()->activeReservoirView() != NULL) + if (RiaApplication::instance()->activeReservoirView() != NULL) { - RIApplication::instance()->activeReservoirView()->maximumFrameRate.setValueFromUi(QVariant(frameRate)); + RiaApplication::instance()->activeReservoirView()->maximumFrameRate.setValueFromUi(QVariant(frameRate)); } } @@ -1141,7 +1141,7 @@ void RIMainWindow::slotBuildWindowActions() //-------------------------------------------------------------------------------------------------- void RIMainWindow::slotCurrentChanged(const QModelIndex & current, const QModelIndex & previous) { - RimReservoirView* activeReservoirView = RIApplication::instance()->activeReservoirView(); + RimReservoirView* activeReservoirView = RiaApplication::instance()->activeReservoirView(); QModelIndex activeViewModelIndex = m_treeModelPdm->getModelIndexFromPdmObject(activeReservoirView); QModelIndex tmp = current; @@ -1159,7 +1159,7 @@ void RIMainWindow::slotCurrentChanged(const QModelIndex & current, const QModelI // show new reservoir view and set this as activate view if (rimReservoirView != activeReservoirView) { - RIApplication::instance()->setActiveReservoirView(rimReservoirView); + RiaApplication::instance()->setActiveReservoirView(rimReservoirView); // Set focus in MDI area to this window if it exists if (rimReservoirView->viewer()) @@ -1225,7 +1225,7 @@ void RIMainWindow::slotNewObjectPropertyView() //-------------------------------------------------------------------------------------------------- void RIMainWindow::slotSnapshotToFile() { - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); app->saveSnapshotPromtpForFilename(); } @@ -1235,7 +1235,7 @@ void RIMainWindow::slotSnapshotToFile() //-------------------------------------------------------------------------------------------------- void RIMainWindow::slotSnapshotToClipboard() { - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); app->copySnapshotToClipboard(); } @@ -1245,7 +1245,7 @@ void RIMainWindow::slotSnapshotToClipboard() //-------------------------------------------------------------------------------------------------- void RIMainWindow::slotSnapshotAllViewsToFile() { - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); app->saveSnapshotForAllViews("snapshots"); } @@ -1269,7 +1269,7 @@ void RIMainWindow::hideAllDockWindows() //-------------------------------------------------------------------------------------------------- void RIMainWindow::slotOpenMultipleCases() { - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); /* RiuMultiCaseImportDialog dialog; diff --git a/ApplicationCode/UserInterface/RIProcessMonitor.cpp b/ApplicationCode/UserInterface/RIProcessMonitor.cpp index c46a6a3fc9..f03f9919e4 100644 --- a/ApplicationCode/UserInterface/RIProcessMonitor.cpp +++ b/ApplicationCode/UserInterface/RIProcessMonitor.cpp @@ -192,7 +192,7 @@ void RIProcessMonitor::slotTerminateProcess() { addStringToLog("Process terminated by user\n"); - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); app->terminateProcess(); } diff --git a/ApplicationCode/UserInterface/RIViewer.cpp b/ApplicationCode/UserInterface/RIViewer.cpp index 6187c278f7..8d4ee50c75 100644 --- a/ApplicationCode/UserInterface/RIViewer.cpp +++ b/ApplicationCode/UserInterface/RIViewer.cpp @@ -219,7 +219,7 @@ void RIViewer::mouseReleaseEvent(QMouseEvent* event) // Get the currently set button press action // We get it here since left click performs it, while we let a clean right click cancel it - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); // Picking if (event->button() == Qt::LeftButton) @@ -248,7 +248,7 @@ void RIViewer::keyPressEvent(QKeyEvent* event) //-------------------------------------------------------------------------------------------------- void RIViewer::handlePickAction(int winPosX, int winPosY) { - RIApplication* app = RIApplication::instance(); + RiaApplication* app = RiaApplication::instance(); RIMainWindow* mainWnd = RIMainWindow::instance(); if (!mainWnd) return; diff --git a/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp b/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp index dd2e77ebc9..8f584e8b20 100644 --- a/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp +++ b/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp @@ -95,7 +95,7 @@ RiuMultiCaseImportDialog::~RiuMultiCaseImportDialog() //-------------------------------------------------------------------------------------------------- void RiuMultiCaseImportDialog::on_m_addSearchFolderButton_clicked() { - QString selectedFolder = QFileDialog::getExistingDirectory(this, "Select an Eclipse case search folder", RIApplication::instance()->defaultFileDialogDirectory("MULTICASEIMPORT")); + QString selectedFolder = QFileDialog::getExistingDirectory(this, "Select an Eclipse case search folder", RiaApplication::instance()->defaultFileDialogDirectory("MULTICASEIMPORT")); QStringList folderNames = m_searchFolders->stringList(); if (!folderNames.contains(selectedFolder)) @@ -105,7 +105,7 @@ void RiuMultiCaseImportDialog::on_m_addSearchFolderButton_clicked() updateGridFileList(); } - RIApplication::instance()->setDefaultFileDialogDirectory("MULTICASEIMPORT", selectedFolder); + RiaApplication::instance()->setDefaultFileDialogDirectory("MULTICASEIMPORT", selectedFolder); } //-------------------------------------------------------------------------------------------------- From 27647248ea7a6540432000573b12ea9de1e7eaa6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 22 Mar 2013 16:12:00 +0100 Subject: [PATCH 166/242] Rename of files: RIBaseDefs RiaBaseDefs RIVersionInfo RiaVersionInfo RIMain RiaMain RIStdInclude RiaStdInclude p4#: 21067 --- ApplicationCode/Adm/{RIBaseDefs.h => RiaBaseDefs.h} | 0 ...{RIVersionInfo.h.cmake => RiaVersionInfo.h.cmake} | 0 ApplicationCode/Application/RIApplication.cpp | 6 +++--- ApplicationCode/Application/RIPreferences.cpp | 2 +- ApplicationCode/CMakeLists.txt | 12 ++++++------ .../RifReaderEclipseOutput-Test.cpp | 2 +- .../FileInterface/FileInterface_UnitTests/main.cpp | 2 +- ApplicationCode/FileInterface/RifReaderMockModel.cpp | 2 +- .../RivCellEdgeEffectGenerator.cpp | 2 +- .../ModelVisualization/RivGridPartMgr.cpp | 2 +- .../ModelVisualization/RivReservoirPartMgr.cpp | 2 +- .../ModelVisualization/RivReservoirPipesPartMgr.cpp | 2 +- .../ModelVisualization/RivReservoirViewPartMgr.cpp | 2 +- .../ProjectDataModel/Rim3dOverlayInfoConfig.cpp | 2 +- .../ProjectDataModel/RimBinaryExportSettings.cpp | 2 +- ApplicationCode/ProjectDataModel/RimCalcScript.cpp | 2 +- .../ProjectDataModel/RimCaseCollection.cpp | 2 +- .../ProjectDataModel/RimCellEdgeResultSlot.cpp | 2 +- ApplicationCode/ProjectDataModel/RimCellFilter.cpp | 2 +- .../ProjectDataModel/RimCellPropertyFilter.cpp | 2 +- .../RimCellPropertyFilterCollection.cpp | 2 +- .../ProjectDataModel/RimCellRangeFilter.cpp | 2 +- .../RimCellRangeFilterCollection.cpp | 2 +- ApplicationCode/ProjectDataModel/RimDefines.cpp | 2 +- .../RimExportInputPropertySettings.cpp | 2 +- .../ProjectDataModel/RimIdenticalGridCaseGroup.cpp | 2 +- .../ProjectDataModel/RimInputProperty.cpp | 2 +- .../ProjectDataModel/RimInputPropertyCollection.cpp | 2 +- .../ProjectDataModel/RimInputReservoir.cpp | 2 +- ApplicationCode/ProjectDataModel/RimLegendConfig.cpp | 2 +- ApplicationCode/ProjectDataModel/RimProject.cpp | 4 ++-- ApplicationCode/ProjectDataModel/RimReservoir.cpp | 2 +- .../RimReservoirCellResultsCacher.cpp | 2 +- .../ProjectDataModel/RimReservoirView.cpp | 2 +- .../ProjectDataModel/RimResultDefinition.cpp | 2 +- .../ProjectDataModel/RimResultReservoir.cpp | 2 +- ApplicationCode/ProjectDataModel/RimResultSlot.cpp | 2 +- .../ProjectDataModel/RimScriptCollection.cpp | 2 +- .../ProjectDataModel/RimStatisticsCase.cpp | 2 +- .../ProjectDataModel/RimStatisticsCaseCollection.cpp | 2 +- .../ProjectDataModel/RimStatisticsCaseEvaluator.cpp | 2 +- .../ProjectDataModel/RimUiTreeModelPdm.cpp | 2 +- ApplicationCode/ProjectDataModel/RimUiTreeView.cpp | 2 +- ApplicationCode/ProjectDataModel/RimWell.cpp | 2 +- .../ProjectDataModel/RimWellCollection.cpp | 2 +- .../RigReservoir-Test.cpp | 2 +- .../ReservoirDataModel_UnitTests/main.cpp | 2 +- ApplicationCode/{RIMain.cpp => RiaMain.cpp} | 2 +- .../{RIStdInclude.cpp => RiaStdInclude.cpp} | 2 +- ApplicationCode/{RIStdInclude.h => RiaStdInclude.h} | 0 ApplicationCode/SocketInterface/RiaSocketServer.cpp | 2 +- ApplicationCode/UserInterface/RICursors.cpp | 2 +- ApplicationCode/UserInterface/RIMainWindow.cpp | 4 ++-- .../UserInterface/RIPreferencesDialog.cpp | 2 +- ApplicationCode/UserInterface/RIProcessMonitor.cpp | 2 +- ApplicationCode/UserInterface/RIResultInfoPanel.cpp | 2 +- ApplicationCode/UserInterface/RIViewer.cpp | 2 +- 57 files changed, 63 insertions(+), 63 deletions(-) rename ApplicationCode/Adm/{RIBaseDefs.h => RiaBaseDefs.h} (100%) rename ApplicationCode/Adm/{RIVersionInfo.h.cmake => RiaVersionInfo.h.cmake} (100%) rename ApplicationCode/{RIMain.cpp => RiaMain.cpp} (97%) rename ApplicationCode/{RIStdInclude.cpp => RiaStdInclude.cpp} (96%) rename ApplicationCode/{RIStdInclude.h => RiaStdInclude.h} (100%) diff --git a/ApplicationCode/Adm/RIBaseDefs.h b/ApplicationCode/Adm/RiaBaseDefs.h similarity index 100% rename from ApplicationCode/Adm/RIBaseDefs.h rename to ApplicationCode/Adm/RiaBaseDefs.h diff --git a/ApplicationCode/Adm/RIVersionInfo.h.cmake b/ApplicationCode/Adm/RiaVersionInfo.h.cmake similarity index 100% rename from ApplicationCode/Adm/RIVersionInfo.h.cmake rename to ApplicationCode/Adm/RiaVersionInfo.h.cmake diff --git a/ApplicationCode/Application/RIApplication.cpp b/ApplicationCode/Application/RIApplication.cpp index c901516b03..5a052538d5 100644 --- a/ApplicationCode/Application/RIApplication.cpp +++ b/ApplicationCode/Application/RIApplication.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "cafLog.h" #include "cafEffectCache.h" @@ -26,8 +26,8 @@ #include "cvfStructGridGeometryGenerator.h" -#include "RIVersionInfo.h" -#include "RIBaseDefs.h" +#include "RiaVersionInfo.h" +#include "RiaBaseDefs.h" #include "RIApplication.h" #include "RIMainWindow.h" diff --git a/ApplicationCode/Application/RIPreferences.cpp b/ApplicationCode/Application/RIPreferences.cpp index 9d016682e5..ff7a9d082e 100644 --- a/ApplicationCode/Application/RIPreferences.cpp +++ b/ApplicationCode/Application/RIPreferences.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RIPreferences.h" #include "cafPdmUiFilePathEditor.h" diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index 23d6f03c15..382778e4c6 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -4,8 +4,8 @@ project (ApplicationCode) # NB: The generated file is written to Cmake binary folder to avoid source tree pollution # This folder is added to include_directories -CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/ApplicationCode/Adm/RIVersionInfo.h.cmake - ${CMAKE_BINARY_DIR}/Generated/RIVersionInfo.h +CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/ApplicationCode/Adm/RiaVersionInfo.h.cmake + ${CMAKE_BINARY_DIR}/Generated/RiaVersionInfo.h ) @@ -28,8 +28,8 @@ include_directories( file( GLOB_RECURSE HEADER_FILES *.h ) list( APPEND CPP_SOURCES - RIMain.cpp - RIStdInclude.cpp + RiaMain.cpp + RiaStdInclude.cpp ) list( APPEND CPP_SOURCES @@ -156,7 +156,7 @@ qt4_add_resources( QRC_FILES_CPP ${QRC_FILES} ) set( RAW_SOURCES ${CPP_SOURCES} ) list( REMOVE_ITEM RAW_SOURCES - RIStdInclude.cpp + RiaStdInclude.cpp ${CODE_SOURCE_FILES} @@ -190,7 +190,7 @@ set( ALL_INCLUDES ${QT_INCLUDES} ) -set( PCH_NAME RIStdInclude ) +set( PCH_NAME RiaStdInclude ) set( GCC_PCH_TARGET gccPCH ) set( PCH_COMPILER_DEFINE EMPTY ) IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux") diff --git a/ApplicationCode/FileInterface/FileInterface_UnitTests/RifReaderEclipseOutput-Test.cpp b/ApplicationCode/FileInterface/FileInterface_UnitTests/RifReaderEclipseOutput-Test.cpp index 797507e7af..ca210e8e0e 100644 --- a/ApplicationCode/FileInterface/FileInterface_UnitTests/RifReaderEclipseOutput-Test.cpp +++ b/ApplicationCode/FileInterface/FileInterface_UnitTests/RifReaderEclipseOutput-Test.cpp @@ -18,7 +18,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "gtest/gtest.h" #include "RigEclipseCase.h" diff --git a/ApplicationCode/FileInterface/FileInterface_UnitTests/main.cpp b/ApplicationCode/FileInterface/FileInterface_UnitTests/main.cpp index a28cfcc87f..03d89c0085 100644 --- a/ApplicationCode/FileInterface/FileInterface_UnitTests/main.cpp +++ b/ApplicationCode/FileInterface/FileInterface_UnitTests/main.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "cvfBase.h" diff --git a/ApplicationCode/FileInterface/RifReaderMockModel.cpp b/ApplicationCode/FileInterface/RifReaderMockModel.cpp index 1fe0b2d44b..659eba791f 100644 --- a/ApplicationCode/FileInterface/RifReaderMockModel.cpp +++ b/ApplicationCode/FileInterface/RifReaderMockModel.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RifReaderMockModel.h" #include "RigReservoirCellResults.h" diff --git a/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp b/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp index 3ffce80792..3a29b456f1 100644 --- a/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RivCellEdgeEffectGenerator.h" diff --git a/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp b/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp index 52fc9a050f..23bec7646b 100644 --- a/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RivGridPartMgr.h" #include "cvfPart.h" #include "cafEffectGenerator.h" diff --git a/ApplicationCode/ModelVisualization/RivReservoirPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirPartMgr.cpp index a7c48f705b..f6fdb6be0a 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirPartMgr.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RivReservoirPartMgr.h" #include "RivGridPartMgr.h" #include "cvfStructGrid.h" diff --git a/ApplicationCode/ModelVisualization/RivReservoirPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirPipesPartMgr.cpp index 4767910b98..156b3d572e 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirPipesPartMgr.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RivReservoirPipesPartMgr.h" #include "RimReservoirView.h" diff --git a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp index 95020a38bd..07fd3f524c 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RivReservoirViewPartMgr.h" #include "RivGridPartMgr.h" #include "RimReservoirView.h" diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index 005133ee9e..9f206d20da 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "Rim3dOverlayInfoConfig.h" #include "RimReservoirView.h" diff --git a/ApplicationCode/ProjectDataModel/RimBinaryExportSettings.cpp b/ApplicationCode/ProjectDataModel/RimBinaryExportSettings.cpp index 0a59a198b2..4d22f6ebe6 100644 --- a/ApplicationCode/ProjectDataModel/RimBinaryExportSettings.cpp +++ b/ApplicationCode/ProjectDataModel/RimBinaryExportSettings.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RimBinaryExportSettings.h" #include "cafPdmUiFilePathEditor.h" diff --git a/ApplicationCode/ProjectDataModel/RimCalcScript.cpp b/ApplicationCode/ProjectDataModel/RimCalcScript.cpp index 7794031863..f9f44a8f46 100644 --- a/ApplicationCode/ProjectDataModel/RimCalcScript.cpp +++ b/ApplicationCode/ProjectDataModel/RimCalcScript.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "cafPdmField.h" diff --git a/ApplicationCode/ProjectDataModel/RimCaseCollection.cpp b/ApplicationCode/ProjectDataModel/RimCaseCollection.cpp index 15d3d92682..0df12839a9 100644 --- a/ApplicationCode/ProjectDataModel/RimCaseCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimCaseCollection.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RimCaseCollection.h" diff --git a/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp b/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp index c2558cc09c..5f979fc9aa 100644 --- a/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RimCellEdgeResultSlot.h" #include "RimLegendConfig.h" diff --git a/ApplicationCode/ProjectDataModel/RimCellFilter.cpp b/ApplicationCode/ProjectDataModel/RimCellFilter.cpp index 0b7f188005..6e901ff774 100644 --- a/ApplicationCode/ProjectDataModel/RimCellFilter.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellFilter.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "cafAppEnum.h" diff --git a/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.cpp b/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.cpp index f1aad6768c..ec0bb22ff9 100644 --- a/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RimReservoirView.h" #include "RimCellPropertyFilter.h" diff --git a/ApplicationCode/ProjectDataModel/RimCellPropertyFilterCollection.cpp b/ApplicationCode/ProjectDataModel/RimCellPropertyFilterCollection.cpp index 828aad2447..b722e74013 100644 --- a/ApplicationCode/ProjectDataModel/RimCellPropertyFilterCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellPropertyFilterCollection.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RimCellPropertyFilterCollection.h" diff --git a/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp b/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp index d8c087a462..5a8b6fa7f8 100644 --- a/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RimCellRangeFilter.h" #include "RimCellRangeFilterCollection.h" diff --git a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp index 7118b05f70..eda15fa00f 100644 --- a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RimCellRangeFilterCollection.h" diff --git a/ApplicationCode/ProjectDataModel/RimDefines.cpp b/ApplicationCode/ProjectDataModel/RimDefines.cpp index 5002d0c42a..9fce926af4 100644 --- a/ApplicationCode/ProjectDataModel/RimDefines.cpp +++ b/ApplicationCode/ProjectDataModel/RimDefines.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RimDefines.h" #include "cafAppEnum.h" diff --git a/ApplicationCode/ProjectDataModel/RimExportInputPropertySettings.cpp b/ApplicationCode/ProjectDataModel/RimExportInputPropertySettings.cpp index f2f432b775..8a2e491420 100644 --- a/ApplicationCode/ProjectDataModel/RimExportInputPropertySettings.cpp +++ b/ApplicationCode/ProjectDataModel/RimExportInputPropertySettings.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RimExportInputPropertySettings.h" #include "cafPdmUiFilePathEditor.h" diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index 2a52911820..669a18cfd6 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -17,7 +17,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RimIdenticalGridCaseGroup.h" #include "RimReservoir.h" diff --git a/ApplicationCode/ProjectDataModel/RimInputProperty.cpp b/ApplicationCode/ProjectDataModel/RimInputProperty.cpp index f226a8673c..95936e5f54 100644 --- a/ApplicationCode/ProjectDataModel/RimInputProperty.cpp +++ b/ApplicationCode/ProjectDataModel/RimInputProperty.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RimInputProperty.h" diff --git a/ApplicationCode/ProjectDataModel/RimInputPropertyCollection.cpp b/ApplicationCode/ProjectDataModel/RimInputPropertyCollection.cpp index 4520653a03..5798253f13 100644 --- a/ApplicationCode/ProjectDataModel/RimInputPropertyCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimInputPropertyCollection.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RimInputPropertyCollection.h" diff --git a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp index b7467f4010..0505d4a9bd 100644 --- a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RimInputReservoir.h" #include "RimInputProperty.h" diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp index 625e8b0d48..a9d392c359 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RimLegendConfig.h" #include "RimReservoirView.h" diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index c815de5054..6338f58615 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -16,11 +16,11 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RimProject.h" #include "RIApplication.h" -#include "RIVersionInfo.h" +#include "RiaVersionInfo.h" #include "RigGridCollection.h" #include "RigEclipseCase.h" diff --git a/ApplicationCode/ProjectDataModel/RimReservoir.cpp b/ApplicationCode/ProjectDataModel/RimReservoir.cpp index 6492c47818..06aface17c 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoir.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RifReaderEclipseOutput.h" #include "RifReaderMockModel.h" diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp index 7c08fa8084..646535e92b 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RimReservoirCellResultsCacher.h" #include "RigReservoirCellResults.h" #include "RIApplication.h" diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp index dd25274ef8..32e13553a1 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RIViewer.h" #include "RimReservoirView.h" diff --git a/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp index cf741cd8a1..5c8cd7dce2 100644 --- a/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RimResultDefinition.h" diff --git a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp index 5cffbd67f6..af5270bcf8 100644 --- a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RimResultReservoir.h" #include "RigEclipseCase.h" #include "RifReaderEclipseOutput.h" diff --git a/ApplicationCode/ProjectDataModel/RimResultSlot.cpp b/ApplicationCode/ProjectDataModel/RimResultSlot.cpp index 9d1564a564..af785b0d19 100644 --- a/ApplicationCode/ProjectDataModel/RimResultSlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultSlot.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RimResultSlot.h" #include "RimLegendConfig.h" diff --git a/ApplicationCode/ProjectDataModel/RimScriptCollection.cpp b/ApplicationCode/ProjectDataModel/RimScriptCollection.cpp index f7e6a2e344..67cc034e78 100644 --- a/ApplicationCode/ProjectDataModel/RimScriptCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimScriptCollection.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RimScriptCollection.h" diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp index 8ccc043e15..502ad2adb1 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RimStatisticsCase.h" #include "RimReservoirView.h" diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCaseCollection.cpp b/ApplicationCode/ProjectDataModel/RimStatisticsCaseCollection.cpp index 59d5b11141..0d68ebdf07 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCaseCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCaseCollection.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RimReservoirView.h" diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.cpp b/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.cpp index b42379e4b4..888d5a6270 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.cpp @@ -15,7 +15,7 @@ // for more details. // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RimStatisticsCaseEvaluator.h" #include "RigReservoirCellResults.h" diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index fa67077eb4..aeb5cb84fa 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RimUiTreeModelPdm.h" #include "RimCellRangeFilter.h" diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index 512ce8eb6f..ebe3cb20d6 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "cafPdmDocument.h" diff --git a/ApplicationCode/ProjectDataModel/RimWell.cpp b/ApplicationCode/ProjectDataModel/RimWell.cpp index 59b8a9ea4e..893a3d13ae 100644 --- a/ApplicationCode/ProjectDataModel/RimWell.cpp +++ b/ApplicationCode/ProjectDataModel/RimWell.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "cafAppEnum.h" diff --git a/ApplicationCode/ProjectDataModel/RimWellCollection.cpp b/ApplicationCode/ProjectDataModel/RimWellCollection.cpp index 8e115ecde6..9258bcc7b9 100644 --- a/ApplicationCode/ProjectDataModel/RimWellCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellCollection.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "cafAppEnum.h" diff --git a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp index b6abc6c47e..e89724299d 100644 --- a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp +++ b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp @@ -18,7 +18,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "gtest/gtest.h" #include "RigEclipseCase.h" diff --git a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/main.cpp b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/main.cpp index fcfac10e30..00d12ebca0 100644 --- a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/main.cpp +++ b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/main.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "cvfBase.h" diff --git a/ApplicationCode/RIMain.cpp b/ApplicationCode/RiaMain.cpp similarity index 97% rename from ApplicationCode/RIMain.cpp rename to ApplicationCode/RiaMain.cpp index 97f82a642f..e31de5c92f 100644 --- a/ApplicationCode/RIMain.cpp +++ b/ApplicationCode/RiaMain.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RIApplication.h" #include "RIMainWindow.h" diff --git a/ApplicationCode/RIStdInclude.cpp b/ApplicationCode/RiaStdInclude.cpp similarity index 96% rename from ApplicationCode/RIStdInclude.cpp rename to ApplicationCode/RiaStdInclude.cpp index e14a6d73e2..2c78f30884 100644 --- a/ApplicationCode/RIStdInclude.cpp +++ b/ApplicationCode/RiaStdInclude.cpp @@ -16,5 +16,5 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" diff --git a/ApplicationCode/RIStdInclude.h b/ApplicationCode/RiaStdInclude.h similarity index 100% rename from ApplicationCode/RIStdInclude.h rename to ApplicationCode/RiaStdInclude.h diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.cpp b/ApplicationCode/SocketInterface/RiaSocketServer.cpp index 4fd4768d08..c4a21a8e90 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.cpp +++ b/ApplicationCode/SocketInterface/RiaSocketServer.cpp @@ -15,7 +15,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include #include diff --git a/ApplicationCode/UserInterface/RICursors.cpp b/ApplicationCode/UserInterface/RICursors.cpp index bdf913ec2a..87cf79d31f 100644 --- a/ApplicationCode/UserInterface/RICursors.cpp +++ b/ApplicationCode/UserInterface/RICursors.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RICursors.h" diff --git a/ApplicationCode/UserInterface/RIMainWindow.cpp b/ApplicationCode/UserInterface/RIMainWindow.cpp index 742f939ec2..70ac50f40b 100644 --- a/ApplicationCode/UserInterface/RIMainWindow.cpp +++ b/ApplicationCode/UserInterface/RIMainWindow.cpp @@ -16,8 +16,8 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" -#include "RIBaseDefs.h" +#include "RiaStdInclude.h" +#include "RiaBaseDefs.h" #include "RIApplication.h" #include "RIMainWindow.h" diff --git a/ApplicationCode/UserInterface/RIPreferencesDialog.cpp b/ApplicationCode/UserInterface/RIPreferencesDialog.cpp index c77785a99d..76c1d60f48 100644 --- a/ApplicationCode/UserInterface/RIPreferencesDialog.cpp +++ b/ApplicationCode/UserInterface/RIPreferencesDialog.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RIPreferencesDialog.h" #include "cafAppEnum.h" diff --git a/ApplicationCode/UserInterface/RIProcessMonitor.cpp b/ApplicationCode/UserInterface/RIProcessMonitor.cpp index f03f9919e4..5cf18846fe 100644 --- a/ApplicationCode/UserInterface/RIProcessMonitor.cpp +++ b/ApplicationCode/UserInterface/RIProcessMonitor.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RIProcessMonitor.h" #include "cafUiProcess.h" diff --git a/ApplicationCode/UserInterface/RIResultInfoPanel.cpp b/ApplicationCode/UserInterface/RIResultInfoPanel.cpp index 56ac7195ca..7ff0e84213 100644 --- a/ApplicationCode/UserInterface/RIResultInfoPanel.cpp +++ b/ApplicationCode/UserInterface/RIResultInfoPanel.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RIResultInfoPanel.h" diff --git a/ApplicationCode/UserInterface/RIViewer.cpp b/ApplicationCode/UserInterface/RIViewer.cpp index 8d4ee50c75..a91df2c78a 100644 --- a/ApplicationCode/UserInterface/RIViewer.cpp +++ b/ApplicationCode/UserInterface/RIViewer.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RIStdInclude.h" +#include "RiaStdInclude.h" #include "RIViewer.h" #include "RIApplication.h" From b903c7f8c29220b602c4df4a93e780b0ef3373dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 22 Mar 2013 16:24:42 +0100 Subject: [PATCH 167/242] Renamed files: RIApplication RiaApplication RIPreferences RiaPreferences p4#: 21068 --- .../Application/{RIApplication.cpp => RiaApplication.cpp} | 6 +++--- .../Application/{RIApplication.h => RiaApplication.h} | 0 .../Application/{RIPreferences.cpp => RiaPreferences.cpp} | 4 ++-- .../Application/{RIPreferences.h => RiaPreferences.h} | 2 +- ApplicationCode/CMakeLists.txt | 6 +++--- .../ProjectDataModel/RimIdenticalGridCaseGroup.cpp | 2 +- ApplicationCode/ProjectDataModel/RimInputReservoir.cpp | 4 ++-- ApplicationCode/ProjectDataModel/RimProject.cpp | 2 +- .../ProjectDataModel/RimReservoirCellResultsCacher.cpp | 2 +- ApplicationCode/ProjectDataModel/RimReservoirView.cpp | 4 ++-- ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp | 2 +- ApplicationCode/ProjectDataModel/RimUiTreeView.cpp | 2 +- ApplicationCode/RiaMain.cpp | 2 +- ApplicationCode/SocketInterface/RiaSocketServer.cpp | 2 +- ApplicationCode/UserInterface/RIMainWindow.cpp | 8 ++++---- ApplicationCode/UserInterface/RIProcessMonitor.cpp | 2 +- ApplicationCode/UserInterface/RIViewer.cpp | 2 +- .../UserInterface/RiuMultiCaseImportDialog.cpp | 2 +- 18 files changed, 27 insertions(+), 27 deletions(-) rename ApplicationCode/Application/{RIApplication.cpp => RiaApplication.cpp} (99%) rename ApplicationCode/Application/{RIApplication.h => RiaApplication.h} (100%) rename ApplicationCode/Application/{RIPreferences.cpp => RiaPreferences.cpp} (98%) rename ApplicationCode/Application/{RIPreferences.h => RiaPreferences.h} (98%) diff --git a/ApplicationCode/Application/RIApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp similarity index 99% rename from ApplicationCode/Application/RIApplication.cpp rename to ApplicationCode/Application/RiaApplication.cpp index 5a052538d5..78b8669482 100644 --- a/ApplicationCode/Application/RIApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -29,11 +29,11 @@ #include "RiaVersionInfo.h" #include "RiaBaseDefs.h" -#include "RIApplication.h" +#include "RiaApplication.h" #include "RIMainWindow.h" #include "RIViewer.h" #include "RIProcessMonitor.h" -#include "RIPreferences.h" +#include "RiaPreferences.h" #include "RimResultReservoir.h" #include "RimInputReservoir.h" @@ -83,7 +83,7 @@ namespace RegTestNames //================================================================================================== /// -/// \class RIApplication +/// \class RiaApplication /// /// Application class /// diff --git a/ApplicationCode/Application/RIApplication.h b/ApplicationCode/Application/RiaApplication.h similarity index 100% rename from ApplicationCode/Application/RIApplication.h rename to ApplicationCode/Application/RiaApplication.h diff --git a/ApplicationCode/Application/RIPreferences.cpp b/ApplicationCode/Application/RiaPreferences.cpp similarity index 98% rename from ApplicationCode/Application/RIPreferences.cpp rename to ApplicationCode/Application/RiaPreferences.cpp index ff7a9d082e..725e13a58c 100644 --- a/ApplicationCode/Application/RIPreferences.cpp +++ b/ApplicationCode/Application/RiaPreferences.cpp @@ -17,10 +17,10 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RiaStdInclude.h" -#include "RIPreferences.h" +#include "RiaPreferences.h" #include "cafPdmUiFilePathEditor.h" -CAF_PDM_SOURCE_INIT(RiaPreferences, "RIPreferences"); +CAF_PDM_SOURCE_INIT(RiaPreferences, "RiaPreferences"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/RIPreferences.h b/ApplicationCode/Application/RiaPreferences.h similarity index 98% rename from ApplicationCode/Application/RIPreferences.h rename to ApplicationCode/Application/RiaPreferences.h index 4bad994edc..367c8ddbde 100644 --- a/ApplicationCode/Application/RIPreferences.h +++ b/ApplicationCode/Application/RiaPreferences.h @@ -19,7 +19,7 @@ #pragma once #include "cafPdmObject.h" -#include "RIApplication.h" +#include "RiaApplication.h" class RiaPreferences : public caf::PdmObject { diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index 382778e4c6..077882c3c9 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -33,8 +33,8 @@ list( APPEND CPP_SOURCES ) list( APPEND CPP_SOURCES - Application/RIApplication.cpp - Application/RIPreferences.cpp + Application/RiaApplication.cpp + Application/RiaPreferences.cpp Application/RiaImageFileCompare.cpp Application/RiaImageCompareReporter.cpp ) @@ -110,7 +110,7 @@ list( APPEND CPP_SOURCES # Define files for MOC-ing set ( QT_MOC_HEADERS - Application/RIApplication.h + Application/RiaApplication.h ProjectDataModel/RimUiTreeModelPdm.h ProjectDataModel/RimUiTreeView.h diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index 669a18cfd6..b90230030b 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -135,7 +135,7 @@ caf::PdmFieldHandle* RimIdenticalGridCaseGroup::userDescriptionField() } //-------------------------------------------------------------------------------------------------- -/// Make sure changes in this functions is validated to RIApplication::addEclipseCases() +/// Make sure changes in this functions is validated to RiaApplication::addEclipseCases() //-------------------------------------------------------------------------------------------------- void RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo() { diff --git a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp index 0505d4a9bd..b3ad9f996f 100644 --- a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp @@ -34,8 +34,8 @@ #include "RifEclipseInputFileTools.h" #include "cafProgressInfo.h" -#include "RIApplication.h" -#include "RIPreferences.h" +#include "RiaApplication.h" +#include "RiaPreferences.h" CAF_PDM_SOURCE_INIT(RimInputCase, "RimInputReservoir"); diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 6338f58615..02a6faa56d 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -19,7 +19,7 @@ #include "RiaStdInclude.h" #include "RimProject.h" -#include "RIApplication.h" +#include "RiaApplication.h" #include "RiaVersionInfo.h" #include "RigGridCollection.h" diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp index 646535e92b..d005a7aef0 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp @@ -19,7 +19,7 @@ #include "RiaStdInclude.h" #include "RimReservoirCellResultsCacher.h" #include "RigReservoirCellResults.h" -#include "RIApplication.h" +#include "RiaApplication.h" #include "RigMainGrid.h" #include "RigCell.h" #include "cafProgressInfo.h" diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp index 32e13553a1..8e035ae6d7 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp @@ -23,8 +23,8 @@ #include "RIMainWindow.h" #include "RigGridBase.h" #include "RigEclipseCase.h" -#include "RIApplication.h" -#include "RIPreferences.h" +#include "RiaApplication.h" +#include "RiaPreferences.h" #include "cafEffectGenerator.h" #include "cafFrameAnimationControl.h" diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index aeb5cb84fa..f1cab1248a 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -29,7 +29,7 @@ #include "RimReservoirView.h" #include "RIViewer.h" #include "RimCalcScript.h" -#include "RIApplication.h" +#include "RiaApplication.h" #include "RIMainWindow.h" #include "RimInputProperty.h" #include "RimInputPropertyCollection.h" diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index ebe3cb20d6..26f19ca806 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -24,7 +24,7 @@ #include "RimUiTreeModelPdm.h" #include "RimReservoirView.h" #include "RimCalcScript.h" -#include "RIApplication.h" +#include "RiaApplication.h" #include "RIMainWindow.h" #include "RimInputPropertyCollection.h" #include "RimExportInputPropertySettings.h" diff --git a/ApplicationCode/RiaMain.cpp b/ApplicationCode/RiaMain.cpp index e31de5c92f..e00b61335c 100644 --- a/ApplicationCode/RiaMain.cpp +++ b/ApplicationCode/RiaMain.cpp @@ -17,7 +17,7 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RiaStdInclude.h" -#include "RIApplication.h" +#include "RiaApplication.h" #include "RIMainWindow.h" diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.cpp b/ApplicationCode/SocketInterface/RiaSocketServer.cpp index c4a21a8e90..ce47666001 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.cpp +++ b/ApplicationCode/SocketInterface/RiaSocketServer.cpp @@ -23,7 +23,7 @@ #include #include "RiaSocketServer.h" -#include "RIApplication.h" +#include "RiaApplication.h" #include "RIMainWindow.h" #include "RimReservoir.h" #include "RigEclipseCase.h" diff --git a/ApplicationCode/UserInterface/RIMainWindow.cpp b/ApplicationCode/UserInterface/RIMainWindow.cpp index 70ac50f40b..7487924db5 100644 --- a/ApplicationCode/UserInterface/RIMainWindow.cpp +++ b/ApplicationCode/UserInterface/RIMainWindow.cpp @@ -19,12 +19,12 @@ #include "RiaStdInclude.h" #include "RiaBaseDefs.h" -#include "RIApplication.h" +#include "RiaApplication.h" #include "RIMainWindow.h" #include "RIViewer.h" #include "RIResultInfoPanel.h" #include "RIProcessMonitor.h" -#include "RIPreferences.h" +#include "RiaPreferences.h" #include "RIPreferencesDialog.h" #include "RigEclipseCase.h" @@ -500,7 +500,7 @@ void RIMainWindow::slotRefreshFileActions() //-------------------------------------------------------------------------------------------------- void RIMainWindow::slotRefreshEditActions() { -// RIApplication* app = RIApplication::instance(); +// RiaApplication* app = RiaApplication::instance(); // RISceneManager* proj = app->project(); } @@ -510,7 +510,7 @@ void RIMainWindow::slotRefreshEditActions() //-------------------------------------------------------------------------------------------------- void RIMainWindow::slotRefreshViewActions() { -// RIApplication* app = RIApplication::instance(); +// RiaApplication* app = RiaApplication::instance(); // RISceneManager* proj = app->project(); bool enabled = true; diff --git a/ApplicationCode/UserInterface/RIProcessMonitor.cpp b/ApplicationCode/UserInterface/RIProcessMonitor.cpp index 5cf18846fe..4f7fa107d7 100644 --- a/ApplicationCode/UserInterface/RIProcessMonitor.cpp +++ b/ApplicationCode/UserInterface/RIProcessMonitor.cpp @@ -20,7 +20,7 @@ #include "RIProcessMonitor.h" #include "cafUiProcess.h" -#include "RIApplication.h" +#include "RiaApplication.h" //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RIViewer.cpp b/ApplicationCode/UserInterface/RIViewer.cpp index a91df2c78a..f0eb28fd66 100644 --- a/ApplicationCode/UserInterface/RIViewer.cpp +++ b/ApplicationCode/UserInterface/RIViewer.cpp @@ -19,7 +19,7 @@ #include "RiaStdInclude.h" #include "RIViewer.h" -#include "RIApplication.h" +#include "RiaApplication.h" #include "RIMainWindow.h" #include "cvfqtOpenGLContext.h" diff --git a/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp b/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp index 8f584e8b20..e6014f07a1 100644 --- a/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp +++ b/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp @@ -22,7 +22,7 @@ #include #include #include -#include "RIApplication.h" +#include "RiaApplication.h" class FileListModel: public QStringListModel { From 6a2cbbcf07722e670540aa531793b8881dd1f009 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 22 Mar 2013 16:40:41 +0100 Subject: [PATCH 168/242] Renamed files: RimReservoir RimCase RimResultReservoir RimResultCase RimInputReservoir RimInputCase p4#: 21069 --- ApplicationCode/Application/RiaApplication.cpp | 4 ++-- ApplicationCode/CMakeLists.txt | 6 +++--- ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp | 2 +- ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp | 2 +- .../ProjectDataModel/{RimReservoir.cpp => RimCase.cpp} | 2 +- .../ProjectDataModel/{RimReservoir.h => RimCase.h} | 0 ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp | 2 +- .../ProjectDataModel/RimIdenticalGridCaseGroup.cpp | 4 ++-- .../{RimInputReservoir.cpp => RimInputCase.cpp} | 4 ++-- .../{RimInputReservoir.h => RimInputCase.h} | 4 ++-- ApplicationCode/ProjectDataModel/RimProject.cpp | 2 +- ApplicationCode/ProjectDataModel/RimReservoirView.cpp | 2 +- ApplicationCode/ProjectDataModel/RimReservoirView.h | 2 +- .../{RimResultReservoir.cpp => RimResultCase.cpp} | 2 +- .../{RimResultReservoir.h => RimResultCase.h} | 2 +- ApplicationCode/ProjectDataModel/RimResultDefinition.cpp | 2 +- ApplicationCode/ProjectDataModel/RimResultSlot.cpp | 2 +- ApplicationCode/ProjectDataModel/RimStatisticsCase.h | 2 +- .../ProjectDataModel/RimStatisticsCaseEvaluator.cpp | 2 +- ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp | 4 ++-- ApplicationCode/ProjectDataModel/RimUiTreeView.cpp | 4 ++-- ApplicationCode/SocketInterface/RiaSocketServer.cpp | 4 ++-- ApplicationCode/UserInterface/RIMainWindow.cpp | 2 +- 23 files changed, 31 insertions(+), 31 deletions(-) rename ApplicationCode/ProjectDataModel/{RimReservoir.cpp => RimCase.cpp} (99%) rename ApplicationCode/ProjectDataModel/{RimReservoir.h => RimCase.h} (100%) rename ApplicationCode/ProjectDataModel/{RimInputReservoir.cpp => RimInputCase.cpp} (99%) rename ApplicationCode/ProjectDataModel/{RimInputReservoir.h => RimInputCase.h} (97%) rename ApplicationCode/ProjectDataModel/{RimResultReservoir.cpp => RimResultCase.cpp} (99%) rename ApplicationCode/ProjectDataModel/{RimResultReservoir.h => RimResultCase.h} (98%) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 78b8669482..8aa233ffdb 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -35,8 +35,8 @@ #include "RIProcessMonitor.h" #include "RiaPreferences.h" -#include "RimResultReservoir.h" -#include "RimInputReservoir.h" +#include "RimResultCase.h" +#include "RimInputCase.h" #include "RimReservoirView.h" #include "RigEclipseCase.h" diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index 077882c3c9..36233c7f34 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -64,12 +64,12 @@ list( APPEND CPP_SOURCES ProjectDataModel/RimDefines.cpp ProjectDataModel/RimLegendConfig.cpp ProjectDataModel/RimProject.cpp - ProjectDataModel/RimReservoir.cpp + ProjectDataModel/RimCase.cpp ProjectDataModel/RimIdenticalGridCaseGroup.cpp ProjectDataModel/RimInputProperty.cpp ProjectDataModel/RimInputPropertyCollection.cpp - ProjectDataModel/RimInputReservoir.cpp - ProjectDataModel/RimResultReservoir.cpp + ProjectDataModel/RimInputCase.cpp + ProjectDataModel/RimResultCase.cpp ProjectDataModel/RimReservoirView.cpp ProjectDataModel/RimResultDefinition.cpp ProjectDataModel/RimResultSlot.cpp diff --git a/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp index f45e79a32b..9a1227efe1 100644 --- a/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp @@ -19,7 +19,7 @@ #include "cvfLibCore.h" -#include "RimReservoir.h" +#include "RimCase.h" #include "RigEclipseCase.h" #include "RivWellPipesPartMgr.h" #include "RigCell.h" diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index 9f206d20da..cc1b04e754 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -21,7 +21,7 @@ #include "Rim3dOverlayInfoConfig.h" #include "RimReservoirView.h" #include "RIViewer.h" -#include "RimReservoir.h" +#include "RimCase.h" #include "RigEclipseCase.h" #include "RigMainGrid.h" #include "RigReservoirCellResults.h" diff --git a/ApplicationCode/ProjectDataModel/RimReservoir.cpp b/ApplicationCode/ProjectDataModel/RimCase.cpp similarity index 99% rename from ApplicationCode/ProjectDataModel/RimReservoir.cpp rename to ApplicationCode/ProjectDataModel/RimCase.cpp index 06aface17c..90c3a0e8d8 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimCase.cpp @@ -21,7 +21,7 @@ #include "RifReaderEclipseOutput.h" #include "RifReaderMockModel.h" -#include "RimReservoir.h" +#include "RimCase.h" #include "RimReservoirView.h" #include "RigEclipseCase.h" diff --git a/ApplicationCode/ProjectDataModel/RimReservoir.h b/ApplicationCode/ProjectDataModel/RimCase.h similarity index 100% rename from ApplicationCode/ProjectDataModel/RimReservoir.h rename to ApplicationCode/ProjectDataModel/RimCase.h diff --git a/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp b/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp index 5f979fc9aa..5d76d13eb9 100644 --- a/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp @@ -21,7 +21,7 @@ #include "RimCellEdgeResultSlot.h" #include "RimLegendConfig.h" #include "RimReservoirView.h" -#include "RimReservoir.h" +#include "RimCase.h" #include "RimReservoirView.h" #include "RigReservoirCellResults.h" #include "RigEclipseCase.h" diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index b90230030b..45af3e6a51 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -20,14 +20,14 @@ #include "RiaStdInclude.h" #include "RimIdenticalGridCaseGroup.h" -#include "RimReservoir.h" +#include "RimCase.h" #include "RimReservoirView.h" #include "RigEclipseCase.h" #include "RigReservoirCellResults.h" #include "RimStatisticsCase.h" #include "RimStatisticsCaseCollection.h" -#include "RimResultReservoir.h" +#include "RimResultCase.h" #include "cafProgressInfo.h" #include "RigActiveCellInfo.h" diff --git a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp b/ApplicationCode/ProjectDataModel/RimInputCase.cpp similarity index 99% rename from ApplicationCode/ProjectDataModel/RimInputReservoir.cpp rename to ApplicationCode/ProjectDataModel/RimInputCase.cpp index b3ad9f996f..12d5fae454 100644 --- a/ApplicationCode/ProjectDataModel/RimInputReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimInputCase.cpp @@ -18,7 +18,7 @@ #include "RiaStdInclude.h" -#include "RimInputReservoir.h" +#include "RimInputCase.h" #include "RimInputProperty.h" #include "RimReservoirView.h" @@ -45,7 +45,7 @@ CAF_PDM_SOURCE_INIT(RimInputCase, "RimInputReservoir"); RimInputCase::RimInputCase() : RimCase() { - CAF_PDM_InitObject("RimInputReservoir", ":/EclipseInput48x48.png", "", ""); + CAF_PDM_InitObject("RimInputCase", ":/EclipseInput48x48.png", "", ""); CAF_PDM_InitField(&m_gridFileName, "GridFileName", QString(), "Case grid filename", "", "" ,""); CAF_PDM_InitFieldNoDefault(&m_additionalFileNames, "AdditionalFileNames", "Additional files", "", "" ,""); diff --git a/ApplicationCode/ProjectDataModel/RimInputReservoir.h b/ApplicationCode/ProjectDataModel/RimInputCase.h similarity index 97% rename from ApplicationCode/ProjectDataModel/RimInputReservoir.h rename to ApplicationCode/ProjectDataModel/RimInputCase.h index 9e0a573b51..525937c9ab 100644 --- a/ApplicationCode/ProjectDataModel/RimInputReservoir.h +++ b/ApplicationCode/ProjectDataModel/RimInputCase.h @@ -23,7 +23,7 @@ #include "cafPdmField.h" #include "cafPdmObject.h" -#include "RimReservoir.h" +#include "RimCase.h" #include "RimInputPropertyCollection.h" @@ -56,7 +56,7 @@ public: void removeProperty(RimInputProperty* inputProperty); - // RimReservoir overrides + // RimCase overrides virtual bool openEclipseGridFile(); // Find grid file among file set. Read, Find read and validate property date. Syncronize child property sets. // PdmObject overrides diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 02a6faa56d..dd26ac2313 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -24,7 +24,7 @@ #include "RigGridCollection.h" #include "RigEclipseCase.h" -#include "RimResultReservoir.h" +#include "RimResultCase.h" CAF_PDM_SOURCE_INIT(RimProject, "ResInsightProject"); diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp index 8e035ae6d7..60a9a48440 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp @@ -41,7 +41,7 @@ #include "cafCadNavigation.h" #include "cafCeetronNavigation.h" -#include "RimReservoir.h" +#include "RimCase.h" #include "Rim3dOverlayInfoConfig.h" #include "RigGridScalarDataAccess.h" diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.h b/ApplicationCode/ProjectDataModel/RimReservoirView.h index c1125d47cf..7f29c5c6b7 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.h +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.h @@ -23,7 +23,7 @@ #include #include -#include "RimReservoir.h" +#include "RimCase.h" #include "RimResultSlot.h" #include "RimCellEdgeResultSlot.h" #include "RimCellRangeFilter.h" diff --git a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp b/ApplicationCode/ProjectDataModel/RimResultCase.cpp similarity index 99% rename from ApplicationCode/ProjectDataModel/RimResultReservoir.cpp rename to ApplicationCode/ProjectDataModel/RimResultCase.cpp index af5270bcf8..7dc3962cd6 100644 --- a/ApplicationCode/ProjectDataModel/RimResultReservoir.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultCase.cpp @@ -17,7 +17,7 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RiaStdInclude.h" -#include "RimResultReservoir.h" +#include "RimResultCase.h" #include "RigEclipseCase.h" #include "RifReaderEclipseOutput.h" #include "RigReservoirCellResults.h" diff --git a/ApplicationCode/ProjectDataModel/RimResultReservoir.h b/ApplicationCode/ProjectDataModel/RimResultCase.h similarity index 98% rename from ApplicationCode/ProjectDataModel/RimResultReservoir.h rename to ApplicationCode/ProjectDataModel/RimResultCase.h index 7824be7f63..1b2aa10235 100644 --- a/ApplicationCode/ProjectDataModel/RimResultReservoir.h +++ b/ApplicationCode/ProjectDataModel/RimResultCase.h @@ -22,7 +22,7 @@ #include "cvfObject.h" #include "cafPdmField.h" #include "cafPdmObject.h" -#include "RimReservoir.h" +#include "RimCase.h" class RifReaderInterface; class RigMainGrid; diff --git a/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp index 5c8cd7dce2..ad13fdc254 100644 --- a/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp @@ -21,7 +21,7 @@ #include "RimResultDefinition.h" #include "RimReservoirView.h" -#include "RimReservoir.h" +#include "RimCase.h" #include "RigReservoirCellResults.h" #include "RigEclipseCase.h" #include "RigMainGrid.h" diff --git a/ApplicationCode/ProjectDataModel/RimResultSlot.cpp b/ApplicationCode/ProjectDataModel/RimResultSlot.cpp index af785b0d19..33085a8729 100644 --- a/ApplicationCode/ProjectDataModel/RimResultSlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultSlot.cpp @@ -21,7 +21,7 @@ #include "RimResultSlot.h" #include "RimLegendConfig.h" #include "RimReservoirView.h" -#include "RimReservoir.h" +#include "RimCase.h" #include "RIMainWindow.h" #include "RimUiTreeModelPdm.h" diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCase.h b/ApplicationCode/ProjectDataModel/RimStatisticsCase.h index 86d424b02d..0d8418a29a 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCase.h +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCase.h @@ -23,7 +23,7 @@ #include "cafPdmField.h" #include "cafPdmObject.h" -#include "RimReservoir.h" +#include "RimCase.h" class RimIdenticalGridCaseGroup; class RimResultDefinition; diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.cpp b/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.cpp index 888d5a6270..6f714550ca 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.cpp @@ -20,7 +20,7 @@ #include "RimStatisticsCaseEvaluator.h" #include "RigReservoirCellResults.h" #include "RimReservoirView.h" -#include "RimReservoir.h" +#include "RimCase.h" #include "RigEclipseCase.h" //#include "RigEclipseCase.h" diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index f1cab1248a..e51c0bf8c4 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -34,9 +34,9 @@ #include "RimInputProperty.h" #include "RimInputPropertyCollection.h" #include "cafPdmField.h" -#include "RimInputReservoir.h" +#include "RimInputCase.h" #include "RimStatisticsCase.h" -#include "RimResultReservoir.h" +#include "RimResultCase.h" //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index 26f19ca806..c07efcaafb 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -30,11 +30,11 @@ #include "RimExportInputPropertySettings.h" #include "RIPreferencesDialog.h" #include "RifEclipseInputFileTools.h" -#include "RimInputReservoir.h" +#include "RimInputCase.h" #include "RimBinaryExportSettings.h" #include "RigReservoirCellResults.h" #include "RimStatisticsCase.h" -#include "RimResultReservoir.h" +#include "RimResultCase.h" //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.cpp b/ApplicationCode/SocketInterface/RiaSocketServer.cpp index ce47666001..7bf70e3f27 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.cpp +++ b/ApplicationCode/SocketInterface/RiaSocketServer.cpp @@ -25,11 +25,11 @@ #include "RiaSocketServer.h" #include "RiaApplication.h" #include "RIMainWindow.h" -#include "RimReservoir.h" +#include "RimCase.h" #include "RigEclipseCase.h" #include "RigReservoirCellResults.h" #include "RimInputProperty.h" -#include "RimInputReservoir.h" +#include "RimInputCase.h" #include "RimUiTreeModelPdm.h" //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RIMainWindow.cpp b/ApplicationCode/UserInterface/RIMainWindow.cpp index 7487924db5..846bbf64ed 100644 --- a/ApplicationCode/UserInterface/RIMainWindow.cpp +++ b/ApplicationCode/UserInterface/RIMainWindow.cpp @@ -29,7 +29,7 @@ #include "RigEclipseCase.h" #include "RigReservoirCellResults.h" -#include "RimReservoir.h" +#include "RimCase.h" #include "RimUiTreeModelPdm.h" #include "cvfqtBasicAboutDialog.h" From f0174a02fae4c85d770b14852482b4da2da0bf95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 22 Mar 2013 16:58:44 +0100 Subject: [PATCH 169/242] More file renaming: RigEclipseCase RigCaseData RigReservoirCellResults RigCaseCellResultsData RigWellResults RigSingleWellResultsData RigGridCollection RigGridManager p4#: 21070 --- ApplicationCode/Application/RiaApplication.cpp | 2 +- .../FileInterface_UnitTests/Ert-Test.cpp | 2 +- .../RifReaderEclipseOutput-Test.cpp | 6 +++--- .../FileInterface/RifEclipseInputFileTools.cpp | 4 ++-- .../FileInterface/RifReaderEclipseInput.cpp | 4 ++-- .../FileInterface/RifReaderEclipseOutput.cpp | 4 ++-- .../FileInterface/RifReaderMockModel.cpp | 2 +- .../RivCellEdgeEffectGenerator.cpp | 4 ++-- .../ModelVisualization/RivGridPartMgr.cpp | 4 ++-- .../ModelVisualization/RivReservoirPartMgr.cpp | 2 +- .../RivReservoirViewPartMgr.cpp | 4 ++-- .../ModelVisualization/RivWellHeadPartMgr.cpp | 2 +- .../ModelVisualization/RivWellPipesPartMgr.cpp | 2 +- .../ModelVisualization/RivWellPipesPartMgr.h | 2 +- .../ProjectDataModel/Rim3dOverlayInfoConfig.cpp | 4 ++-- ApplicationCode/ProjectDataModel/RimCase.cpp | 4 ++-- .../ProjectDataModel/RimCellEdgeResultSlot.cpp | 4 ++-- .../ProjectDataModel/RimCellPropertyFilter.cpp | 2 +- .../RimCellPropertyFilterCollection.cpp | 2 +- .../ProjectDataModel/RimCellRangeFilter.cpp | 2 +- .../RimCellRangeFilterCollection.cpp | 2 +- .../RimIdenticalGridCaseGroup.cpp | 4 ++-- .../ProjectDataModel/RimInputCase.cpp | 4 ++-- ApplicationCode/ProjectDataModel/RimProject.cpp | 4 ++-- .../RimReservoirCellResultsCacher.cpp | 4 ++-- .../ProjectDataModel/RimReservoirView.cpp | 4 ++-- .../ProjectDataModel/RimResultCase.cpp | 4 ++-- .../ProjectDataModel/RimResultDefinition.cpp | 4 ++-- .../ProjectDataModel/RimStatisticsCase.cpp | 4 ++-- .../RimStatisticsCaseEvaluator.cpp | 8 ++++---- .../ProjectDataModel/RimUiTreeView.cpp | 2 +- ApplicationCode/ProjectDataModel/RimWell.h | 2 +- .../ProjectDataModel/RimWellCollection.cpp | 2 +- .../ReservoirDataModel/CMakeLists_files.cmake | 16 ++++++++-------- .../RigReservoir-Test.cpp | 6 +++--- ...ellResults.cpp => RigCaseCellResultsData.cpp} | 2 +- ...oirCellResults.h => RigCaseCellResultsData.h} | 0 .../{RigEclipseCase.cpp => RigCaseData.cpp} | 6 +++--- .../{RigEclipseCase.h => RigCaseData.h} | 2 +- .../ReservoirDataModel/RigGridBase.cpp | 2 +- ...{RigGridCollection.cpp => RigGridManager.cpp} | 4 ++-- .../{RigGridCollection.h => RigGridManager.h} | 0 .../RigGridScalarDataAccess.cpp | 4 ++-- .../RigReservoirBuilderMock.cpp | 2 +- .../ReservoirDataModel/RigReservoirBuilderMock.h | 2 +- ...lResults.cpp => RigSingleWellResultsData.cpp} | 2 +- ...gWellResults.h => RigSingleWellResultsData.h} | 0 .../SocketInterface/RiaSocketServer.cpp | 4 ++-- ApplicationCode/UserInterface/RIMainWindow.cpp | 4 ++-- ApplicationCode/UserInterface/RIViewer.cpp | 2 +- 50 files changed, 84 insertions(+), 84 deletions(-) rename ApplicationCode/ReservoirDataModel/{RigReservoirCellResults.cpp => RigCaseCellResultsData.cpp} (99%) rename ApplicationCode/ReservoirDataModel/{RigReservoirCellResults.h => RigCaseCellResultsData.h} (100%) rename ApplicationCode/ReservoirDataModel/{RigEclipseCase.cpp => RigCaseData.cpp} (99%) rename ApplicationCode/ReservoirDataModel/{RigEclipseCase.h => RigCaseData.h} (99%) rename ApplicationCode/ReservoirDataModel/{RigGridCollection.cpp => RigGridManager.cpp} (98%) rename ApplicationCode/ReservoirDataModel/{RigGridCollection.h => RigGridManager.h} (100%) rename ApplicationCode/ReservoirDataModel/{RigWellResults.cpp => RigSingleWellResultsData.cpp} (99%) rename ApplicationCode/ReservoirDataModel/{RigWellResults.h => RigSingleWellResultsData.h} (100%) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 8aa233ffdb..3475229391 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -39,7 +39,7 @@ #include "RimInputCase.h" #include "RimReservoirView.h" -#include "RigEclipseCase.h" +#include "RigCaseData.h" #include "RigCell.h" #include "RigReservoirBuilderMock.h" diff --git a/ApplicationCode/FileInterface/FileInterface_UnitTests/Ert-Test.cpp b/ApplicationCode/FileInterface/FileInterface_UnitTests/Ert-Test.cpp index 02324bd68a..390ec2cf56 100644 --- a/ApplicationCode/FileInterface/FileInterface_UnitTests/Ert-Test.cpp +++ b/ApplicationCode/FileInterface/FileInterface_UnitTests/Ert-Test.cpp @@ -37,7 +37,7 @@ #include "gtest/gtest.h" -#include "RigEclipseCase.h" +#include "RigCaseData.h" #include "RifReaderEclipseInput.h" #if 0 diff --git a/ApplicationCode/FileInterface/FileInterface_UnitTests/RifReaderEclipseOutput-Test.cpp b/ApplicationCode/FileInterface/FileInterface_UnitTests/RifReaderEclipseOutput-Test.cpp index ca210e8e0e..d1fbe43b49 100644 --- a/ApplicationCode/FileInterface/FileInterface_UnitTests/RifReaderEclipseOutput-Test.cpp +++ b/ApplicationCode/FileInterface/FileInterface_UnitTests/RifReaderEclipseOutput-Test.cpp @@ -21,12 +21,12 @@ #include "RiaStdInclude.h" #include "gtest/gtest.h" -#include "RigEclipseCase.h" +#include "RigCaseData.h" #include "RifReaderEclipseOutput.h" #include "ecl_file.h" #include "RifEclipseOutputFileTools.h" -#include "RigReservoirCellResults.h" +#include "RigCaseCellResultsData.h" @@ -68,7 +68,7 @@ TEST(RigReservoirTest, FileOutputToolsTest) void buildResultInfoString(RigReservoir* reservoir, RifReaderInterface::PorosityModelResultType porosityModel, RimDefines::ResultCatType resultType) { - RigReservoirCellResults* matrixResults = reservoir->results(porosityModel); + RigCaseCellResultsData* matrixResults = reservoir->results(porosityModel); { QStringList resultNames = matrixResults->resultNames(resultType); diff --git a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp index 482f55456e..0fcbadf854 100644 --- a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp @@ -18,9 +18,9 @@ #include "RifEclipseInputFileTools.h" #include "RifReaderEclipseOutput.h" -#include "RigReservoirCellResults.h" +#include "RigCaseCellResultsData.h" -#include "RigEclipseCase.h" +#include "RigCaseData.h" #include "cafProgressInfo.h" #include diff --git a/ApplicationCode/FileInterface/RifReaderEclipseInput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseInput.cpp index 41cd834951..3836f514b8 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseInput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseInput.cpp @@ -19,8 +19,8 @@ #include "cvfBase.h" #include "RigMainGrid.h" -#include "RigEclipseCase.h" -#include "RigReservoirCellResults.h" +#include "RigCaseData.h" +#include "RigCaseCellResultsData.h" #include "RifReaderEclipseInput.h" #include "RifReaderEclipseOutput.h" diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index 5f3153b794..e7fa03c1bd 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -19,8 +19,8 @@ #include "cvfBase.h" #include "RigMainGrid.h" -#include "RigEclipseCase.h" -#include "RigReservoirCellResults.h" +#include "RigCaseData.h" +#include "RigCaseCellResultsData.h" #include "RifReaderEclipseOutput.h" #include "RifEclipseOutputFileTools.h" diff --git a/ApplicationCode/FileInterface/RifReaderMockModel.cpp b/ApplicationCode/FileInterface/RifReaderMockModel.cpp index 659eba791f..f03a79e40f 100644 --- a/ApplicationCode/FileInterface/RifReaderMockModel.cpp +++ b/ApplicationCode/FileInterface/RifReaderMockModel.cpp @@ -19,7 +19,7 @@ #include "RiaStdInclude.h" #include "RifReaderMockModel.h" -#include "RigReservoirCellResults.h" +#include "RigCaseCellResultsData.h" #include "RifReaderInterface.h" //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp b/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp index 3a29b456f1..1973d147c8 100644 --- a/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp @@ -49,8 +49,8 @@ #include "RigGridBase.h" #include "RigMainGrid.h" -#include "RigReservoirCellResults.h" -#include "RigEclipseCase.h" +#include "RigCaseCellResultsData.h" +#include "RigCaseData.h" #include "RigActiveCellInfo.h" diff --git a/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp b/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp index 23bec7646b..64e1f6437c 100644 --- a/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp @@ -28,8 +28,8 @@ #include "RimResultSlot.h" #include "RimCellEdgeResultSlot.h" #include "RigGridScalarDataAccess.h" -#include "RigReservoirCellResults.h" -#include "RigEclipseCase.h" +#include "RigCaseCellResultsData.h" +#include "RigCaseData.h" //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/RivReservoirPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirPartMgr.cpp index f6fdb6be0a..c51ec3c230 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirPartMgr.cpp @@ -21,7 +21,7 @@ #include "RivGridPartMgr.h" #include "cvfStructGrid.h" #include "cvfModelBasicList.h" -#include "RigEclipseCase.h" +#include "RigCaseData.h" //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp index 07fd3f524c..7f81bee176 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp @@ -20,9 +20,9 @@ #include "RivReservoirViewPartMgr.h" #include "RivGridPartMgr.h" #include "RimReservoirView.h" -#include "RigEclipseCase.h" +#include "RigCaseData.h" #include "RigGridBase.h" -#include "RigReservoirCellResults.h" +#include "RigCaseCellResultsData.h" #include "RigGridScalarDataAccess.h" //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp index 1d721e24e7..d578779940 100644 --- a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp @@ -36,7 +36,7 @@ #include "RimReservoirView.h" -#include "RigEclipseCase.h" +#include "RigCaseData.h" #include "RigCell.h" #include "RivPipeGeometryGenerator.h" diff --git a/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp index 9a1227efe1..7d82f2f717 100644 --- a/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp @@ -20,7 +20,7 @@ #include "cvfLibCore.h" #include "RimCase.h" -#include "RigEclipseCase.h" +#include "RigCaseData.h" #include "RivWellPipesPartMgr.h" #include "RigCell.h" #include "RivPipeGeometryGenerator.h" diff --git a/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.h index f3fc473a50..942b50866c 100644 --- a/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.h @@ -20,7 +20,7 @@ #include "cafPdmPointer.h" #include -#include "RigWellResults.h" +#include "RigSingleWellResultsData.h" namespace cvf { diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index cc1b04e754..e9617def3d 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -22,9 +22,9 @@ #include "RimReservoirView.h" #include "RIViewer.h" #include "RimCase.h" -#include "RigEclipseCase.h" +#include "RigCaseData.h" #include "RigMainGrid.h" -#include "RigReservoirCellResults.h" +#include "RigCaseCellResultsData.h" CAF_PDM_SOURCE_INIT(Rim3dOverlayInfoConfig, "View3dOverlayInfoConfig"); diff --git a/ApplicationCode/ProjectDataModel/RimCase.cpp b/ApplicationCode/ProjectDataModel/RimCase.cpp index 90c3a0e8d8..d7f1beae97 100644 --- a/ApplicationCode/ProjectDataModel/RimCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimCase.cpp @@ -24,9 +24,9 @@ #include "RimCase.h" #include "RimReservoirView.h" -#include "RigEclipseCase.h" +#include "RigCaseData.h" #include "RigMainGrid.h" -#include "RigReservoirCellResults.h" +#include "RigCaseCellResultsData.h" #include "cvfAssert.h" diff --git a/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp b/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp index 5d76d13eb9..28f638ff9d 100644 --- a/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellEdgeResultSlot.cpp @@ -23,8 +23,8 @@ #include "RimReservoirView.h" #include "RimCase.h" #include "RimReservoirView.h" -#include "RigReservoirCellResults.h" -#include "RigEclipseCase.h" +#include "RigCaseCellResultsData.h" +#include "RigCaseData.h" #include "cafPdmUiListEditor.h" diff --git a/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.cpp b/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.cpp index ec0bb22ff9..8666c153d5 100644 --- a/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.cpp @@ -22,7 +22,7 @@ #include "RimCellPropertyFilter.h" #include "RimCellPropertyFilterCollection.h" #include "RigGridBase.h" -#include "RigReservoirCellResults.h" +#include "RigCaseCellResultsData.h" #include "cafPdmUiDoubleSliderEditor.h" diff --git a/ApplicationCode/ProjectDataModel/RimCellPropertyFilterCollection.cpp b/ApplicationCode/ProjectDataModel/RimCellPropertyFilterCollection.cpp index b722e74013..c69141e0a7 100644 --- a/ApplicationCode/ProjectDataModel/RimCellPropertyFilterCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellPropertyFilterCollection.cpp @@ -22,7 +22,7 @@ #include "RimReservoirView.h" #include "RigGridBase.h" -#include "RigReservoirCellResults.h" +#include "RigCaseCellResultsData.h" CAF_PDM_SOURCE_INIT(RimCellPropertyFilterCollection, "CellPropertyFilters"); diff --git a/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp b/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp index 5a8b6fa7f8..965a93f78f 100644 --- a/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp @@ -21,7 +21,7 @@ #include "RimCellRangeFilter.h" #include "RimCellRangeFilterCollection.h" #include "RimReservoirView.h" -#include "RigEclipseCase.h" +#include "RigCaseData.h" #include "cafPdmUiSliderEditor.h" diff --git a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp index eda15fa00f..73f90a8c7e 100644 --- a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp @@ -21,7 +21,7 @@ #include "RimCellRangeFilterCollection.h" #include "RimReservoirView.h" -#include "RigEclipseCase.h" +#include "RigCaseData.h" diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index 45af3e6a51..b05b711df2 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -22,8 +22,8 @@ #include "RimIdenticalGridCaseGroup.h" #include "RimCase.h" #include "RimReservoirView.h" -#include "RigEclipseCase.h" -#include "RigReservoirCellResults.h" +#include "RigCaseData.h" +#include "RigCaseCellResultsData.h" #include "RimStatisticsCase.h" #include "RimStatisticsCaseCollection.h" diff --git a/ApplicationCode/ProjectDataModel/RimInputCase.cpp b/ApplicationCode/ProjectDataModel/RimInputCase.cpp index 12d5fae454..229d25dd73 100644 --- a/ApplicationCode/ProjectDataModel/RimInputCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimInputCase.cpp @@ -24,8 +24,8 @@ #include "RifReaderEclipseInput.h" -#include "RigEclipseCase.h" -#include "RigReservoirCellResults.h" +#include "RigCaseData.h" +#include "RigCaseCellResultsData.h" #include "cvfAssert.h" diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index dd26ac2313..a939da0784 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -22,8 +22,8 @@ #include "RiaApplication.h" #include "RiaVersionInfo.h" -#include "RigGridCollection.h" -#include "RigEclipseCase.h" +#include "RigGridManager.h" +#include "RigCaseData.h" #include "RimResultCase.h" diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp index d005a7aef0..b88a70c3c3 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp @@ -18,7 +18,7 @@ #include "RiaStdInclude.h" #include "RimReservoirCellResultsCacher.h" -#include "RigReservoirCellResults.h" +#include "RigCaseCellResultsData.h" #include "RiaApplication.h" #include "RigMainGrid.h" #include "RigCell.h" @@ -51,7 +51,7 @@ RimReservoirCellResultsStorage::~RimReservoirCellResultsStorage() } //-------------------------------------------------------------------------------------------------- -/// This override populates the metainfo regarding the cell results data in the RigReservoirCellResults +/// This override populates the metainfo regarding the cell results data in the RigCaseCellResultsData /// object. This metainfo will then be written to the project file when saving, and thus read on project file open. /// This method then writes the actual double arrays to the data file in a simple format: /// MagicNumber, Version, ResultVariables< Array < TimeStep< CellDataArraySize, CellData< Array > > > diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp index 60a9a48440..ad3f02ccbd 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp @@ -22,7 +22,7 @@ #include "RimReservoirView.h" #include "RIMainWindow.h" #include "RigGridBase.h" -#include "RigEclipseCase.h" +#include "RigCaseData.h" #include "RiaApplication.h" #include "RiaPreferences.h" @@ -32,7 +32,7 @@ #include "RimCellRangeFilterCollection.h" #include "cvfStructGridGeometryGenerator.h" -#include "RigReservoirCellResults.h" +#include "RigCaseCellResultsData.h" #include "RivCellEdgeEffectGenerator.h" #include "RimCellEdgeResultSlot.h" #include "cvfqtUtils.h" diff --git a/ApplicationCode/ProjectDataModel/RimResultCase.cpp b/ApplicationCode/ProjectDataModel/RimResultCase.cpp index 7dc3962cd6..4f4f7fca76 100644 --- a/ApplicationCode/ProjectDataModel/RimResultCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultCase.cpp @@ -18,9 +18,9 @@ #include "RiaStdInclude.h" #include "RimResultCase.h" -#include "RigEclipseCase.h" +#include "RigCaseData.h" #include "RifReaderEclipseOutput.h" -#include "RigReservoirCellResults.h" +#include "RigCaseCellResultsData.h" #include "RimReservoirView.h" #include "RifReaderMockModel.h" #include "RifReaderEclipseInput.h" diff --git a/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp index ad13fdc254..9af564420b 100644 --- a/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp @@ -22,8 +22,8 @@ #include "RimReservoirView.h" #include "RimCase.h" -#include "RigReservoirCellResults.h" -#include "RigEclipseCase.h" +#include "RigCaseCellResultsData.h" +#include "RigCaseData.h" #include "RigMainGrid.h" #include "cafPdmUiListEditor.h" diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp index 502ad2adb1..e50e084f43 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp @@ -22,8 +22,8 @@ #include "RimReservoirView.h" #include "cafPdmUiOrdering.h" #include "RimIdenticalGridCaseGroup.h" -#include "RigEclipseCase.h" -#include "RigReservoirCellResults.h" +#include "RigCaseData.h" +#include "RigCaseCellResultsData.h" #include "RimStatisticsCaseEvaluator.h" #include "RigMainGrid.h" diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.cpp b/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.cpp index 6f714550ca..8ce57e857e 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.cpp @@ -18,12 +18,12 @@ #include "RiaStdInclude.h" #include "RimStatisticsCaseEvaluator.h" -#include "RigReservoirCellResults.h" +#include "RigCaseCellResultsData.h" #include "RimReservoirView.h" #include "RimCase.h" -#include "RigEclipseCase.h" +#include "RigCaseData.h" -//#include "RigEclipseCase.h" +//#include "RigCaseData.h" #include #include "cafProgressInfo.h" @@ -179,7 +179,7 @@ void RimStatisticsCaseEvaluator::evaluateForResults(const QListresults(RifReaderInterface::MATRIX_RESULTS)->cellResults()->findScalarResultIndex(resultType, "SWAT"); diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index c07efcaafb..37e0d635d4 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -32,7 +32,7 @@ #include "RifEclipseInputFileTools.h" #include "RimInputCase.h" #include "RimBinaryExportSettings.h" -#include "RigReservoirCellResults.h" +#include "RigCaseCellResultsData.h" #include "RimStatisticsCase.h" #include "RimResultCase.h" diff --git a/ApplicationCode/ProjectDataModel/RimWell.h b/ApplicationCode/ProjectDataModel/RimWell.h index d2b136cff4..a9f18b1ea7 100644 --- a/ApplicationCode/ProjectDataModel/RimWell.h +++ b/ApplicationCode/ProjectDataModel/RimWell.h @@ -24,7 +24,7 @@ #include "cafAppEnum.h" #include "cafPdmFieldCvfColor.h" -#include "RigWellResults.h" +#include "RigSingleWellResultsData.h" class RimReservoirView; //================================================================================================== diff --git a/ApplicationCode/ProjectDataModel/RimWellCollection.cpp b/ApplicationCode/ProjectDataModel/RimWellCollection.cpp index 9258bcc7b9..d1fd3f5ba0 100644 --- a/ApplicationCode/ProjectDataModel/RimWellCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellCollection.cpp @@ -22,7 +22,7 @@ #include "cafAppEnum.h" #include "cafPdmFieldCvfColor.h" -#include "RigWellResults.h" +#include "RigSingleWellResultsData.h" #include "RimWellCollection.h" #include "RimWell.h" #include "RimReservoirView.h" diff --git a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake index 5239d1e831..71c1ec37e7 100644 --- a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake @@ -8,29 +8,29 @@ endif() list(APPEND CODE_HEADER_FILES ${CEE_CURRENT_LIST_DIR}RigActiveCellInfo.h ${CEE_CURRENT_LIST_DIR}RigCell.h -${CEE_CURRENT_LIST_DIR}RigEclipseCase.h +${CEE_CURRENT_LIST_DIR}RigCaseData.h ${CEE_CURRENT_LIST_DIR}RigGridBase.h -${CEE_CURRENT_LIST_DIR}RigGridCollection.h +${CEE_CURRENT_LIST_DIR}RigGridManager.h ${CEE_CURRENT_LIST_DIR}RigGridScalarDataAccess.h ${CEE_CURRENT_LIST_DIR}RigLocalGrid.h ${CEE_CURRENT_LIST_DIR}RigMainGrid.h ${CEE_CURRENT_LIST_DIR}RigReservoirBuilderMock.h -${CEE_CURRENT_LIST_DIR}RigReservoirCellResults.h -${CEE_CURRENT_LIST_DIR}RigWellResults.h +${CEE_CURRENT_LIST_DIR}RigCaseCellResultsData.h +${CEE_CURRENT_LIST_DIR}RigSingleWellResultsData.h ) list(APPEND CODE_SOURCE_FILES ${CEE_CURRENT_LIST_DIR}RigActiveCellInfo.cpp ${CEE_CURRENT_LIST_DIR}RigCell.cpp -${CEE_CURRENT_LIST_DIR}RigEclipseCase.cpp +${CEE_CURRENT_LIST_DIR}RigCaseData.cpp ${CEE_CURRENT_LIST_DIR}RigGridBase.cpp -${CEE_CURRENT_LIST_DIR}RigGridCollection.cpp +${CEE_CURRENT_LIST_DIR}RigGridManager.cpp ${CEE_CURRENT_LIST_DIR}RigGridScalarDataAccess.cpp ${CEE_CURRENT_LIST_DIR}RigLocalGrid.cpp ${CEE_CURRENT_LIST_DIR}RigMainGrid.cpp ${CEE_CURRENT_LIST_DIR}RigReservoirBuilderMock.cpp -${CEE_CURRENT_LIST_DIR}RigReservoirCellResults.cpp -${CEE_CURRENT_LIST_DIR}RigWellResults.cpp +${CEE_CURRENT_LIST_DIR}RigCaseCellResultsData.cpp +${CEE_CURRENT_LIST_DIR}RigSingleWellResultsData.cpp ) diff --git a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp index e89724299d..5fe9cd233b 100644 --- a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp +++ b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigReservoir-Test.cpp @@ -21,8 +21,8 @@ #include "RiaStdInclude.h" #include "gtest/gtest.h" -#include "RigEclipseCase.h" -#include "RigGridCollection.h" +#include "RigCaseData.h" +#include "RigGridManager.h" //-------------------------------------------------------------------------------------------------- @@ -96,7 +96,7 @@ TEST(RigGridManager, EqualTests) //-------------------------------------------------------------------------------------------------- TEST(RigReservoirTest, BasicTest) { - cvf::ref wellCellTimeHistory = new RigWellResults; + cvf::ref wellCellTimeHistory = new RigSingleWellResultsData; QDateTime wellStartTime = QDateTime::currentDateTime(); diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp similarity index 99% rename from ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp rename to ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index 115ad0a66a..517aca7693 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RigReservoirCellResults.h" +#include "RigCaseCellResultsData.h" #include "RifReaderInterface.h" #include "RigMainGrid.h" diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h similarity index 100% rename from ApplicationCode/ReservoirDataModel/RigReservoirCellResults.h rename to ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp b/ApplicationCode/ReservoirDataModel/RigCaseData.cpp similarity index 99% rename from ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp rename to ApplicationCode/ReservoirDataModel/RigCaseData.cpp index 76b3617dd0..b10a189744 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseData.cpp @@ -16,9 +16,9 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RigEclipseCase.h" +#include "RigCaseData.h" #include "RigMainGrid.h" -#include "RigReservoirCellResults.h" +#include "RigCaseCellResultsData.h" #include "RigGridScalarDataAccess.h" //-------------------------------------------------------------------------------------------------- @@ -474,7 +474,7 @@ cvf::ref RigCaseData::dataAccessObject(const Ri //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigEclipseCase::closeReaderInterface() +void RigCaseData::closeReaderInterface() { RifReaderInterface* readerInterface = m_matrixModelResults->readerInterface(); diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCase.h b/ApplicationCode/ReservoirDataModel/RigCaseData.h similarity index 99% rename from ApplicationCode/ReservoirDataModel/RigEclipseCase.h rename to ApplicationCode/ReservoirDataModel/RigCaseData.h index 04900460a8..866dec4819 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCase.h +++ b/ApplicationCode/ReservoirDataModel/RigCaseData.h @@ -24,7 +24,7 @@ #include "cvfAssert.h" #include "cvfObject.h" #include "RigMainGrid.h" -#include "RigWellResults.h" +#include "RigSingleWellResultsData.h" #include "RigActiveCellInfo.h" class RigCaseCellResultsData; diff --git a/ApplicationCode/ReservoirDataModel/RigGridBase.cpp b/ApplicationCode/ReservoirDataModel/RigGridBase.cpp index 69b62a8856..77946bd15e 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridBase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridBase.cpp @@ -19,7 +19,7 @@ #include "RigGridBase.h" #include "RigMainGrid.h" #include "RigCell.h" -#include "RigReservoirCellResults.h" +#include "RigCaseCellResultsData.h" #include "RigGridScalarDataAccess.h" #include "cvfAssert.h" diff --git a/ApplicationCode/ReservoirDataModel/RigGridCollection.cpp b/ApplicationCode/ReservoirDataModel/RigGridManager.cpp similarity index 98% rename from ApplicationCode/ReservoirDataModel/RigGridCollection.cpp rename to ApplicationCode/ReservoirDataModel/RigGridManager.cpp index 61812211a6..2c7fbbba91 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridCollection.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridManager.cpp @@ -16,8 +16,8 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RigGridCollection.h" -#include "RigEclipseCase.h" +#include "RigGridManager.h" +#include "RigCaseData.h" #include "RigMainGrid.h" diff --git a/ApplicationCode/ReservoirDataModel/RigGridCollection.h b/ApplicationCode/ReservoirDataModel/RigGridManager.h similarity index 100% rename from ApplicationCode/ReservoirDataModel/RigGridCollection.h rename to ApplicationCode/ReservoirDataModel/RigGridManager.h diff --git a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp index 8377a35c67..68136b67d0 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp @@ -25,10 +25,10 @@ #include "cvfAssert.h" #include "RigMainGrid.h" -#include "RigReservoirCellResults.h" +#include "RigCaseCellResultsData.h" #include "RigActiveCellInfo.h" #include "RigGridBase.h" -#include "RigEclipseCase.h" +#include "RigCaseData.h" #include //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp index 6f2dfccfb5..74671abf98 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp @@ -17,7 +17,7 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RigReservoirBuilderMock.h" -#include "RigEclipseCase.h" +#include "RigCaseData.h" #include "RigActiveCellInfo.h" diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.h b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.h index c22bfbd926..d6c0f0fec4 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.h +++ b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.h @@ -23,7 +23,7 @@ #include "cvfArray.h" #include "cvfVector3.h" #include "RigCell.h" -#include "RigEclipseCase.h" +#include "RigCaseData.h" class LocalGridRefinement { diff --git a/ApplicationCode/ReservoirDataModel/RigWellResults.cpp b/ApplicationCode/ReservoirDataModel/RigSingleWellResultsData.cpp similarity index 99% rename from ApplicationCode/ReservoirDataModel/RigWellResults.cpp rename to ApplicationCode/ReservoirDataModel/RigSingleWellResultsData.cpp index a52fea4430..a36cf5752f 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellResults.cpp +++ b/ApplicationCode/ReservoirDataModel/RigSingleWellResultsData.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RigWellResults.h" +#include "RigSingleWellResultsData.h" #include #include diff --git a/ApplicationCode/ReservoirDataModel/RigWellResults.h b/ApplicationCode/ReservoirDataModel/RigSingleWellResultsData.h similarity index 100% rename from ApplicationCode/ReservoirDataModel/RigWellResults.h rename to ApplicationCode/ReservoirDataModel/RigSingleWellResultsData.h diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.cpp b/ApplicationCode/SocketInterface/RiaSocketServer.cpp index 7bf70e3f27..4acb24ccf6 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.cpp +++ b/ApplicationCode/SocketInterface/RiaSocketServer.cpp @@ -26,8 +26,8 @@ #include "RiaApplication.h" #include "RIMainWindow.h" #include "RimCase.h" -#include "RigEclipseCase.h" -#include "RigReservoirCellResults.h" +#include "RigCaseData.h" +#include "RigCaseCellResultsData.h" #include "RimInputProperty.h" #include "RimInputCase.h" #include "RimUiTreeModelPdm.h" diff --git a/ApplicationCode/UserInterface/RIMainWindow.cpp b/ApplicationCode/UserInterface/RIMainWindow.cpp index 846bbf64ed..3bbe25ad1e 100644 --- a/ApplicationCode/UserInterface/RIMainWindow.cpp +++ b/ApplicationCode/UserInterface/RIMainWindow.cpp @@ -27,8 +27,8 @@ #include "RiaPreferences.h" #include "RIPreferencesDialog.h" -#include "RigEclipseCase.h" -#include "RigReservoirCellResults.h" +#include "RigCaseData.h" +#include "RigCaseCellResultsData.h" #include "RimCase.h" #include "RimUiTreeModelPdm.h" diff --git a/ApplicationCode/UserInterface/RIViewer.cpp b/ApplicationCode/UserInterface/RIViewer.cpp index f0eb28fd66..ddac6c550d 100644 --- a/ApplicationCode/UserInterface/RIViewer.cpp +++ b/ApplicationCode/UserInterface/RIViewer.cpp @@ -28,7 +28,7 @@ #include "cvfRendering.h" #include "cvfDrawableGeo.h" #include "RICursors.h" -#include "RigEclipseCase.h" +#include "RigCaseData.h" #include "cafUtils.h" #include "cafFrameAnimationControl.h" From c8da0f417995c182c4a5fc53575450ba050529ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 22 Mar 2013 17:17:56 +0100 Subject: [PATCH 170/242] Aligning prefix of class names with standard: RICursors RiuCursors RIMainWindow RiuMainWindow RIPreferencesDialog RiuPreferencesDialog RIProcessMonitor RiuProcessMonitor RIResultInfoPanel RiuResultInfoPanel RIViewer RiuViewer p4#: 21071 --- .../Application/RiaApplication.cpp | 24 ++-- .../ProjectDataModel/RimReservoirView.cpp | 14 +- .../ProjectDataModel/RimReservoirView.h | 6 +- .../ProjectDataModel/RimResultSlot.cpp | 4 +- .../ProjectDataModel/RimScriptCollection.cpp | 2 +- .../ProjectDataModel/RimUiTreeView.cpp | 10 +- ApplicationCode/RiaMain.cpp | 2 +- .../SocketInterface/RiaSocketServer.cpp | 4 +- ApplicationCode/UserInterface/RICursors.cpp | 8 +- ApplicationCode/UserInterface/RICursors.h | 4 +- .../UserInterface/RIMainWindow.cpp | 126 +++++++++--------- ApplicationCode/UserInterface/RIMainWindow.h | 30 ++--- .../UserInterface/RIPreferencesDialog.cpp | 4 +- .../UserInterface/RIPreferencesDialog.h | 4 +- .../UserInterface/RIProcessMonitor.cpp | 22 +-- .../UserInterface/RIProcessMonitor.h | 6 +- .../UserInterface/RIResultInfoPanel.cpp | 8 +- .../UserInterface/RIResultInfoPanel.h | 4 +- ApplicationCode/UserInterface/RIViewer.cpp | 48 +++---- ApplicationCode/UserInterface/RIViewer.h | 6 +- 20 files changed, 168 insertions(+), 168 deletions(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 3475229391..8056fb11ee 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -160,7 +160,7 @@ RiaApplication* RiaApplication::instance() //-------------------------------------------------------------------------------------------------- void RiaApplication::setWindowCaptionFromAppState() { - RIMainWindow* mainWnd = RIMainWindow::instance(); + RiuMainWindow* mainWnd = RiuMainWindow::instance(); if (!mainWnd) return; // The stuff being done here should really be handled by Qt automatically as a result of @@ -245,7 +245,7 @@ bool RiaApplication::loadProject(const QString& projectFileName) QString tmp = QString("Unknown project file version detected in file \n%1\n\nCould not open project.").arg(projectFileName); QMessageBox::warning(NULL, "Error when opening project file", tmp); - RIMainWindow* mainWnd = RIMainWindow::instance(); + RiuMainWindow* mainWnd = RiuMainWindow::instance(); mainWnd->setPdmRoot(NULL); // Delete all object possibly generated by readFile() @@ -413,7 +413,7 @@ bool RiaApplication::saveProjectAs(const QString& fileName) //-------------------------------------------------------------------------------------------------- bool RiaApplication::closeProject(bool askToSaveIfDirty) { - RIMainWindow* mainWnd = RIMainWindow::instance(); + RiuMainWindow* mainWnd = RiuMainWindow::instance(); terminateProcess(); @@ -453,7 +453,7 @@ bool RiaApplication::closeProject(bool askToSaveIfDirty) //-------------------------------------------------------------------------------------------------- void RiaApplication::onProjectOpenedOrClosed() { - RIMainWindow* mainWnd = RIMainWindow::instance(); + RiuMainWindow* mainWnd = RiuMainWindow::instance(); if (!mainWnd) return; mainWnd->initializeGuiNewProjectLoaded(); @@ -820,7 +820,7 @@ bool RiaApplication::parseArguments() if (isRunRegressionTest) { - RIMainWindow* mainWnd = RIMainWindow::instance(); + RiuMainWindow* mainWnd = RiuMainWindow::instance(); if (mainWnd) { mainWnd->hideAllDockWindows(); @@ -911,7 +911,7 @@ QString RiaApplication::octavePath() const //-------------------------------------------------------------------------------------------------- void RiaApplication::slotWorkerProcessFinished(int exitCode, QProcess::ExitStatus exitStatus) { - RIMainWindow::instance()->processMonitor()->stopMonitorWorkProcess(); + RiuMainWindow::instance()->processMonitor()->stopMonitorWorkProcess(); // Execute delete later so that other slots that are hooked up // get a chance to run before we delete the object @@ -950,7 +950,7 @@ bool RiaApplication::launchProcess(const QString& program, const QStringList& ar m_workerProcess = new caf::UiProcess(this); connect(m_workerProcess, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(slotWorkerProcessFinished(int, QProcess::ExitStatus))); - RIMainWindow::instance()->processMonitor()->startMonitorWorkProcess(m_workerProcess); + RiuMainWindow::instance()->processMonitor()->startMonitorWorkProcess(m_workerProcess); m_workerProcess->start(program, arguments); if (!m_workerProcess->waitForStarted(1000)) @@ -958,9 +958,9 @@ bool RiaApplication::launchProcess(const QString& program, const QStringList& ar m_workerProcess->close(); m_workerProcess = NULL; - RIMainWindow::instance()->processMonitor()->stopMonitorWorkProcess(); + RiuMainWindow::instance()->processMonitor()->stopMonitorWorkProcess(); - QMessageBox::warning(RIMainWindow::instance(), "Script execution", "Failed to start script executable located at\n" + program); + QMessageBox::warning(RiuMainWindow::instance(), "Script execution", "Failed to start script executable located at\n" + program); return false; } @@ -1054,7 +1054,7 @@ void RiaApplication::applyPreferences() if (this->project()) { this->project()->setUserScriptPath(m_preferences->scriptDirectory()); - RimUiTreeModelPdm* treeModel = RIMainWindow::instance()->uiPdmModel(); + RimUiTreeModelPdm* treeModel = RiuMainWindow::instance()->uiPdmModel(); if (treeModel) treeModel->rebuildUiSubTree(this->project()->scriptCollection()); } @@ -1169,7 +1169,7 @@ void RiaApplication::copySnapshotToClipboard() //-------------------------------------------------------------------------------------------------- void RiaApplication::saveSnapshotForAllViews(const QString& snapshotFolderName) { - RIMainWindow* mainWnd = RIMainWindow::instance(); + RiuMainWindow* mainWnd = RiuMainWindow::instance(); if (!mainWnd) return; if (m_project.isNull()) return; @@ -1200,7 +1200,7 @@ void RiaApplication::saveSnapshotForAllViews(const QString& snapshotFolderName) { setActiveReservoirView(riv); - RIViewer* viewer = riv->viewer(); + RiuViewer* viewer = riv->viewer(); mainWnd->setActiveViewer(viewer); // Process all events to avoid a black image when grabbing frame buffer diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp index ad3f02ccbd..c77f00e97d 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp @@ -172,7 +172,7 @@ RimReservoirView::~RimReservoirView() if (m_viewer) { - RIMainWindow::instance()->removeViewer(m_viewer); + RiuMainWindow::instance()->removeViewer(m_viewer); } m_geometry->clearGeometryCache(); @@ -194,10 +194,10 @@ void RimReservoirView::updateViewerWidget() QGLFormat glFormat; glFormat.setDirectRendering(RiaApplication::instance()->useShaders()); - m_viewer = new RIViewer(glFormat, NULL); + m_viewer = new RiuViewer(glFormat, NULL); m_viewer->setOwnerReservoirView(this); - RIMainWindow::instance()->addViewer(m_viewer); + RiuMainWindow::instance()->addViewer(m_viewer); m_viewer->setMinNearPlaneDistance(10); this->cellResult()->legendConfig->recreateLegend(); this->cellEdgeResult()->legendConfig->recreateLegend(); @@ -220,7 +220,7 @@ void RimReservoirView::updateViewerWidget() isViewerCreated = true; } - RIMainWindow::instance()->setActiveViewer(m_viewer); + RiuMainWindow::instance()->setActiveViewer(m_viewer); if (isViewerCreated) m_viewer->mainCamera()->setViewMatrix(cameraPosition); m_viewer->mainCamera()->viewport()->setClearColor(cvf::Color4f(backgroundColor())); @@ -303,7 +303,7 @@ void RimReservoirView::createDisplayModelAndRedraw() } } - RIMainWindow::instance()->refreshAnimationActions(); + RiuMainWindow::instance()->refreshAnimationActions(); } //-------------------------------------------------------------------------------------------------- @@ -702,7 +702,7 @@ void RimReservoirView::loadDataAndUpdate() { if (!m_reservoir->openEclipseGridFile()) { - QMessageBox::warning(RIMainWindow::instance(), "Error when opening project file", "Could not open the Eclipse Grid file (EGRID/GRID): \n"+ m_reservoir->caseName()); + QMessageBox::warning(RiuMainWindow::instance(), "Error when opening project file", "Could not open the Eclipse Grid file (EGRID/GRID): \n"+ m_reservoir->caseName()); m_reservoir = NULL; return; } @@ -832,7 +832,7 @@ void RimReservoirView::updateStaticCellColors(unsigned short geometryType) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RIViewer* RimReservoirView::viewer() +RiuViewer* RimReservoirView::viewer() { return m_viewer; } diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.h b/ApplicationCode/ProjectDataModel/RimReservoirView.h index 7f29c5c6b7..68ecde5cac 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.h +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.h @@ -39,7 +39,7 @@ #include "RivReservoirViewPartMgr.h" #include "RivReservoirPipesPartMgr.h" -class RIViewer; +class RiuViewer; class RigGridBase; class RigGridCellFaceVisibilityFilter; class RivReservoirViewPartMgr; @@ -130,7 +130,7 @@ public: void endAnimation(); // 3D Viewer - RIViewer* viewer(); + RiuViewer* viewer(); void updateViewerWidget(); void updateViewerWidgetWindowTitle(); void setDefaultView(); @@ -178,7 +178,7 @@ private: private: caf::PdmField m_currentTimeStep; - QPointer m_viewer; + QPointer m_viewer; caf::PdmPointer m_reservoir; diff --git a/ApplicationCode/ProjectDataModel/RimResultSlot.cpp b/ApplicationCode/ProjectDataModel/RimResultSlot.cpp index 33085a8729..949170296e 100644 --- a/ApplicationCode/ProjectDataModel/RimResultSlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultSlot.cpp @@ -91,7 +91,7 @@ void RimResultSlot::changeLegendConfig(QString resultVarNameOfNewLegend) m_legendConfigData.v().erase(it); m_legendConfigData.v().push_back(this->legendConfig()); this->legendConfig = newLegend; - RIMainWindow::instance()->uiPdmModel()->rebuildUiSubTree(this); + RiuMainWindow::instance()->uiPdmModel()->rebuildUiSubTree(this); found = true; break; } @@ -105,7 +105,7 @@ void RimResultSlot::changeLegendConfig(QString resultVarNameOfNewLegend) newLegend->resultVariableName = resultVarNameOfNewLegend; m_legendConfigData.v().push_back(this->legendConfig()); this->legendConfig = newLegend; - RIMainWindow::instance()->uiPdmModel()->rebuildUiSubTree(this); + RiuMainWindow::instance()->uiPdmModel()->rebuildUiSubTree(this); } } diff --git a/ApplicationCode/ProjectDataModel/RimScriptCollection.cpp b/ApplicationCode/ProjectDataModel/RimScriptCollection.cpp index 67cc034e78..475e809eb8 100644 --- a/ApplicationCode/ProjectDataModel/RimScriptCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimScriptCollection.cpp @@ -161,7 +161,7 @@ void RimScriptCollection::fieldChangedByUi(const caf::PdmFieldHandle *changedFie QFileInfo fi(directory); this->setUiName(fi.baseName()); this->readContentFromDisc(); - RimUiTreeModelPdm* treeModel = RIMainWindow::instance()->uiPdmModel(); + RimUiTreeModelPdm* treeModel = RiuMainWindow::instance()->uiPdmModel(); if (treeModel) treeModel->rebuildUiSubTree(this); } } diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index 37e0d635d4..4ec3e05659 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -437,7 +437,7 @@ void RimUiTreeView::slotEditScript() if (!myProcess->waitForStarted(1000)) { - QMessageBox::warning(RIMainWindow::instance(), "Script editor", "Failed to start script editor executable\n" + scriptEditor); + QMessageBox::warning(RiuMainWindow::instance(), "Script editor", "Failed to start script editor executable\n" + scriptEditor); } } } @@ -494,7 +494,7 @@ void RimUiTreeView::slotNewScript() if (!myProcess->waitForStarted(1000)) { - QMessageBox::warning(RIMainWindow::instance(), "Script editor", "Failed to start script editor executable\n" + scriptEditor); + QMessageBox::warning(RiuMainWindow::instance(), "Script editor", "Failed to start script editor executable\n" + scriptEditor); } } } @@ -676,7 +676,7 @@ void RimUiTreeView::slotWriteInputProperty() if (!isResolved) { - QMessageBox::warning(RIMainWindow::instance(), "Export failure", "Property is not resolved, and then it is not possible to export the property."); + QMessageBox::warning(RiuMainWindow::instance(), "Export failure", "Property is not resolved, and then it is not possible to export the property."); return; } @@ -724,7 +724,7 @@ void RimUiTreeView::slotWriteInputProperty() exportSettings.fileName = outputFileName; } - RIPreferencesDialog preferencesDialog(this, &exportSettings, "Export Eclipse Property to Text File"); + RiuPreferencesDialog preferencesDialog(this, &exportSettings, "Export Eclipse Property to Text File"); if (preferencesDialog.exec() == QDialog::Accepted) { bool isOk = RifEclipseInputFileTools::writePropertyToTextFile(exportSettings.fileName, inputReservoir->reservoirData(), 0, inputProperty->resultName, exportSettings.eclipseKeyword); @@ -777,7 +777,7 @@ void RimUiTreeView::slotWriteBinaryResultAsInputProperty() exportSettings.fileName = outputFileName; } - RIPreferencesDialog preferencesDialog(this, &exportSettings, "Export Binary Eclipse Data to Text File"); + RiuPreferencesDialog preferencesDialog(this, &exportSettings, "Export Binary Eclipse Data to Text File"); if (preferencesDialog.exec() == QDialog::Accepted) { size_t timeStep = resultSlot->reservoirView()->currentTimeStep(); diff --git a/ApplicationCode/RiaMain.cpp b/ApplicationCode/RiaMain.cpp index e00b61335c..a61099b46f 100644 --- a/ApplicationCode/RiaMain.cpp +++ b/ApplicationCode/RiaMain.cpp @@ -27,7 +27,7 @@ int main(int argc, char *argv[]) QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates)); - RIMainWindow window; + RiuMainWindow window; QString platform = cvf::System::is64Bit() ? "(64bit)" : "(32bit)"; window.setWindowTitle("ResInsight " + platform); window.resize(1000, 800); diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.cpp b/ApplicationCode/SocketInterface/RiaSocketServer.cpp index 4acb24ccf6..7cd51e467f 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.cpp +++ b/ApplicationCode/SocketInterface/RiaSocketServer.cpp @@ -47,7 +47,7 @@ RiaSocketServer::RiaSocketServer(QObject* parent) m_invalidActiveCellCountDetected(false), m_readState(ReadingCommand) { - m_errorMessageDialog = new QErrorMessage(RIMainWindow::instance()); + m_errorMessageDialog = new QErrorMessage(RiuMainWindow::instance()); // TCP server setup @@ -514,7 +514,7 @@ void RiaSocketServer::readPropertyDataFromOctave() inputProperty->eclipseKeyword = ""; inputProperty->fileName = ""; inputRes->m_inputPropertyCollection->inputProperties.push_back(inputProperty); - RimUiTreeModelPdm* treeModel = RIMainWindow::instance()->uiPdmModel(); + RimUiTreeModelPdm* treeModel = RiuMainWindow::instance()->uiPdmModel(); treeModel->rebuildUiSubTree(inputRes->m_inputPropertyCollection()); } inputProperty->resolvedState = RimInputProperty::RESOLVED_NOT_SAVED; diff --git a/ApplicationCode/UserInterface/RICursors.cpp b/ApplicationCode/UserInterface/RICursors.cpp index 87cf79d31f..9d1f74d35b 100644 --- a/ApplicationCode/UserInterface/RICursors.cpp +++ b/ApplicationCode/UserInterface/RICursors.cpp @@ -35,7 +35,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RICursors::RICursors() +RiuCursors::RiuCursors() { m_cursors[FILTER_BOX] = cursorFromFile(":/Cursors/curFilterBox.bmp", 10, 10); m_cursors[NORMAL] = cursorFromFile(":/Cursors/curNormal.bmp", 10, 10); @@ -53,10 +53,10 @@ RICursors::RICursors() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QCursor RICursors::get(CursorIndex cursorIdx) +QCursor RiuCursors::get(CursorIndex cursorIdx) { // Create our single instance in a local static variable - static RICursors myStaticInstance; + static RiuCursors myStaticInstance; return myStaticInstance.m_cursors[cursorIdx]; } @@ -65,7 +65,7 @@ QCursor RICursors::get(CursorIndex cursorIdx) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QCursor RICursors::cursorFromFile(const QString& fileName, int hotspotX, int hotspotY) +QCursor RiuCursors::cursorFromFile(const QString& fileName, int hotspotX, int hotspotY) { QImage image(fileName); if (image.width() == 0 || image.height() == 0) diff --git a/ApplicationCode/UserInterface/RICursors.h b/ApplicationCode/UserInterface/RICursors.h index 136642c9fd..61fb559a01 100644 --- a/ApplicationCode/UserInterface/RICursors.h +++ b/ApplicationCode/UserInterface/RICursors.h @@ -27,7 +27,7 @@ // Singleton for getting the cursors // //================================================================================================== -class RICursors +class RiuCursors { public: enum CursorIndex @@ -48,7 +48,7 @@ public: static QCursor get(CursorIndex cursorIdx); private: - RICursors(); + RiuCursors(); static QCursor cursorFromFile(const QString& fileName, int hotspotX = -1, int hotspotY = -1); private: diff --git a/ApplicationCode/UserInterface/RIMainWindow.cpp b/ApplicationCode/UserInterface/RIMainWindow.cpp index 3bbe25ad1e..a118d350a1 100644 --- a/ApplicationCode/UserInterface/RIMainWindow.cpp +++ b/ApplicationCode/UserInterface/RIMainWindow.cpp @@ -53,12 +53,12 @@ //================================================================================================== -RIMainWindow* RIMainWindow::sm_mainWindowInstance = NULL; +RiuMainWindow* RiuMainWindow::sm_mainWindowInstance = NULL; //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RIMainWindow::RIMainWindow() +RiuMainWindow::RiuMainWindow() : m_treeView(NULL), m_pdmRoot(NULL), m_mainViewer(NULL), @@ -103,7 +103,7 @@ RIMainWindow::RIMainWindow() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RIMainWindow* RIMainWindow::instance() +RiuMainWindow* RiuMainWindow::instance() { return sm_mainWindowInstance; } @@ -111,7 +111,7 @@ RIMainWindow* RIMainWindow::instance() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::initializeGuiNewProjectLoaded() +void RiuMainWindow::initializeGuiNewProjectLoaded() { slotRefreshFileActions(); slotRefreshEditActions(); @@ -122,7 +122,7 @@ void RIMainWindow::initializeGuiNewProjectLoaded() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::cleanupGuiBeforeProjectClose() +void RiuMainWindow::cleanupGuiBeforeProjectClose() { setPdmRoot(NULL); setResultInfo(""); @@ -138,7 +138,7 @@ void RIMainWindow::cleanupGuiBeforeProjectClose() //-------------------------------------------------------------------------------------------------- /// Lightweight refresh of GUI (mainly toolbar actions). Called during idle processing //-------------------------------------------------------------------------------------------------- -void RIMainWindow::refreshGuiLightweight() +void RiuMainWindow::refreshGuiLightweight() { refreshToolbars(); } @@ -146,7 +146,7 @@ void RIMainWindow::refreshGuiLightweight() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::refreshToolbars() +void RiuMainWindow::refreshToolbars() { slotRefreshFileActions(); slotRefreshViewActions(); @@ -155,7 +155,7 @@ void RIMainWindow::refreshToolbars() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::closeEvent(QCloseEvent* event) +void RiuMainWindow::closeEvent(QCloseEvent* event) { if (!RiaApplication::instance()->closeProject(true)) { @@ -173,7 +173,7 @@ void RIMainWindow::closeEvent(QCloseEvent* event) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::createActions() +void RiuMainWindow::createActions() { // File actions m_openAction = new QAction(QIcon(":/AppLogo48x48.png"), "&Open Eclipse Case", this); @@ -262,7 +262,7 @@ void RIMainWindow::createActions() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::createMenus() +void RiuMainWindow::createMenus() { // File menu QMenu* fileMenu = menuBar()->addMenu("&File"); @@ -330,7 +330,7 @@ void RIMainWindow::createMenus() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::createToolBars() +void RiuMainWindow::createToolBars() { m_standardToolBar = addToolBar(tr("Standard")); @@ -366,7 +366,7 @@ void RIMainWindow::createToolBars() /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::createDockPanels() +void RiuMainWindow::createDockPanels() { { QDockWidget* dockWidget = new QDockWidget("Project", this); @@ -392,7 +392,7 @@ void RIMainWindow::createDockPanels() QDockWidget* dockPanel = new QDockWidget("Result Info", this); dockPanel->setObjectName("dockResultInfoPanel"); dockPanel->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); - m_resultInfoPanel = new RIResultInfoPanel(dockPanel); + m_resultInfoPanel = new RiuResultInfoPanel(dockPanel); dockPanel->setWidget(m_resultInfoPanel); addDockWidget(Qt::BottomDockWidgetArea, dockPanel); @@ -402,7 +402,7 @@ void RIMainWindow::createDockPanels() QDockWidget* dockPanel = new QDockWidget("Process Monitor", this); dockPanel->setObjectName("dockProcessMonitor"); dockPanel->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); - m_processMonitor = new RIProcessMonitor(dockPanel); + m_processMonitor = new RiuProcessMonitor(dockPanel); dockPanel->setWidget(m_processMonitor); addDockWidget(Qt::BottomDockWidgetArea, dockPanel); @@ -429,7 +429,7 @@ void RIMainWindow::createDockPanels() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::saveWinGeoAndDockToolBarLayout() +void RiuMainWindow::saveWinGeoAndDockToolBarLayout() { // Company and appname set through QCoreApplication QSettings settings; @@ -445,7 +445,7 @@ void RIMainWindow::saveWinGeoAndDockToolBarLayout() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::loadWinGeoAndDockToolBarLayout() +void RiuMainWindow::loadWinGeoAndDockToolBarLayout() { // Company and appname set through QCoreApplication QSettings settings; @@ -468,7 +468,7 @@ void RIMainWindow::loadWinGeoAndDockToolBarLayout() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::setResultInfo(const QString& info) const +void RiuMainWindow::setResultInfo(const QString& info) const { m_resultInfoPanel->setInfo(info); } @@ -484,7 +484,7 @@ void RIMainWindow::setResultInfo(const QString& info) const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotRefreshFileActions() +void RiuMainWindow::slotRefreshFileActions() { RiaApplication* app = RiaApplication::instance(); @@ -498,7 +498,7 @@ void RIMainWindow::slotRefreshFileActions() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotRefreshEditActions() +void RiuMainWindow::slotRefreshEditActions() { // RiaApplication* app = RiaApplication::instance(); // RISceneManager* proj = app->project(); @@ -508,7 +508,7 @@ void RIMainWindow::slotRefreshEditActions() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotRefreshViewActions() +void RiuMainWindow::slotRefreshViewActions() { // RiaApplication* app = RiaApplication::instance(); // RISceneManager* proj = app->project(); @@ -525,7 +525,7 @@ void RIMainWindow::slotRefreshViewActions() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::refreshAnimationActions() +void RiuMainWindow::refreshAnimationActions() { caf::FrameAnimationControl* ac = NULL; if (RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer()) @@ -593,7 +593,7 @@ void RIMainWindow::refreshAnimationActions() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotAbout() +void RiuMainWindow::slotAbout() { cvfqt::BasicAboutDialog dlg(this); @@ -626,7 +626,7 @@ void RIMainWindow::slotAbout() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotOpenBinaryGridFiles() +void RiuMainWindow::slotOpenBinaryGridFiles() { if (checkForDocumentModifications()) { @@ -654,7 +654,7 @@ void RIMainWindow::slotOpenBinaryGridFiles() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotOpenInputFiles() +void RiuMainWindow::slotOpenInputFiles() { if (checkForDocumentModifications()) { @@ -675,7 +675,7 @@ void RIMainWindow::slotOpenInputFiles() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotOpenProject() +void RiuMainWindow::slotOpenProject() { if (checkForDocumentModifications()) { @@ -697,7 +697,7 @@ void RIMainWindow::slotOpenProject() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotOpenLastUsedProject() +void RiuMainWindow::slotOpenLastUsedProject() { RiaApplication* app = RiaApplication::instance(); app->loadLastUsedProject(); @@ -706,7 +706,7 @@ void RIMainWindow::slotOpenLastUsedProject() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotMockModel() +void RiuMainWindow::slotMockModel() { RiaApplication* app = RiaApplication::instance(); app->createMockModel(); @@ -717,7 +717,7 @@ void RIMainWindow::slotMockModel() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotMockResultsModel() +void RiuMainWindow::slotMockResultsModel() { RiaApplication* app = RiaApplication::instance(); app->createResultsMockModel(); @@ -729,7 +729,7 @@ void RIMainWindow::slotMockResultsModel() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotMockLargeResultsModel() +void RiuMainWindow::slotMockLargeResultsModel() { RiaApplication* app = RiaApplication::instance(); app->createLargeResultsMockModel(); @@ -739,7 +739,7 @@ void RIMainWindow::slotMockLargeResultsModel() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotInputMockModel() +void RiuMainWindow::slotInputMockModel() { RiaApplication* app = RiaApplication::instance(); app->createInputMockModel(); @@ -749,7 +749,7 @@ void RIMainWindow::slotInputMockModel() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotSetCurrentFrame(int frameIndex) +void RiuMainWindow::slotSetCurrentFrame(int frameIndex) { RiaApplication* app = RiaApplication::instance(); // app->setTimeStep(frameIndex); @@ -758,7 +758,7 @@ void RIMainWindow::slotSetCurrentFrame(int frameIndex) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RIMainWindow::checkForDocumentModifications() +bool RiuMainWindow::checkForDocumentModifications() { RiaApplication* app = RiaApplication::instance(); // RISceneManager* project = app->sceneManager(); @@ -788,7 +788,7 @@ bool RIMainWindow::checkForDocumentModifications() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotCloseProject() +void RiuMainWindow::slotCloseProject() { RiaApplication* app = RiaApplication::instance(); bool ret = app->closeProject(true); @@ -798,7 +798,7 @@ void RIMainWindow::slotCloseProject() /// //-------------------------------------------------------------------------------------------------- -QMdiSubWindow* RIMainWindow::findMdiSubWindow(RIViewer* viewer) +QMdiSubWindow* RiuMainWindow::findMdiSubWindow(RiuViewer* viewer) { QList subws = m_mdiArea->subWindowList(); int i; @@ -817,7 +817,7 @@ QMdiSubWindow* RIMainWindow::findMdiSubWindow(RIViewer* viewer) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::removeViewer(RIViewer* viewer) +void RiuMainWindow::removeViewer(RiuViewer* viewer) { #if 0 m_CentralFrame->layout()->removeWidget(viewer->layoutWidget()); @@ -829,7 +829,7 @@ void RIMainWindow::removeViewer(RIViewer* viewer) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::addViewer(RIViewer* viewer) +void RiuMainWindow::addViewer(RiuViewer* viewer) { #if 0 m_CentralFrame->layout()->addWidget(viewer->layoutWidget()); @@ -852,7 +852,7 @@ void RIMainWindow::addViewer(RIViewer* viewer) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotSaveProject() +void RiuMainWindow::slotSaveProject() { RiaApplication* app = RiaApplication::instance(); @@ -862,7 +862,7 @@ void RIMainWindow::slotSaveProject() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotSaveProjectAs() +void RiuMainWindow::slotSaveProjectAs() { RiaApplication* app = RiaApplication::instance(); @@ -873,7 +873,7 @@ void RIMainWindow::slotSaveProjectAs() //-------------------------------------------------------------------------------------------------- /// This method needs to handle memory deallocation !!! //-------------------------------------------------------------------------------------------------- -void RIMainWindow::setPdmRoot(caf::PdmObject* pdmRoot) +void RiuMainWindow::setPdmRoot(caf::PdmObject* pdmRoot) { m_pdmRoot = pdmRoot; @@ -891,7 +891,7 @@ void RIMainWindow::setPdmRoot(caf::PdmObject* pdmRoot) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotViewFromNorth() +void RiuMainWindow::slotViewFromNorth() { if (RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer()) { @@ -902,7 +902,7 @@ void RIMainWindow::slotViewFromNorth() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotViewFromSouth() +void RiuMainWindow::slotViewFromSouth() { if (RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer()) { @@ -913,7 +913,7 @@ void RIMainWindow::slotViewFromSouth() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotViewFromEast() +void RiuMainWindow::slotViewFromEast() { if (RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer()) { @@ -924,7 +924,7 @@ void RIMainWindow::slotViewFromEast() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotViewFromWest() +void RiuMainWindow::slotViewFromWest() { if (RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer()) { @@ -935,7 +935,7 @@ void RIMainWindow::slotViewFromWest() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotViewFromAbove() +void RiuMainWindow::slotViewFromAbove() { if (RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer()) { @@ -946,7 +946,7 @@ void RIMainWindow::slotViewFromAbove() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotViewFromBelow() +void RiuMainWindow::slotViewFromBelow() { if (RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer()) { @@ -957,7 +957,7 @@ void RIMainWindow::slotViewFromBelow() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotZoomAll() +void RiuMainWindow::slotZoomAll() { if (RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer()) { @@ -968,7 +968,7 @@ void RIMainWindow::slotZoomAll() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotSubWindowActivated(QMdiSubWindow* subWindow) +void RiuMainWindow::slotSubWindowActivated(QMdiSubWindow* subWindow) { RimProject * proj = RiaApplication::instance()->project(); if (!proj) return; @@ -1050,7 +1050,7 @@ void RIMainWindow::slotSubWindowActivated(QMdiSubWindow* subWindow) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotUseShaders(bool enable) +void RiuMainWindow::slotUseShaders(bool enable) { RiaApplication::instance()->setUseShaders(enable); } @@ -1058,7 +1058,7 @@ void RIMainWindow::slotUseShaders(bool enable) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotShowPerformanceInfo(bool enable) +void RiuMainWindow::slotShowPerformanceInfo(bool enable) { RiaApplication::instance()->setShowPerformanceInfo(enable); } @@ -1066,7 +1066,7 @@ void RIMainWindow::slotShowPerformanceInfo(bool enable) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotRefreshDebugActions() +void RiuMainWindow::slotRefreshDebugActions() { RiaApplication* app = RiaApplication::instance(); } @@ -1074,10 +1074,10 @@ void RIMainWindow::slotRefreshDebugActions() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotEditPreferences() +void RiuMainWindow::slotEditPreferences() { RiaApplication* app = RiaApplication::instance(); - RIPreferencesDialog preferencesDialog(this, app->preferences(), "Preferences"); + RiuPreferencesDialog preferencesDialog(this, app->preferences(), "Preferences"); if (preferencesDialog.exec() == QDialog::Accepted) { // Write preferences using QSettings and apply them to the application @@ -1094,7 +1094,7 @@ void RIMainWindow::slotEditPreferences() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::setActiveViewer(RIViewer* viewer) +void RiuMainWindow::setActiveViewer(RiuViewer* viewer) { QMdiSubWindow * swin = findMdiSubWindow(viewer); if (swin) m_mdiArea->setActiveSubWindow(swin); @@ -1103,7 +1103,7 @@ void RIMainWindow::setActiveViewer(RIViewer* viewer) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotFramerateChanged(double frameRate) +void RiuMainWindow::slotFramerateChanged(double frameRate) { if (RiaApplication::instance()->activeReservoirView() != NULL) { @@ -1114,7 +1114,7 @@ void RIMainWindow::slotFramerateChanged(double frameRate) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RIProcessMonitor* RIMainWindow::processMonitor() +RiuProcessMonitor* RiuMainWindow::processMonitor() { return m_processMonitor; } @@ -1122,7 +1122,7 @@ RIProcessMonitor* RIMainWindow::processMonitor() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotBuildWindowActions() +void RiuMainWindow::slotBuildWindowActions() { m_windowMenu->clear(); @@ -1139,7 +1139,7 @@ void RIMainWindow::slotBuildWindowActions() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotCurrentChanged(const QModelIndex & current, const QModelIndex & previous) +void RiuMainWindow::slotCurrentChanged(const QModelIndex & current, const QModelIndex & previous) { RimReservoirView* activeReservoirView = RiaApplication::instance()->activeReservoirView(); QModelIndex activeViewModelIndex = m_treeModelPdm->getModelIndexFromPdmObject(activeReservoirView); @@ -1185,7 +1185,7 @@ void RIMainWindow::slotCurrentChanged(const QModelIndex & current, const QModelI //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotNewObjectPropertyView() +void RiuMainWindow::slotNewObjectPropertyView() { if (!m_treeModelPdm) return; @@ -1223,7 +1223,7 @@ void RIMainWindow::slotNewObjectPropertyView() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotSnapshotToFile() +void RiuMainWindow::slotSnapshotToFile() { RiaApplication* app = RiaApplication::instance(); @@ -1233,7 +1233,7 @@ void RIMainWindow::slotSnapshotToFile() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotSnapshotToClipboard() +void RiuMainWindow::slotSnapshotToClipboard() { RiaApplication* app = RiaApplication::instance(); @@ -1243,7 +1243,7 @@ void RIMainWindow::slotSnapshotToClipboard() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotSnapshotAllViewsToFile() +void RiuMainWindow::slotSnapshotAllViewsToFile() { RiaApplication* app = RiaApplication::instance(); @@ -1253,7 +1253,7 @@ void RIMainWindow::slotSnapshotAllViewsToFile() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::hideAllDockWindows() +void RiuMainWindow::hideAllDockWindows() { QList dockWidgets = findChildren(); @@ -1267,7 +1267,7 @@ void RIMainWindow::hideAllDockWindows() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIMainWindow::slotOpenMultipleCases() +void RiuMainWindow::slotOpenMultipleCases() { RiaApplication* app = RiaApplication::instance(); diff --git a/ApplicationCode/UserInterface/RIMainWindow.h b/ApplicationCode/UserInterface/RIMainWindow.h index 284ab19bdd..463599aa36 100644 --- a/ApplicationCode/UserInterface/RIMainWindow.h +++ b/ApplicationCode/UserInterface/RIMainWindow.h @@ -32,9 +32,9 @@ class QLabel; class QLineEdit; class QItemSelection; -class RIViewer; -class RIResultInfoPanel; -class RIProcessMonitor; +class RiuViewer; +class RiuResultInfoPanel; +class RiuProcessMonitor; class RimUiTreeModelPdm; namespace caf @@ -52,13 +52,13 @@ namespace caf // // //================================================================================================== -class RIMainWindow : public QMainWindow +class RiuMainWindow : public QMainWindow { Q_OBJECT public: - RIMainWindow(); - static RIMainWindow* instance(); + RiuMainWindow(); + static RiuMainWindow* instance(); void initializeGuiNewProjectLoaded(); void cleanupGuiBeforeProjectClose(); @@ -66,9 +66,9 @@ public: void refreshGuiLightweight(); void refreshToolbars(); - void removeViewer( RIViewer* viewer ); - void addViewer(RIViewer* viewer); - void setActiveViewer(RIViewer* subWindow); + void removeViewer( RiuViewer* viewer ); + void addViewer(RiuViewer* viewer); + void setActiveViewer(RiuViewer* subWindow); void setResultInfo(const QString& info) const; @@ -76,7 +76,7 @@ public: RimUiTreeModelPdm* uiPdmModel() { return m_treeModelPdm;} - RIProcessMonitor* processMonitor(); + RiuProcessMonitor* processMonitor(); void hideAllDockWindows(); @@ -95,10 +95,10 @@ private: void updateMRUList(const QString &fileName, bool remove = false); - QMdiSubWindow* findMdiSubWindow(RIViewer* viewer); + QMdiSubWindow* findMdiSubWindow(RiuViewer* viewer); private: - static RIMainWindow* sm_mainWindowInstance; + static RiuMainWindow* sm_mainWindowInstance; QByteArray m_initialDockAndToolbarLayout; // Initial dock window and toolbar layout, used to reset GUI @@ -150,9 +150,9 @@ private: QFrame* m_CentralFrame; QMdiArea* m_mdiArea; - RIViewer* m_mainViewer; - RIResultInfoPanel* m_resultInfoPanel; - RIProcessMonitor* m_processMonitor; + RiuViewer* m_mainViewer; + RiuResultInfoPanel* m_resultInfoPanel; + RiuProcessMonitor* m_processMonitor; QMenu* m_windowMenu; diff --git a/ApplicationCode/UserInterface/RIPreferencesDialog.cpp b/ApplicationCode/UserInterface/RIPreferencesDialog.cpp index 76c1d60f48..8b09a2a9a3 100644 --- a/ApplicationCode/UserInterface/RIPreferencesDialog.cpp +++ b/ApplicationCode/UserInterface/RIPreferencesDialog.cpp @@ -30,7 +30,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RIPreferencesDialog::RIPreferencesDialog(QWidget* parent, caf::PdmObject* object, const QString& windowTitle) +RiuPreferencesDialog::RiuPreferencesDialog(QWidget* parent, caf::PdmObject* object, const QString& windowTitle) : QDialog(parent) { CVF_ASSERT(object); @@ -44,7 +44,7 @@ RIPreferencesDialog::RIPreferencesDialog(QWidget* parent, caf::PdmObject* object //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIPreferencesDialog::setupUi() +void RiuPreferencesDialog::setupUi() { setWindowTitle(m_windowTitle); diff --git a/ApplicationCode/UserInterface/RIPreferencesDialog.h b/ApplicationCode/UserInterface/RIPreferencesDialog.h index b33c4924d2..3751e108fb 100644 --- a/ApplicationCode/UserInterface/RIPreferencesDialog.h +++ b/ApplicationCode/UserInterface/RIPreferencesDialog.h @@ -32,12 +32,12 @@ namespace caf // // //================================================================================================== -class RIPreferencesDialog : public QDialog +class RiuPreferencesDialog : public QDialog { Q_OBJECT public: - RIPreferencesDialog(QWidget* parent, caf::PdmObject* object, const QString& windowTitle); + RiuPreferencesDialog(QWidget* parent, caf::PdmObject* object, const QString& windowTitle); private: void setupUi(); diff --git a/ApplicationCode/UserInterface/RIProcessMonitor.cpp b/ApplicationCode/UserInterface/RIProcessMonitor.cpp index 4f7fa107d7..c2201a0baa 100644 --- a/ApplicationCode/UserInterface/RIProcessMonitor.cpp +++ b/ApplicationCode/UserInterface/RIProcessMonitor.cpp @@ -26,7 +26,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RIProcessMonitor::RIProcessMonitor(QDockWidget* pParent) +RiuProcessMonitor::RiuProcessMonitor(QDockWidget* pParent) : QWidget(pParent) { m_monitoredProcess = NULL; @@ -70,7 +70,7 @@ RIProcessMonitor::RIProcessMonitor(QDockWidget* pParent) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RIProcessMonitor::~RIProcessMonitor() +RiuProcessMonitor::~RiuProcessMonitor() { } @@ -79,7 +79,7 @@ RIProcessMonitor::~RIProcessMonitor() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIProcessMonitor::startMonitorWorkProcess(caf::UiProcess* pProcess) +void RiuProcessMonitor::startMonitorWorkProcess(caf::UiProcess* pProcess) { setStatusMsg("N/A", caf::PROCESS_STATE_NORMAL); @@ -102,7 +102,7 @@ void RIProcessMonitor::startMonitorWorkProcess(caf::UiProcess* pProcess) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIProcessMonitor::stopMonitorWorkProcess() +void RiuProcessMonitor::stopMonitorWorkProcess() { m_monitoredProcess = NULL; @@ -118,7 +118,7 @@ void RIProcessMonitor::stopMonitorWorkProcess() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIProcessMonitor::setStatusMsg(const QString& sStatusMsg, int iStatusMsgType) +void RiuProcessMonitor::setStatusMsg(const QString& sStatusMsg, int iStatusMsgType) { if (!m_labelStatus) return; @@ -138,7 +138,7 @@ void RIProcessMonitor::setStatusMsg(const QString& sStatusMsg, int iStatusMsgTyp //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIProcessMonitor::addStringToLog(const QString& sTxt) +void RiuProcessMonitor::addStringToLog(const QString& sTxt) { m_textEdit->moveCursor(QTextCursor::End); m_textEdit->insertPlainText(sTxt); @@ -150,7 +150,7 @@ void RIProcessMonitor::addStringToLog(const QString& sTxt) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIProcessMonitor::slotShowProcStatusMsg(const QString& sMsg, int iStatusMsgType) +void RiuProcessMonitor::slotShowProcStatusMsg(const QString& sMsg, int iStatusMsgType) { setStatusMsg(sMsg, iStatusMsgType); } @@ -159,7 +159,7 @@ void RIProcessMonitor::slotShowProcStatusMsg(const QString& sMsg, int iStatusMsg //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIProcessMonitor::slotProcReadyReadStdOut() +void RiuProcessMonitor::slotProcReadyReadStdOut() { if (!m_monitoredProcess) return; @@ -174,7 +174,7 @@ void RIProcessMonitor::slotProcReadyReadStdOut() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIProcessMonitor::slotProcReadyReadStdErr() +void RiuProcessMonitor::slotProcReadyReadStdErr() { if (!m_monitoredProcess) return; @@ -188,7 +188,7 @@ void RIProcessMonitor::slotProcReadyReadStdErr() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIProcessMonitor::slotTerminateProcess() +void RiuProcessMonitor::slotTerminateProcess() { addStringToLog("Process terminated by user\n"); @@ -199,7 +199,7 @@ void RIProcessMonitor::slotTerminateProcess() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIProcessMonitor::slotClearTextEdit() +void RiuProcessMonitor::slotClearTextEdit() { m_textEdit->clear(); } diff --git a/ApplicationCode/UserInterface/RIProcessMonitor.h b/ApplicationCode/UserInterface/RIProcessMonitor.h index 7a421ac1e0..8a58d66ca2 100644 --- a/ApplicationCode/UserInterface/RIProcessMonitor.h +++ b/ApplicationCode/UserInterface/RIProcessMonitor.h @@ -34,7 +34,7 @@ namespace caf //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -class RIProcessMonitor : public QWidget +class RiuProcessMonitor : public QWidget { Q_OBJECT @@ -46,8 +46,8 @@ private: caf::UiProcess* m_monitoredProcess; // Pointer to the process we're monitoring. Needed to fetch text public: - RIProcessMonitor(QDockWidget* pParent); - ~RIProcessMonitor(); + RiuProcessMonitor(QDockWidget* pParent); + ~RiuProcessMonitor(); void startMonitorWorkProcess(caf::UiProcess* process); void stopMonitorWorkProcess(); diff --git a/ApplicationCode/UserInterface/RIResultInfoPanel.cpp b/ApplicationCode/UserInterface/RIResultInfoPanel.cpp index 7ff0e84213..86aa29f811 100644 --- a/ApplicationCode/UserInterface/RIResultInfoPanel.cpp +++ b/ApplicationCode/UserInterface/RIResultInfoPanel.cpp @@ -33,7 +33,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RIResultInfoPanel::RIResultInfoPanel(QDockWidget* parent) +RiuResultInfoPanel::RiuResultInfoPanel(QDockWidget* parent) : QWidget(parent) { m_textEdit = new QTextEdit(this); @@ -49,7 +49,7 @@ RIResultInfoPanel::RIResultInfoPanel(QDockWidget* parent) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIResultInfoPanel::setInfo(const QString& info) +void RiuResultInfoPanel::setInfo(const QString& info) { QString tmp(info); @@ -62,7 +62,7 @@ void RIResultInfoPanel::setInfo(const QString& info) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIResultInfoPanel::convertStringToHTML(QString* str) +void RiuResultInfoPanel::convertStringToHTML(QString* str) { str->replace("\n", "
"); str->replace(" ", " "); @@ -72,7 +72,7 @@ void RIResultInfoPanel::convertStringToHTML(QString* str) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QSize RIResultInfoPanel::sizeHint () const +QSize RiuResultInfoPanel::sizeHint () const { // As small as possible fow now return QSize(20, 20); diff --git a/ApplicationCode/UserInterface/RIResultInfoPanel.h b/ApplicationCode/UserInterface/RIResultInfoPanel.h index 3c753b3e86..7eb1383dbf 100644 --- a/ApplicationCode/UserInterface/RIResultInfoPanel.h +++ b/ApplicationCode/UserInterface/RIResultInfoPanel.h @@ -30,12 +30,12 @@ class QTextEdit; // RIResultInfoPanel // //================================================================================================== -class RIResultInfoPanel : public QWidget +class RiuResultInfoPanel : public QWidget { Q_OBJECT public: - RIResultInfoPanel(QDockWidget* parent); + RiuResultInfoPanel(QDockWidget* parent); void setInfo(const QString& info); diff --git a/ApplicationCode/UserInterface/RIViewer.cpp b/ApplicationCode/UserInterface/RIViewer.cpp index ddac6c550d..3078df0e20 100644 --- a/ApplicationCode/UserInterface/RIViewer.cpp +++ b/ApplicationCode/UserInterface/RIViewer.cpp @@ -54,7 +54,7 @@ const double RI_MIN_NEARPLANE_DISTANCE = 0.1; //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RIViewer::RIViewer(const QGLFormat& format, QWidget* parent) +RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent) : caf::Viewer(format, parent) { cvf::FixedAtlasFont* font = new cvf::FixedAtlasFont(cvf::FixedAtlasFont::STANDARD); @@ -113,7 +113,7 @@ RIViewer::RIViewer(const QGLFormat& format, QWidget* parent) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RIViewer::~RIViewer() +RiuViewer::~RiuViewer() { m_reservoirView->showWindow = false; m_reservoirView->cameraPosition = m_mainCamera->viewMatrix(); @@ -128,7 +128,7 @@ RIViewer::~RIViewer() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIViewer::setColorLegend1(cvf::OverlayScalarMapperLegend* legend) +void RiuViewer::setColorLegend1(cvf::OverlayScalarMapperLegend* legend) { m_mainRendering->removeOverlayItem(m_legend1.p()); @@ -141,7 +141,7 @@ void RIViewer::setColorLegend1(cvf::OverlayScalarMapperLegend* legend) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIViewer::setColorLegend2(cvf::OverlayScalarMapperLegend* legend) +void RiuViewer::setColorLegend2(cvf::OverlayScalarMapperLegend* legend) { m_mainRendering->removeOverlayItem(m_legend2.p()); @@ -153,7 +153,7 @@ void RIViewer::setColorLegend2(cvf::OverlayScalarMapperLegend* legend) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIViewer::updateLegends() +void RiuViewer::updateLegends() { cvf::Rendering* firstRendering = m_renderingSequence->firstRendering(); CVF_ASSERT(firstRendering); @@ -175,7 +175,7 @@ void RIViewer::updateLegends() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIViewer::setDefaultView() +void RiuViewer::setDefaultView() { cvf::BoundingBox bb; @@ -211,7 +211,7 @@ void RIViewer::setDefaultView() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIViewer::mouseReleaseEvent(QMouseEvent* event) +void RiuViewer::mouseReleaseEvent(QMouseEvent* event) { m_mouseState.updateFromMouseEvent(event); @@ -233,7 +233,7 @@ void RIViewer::mouseReleaseEvent(QMouseEvent* event) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIViewer::keyPressEvent(QKeyEvent* event) +void RiuViewer::keyPressEvent(QKeyEvent* event) { // Trap escape key so we can get out of direct button press actions if (event->key() == Qt::Key_Escape) @@ -246,11 +246,11 @@ void RIViewer::keyPressEvent(QKeyEvent* event) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIViewer::handlePickAction(int winPosX, int winPosY) +void RiuViewer::handlePickAction(int winPosX, int winPosY) { RiaApplication* app = RiaApplication::instance(); - RIMainWindow* mainWnd = RIMainWindow::instance(); + RiuMainWindow* mainWnd = RiuMainWindow::instance(); if (!mainWnd) return; QString pickInfo = "No hits"; @@ -310,7 +310,7 @@ void RIViewer::handlePickAction(int winPosX, int winPosY) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIViewer::slotEndAnimation() +void RiuViewer::slotEndAnimation() { cvf::Rendering* firstRendering = m_renderingSequence->firstRendering(); CVF_ASSERT(firstRendering); @@ -328,7 +328,7 @@ void RIViewer::slotEndAnimation() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIViewer::slotSetCurrentFrame(int frameIndex) +void RiuViewer::slotSetCurrentFrame(int frameIndex) { cvf::Rendering* firstRendering = m_renderingSequence->firstRendering(); CVF_ASSERT(firstRendering); @@ -343,7 +343,7 @@ void RIViewer::slotSetCurrentFrame(int frameIndex) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::Vec3d RIViewer::pointOfInterest() +cvf::Vec3d RiuViewer::pointOfInterest() { return m_navigationPolicy->pointOfInterest(); } @@ -351,7 +351,7 @@ cvf::Vec3d RIViewer::pointOfInterest() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIViewer::setPointOfInterest(cvf::Vec3d poi) +void RiuViewer::setPointOfInterest(cvf::Vec3d poi) { m_navigationPolicy->setPointOfInterest(poi); } @@ -359,7 +359,7 @@ void RIViewer::setPointOfInterest(cvf::Vec3d poi) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIViewer::setOwnerReservoirView(RimReservoirView * owner) +void RiuViewer::setOwnerReservoirView(RimReservoirView * owner) { m_reservoirView = owner; } @@ -367,7 +367,7 @@ void RIViewer::setOwnerReservoirView(RimReservoirView * owner) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIViewer::setEnableMask(unsigned int mask) +void RiuViewer::setEnableMask(unsigned int mask) { m_mainRendering->setEnableMask(mask); } @@ -375,7 +375,7 @@ void RIViewer::setEnableMask(unsigned int mask) //-------------------------------------------------------------------------------------------------- /// Perform picking and return the index of the face that was hit, if a drawable geo was hit //-------------------------------------------------------------------------------------------------- -cvf::Part* RIViewer::pickPointAndFace(int winPosX, int winPosY, uint* faceHit, cvf::Vec3d* localIntersectionPoint) +cvf::Part* RiuViewer::pickPointAndFace(int winPosX, int winPosY, uint* faceHit, cvf::Vec3d* localIntersectionPoint) { CVF_ASSERT(faceHit); @@ -425,7 +425,7 @@ cvf::Part* RIViewer::pickPointAndFace(int winPosX, int winPosY, uint* faceHit, c //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIViewer::paintOverlayItems(QPainter* painter) +void RiuViewer::paintOverlayItems(QPainter* painter) { // No support for overlay items using SW rendering yet. //if (!isShadersSupported()) @@ -475,7 +475,7 @@ void RIViewer::paintOverlayItems(QPainter* painter) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIViewer::setInfoText(QString text) +void RiuViewer::setInfoText(QString text) { m_InfoLabel->setText(text); } @@ -483,7 +483,7 @@ void RIViewer::setInfoText(QString text) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIViewer::showInfoText(bool enable) +void RiuViewer::showInfoText(bool enable) { m_showInfoText = enable; } @@ -491,7 +491,7 @@ void RIViewer::showInfoText(bool enable) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIViewer::setHistogram(double min, double max, const std::vector& histogram) +void RiuViewer::setHistogram(double min, double max, const std::vector& histogram) { m_histogramWidget->setHistogramData(min, max, histogram); } @@ -499,7 +499,7 @@ void RIViewer::setHistogram(double min, double max, const std::vector& h //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIViewer::setHistogramPercentiles(double pmin, double pmax, double mean) +void RiuViewer::setHistogramPercentiles(double pmin, double pmax, double mean) { m_histogramWidget->setPercentiles(pmin, pmax); m_histogramWidget->setMean(mean); @@ -508,7 +508,7 @@ void RIViewer::setHistogramPercentiles(double pmin, double pmax, double mean) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIViewer::showAnimationProgress(bool enable) +void RiuViewer::showAnimationProgress(bool enable) { m_showAnimProgress = enable; } @@ -516,7 +516,7 @@ void RIViewer::showAnimationProgress(bool enable) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RIViewer::showHistogram(bool enable) +void RiuViewer::showHistogram(bool enable) { m_showHistogram = enable; } diff --git a/ApplicationCode/UserInterface/RIViewer.h b/ApplicationCode/UserInterface/RIViewer.h index 349f415783..713c220572 100644 --- a/ApplicationCode/UserInterface/RIViewer.h +++ b/ApplicationCode/UserInterface/RIViewer.h @@ -41,13 +41,13 @@ namespace cvf // RIViewer // //================================================================================================== -class RIViewer : public caf::Viewer +class RiuViewer : public caf::Viewer { Q_OBJECT public: - RIViewer(const QGLFormat& format, QWidget* parent); - ~RIViewer(); + RiuViewer(const QGLFormat& format, QWidget* parent); + ~RiuViewer(); void setColorLegend1(cvf::OverlayScalarMapperLegend* legend); void setColorLegend2(cvf::OverlayScalarMapperLegend* legend); From e10bd73658735f7eb020016bdacde0c523dda255 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 22 Mar 2013 17:30:50 +0100 Subject: [PATCH 171/242] Renamed the final filenames for this time: RICursors RiuCursors RIMainWindow RiuMainWindow RIPreferencesDialog RiuPreferencesDialog RIProcessMonitor RiuProcessMonitor RIResultInfoPanel RiuResultInfoPanel RIViewer RiuViewer p4#: 21072 --- .../Application/RiaApplication.cpp | 6 ++--- ApplicationCode/CMakeLists.txt | 22 +++++++++---------- .../Rim3dOverlayInfoConfig.cpp | 2 +- .../ProjectDataModel/RimReservoirView.cpp | 4 ++-- .../ProjectDataModel/RimResultSlot.cpp | 2 +- .../ProjectDataModel/RimScriptCollection.cpp | 2 +- .../ProjectDataModel/RimUiTreeModelPdm.cpp | 4 ++-- .../ProjectDataModel/RimUiTreeView.cpp | 4 ++-- ApplicationCode/RiaMain.cpp | 2 +- .../SocketInterface/RiaSocketServer.cpp | 2 +- .../{RICursors.cpp => RiuCursors.cpp} | 2 +- .../{RICursors.h => RiuCursors.h} | 0 .../{RIMainWindow.cpp => RiuMainWindow.cpp} | 12 +++++----- .../{RIMainWindow.h => RiuMainWindow.h} | 0 ...cesDialog.cpp => RiuPreferencesDialog.cpp} | 2 +- ...erencesDialog.h => RiuPreferencesDialog.h} | 0 ...ocessMonitor.cpp => RiuProcessMonitor.cpp} | 2 +- ...RIProcessMonitor.h => RiuProcessMonitor.h} | 0 ...ltInfoPanel.cpp => RiuResultInfoPanel.cpp} | 4 ++-- ...ResultInfoPanel.h => RiuResultInfoPanel.h} | 2 +- .../{RIViewer.cpp => RiuViewer.cpp} | 8 +++---- .../UserInterface/{RIViewer.h => RiuViewer.h} | 2 +- cafViewer/cafCadNavigation.cpp | 4 ++-- cafViewer/cafCeetronNavigation.cpp | 8 +++---- 24 files changed, 48 insertions(+), 48 deletions(-) rename ApplicationCode/UserInterface/{RICursors.cpp => RiuCursors.cpp} (99%) rename ApplicationCode/UserInterface/{RICursors.h => RiuCursors.h} (100%) rename ApplicationCode/UserInterface/{RIMainWindow.cpp => RiuMainWindow.cpp} (99%) rename ApplicationCode/UserInterface/{RIMainWindow.h => RiuMainWindow.h} (100%) rename ApplicationCode/UserInterface/{RIPreferencesDialog.cpp => RiuPreferencesDialog.cpp} (98%) rename ApplicationCode/UserInterface/{RIPreferencesDialog.h => RiuPreferencesDialog.h} (100%) rename ApplicationCode/UserInterface/{RIProcessMonitor.cpp => RiuProcessMonitor.cpp} (99%) rename ApplicationCode/UserInterface/{RIProcessMonitor.h => RiuProcessMonitor.h} (100%) rename ApplicationCode/UserInterface/{RIResultInfoPanel.cpp => RiuResultInfoPanel.cpp} (97%) rename ApplicationCode/UserInterface/{RIResultInfoPanel.h => RiuResultInfoPanel.h} (98%) rename ApplicationCode/UserInterface/{RIViewer.cpp => RiuViewer.cpp} (99%) rename ApplicationCode/UserInterface/{RIViewer.h => RiuViewer.h} (99%) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 8056fb11ee..c534ebc91d 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -30,9 +30,9 @@ #include "RiaBaseDefs.h" #include "RiaApplication.h" -#include "RIMainWindow.h" -#include "RIViewer.h" -#include "RIProcessMonitor.h" +#include "RiuMainWindow.h" +#include "RiuViewer.h" +#include "RiuProcessMonitor.h" #include "RiaPreferences.h" #include "RimResultCase.h" diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index 36233c7f34..ba0d50800c 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -97,14 +97,14 @@ list( APPEND CPP_SOURCES ) list( APPEND CPP_SOURCES - UserInterface/RICursors.cpp - UserInterface/RIMainWindow.cpp - UserInterface/RIPreferencesDialog.cpp - UserInterface/RIResultInfoPanel.cpp - UserInterface/RIViewer.cpp + UserInterface/RiuCursors.cpp + UserInterface/RiuMainWindow.cpp + UserInterface/RiuPreferencesDialog.cpp + UserInterface/RiuResultInfoPanel.cpp + UserInterface/RiuViewer.cpp UserInterface/RiuSimpleHistogramWidget.cpp UserInterface/RiuMultiCaseImportDialog.cpp - UserInterface/RIProcessMonitor.cpp + UserInterface/RiuProcessMonitor.cpp ) @@ -115,11 +115,11 @@ set ( QT_MOC_HEADERS ProjectDataModel/RimUiTreeModelPdm.h ProjectDataModel/RimUiTreeView.h - UserInterface/RIMainWindow.h - UserInterface/RIPreferencesDialog.h - UserInterface/RIResultInfoPanel.h - UserInterface/RIViewer.h - UserInterface/RIProcessMonitor.h + UserInterface/RiuMainWindow.h + UserInterface/RiuPreferencesDialog.h + UserInterface/RiuResultInfoPanel.h + UserInterface/RiuViewer.h + UserInterface/RiuProcessMonitor.h SocketInterface/RiaSocketServer.h UserInterface/RiuMultiCaseImportDialog.h ) diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index e9617def3d..09ec328590 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -20,7 +20,7 @@ #include "Rim3dOverlayInfoConfig.h" #include "RimReservoirView.h" -#include "RIViewer.h" +#include "RiuViewer.h" #include "RimCase.h" #include "RigCaseData.h" #include "RigMainGrid.h" diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp index c77f00e97d..8135349553 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp @@ -17,10 +17,10 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RiaStdInclude.h" -#include "RIViewer.h" +#include "RiuViewer.h" #include "RimReservoirView.h" -#include "RIMainWindow.h" +#include "RiuMainWindow.h" #include "RigGridBase.h" #include "RigCaseData.h" #include "RiaApplication.h" diff --git a/ApplicationCode/ProjectDataModel/RimResultSlot.cpp b/ApplicationCode/ProjectDataModel/RimResultSlot.cpp index 949170296e..3e7cbac4ff 100644 --- a/ApplicationCode/ProjectDataModel/RimResultSlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultSlot.cpp @@ -22,7 +22,7 @@ #include "RimLegendConfig.h" #include "RimReservoirView.h" #include "RimCase.h" -#include "RIMainWindow.h" +#include "RiuMainWindow.h" #include "RimUiTreeModelPdm.h" diff --git a/ApplicationCode/ProjectDataModel/RimScriptCollection.cpp b/ApplicationCode/ProjectDataModel/RimScriptCollection.cpp index 475e809eb8..e267ab6389 100644 --- a/ApplicationCode/ProjectDataModel/RimScriptCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimScriptCollection.cpp @@ -22,7 +22,7 @@ #include "RimScriptCollection.h" #include "cafPdmField.h" #include "cafUtils.h" -#include "RIMainWindow.h" +#include "RiuMainWindow.h" #include "RimUiTreeModelPdm.h" #include "cafPdmUiFilePathEditor.h" diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index e51c0bf8c4..7d642a029e 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -27,10 +27,10 @@ #include "RimCellPropertyFilterCollection.h" #include "RimReservoirView.h" -#include "RIViewer.h" +#include "RiuViewer.h" #include "RimCalcScript.h" #include "RiaApplication.h" -#include "RIMainWindow.h" +#include "RiuMainWindow.h" #include "RimInputProperty.h" #include "RimInputPropertyCollection.h" #include "cafPdmField.h" diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index 4ec3e05659..c4aee2049b 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -25,10 +25,10 @@ #include "RimReservoirView.h" #include "RimCalcScript.h" #include "RiaApplication.h" -#include "RIMainWindow.h" +#include "RiuMainWindow.h" #include "RimInputPropertyCollection.h" #include "RimExportInputPropertySettings.h" -#include "RIPreferencesDialog.h" +#include "RiuPreferencesDialog.h" #include "RifEclipseInputFileTools.h" #include "RimInputCase.h" #include "RimBinaryExportSettings.h" diff --git a/ApplicationCode/RiaMain.cpp b/ApplicationCode/RiaMain.cpp index a61099b46f..5804647de9 100644 --- a/ApplicationCode/RiaMain.cpp +++ b/ApplicationCode/RiaMain.cpp @@ -18,7 +18,7 @@ #include "RiaStdInclude.h" #include "RiaApplication.h" -#include "RIMainWindow.h" +#include "RiuMainWindow.h" int main(int argc, char *argv[]) diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.cpp b/ApplicationCode/SocketInterface/RiaSocketServer.cpp index 7cd51e467f..ca25c15ea8 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.cpp +++ b/ApplicationCode/SocketInterface/RiaSocketServer.cpp @@ -24,7 +24,7 @@ #include "RiaSocketServer.h" #include "RiaApplication.h" -#include "RIMainWindow.h" +#include "RiuMainWindow.h" #include "RimCase.h" #include "RigCaseData.h" #include "RigCaseCellResultsData.h" diff --git a/ApplicationCode/UserInterface/RICursors.cpp b/ApplicationCode/UserInterface/RiuCursors.cpp similarity index 99% rename from ApplicationCode/UserInterface/RICursors.cpp rename to ApplicationCode/UserInterface/RiuCursors.cpp index 9d1f74d35b..bc84b95511 100644 --- a/ApplicationCode/UserInterface/RICursors.cpp +++ b/ApplicationCode/UserInterface/RiuCursors.cpp @@ -18,7 +18,7 @@ #include "RiaStdInclude.h" -#include "RICursors.h" +#include "RiuCursors.h" #include #include diff --git a/ApplicationCode/UserInterface/RICursors.h b/ApplicationCode/UserInterface/RiuCursors.h similarity index 100% rename from ApplicationCode/UserInterface/RICursors.h rename to ApplicationCode/UserInterface/RiuCursors.h diff --git a/ApplicationCode/UserInterface/RIMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp similarity index 99% rename from ApplicationCode/UserInterface/RIMainWindow.cpp rename to ApplicationCode/UserInterface/RiuMainWindow.cpp index a118d350a1..a7ce76fb97 100644 --- a/ApplicationCode/UserInterface/RIMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -20,12 +20,12 @@ #include "RiaBaseDefs.h" #include "RiaApplication.h" -#include "RIMainWindow.h" -#include "RIViewer.h" -#include "RIResultInfoPanel.h" -#include "RIProcessMonitor.h" +#include "RiuMainWindow.h" +#include "RiuViewer.h" +#include "RiuResultInfoPanel.h" +#include "RiuProcessMonitor.h" #include "RiaPreferences.h" -#include "RIPreferencesDialog.h" +#include "RiuPreferencesDialog.h" #include "RigCaseData.h" #include "RigCaseCellResultsData.h" @@ -46,7 +46,7 @@ //================================================================================================== /// -/// \class RIMainWindow +/// \class RiuMainWindow /// /// Contains our main window /// diff --git a/ApplicationCode/UserInterface/RIMainWindow.h b/ApplicationCode/UserInterface/RiuMainWindow.h similarity index 100% rename from ApplicationCode/UserInterface/RIMainWindow.h rename to ApplicationCode/UserInterface/RiuMainWindow.h diff --git a/ApplicationCode/UserInterface/RIPreferencesDialog.cpp b/ApplicationCode/UserInterface/RiuPreferencesDialog.cpp similarity index 98% rename from ApplicationCode/UserInterface/RIPreferencesDialog.cpp rename to ApplicationCode/UserInterface/RiuPreferencesDialog.cpp index 8b09a2a9a3..7a094776c8 100644 --- a/ApplicationCode/UserInterface/RIPreferencesDialog.cpp +++ b/ApplicationCode/UserInterface/RiuPreferencesDialog.cpp @@ -17,7 +17,7 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RiaStdInclude.h" -#include "RIPreferencesDialog.h" +#include "RiuPreferencesDialog.h" #include "cafAppEnum.h" #include "cafPdmObject.h" diff --git a/ApplicationCode/UserInterface/RIPreferencesDialog.h b/ApplicationCode/UserInterface/RiuPreferencesDialog.h similarity index 100% rename from ApplicationCode/UserInterface/RIPreferencesDialog.h rename to ApplicationCode/UserInterface/RiuPreferencesDialog.h diff --git a/ApplicationCode/UserInterface/RIProcessMonitor.cpp b/ApplicationCode/UserInterface/RiuProcessMonitor.cpp similarity index 99% rename from ApplicationCode/UserInterface/RIProcessMonitor.cpp rename to ApplicationCode/UserInterface/RiuProcessMonitor.cpp index c2201a0baa..4c4396954b 100644 --- a/ApplicationCode/UserInterface/RIProcessMonitor.cpp +++ b/ApplicationCode/UserInterface/RiuProcessMonitor.cpp @@ -18,7 +18,7 @@ #include "RiaStdInclude.h" -#include "RIProcessMonitor.h" +#include "RiuProcessMonitor.h" #include "cafUiProcess.h" #include "RiaApplication.h" diff --git a/ApplicationCode/UserInterface/RIProcessMonitor.h b/ApplicationCode/UserInterface/RiuProcessMonitor.h similarity index 100% rename from ApplicationCode/UserInterface/RIProcessMonitor.h rename to ApplicationCode/UserInterface/RiuProcessMonitor.h diff --git a/ApplicationCode/UserInterface/RIResultInfoPanel.cpp b/ApplicationCode/UserInterface/RiuResultInfoPanel.cpp similarity index 97% rename from ApplicationCode/UserInterface/RIResultInfoPanel.cpp rename to ApplicationCode/UserInterface/RiuResultInfoPanel.cpp index 86aa29f811..124f96f632 100644 --- a/ApplicationCode/UserInterface/RIResultInfoPanel.cpp +++ b/ApplicationCode/UserInterface/RiuResultInfoPanel.cpp @@ -17,13 +17,13 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RiaStdInclude.h" -#include "RIResultInfoPanel.h" +#include "RiuResultInfoPanel.h" //================================================================================================== /// -/// \class RIResultInfoPanel +/// \class RiuResultInfoPanel /// \ingroup ResInsight /// /// diff --git a/ApplicationCode/UserInterface/RIResultInfoPanel.h b/ApplicationCode/UserInterface/RiuResultInfoPanel.h similarity index 98% rename from ApplicationCode/UserInterface/RIResultInfoPanel.h rename to ApplicationCode/UserInterface/RiuResultInfoPanel.h index 7eb1383dbf..9ee0ba1b24 100644 --- a/ApplicationCode/UserInterface/RIResultInfoPanel.h +++ b/ApplicationCode/UserInterface/RiuResultInfoPanel.h @@ -27,7 +27,7 @@ class QTextEdit; //================================================================================================== // -// RIResultInfoPanel +// RiuResultInfoPanel // //================================================================================================== class RiuResultInfoPanel : public QWidget diff --git a/ApplicationCode/UserInterface/RIViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp similarity index 99% rename from ApplicationCode/UserInterface/RIViewer.cpp rename to ApplicationCode/UserInterface/RiuViewer.cpp index 3078df0e20..ff5a2d6657 100644 --- a/ApplicationCode/UserInterface/RIViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -18,16 +18,16 @@ #include "RiaStdInclude.h" -#include "RIViewer.h" +#include "RiuViewer.h" #include "RiaApplication.h" -#include "RIMainWindow.h" +#include "RiuMainWindow.h" #include "cvfqtOpenGLContext.h" #include "cvfqtPerformanceInfoHud.h" #include "cvfCamera.h" #include "cvfRendering.h" #include "cvfDrawableGeo.h" -#include "RICursors.h" +#include "RiuCursors.h" #include "RigCaseData.h" #include "cafUtils.h" @@ -44,7 +44,7 @@ const double RI_MIN_NEARPLANE_DISTANCE = 0.1; //================================================================================================== /// -/// \class RIViewer +/// \class RiuViewer /// \ingroup ResInsight /// /// diff --git a/ApplicationCode/UserInterface/RIViewer.h b/ApplicationCode/UserInterface/RiuViewer.h similarity index 99% rename from ApplicationCode/UserInterface/RIViewer.h rename to ApplicationCode/UserInterface/RiuViewer.h index 713c220572..71c7b32790 100644 --- a/ApplicationCode/UserInterface/RIViewer.h +++ b/ApplicationCode/UserInterface/RiuViewer.h @@ -38,7 +38,7 @@ namespace cvf //================================================================================================== // -// RIViewer +// RiuViewer // //================================================================================================== class RiuViewer : public caf::Viewer diff --git a/cafViewer/cafCadNavigation.cpp b/cafViewer/cafCadNavigation.cpp index 03c0b67cd9..28b4023d91 100644 --- a/cafViewer/cafCadNavigation.cpp +++ b/cafViewer/cafCadNavigation.cpp @@ -83,7 +83,7 @@ bool caf::CadNavigation::handleInputEvent(QInputEvent* inputEvent) } m_trackball->startNavigation(cvf::ManipulatorTrackball::ROTATE, translatedMousePosX, translatedMousePosY); - //m_viewer->setCursor(RICursors::get(RICursors::ROTATE)); + //m_viewer->setCursor(RiuCursors::get(RiuCursors::ROTATE)); m_isRotating = true; isEventHandled = true; } @@ -98,7 +98,7 @@ bool caf::CadNavigation::handleInputEvent(QInputEvent* inputEvent) if (me->button() == Qt::MidButton) { m_trackball->endNavigation(); - //m_viewer->setCursor(RICursors::get(RICursors::PICK)); + //m_viewer->setCursor(RiuCursors::get(RiuCursors::PICK)); m_isRotating = false; isEventHandled = true; } diff --git a/cafViewer/cafCeetronNavigation.cpp b/cafViewer/cafCeetronNavigation.cpp index 4b09a40da2..e4a444ed20 100644 --- a/cafViewer/cafCeetronNavigation.cpp +++ b/cafViewer/cafCeetronNavigation.cpp @@ -237,19 +237,19 @@ void caf::CeetronNavigation::setCursorFromCurrentState() switch (navType) { case ManipulatorTrackball::PAN: - //m_viewer->setCursor(RICursors::get(RICursors::PAN)); + //m_viewer->setCursor(RiuCursors::get(RiuCursors::PAN)); return; case ManipulatorTrackball::WALK: - //m_viewer->setCursor(RICursors::get(RICursors::WALK)); + //m_viewer->setCursor(RiuCursors::get(RiuCursors::WALK)); return; case ManipulatorTrackball::ROTATE: - //m_viewer->setCursor(RICursors::get(RICursors::ROTATE)); + //m_viewer->setCursor(RiuCursors::get(RiuCursors::ROTATE)); return; default: break; } - // m_viewer->setCursor(RICursors::get(RICursors::PICK)); + // m_viewer->setCursor(RiuCursors::get(RiuCursors::PICK)); } //-------------------------------------------------------------------------------------------------- From c16db0640b20928cc4d6a706a3de6eace60dc8ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 2 Apr 2013 15:20:55 +0200 Subject: [PATCH 172/242] First start of statistics control data model p4#: 21097 --- .../ProjectDataModel/RimStatisticsCase.cpp | 62 ++++++++++++++++--- .../ProjectDataModel/RimStatisticsCase.h | 28 ++++++++- 2 files changed, 78 insertions(+), 12 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp index e50e084f43..1e2e6248a2 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp @@ -27,6 +27,17 @@ #include "RimStatisticsCaseEvaluator.h" #include "RigMainGrid.h" +namespace caf { + template<> + void caf::AppEnum::setUp() + { + addItem(RimStatisticsCase::EXACT, "ExactPercentile", "Exact"); + addItem(RimStatisticsCase::HISTOGRAM_ESTIMATED, "HistogramEstimatedPercentile", "Estimated (Faster for large case counts)"); + setDefault(RimStatisticsCase::EXACT); + } +} + + CAF_PDM_SOURCE_INIT(RimStatisticsCase, "RimStatisticalCalculation"); @@ -37,7 +48,23 @@ RimStatisticsCase::RimStatisticsCase() : RimCase() { CAF_PDM_InitObject("Case Group Statistics", ":/Histogram16x16.png", "", ""); - CAF_PDM_InitField(&m_resultName, "ResultName", QString("PRESSURE"), "ResultName", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_resultType, "ResultType", "Result Type", "", "", ""); + m_resultType.setIOWritable(false); + CAF_PDM_InitFieldNoDefault(&m_porosityModel, "PorosityModel", "Porosity Model", "", "", ""); + m_porosityModel.setIOWritable(false); + + CAF_PDM_InitFieldNoDefault(&m_selectedDynamicProperties, "DynamicPropertiesToCalculate", "", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_selectedStaticProperties, "StaticPropertiesToCalculate", "", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_selectedGeneratedProperties, "GeneratedPropertiesToCalculate", "", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_selectedInputProperties, "InputPropertiesToCalculate", "", "", "", ""); + + CAF_PDM_InitField(&m_calculatePercentiles, "CalculatePercentiles", true, "Calculate Percentiles", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_percentileCalculationType, "PercentileCalculationType", "Method", "", "", ""); + + CAF_PDM_InitField(&m_lowPercentile, "LowPercentile", 10.0, "Low", "", "", ""); + CAF_PDM_InitField(&m_midPercentile, "MidPercentile", 50.0, "Mid", "", "", ""); + CAF_PDM_InitField(&m_highPercentile, "HighPercentile", 90.0, "High", "", "", ""); + } @@ -87,14 +114,6 @@ bool RimStatisticsCase::openEclipseGridFile() return true; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimStatisticsCase::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const -{ - -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -218,3 +237,28 @@ RimIdenticalGridCaseGroup* RimStatisticsCase::caseGroup() return NULL; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimStatisticsCase::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimStatisticsCase::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) +{ + QList options; + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimStatisticsCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + +} diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCase.h b/ApplicationCode/ProjectDataModel/RimStatisticsCase.h index 0d8418a29a..2b0e0df5fe 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCase.h +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCase.h @@ -46,14 +46,36 @@ public: void setMainGrid(RigMainGrid* mainGrid); - virtual bool openEclipseGridFile(); + caf::PdmField< caf::AppEnum< RimDefines::ResultCatType > > m_resultType; + caf::PdmField< caf::AppEnum< RimDefines::PorosityModelType > > m_porosityModel; - caf::PdmField m_resultName; + caf::PdmField > m_selectedDynamicProperties; + caf::PdmField > m_selectedStaticProperties; + caf::PdmField > m_selectedGeneratedProperties; + caf::PdmField > m_selectedInputProperties; + + enum PercentileCalcType + { + EXACT, + HISTOGRAM_ESTIMATED + }; + + caf::PdmField< bool > m_calculatePercentiles; + caf::PdmField< caf::AppEnum< PercentileCalcType > > m_percentileCalculationType; + caf::PdmField m_lowPercentile; + caf::PdmField m_midPercentile; + caf::PdmField m_highPercentile; + + + void computeStatistics(); + virtual bool openEclipseGridFile(); RimCaseCollection* parentStatisticsCaseCollection(); + // Pdm system overrides virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) const; - void computeStatistics(); + virtual QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly ); + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); private: RimIdenticalGridCaseGroup* caseGroup(); From 7da552020750a09ba7004d4836f915c54b47194e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 2 Apr 2013 16:34:13 +0200 Subject: [PATCH 173/242] Reverted an accidental checkin regarding generating of test projects p4#: 21098 --- ApplicationCode/UserInterface/RiuMainWindow.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index a7ce76fb97..2314a57329 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -1269,9 +1269,8 @@ void RiuMainWindow::hideAllDockWindows() //-------------------------------------------------------------------------------------------------- void RiuMainWindow::slotOpenMultipleCases() { +#if 1 RiaApplication* app = RiaApplication::instance(); - - /* RiuMultiCaseImportDialog dialog; int action = dialog.exec(); if (action == QDialog::Accepted) @@ -1279,8 +1278,9 @@ void RiuMainWindow::slotOpenMultipleCases() QStringList gridFileNames = dialog.eclipseCaseFileNames(); app->addEclipseCases(gridFileNames); } - */ +#else // Code to fast generate a test project + RiaApplication* app = RiaApplication::instance(); QStringList gridFileNames; @@ -1299,6 +1299,6 @@ void RiuMainWindow::slotOpenMultipleCases() } app->addEclipseCases(gridFileNames); - +#endif } From 51c4b6a38da83a16f737ed1a82b4685d1ef89509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 2 Apr 2013 16:59:55 +0200 Subject: [PATCH 174/242] Start of the ui working for setting up statistics calculations p4#: 21100 --- .../RimIdenticalGridCaseGroup.cpp | 15 +++ .../RimIdenticalGridCaseGroup.h | 39 ++++---- .../ProjectDataModel/RimStatisticsCase.cpp | 91 ++++++++++++++++++- .../ProjectDataModel/RimStatisticsCase.h | 47 ++++++---- 4 files changed, 153 insertions(+), 39 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index b05b711df2..10981db99b 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -405,3 +405,18 @@ bool RimIdenticalGridCaseGroup::isStatisticsCaseCollection(RimCaseCollection* ri return false; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCase* RimIdenticalGridCaseGroup::mainCase() +{ + if(caseCollection()->reservoirs().size()) + { + return caseCollection()->reservoirs()[0]; + } + else + { + return NULL; + } +} diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h index 7e379b4a10..c35eedb77e 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h @@ -43,37 +43,38 @@ public: RimIdenticalGridCaseGroup(); virtual ~RimIdenticalGridCaseGroup(); - caf::PdmField name; + caf::PdmField name; + caf::PdmField caseCollection; + caf::PdmField statisticsCaseCollection; - void addCase(RimCase* reservoir); - void removeCase(RimCase* reservoir); - bool contains(RimCase* reservoir) const; + void addCase(RimCase* reservoir); + void removeCase(RimCase* reservoir); + bool contains(RimCase* reservoir) const; - RimStatisticsCase* createAndAppendStatisticsCase(); + RimStatisticsCase* createAndAppendStatisticsCase(); - caf::PdmField caseCollection; - caf::PdmField statisticsCaseCollection; - void loadMainCaseAndActiveCellInfo(); + RimCase* mainCase(); + void loadMainCaseAndActiveCellInfo(); - RigMainGrid* mainGrid(); - RigActiveCellInfo* unionOfActiveCells(RifReaderInterface::PorosityModelResultType porosityType); + RigMainGrid* mainGrid(); - void computeUnionOfActiveCells(); + RigActiveCellInfo* unionOfActiveCells(RifReaderInterface::PorosityModelResultType porosityType); + void computeUnionOfActiveCells(); - static bool isStatisticsCaseCollection(RimCaseCollection* rimCaseCollection); + static bool isStatisticsCaseCollection(RimCaseCollection* rimCaseCollection); protected: - virtual caf::PdmFieldHandle* userDescriptionField(); + virtual caf::PdmFieldHandle* userDescriptionField(); private: - void updateMainGridAndActiveCellsForStatisticsCases(); - void clearStatisticsResults(); - void clearActiveCellUnions(); + void updateMainGridAndActiveCellsForStatisticsCases(); + void clearStatisticsResults(); + void clearActiveCellUnions(); private: - RigMainGrid* m_mainGrid; + RigMainGrid* m_mainGrid; - cvf::ref m_unionOfMatrixActiveCells; - cvf::ref m_unionOfFractureActiveCells; + cvf::ref m_unionOfMatrixActiveCells; + cvf::ref m_unionOfFractureActiveCells; }; diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp index 1e2e6248a2..3974e4b491 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp @@ -58,6 +58,13 @@ RimStatisticsCase::RimStatisticsCase() CAF_PDM_InitFieldNoDefault(&m_selectedGeneratedProperties, "GeneratedPropertiesToCalculate", "", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_selectedInputProperties, "InputPropertiesToCalculate", "", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_selectedFractureDynamicProperties, "FractureDynamicPropertiesToCalculate", "", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_selectedFractureStaticProperties, "FractureStaticPropertiesToCalculate", "", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_selectedFractureGeneratedProperties, "FractureGeneratedPropertiesToCalculate", "", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_selectedFractureInputProperties, "FractureInputPropertiesToCalculate", "", "", "", ""); + + + CAF_PDM_InitField(&m_calculatePercentiles, "CalculatePercentiles", true, "Calculate Percentiles", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_percentileCalculationType, "PercentileCalculationType", "Method", "", "", ""); @@ -66,6 +73,7 @@ RimStatisticsCase::RimStatisticsCase() CAF_PDM_InitField(&m_highPercentile, "HighPercentile", 90.0, "High", "", "", ""); + updateSelectionListVisibilities(); } //-------------------------------------------------------------------------------------------------- @@ -246,12 +254,74 @@ void RimStatisticsCase::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderin } +QList toOptionList(const QStringList& varList) +{ + QList optionList; + int i; + for (i = 0; i < varList.size(); ++i) + { + optionList.push_back(caf::PdmOptionItemInfo( varList[i], varList[i])); + } + return optionList; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- QList RimStatisticsCase::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) { QList options; + if (useOptionsOnly) *useOptionsOnly = true; + + RimIdenticalGridCaseGroup* idgcg = caseGroup(); + if (!(caseGroup() && caseGroup()->mainCase() && caseGroup()->mainCase()->reservoirData())) + { + return options; + } + + RigCaseData* caseData = idgcg->mainCase()->reservoirData(); + + if (&m_selectedDynamicProperties == fieldNeedingOptions) + { + QStringList varList = caseData->results(RifReaderInterface::MATRIX_RESULTS)->resultNames(RimDefines::DYNAMIC_NATIVE); + return toOptionList(varList); + } + else if (&m_selectedStaticProperties == fieldNeedingOptions) + { + QStringList varList = caseData->results(RifReaderInterface::MATRIX_RESULTS)->resultNames(RimDefines::STATIC_NATIVE); + return toOptionList(varList); + } + else if (&m_selectedGeneratedProperties == fieldNeedingOptions) + { + QStringList varList = caseData->results(RifReaderInterface::MATRIX_RESULTS)->resultNames(RimDefines::GENERATED); + return toOptionList(varList); + } + else if (&m_selectedInputProperties == fieldNeedingOptions) + { + QStringList varList = caseData->results(RifReaderInterface::MATRIX_RESULTS)->resultNames(RimDefines::INPUT_PROPERTY); + return toOptionList(varList); + } + else if (&m_selectedFractureDynamicProperties == fieldNeedingOptions) + { + QStringList varList = caseData->results(RifReaderInterface::FRACTURE_RESULTS)->resultNames(RimDefines::DYNAMIC_NATIVE); + return toOptionList(varList); + } + else if (&m_selectedFractureStaticProperties == fieldNeedingOptions) + { + QStringList varList = caseData->results(RifReaderInterface::FRACTURE_RESULTS)->resultNames(RimDefines::STATIC_NATIVE); + return toOptionList(varList); + } + else if (&m_selectedFractureGeneratedProperties == fieldNeedingOptions) + { + QStringList varList = caseData->results(RifReaderInterface::FRACTURE_RESULTS)->resultNames(RimDefines::GENERATED); + return toOptionList(varList); + } + else if (&m_selectedFractureInputProperties == fieldNeedingOptions) + { + QStringList varList = caseData->results(RifReaderInterface::FRACTURE_RESULTS)->resultNames(RimDefines::INPUT_PROPERTY); + return toOptionList(varList); + } + return options; } @@ -260,5 +330,24 @@ QList RimStatisticsCase::calculateValueOptions(const caf //-------------------------------------------------------------------------------------------------- void RimStatisticsCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { - + if (&m_resultType == changedField || &m_porosityModel == changedField) + { + updateSelectionListVisibilities(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimStatisticsCase::updateSelectionListVisibilities() +{ + m_selectedDynamicProperties.setUiHidden( !(m_porosityModel() == RimDefines::MATRIX_MODEL && m_resultType() == RimDefines::DYNAMIC_NATIVE)); + m_selectedStaticProperties.setUiHidden( !(m_porosityModel() == RimDefines::MATRIX_MODEL && m_resultType() == RimDefines::STATIC_NATIVE)); + m_selectedGeneratedProperties.setUiHidden( !(m_porosityModel() == RimDefines::MATRIX_MODEL && m_resultType() == RimDefines::GENERATED)); + m_selectedInputProperties.setUiHidden( !(m_porosityModel() == RimDefines::MATRIX_MODEL && m_resultType() == RimDefines::INPUT_PROPERTY)); + + m_selectedFractureDynamicProperties.setUiHidden( !(m_porosityModel() == RimDefines::FRACTURE_MODEL && m_resultType() == RimDefines::DYNAMIC_NATIVE)); + m_selectedFractureStaticProperties.setUiHidden( !(m_porosityModel() == RimDefines::FRACTURE_MODEL && m_resultType() == RimDefines::STATIC_NATIVE)); + m_selectedFractureGeneratedProperties.setUiHidden( !(m_porosityModel() == RimDefines::FRACTURE_MODEL && m_resultType() == RimDefines::GENERATED)); + m_selectedFractureInputProperties.setUiHidden( !(m_porosityModel() == RimDefines::FRACTURE_MODEL && m_resultType() == RimDefines::INPUT_PROPERTY)); } diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCase.h b/ApplicationCode/ProjectDataModel/RimStatisticsCase.h index 2b0e0df5fe..b5b526311f 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCase.h +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCase.h @@ -46,26 +46,7 @@ public: void setMainGrid(RigMainGrid* mainGrid); - caf::PdmField< caf::AppEnum< RimDefines::ResultCatType > > m_resultType; - caf::PdmField< caf::AppEnum< RimDefines::PorosityModelType > > m_porosityModel; - caf::PdmField > m_selectedDynamicProperties; - caf::PdmField > m_selectedStaticProperties; - caf::PdmField > m_selectedGeneratedProperties; - caf::PdmField > m_selectedInputProperties; - - enum PercentileCalcType - { - EXACT, - HISTOGRAM_ESTIMATED - }; - - caf::PdmField< bool > m_calculatePercentiles; - caf::PdmField< caf::AppEnum< PercentileCalcType > > m_percentileCalculationType; - caf::PdmField m_lowPercentile; - caf::PdmField m_midPercentile; - caf::PdmField m_highPercentile; - void computeStatistics(); virtual bool openEclipseGridFile(); @@ -77,9 +58,37 @@ public: virtual QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly ); virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); + enum PercentileCalcType + { + EXACT, + HISTOGRAM_ESTIMATED + }; + private: RimIdenticalGridCaseGroup* caseGroup(); void getSourceCases(std::vector& sourceCases); + void updateSelectionListVisibilities(); + + caf::PdmField< caf::AppEnum< RimDefines::ResultCatType > > m_resultType; + caf::PdmField< caf::AppEnum< RimDefines::PorosityModelType > > m_porosityModel; + + caf::PdmField > m_selectedDynamicProperties; + caf::PdmField > m_selectedStaticProperties; + caf::PdmField > m_selectedGeneratedProperties; + caf::PdmField > m_selectedInputProperties; + + caf::PdmField > m_selectedFractureDynamicProperties; + caf::PdmField > m_selectedFractureStaticProperties; + caf::PdmField > m_selectedFractureGeneratedProperties; + caf::PdmField > m_selectedFractureInputProperties; + + + caf::PdmField< bool > m_calculatePercentiles; + caf::PdmField< caf::AppEnum< PercentileCalcType > > m_percentileCalculationType; + caf::PdmField m_lowPercentile; + caf::PdmField m_midPercentile; + caf::PdmField m_highPercentile; + }; From e49895ea65ae94d84da4642dd2aa7ca30bd025dd Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 3 Apr 2013 09:09:53 +0200 Subject: [PATCH 175/242] Updated file headers p4#: 21104 --- .../RigGridScalarDataAccess.cpp | 31 +++++++++---------- .../RigGridScalarDataAccess.h | 31 +++++++++---------- 2 files changed, 30 insertions(+), 32 deletions(-) diff --git a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp index 68136b67d0..04280e6c19 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.cpp @@ -1,21 +1,20 @@ -//################################################################################################## +///////////////////////////////////////////////////////////////////////////////// // -// Custom Visualization Core library -// Copyright (C) 2011-2012 Ceetron AS -// -// This library 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. -// -// This library 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. +// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 "RigGridScalarDataAccess.h" diff --git a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.h b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.h index 4757bf5d39..d098829f66 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.h +++ b/ApplicationCode/ReservoirDataModel/RigGridScalarDataAccess.h @@ -1,21 +1,20 @@ -//################################################################################################## +///////////////////////////////////////////////////////////////////////////////// // -// Custom Visualization Core library -// Copyright (C) 2011-2012 Ceetron AS -// -// This library 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. -// -// This library 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. +// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 From 70347c281f69492807da74db13948fe80d989a36 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 3 Apr 2013 09:24:33 +0200 Subject: [PATCH 176/242] Do not use deprecated Octave functions https://github.com/OPM/ResInsight/commit/b5ad0b9170f14b1c0f90c9e9292c93fabc744e35 p4#: 21106 --- OctavePlugin/riGetActiveCellInfo.cpp | 2 +- OctavePlugin/riGetMainGridDimensions.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/OctavePlugin/riGetActiveCellInfo.cpp b/OctavePlugin/riGetActiveCellInfo.cpp index 65deb8bb78..1c9c8311cb 100644 --- a/OctavePlugin/riGetActiveCellInfo.cpp +++ b/OctavePlugin/riGetActiveCellInfo.cpp @@ -52,7 +52,7 @@ void getActiveCellInfo(int32NDArray& activeCellInfo, const QString &hostName, qu activeCellCount = byteCount / sizeof(qint32); - dim_vector dv (2); + dim_vector dv (2, 1); dv(0) = activeCellCount; dv(1) = timestepCount; activeCellInfo.resize(dv); diff --git a/OctavePlugin/riGetMainGridDimensions.cpp b/OctavePlugin/riGetMainGridDimensions.cpp index c3664be866..c6690921cb 100644 --- a/OctavePlugin/riGetMainGridDimensions.cpp +++ b/OctavePlugin/riGetMainGridDimensions.cpp @@ -51,7 +51,7 @@ void getMainGridDimensions(int32NDArray& gridDimensions, const QString &hostName socketStream >> jCount; socketStream >> kCount; - dim_vector dv (1); + dim_vector dv (1, 1); dv(0) = 3; gridDimensions.resize(dv); From 770a81648d8b4d084b0e682edb480bba6b7fb685 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 3 Apr 2013 16:06:00 +0200 Subject: [PATCH 177/242] Added a new editor to work with text fields. Supports multiline formatted text p4#: 21114 --- cafUserInterface/CMakeLists.txt | 2 + cafUserInterface/cafPdmUiTextEditor.cpp | 130 ++++++++++++++++++++++++ cafUserInterface/cafPdmUiTextEditor.h | 81 +++++++++++++++ 3 files changed, 213 insertions(+) create mode 100644 cafUserInterface/cafPdmUiTextEditor.cpp create mode 100644 cafUserInterface/cafPdmUiTextEditor.h diff --git a/cafUserInterface/CMakeLists.txt b/cafUserInterface/CMakeLists.txt index b35796a516..16b28b4603 100644 --- a/cafUserInterface/CMakeLists.txt +++ b/cafUserInterface/CMakeLists.txt @@ -20,6 +20,7 @@ set( QOBJECT_HEADERS cafPdmUiListEditor.h cafPdmUiSliderEditor.h cafPdmUiDoubleSliderEditor.h + cafPdmUiTextEditor.h cafPdmUiColorEditor.h @@ -47,6 +48,7 @@ add_library( ${PROJECT_NAME} cafPdmUiSliderEditor.cpp cafPdmUiDoubleSliderEditor.cpp cafPdmUiColorEditor.cpp + cafPdmUiTextEditor.cpp cafPdmUiPropertyView.cpp ${MOC_FILES_CPP} diff --git a/cafUserInterface/cafPdmUiTextEditor.cpp b/cafUserInterface/cafPdmUiTextEditor.cpp new file mode 100644 index 0000000000..c5758b7723 --- /dev/null +++ b/cafUserInterface/cafPdmUiTextEditor.cpp @@ -0,0 +1,130 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2012 Ceetron AS +// +// This library 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. +// +// This library 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 "cafPdmUiTextEditor.h" + +#include "cafPdmUiDefaultObjectEditor.h" + +#include "cafPdmObject.h" +#include "cafPdmUiFieldEditorHandle.h" +#include "cafPdmUiOrdering.h" + +#include "cafPdmField.h" + +#include +#include +#include + +#include +#include "cafFactory.h" + + + +namespace caf +{ + +CAF_PDM_UI_FIELD_EDITOR_SOURCE_INIT(PdmUiTextEditor); + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmUiTextEditor::configureAndUpdateUi(const QString& uiConfigName) +{ + assert(!m_textEdit.isNull()); + assert(!m_label.isNull()); + + QIcon ic = field()->uiIcon(uiConfigName); + if (!ic.isNull()) + { + m_label->setPixmap(ic.pixmap(ic.actualSize(QSize(64, 64)))); + } + else + { + m_label->setText(field()->uiName(uiConfigName)); + } + + //m_label->setEnabled(!field()->isUiReadOnly(uiConfigName)); + + m_textEdit->setReadOnly(field()->isUiReadOnly(uiConfigName)); + //m_textEdit->setEnabled(!field()->isUiReadOnly(uiConfigName)); // Neccesary ? + + PdmUiTextEditorAttribute leab; + field()->ownerObject()->editorAttribute(field(), uiConfigName, &leab); + m_textMode = leab.textMode; + + m_textEdit->blockSignals(true); + switch (leab.textMode) + { + case PdmUiTextEditorAttribute::PLAIN: + m_textEdit->setPlainText(field()->uiValue().toString()); + break; + case PdmUiTextEditorAttribute::HTML: + m_textEdit->setHtml(field()->uiValue().toString()); + break; + } + m_textEdit->blockSignals(false); + +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QWidget* PdmUiTextEditor::createEditorWidget(QWidget * parent) +{ + m_textEdit = new QTextEdit(parent); + connect(m_textEdit, SIGNAL(textChanged()), this, SLOT(slotTextChanged())); + return m_textEdit; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QWidget* PdmUiTextEditor::createLabelWidget(QWidget * parent) +{ + m_label = new QLabel(parent); + return m_label; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmUiTextEditor::slotTextChanged() +{ + QVariant v; + QString textValue; + + switch (m_textMode) + { + case PdmUiTextEditorAttribute::PLAIN: + textValue = m_textEdit->toPlainText(); + break; + case PdmUiTextEditorAttribute::HTML: + textValue = m_textEdit->toHtml(); + break; + } + + v = textValue; + + this->setValueToField(v); +} + + +} // end namespace caf diff --git a/cafUserInterface/cafPdmUiTextEditor.h b/cafUserInterface/cafPdmUiTextEditor.h new file mode 100644 index 0000000000..f553ed9500 --- /dev/null +++ b/cafUserInterface/cafPdmUiTextEditor.h @@ -0,0 +1,81 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2012 Ceetron AS +// +// This library 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. +// +// This library 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 "cafPdmUiFieldEditorHandle.h" +#include +#include +#include +#include +#include + +class QGridLayout; + +namespace caf +{ + +//================================================================================================== +/// An editor to show (and possibly edit?) formatted larger portions of text +//================================================================================================== + +class PdmUiTextEditorAttribute : public PdmUiEditorAttribute +{ +public: + PdmUiTextEditorAttribute() + { + textMode = PLAIN; + } + + enum TextMode + { + PLAIN, + HTML + }; + +public: + TextMode textMode; +}; + + +class PdmUiTextEditor : public PdmUiFieldEditorHandle +{ + Q_OBJECT + CAF_PDM_UI_FIELD_EDITOR_HEADER_INIT; + +public: + PdmUiTextEditor() { m_textMode = PdmUiTextEditorAttribute::PLAIN; } + virtual ~PdmUiTextEditor() {} + +protected: + virtual QWidget* createEditorWidget(QWidget * parent); + virtual QWidget* createLabelWidget(QWidget * parent); + virtual void configureAndUpdateUi(const QString& uiConfigName); + +protected slots: + void slotTextChanged(); + +private: + QPointer m_textEdit; + QPointer m_label; + + PdmUiTextEditorAttribute::TextMode m_textMode; +}; + + +} // end namespace caf From ef6ee4a26ce9eac395b58d19a375cadf9c745033 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 3 Apr 2013 16:13:49 +0200 Subject: [PATCH 178/242] Statistics case now has a prototype datamodel and Ui. The data is not yet used to control the calculations. p4#: 21116 --- .../ProjectDataModel/RimStatisticsCase.cpp | 131 +++++++++++++++++- .../ProjectDataModel/RimStatisticsCase.h | 45 +++--- cafProjectDataModel/cafPdmUiItem.cpp | 4 +- cafProjectDataModel/cafPdmUiItem.h | 13 +- cafUserInterface/cafPdmUiCheckBoxEditor.cpp | 1 - cafUserInterface/cafPdmUiColorEditor.cpp | 1 - cafUserInterface/cafPdmUiComboBoxEditor.cpp | 2 - .../cafPdmUiDefaultObjectEditor.cpp | 35 +++-- .../cafPdmUiDoubleSliderEditor.cpp | 1 - cafUserInterface/cafPdmUiFilePathEditor.cpp | 1 - cafUserInterface/cafPdmUiLineEditor.cpp | 2 - cafUserInterface/cafPdmUiListEditor.cpp | 2 - cafUserInterface/cafPdmUiPushButtonEditor.cpp | 1 - cafUserInterface/cafPdmUiSliderEditor.cpp | 2 - 14 files changed, 183 insertions(+), 58 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp index 3974e4b491..891797524b 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp @@ -26,6 +26,7 @@ #include "RigCaseCellResultsData.h" #include "RimStatisticsCaseEvaluator.h" #include "RigMainGrid.h" +#include "cafPdmUiTextEditor.h" namespace caf { template<> @@ -48,22 +49,38 @@ RimStatisticsCase::RimStatisticsCase() : RimCase() { CAF_PDM_InitObject("Case Group Statistics", ":/Histogram16x16.png", "", ""); + + CAF_PDM_InitField(&m_selectionSummary, "SelectionSummary", QString(""), "Selected Properties", "", "", ""); + m_selectionSummary.setIOWritable(false); + m_selectionSummary.setIOReadable(false); + m_selectionSummary.setUiReadOnly(true); + m_selectionSummary.setUiEditorTypeName(caf::PdmUiTextEditor::uiEditorTypeName()); + m_selectionSummary.setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + CAF_PDM_InitFieldNoDefault(&m_resultType, "ResultType", "Result Type", "", "", ""); m_resultType.setIOWritable(false); CAF_PDM_InitFieldNoDefault(&m_porosityModel, "PorosityModel", "Porosity Model", "", "", ""); m_porosityModel.setIOWritable(false); - CAF_PDM_InitFieldNoDefault(&m_selectedDynamicProperties, "DynamicPropertiesToCalculate", "", "", "", ""); - CAF_PDM_InitFieldNoDefault(&m_selectedStaticProperties, "StaticPropertiesToCalculate", "", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_selectedDynamicProperties, "DynamicPropertiesToCalculate", "Dyn Prop", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_selectedStaticProperties, "StaticPropertiesToCalculate", "Stat Prop", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_selectedGeneratedProperties, "GeneratedPropertiesToCalculate", "", "", "", ""); - CAF_PDM_InitFieldNoDefault(&m_selectedInputProperties, "InputPropertiesToCalculate", "", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_selectedInputProperties, "InputPropertiesToCalculate", "", "", "", ""); - CAF_PDM_InitFieldNoDefault(&m_selectedFractureDynamicProperties, "FractureDynamicPropertiesToCalculate", "", "", "", ""); - CAF_PDM_InitFieldNoDefault(&m_selectedFractureStaticProperties, "FractureStaticPropertiesToCalculate", "", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_selectedFractureDynamicProperties, "FractureDynamicPropertiesToCalculate", "", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_selectedFractureStaticProperties, "FractureStaticPropertiesToCalculate", "", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_selectedFractureGeneratedProperties, "FractureGeneratedPropertiesToCalculate", "", "", "", ""); - CAF_PDM_InitFieldNoDefault(&m_selectedFractureInputProperties, "FractureInputPropertiesToCalculate", "", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_selectedFractureInputProperties, "FractureInputPropertiesToCalculate", "", "", "", ""); + m_selectedDynamicProperties.setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + m_selectedStaticProperties.setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + m_selectedGeneratedProperties.setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + m_selectedInputProperties.setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + m_selectedFractureDynamicProperties.setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + m_selectedFractureStaticProperties.setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + m_selectedFractureGeneratedProperties.setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + m_selectedFractureInputProperties.setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); CAF_PDM_InitField(&m_calculatePercentiles, "CalculatePercentiles", true, "Calculate Percentiles", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_percentileCalculationType, "PercentileCalculationType", "Method", "", "", ""); @@ -72,8 +89,9 @@ RimStatisticsCase::RimStatisticsCase() CAF_PDM_InitField(&m_midPercentile, "MidPercentile", 50.0, "Mid", "", "", ""); CAF_PDM_InitField(&m_highPercentile, "HighPercentile", 90.0, "High", "", "", ""); - updateSelectionListVisibilities(); + updateSelectionSummaryLabel(); + updatePercentileUiVisibility(); } //-------------------------------------------------------------------------------------------------- @@ -251,7 +269,27 @@ RimIdenticalGridCaseGroup* RimStatisticsCase::caseGroup() //-------------------------------------------------------------------------------------------------- void RimStatisticsCase::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const { + uiOrdering.add(&caseName); + caf::PdmUiGroup * group = uiOrdering.addNewGroup("Property Selection"); + group->add(&m_selectionSummary); + group->add(&m_resultType); + group->add(&m_porosityModel); + group->add(&m_selectedDynamicProperties); + group->add(&m_selectedStaticProperties); + group->add(&m_selectedGeneratedProperties); + group->add(&m_selectedInputProperties); + group->add(&m_selectedFractureDynamicProperties); + group->add(&m_selectedFractureStaticProperties); + group->add(&m_selectedFractureGeneratedProperties); + group->add(&m_selectedFractureInputProperties); + + group = uiOrdering.addNewGroup("Percentiles"); + group->add(&m_calculatePercentiles); + group->add(&m_percentileCalculationType); + group->add(&m_lowPercentile); + group->add(&m_midPercentile); + group->add(&m_highPercentile); } QList toOptionList(const QStringList& varList) @@ -334,6 +372,9 @@ void RimStatisticsCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField { updateSelectionListVisibilities(); } + + updateSelectionSummaryLabel(); + updatePercentileUiVisibility(); } //-------------------------------------------------------------------------------------------------- @@ -351,3 +392,79 @@ void RimStatisticsCase::updateSelectionListVisibilities() m_selectedFractureGeneratedProperties.setUiHidden( !(m_porosityModel() == RimDefines::FRACTURE_MODEL && m_resultType() == RimDefines::GENERATED)); m_selectedFractureInputProperties.setUiHidden( !(m_porosityModel() == RimDefines::FRACTURE_MODEL && m_resultType() == RimDefines::INPUT_PROPERTY)); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimStatisticsCase::updateSelectionSummaryLabel() +{ + QString html; + + html += ""; + + if (m_selectedDynamicProperties().size()) + { + html += "

Dynamic properties:

"; + for (size_t pIdx = 0; pIdx < m_selectedDynamicProperties().size(); ++pIdx) + { + html += "" + m_selectedDynamicProperties()[pIdx] + "
"; + } + html += "

"; + } + + if (m_selectedStaticProperties().size()) + { + html += "Static properties:

"; + for (size_t pIdx = 0; pIdx < m_selectedStaticProperties().size(); ++pIdx) + { + html += " " + m_selectedStaticProperties()[pIdx] + "
"; + } + html += "

"; + } + if (m_selectedGeneratedProperties().size()) + { + html += "Generated properties:

"; + for (size_t pIdx = 0; pIdx < m_selectedGeneratedProperties().size(); ++pIdx) + { + html += " " + m_selectedGeneratedProperties()[pIdx] + "
"; + } + html += "

"; + } + if (m_selectedInputProperties().size()) + { + html += "Input properties:

"; + for (size_t pIdx = 0; pIdx < m_selectedInputProperties().size(); ++pIdx) + { + html += " " + m_selectedInputProperties()[pIdx] + "
"; + } + html += "

"; + } + m_selectionSummary = html; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimStatisticsCase::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute) +{ + if (&m_selectionSummary == field) + { + caf::PdmUiTextEditorAttribute* textEditAttrib = dynamic_cast (attribute); + textEditAttrib->textMode = caf::PdmUiTextEditorAttribute::HTML; + } + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimStatisticsCase::updatePercentileUiVisibility() +{ + m_percentileCalculationType.setUiHidden( !m_calculatePercentiles()); + m_lowPercentile .setUiHidden( !m_calculatePercentiles()); + m_midPercentile .setUiHidden( !m_calculatePercentiles()); + m_highPercentile.setUiHidden( !m_calculatePercentiles()); +} diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCase.h b/ApplicationCode/ProjectDataModel/RimStatisticsCase.h index b5b526311f..cd4eeb1224 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCase.h +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCase.h @@ -46,18 +46,11 @@ public: void setMainGrid(RigMainGrid* mainGrid); - - void computeStatistics(); virtual bool openEclipseGridFile(); RimCaseCollection* parentStatisticsCaseCollection(); - // Pdm system overrides - virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) const; - virtual QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly ); - virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); - enum PercentileCalcType { EXACT, @@ -70,25 +63,37 @@ private: void getSourceCases(std::vector& sourceCases); void updateSelectionListVisibilities(); + void updateSelectionSummaryLabel(); + void updatePercentileUiVisibility(); + // Pdm system overrides + virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) const; + virtual QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly ); + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); + + virtual void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute ); + + // Fields caf::PdmField< caf::AppEnum< RimDefines::ResultCatType > > m_resultType; caf::PdmField< caf::AppEnum< RimDefines::PorosityModelType > > m_porosityModel; - caf::PdmField > m_selectedDynamicProperties; - caf::PdmField > m_selectedStaticProperties; - caf::PdmField > m_selectedGeneratedProperties; - caf::PdmField > m_selectedInputProperties; + caf::PdmField m_selectionSummary; - caf::PdmField > m_selectedFractureDynamicProperties; - caf::PdmField > m_selectedFractureStaticProperties; - caf::PdmField > m_selectedFractureGeneratedProperties; - caf::PdmField > m_selectedFractureInputProperties; + caf::PdmField > m_selectedDynamicProperties; + caf::PdmField > m_selectedStaticProperties; + caf::PdmField > m_selectedGeneratedProperties; + caf::PdmField > m_selectedInputProperties; + + caf::PdmField > m_selectedFractureDynamicProperties; + caf::PdmField > m_selectedFractureStaticProperties; + caf::PdmField > m_selectedFractureGeneratedProperties; + caf::PdmField > m_selectedFractureInputProperties; - caf::PdmField< bool > m_calculatePercentiles; - caf::PdmField< caf::AppEnum< PercentileCalcType > > m_percentileCalculationType; - caf::PdmField m_lowPercentile; - caf::PdmField m_midPercentile; - caf::PdmField m_highPercentile; + caf::PdmField< bool > m_calculatePercentiles; + caf::PdmField< caf::AppEnum< PercentileCalcType > > m_percentileCalculationType; + caf::PdmField m_lowPercentile; + caf::PdmField m_midPercentile; + caf::PdmField m_highPercentile; }; diff --git a/cafProjectDataModel/cafPdmUiItem.cpp b/cafProjectDataModel/cafPdmUiItem.cpp index ddaed700eb..256b15faa0 100644 --- a/cafProjectDataModel/cafPdmUiItem.cpp +++ b/cafProjectDataModel/cafPdmUiItem.cpp @@ -200,7 +200,7 @@ QString PdmUiItem::uiEditorTypeName(const QString& uiConfigName) const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -Qt::Alignment PdmUiItem::labelAlignment(QString uiConfigName) const +PdmUiItemInfo::LabelPosType PdmUiItem::uiLabelPosition(QString uiConfigName) const { const PdmUiItemInfo* conInfo = configInfo(uiConfigName); const PdmUiItemInfo* defInfo = defaultInfo(); @@ -210,7 +210,7 @@ Qt::Alignment PdmUiItem::labelAlignment(QString uiConfigName) const if (defInfo) return defInfo->m_labelAlignment; if (sttInfo) return sttInfo->m_labelAlignment; - return Qt::AlignLeft; + return PdmUiItemInfo::LEFT; } //-------------------------------------------------------------------------------------------------- diff --git a/cafProjectDataModel/cafPdmUiItem.h b/cafProjectDataModel/cafPdmUiItem.h index d8d68c439b..36da02ef18 100644 --- a/cafProjectDataModel/cafPdmUiItem.h +++ b/cafProjectDataModel/cafPdmUiItem.h @@ -40,9 +40,11 @@ public: PdmUiItemInfo( QString uiName, QIcon icon = QIcon(), QString toolTip = "", QString whatsThis = "") : m_uiName(uiName), m_icon(icon), m_toolTip(toolTip), m_whatsThis(whatsThis), - m_editorTypeName(""), m_isHidden(false), m_isReadOnly(false), m_labelAlignment(Qt::AlignLeft) + m_editorTypeName(""), m_isHidden(false), m_isReadOnly(false), m_labelAlignment(LEFT) { } + enum LabelPosType { LEFT, TOP, HIDDEN }; + private: friend class PdmUiItem; QString m_uiName; @@ -52,7 +54,7 @@ private: QString m_editorTypeName; ///< Use this exact type of editor to edit this UiItem int m_isHidden; ///< UiItem should be hidden. -1 means not set int m_isReadOnly; ///< UiItem should be insensitive, or read only. -1 means not set. - Qt::Alignment m_labelAlignment; + LabelPosType m_labelAlignment; }; //================================================================================================== @@ -115,9 +117,10 @@ public: bool isUiReadOnly(QString uiConfigName = ""); void setUiReadOnly(bool isReadOnly, QString uiConfigName = "") { m_configItemInfos[uiConfigName].m_isReadOnly = isReadOnly; } - - Qt::Alignment labelAlignment(QString uiConfigName = "") const; - void setLabelAlignment(Qt::Alignment alignment, QString uiConfigName = "") { m_configItemInfos[uiConfigName].m_labelAlignment = alignment; } + + PdmUiItemInfo::LabelPosType + uiLabelPosition(QString uiConfigName = "") const; + void setUiLabelPosition(PdmUiItemInfo::LabelPosType alignment, QString uiConfigName = "") { m_configItemInfos[uiConfigName].m_labelAlignment = alignment; } QString uiEditorTypeName(const QString& uiConfigName) const; void setUiEditorTypeName(const QString& editorTypeName, QString uiConfigName = "") { m_configItemInfos[uiConfigName].m_editorTypeName = editorTypeName; } diff --git a/cafUserInterface/cafPdmUiCheckBoxEditor.cpp b/cafUserInterface/cafPdmUiCheckBoxEditor.cpp index 50447083da..84a9cdd207 100644 --- a/cafUserInterface/cafPdmUiCheckBoxEditor.cpp +++ b/cafUserInterface/cafPdmUiCheckBoxEditor.cpp @@ -55,7 +55,6 @@ void PdmUiCheckBoxEditor::configureAndUpdateUi(const QString& uiConfigName) m_label->setText(field()->uiName(uiConfigName)); } - m_label->setVisible(!field()->isUiHidden(uiConfigName)); m_label->setEnabled(!field()->isUiReadOnly(uiConfigName)); m_label->setToolTip(field()->uiToolTip(uiConfigName)); diff --git a/cafUserInterface/cafPdmUiColorEditor.cpp b/cafUserInterface/cafPdmUiColorEditor.cpp index 5c4cb3d41d..450d8511f6 100644 --- a/cafUserInterface/cafPdmUiColorEditor.cpp +++ b/cafUserInterface/cafPdmUiColorEditor.cpp @@ -69,7 +69,6 @@ void PdmUiColorEditor::configureAndUpdateUi(const QString& uiConfigName) m_label->setText(field()->uiName(uiConfigName)); } - m_label->setVisible(!field()->isUiHidden(uiConfigName)); m_label->setEnabled(!field()->isUiReadOnly(uiConfigName)); field()->ownerObject()->editorAttribute(field(), uiConfigName, &m_attributes); diff --git a/cafUserInterface/cafPdmUiComboBoxEditor.cpp b/cafUserInterface/cafPdmUiComboBoxEditor.cpp index c18731d906..f0f68ac396 100644 --- a/cafUserInterface/cafPdmUiComboBoxEditor.cpp +++ b/cafUserInterface/cafPdmUiComboBoxEditor.cpp @@ -54,9 +54,7 @@ void PdmUiComboBoxEditor::configureAndUpdateUi(const QString& uiConfigName) m_label->setText(field()->uiName(uiConfigName)); } - m_label->setVisible(!field()->isUiHidden(uiConfigName)); m_label->setEnabled(!field()->isUiReadOnly(uiConfigName)); - m_comboBox->setEnabled(!field()->isUiReadOnly(uiConfigName)); // Demo code for attribute retreival when becoming relevant diff --git a/cafUserInterface/cafPdmUiDefaultObjectEditor.cpp b/cafUserInterface/cafPdmUiDefaultObjectEditor.cpp index 58aeaa74f2..0aa8cb2d41 100644 --- a/cafUserInterface/cafPdmUiDefaultObjectEditor.cpp +++ b/cafUserInterface/cafPdmUiDefaultObjectEditor.cpp @@ -258,29 +258,42 @@ void PdmUiDefaultObjectEditor::recursiveSetupFieldsAndGroups(const std::vector

editorWidget(); - QWidget* fieldLabelWidget = fieldEditor->labelWidget(); - bool labelOnTop = field->labelAlignment(uiConfigName) & Qt::AlignTop; + PdmUiItemInfo::LabelPosType labelPos = field->uiLabelPosition(uiConfigName); + bool labelOnTop = (labelPos == PdmUiItemInfo::TOP); + bool editorSpanBoth = labelOnTop; - if (fieldLabelWidget) + if (labelPos != PdmUiItemInfo::HIDDEN) { - fieldLabelWidget->setParent(parent); + QWidget* fieldLabelWidget = fieldEditor->labelWidget(); + if (fieldLabelWidget ) + { + fieldLabelWidget->setParent(parent); - // Label widget will span two columns if aligned on top - int colSpan = labelOnTop ? 2 : 1; - parentLayout->addWidget(fieldLabelWidget, currentRowIndex, 0, 1, colSpan, Qt::AlignTop); + // Label widget will span two columns if aligned on top + int colSpan = labelOnTop ? 2 : 1; + parentLayout->addWidget(fieldLabelWidget, currentRowIndex, 0, 1, colSpan, Qt::AlignTop); + fieldLabelWidget->show(); - if (labelOnTop) currentRowIndex++; + if (labelOnTop) currentRowIndex++; + } } + else + { + QWidget* fieldLabelWidget = fieldEditor->labelWidget(); + if (fieldLabelWidget ) fieldLabelWidget->hide(); + editorSpanBoth = true; // To span both columns when there is no label + } + + QWidget* fieldEditorWidget = fieldEditor->editorWidget(); if (fieldEditorWidget) { fieldEditorWidget->setParent(parent); // To make sure this widget has the current group box as parent. // Label widget will span two columns if aligned on top - int colSpan = labelOnTop ? 2 : 1; - int colIndex = labelOnTop ? 0 : 1; + int colSpan = editorSpanBoth ? 2 : 1; + int colIndex = editorSpanBoth ? 0 : 1; parentLayout->addWidget(fieldEditorWidget, currentRowIndex, colIndex, 1, colSpan, Qt::AlignTop); } diff --git a/cafUserInterface/cafPdmUiDoubleSliderEditor.cpp b/cafUserInterface/cafPdmUiDoubleSliderEditor.cpp index 15b632237b..0fb790dfa8 100644 --- a/cafUserInterface/cafPdmUiDoubleSliderEditor.cpp +++ b/cafUserInterface/cafPdmUiDoubleSliderEditor.cpp @@ -87,7 +87,6 @@ void PdmUiDoubleSliderEditor::configureAndUpdateUi(const QString& uiConfigName) m_label->setText(field()->uiName(uiConfigName)); } - m_label->setVisible(!field()->isUiHidden(uiConfigName)); m_label->setEnabled(!field()->isUiReadOnly(uiConfigName)); m_lineEdit->setEnabled(!field()->isUiReadOnly(uiConfigName)); diff --git a/cafUserInterface/cafPdmUiFilePathEditor.cpp b/cafUserInterface/cafPdmUiFilePathEditor.cpp index c6e581b718..ece3c61bcd 100644 --- a/cafUserInterface/cafPdmUiFilePathEditor.cpp +++ b/cafUserInterface/cafPdmUiFilePathEditor.cpp @@ -62,7 +62,6 @@ void PdmUiFilePathEditor::configureAndUpdateUi(const QString& uiConfigName) m_label->setText(field()->uiName(uiConfigName)); } - m_label->setVisible(!field()->isUiHidden(uiConfigName)); m_label->setEnabled(!field()->isUiReadOnly(uiConfigName)); m_lineEdit->setEnabled(!field()->isUiReadOnly(uiConfigName)); diff --git a/cafUserInterface/cafPdmUiLineEditor.cpp b/cafUserInterface/cafPdmUiLineEditor.cpp index 78c23ee291..0e9b59bc51 100644 --- a/cafUserInterface/cafPdmUiLineEditor.cpp +++ b/cafUserInterface/cafPdmUiLineEditor.cpp @@ -60,9 +60,7 @@ void PdmUiLineEditor::configureAndUpdateUi(const QString& uiConfigName) m_label->setText(field()->uiName(uiConfigName)); } - m_label->setVisible(!field()->isUiHidden(uiConfigName)); m_label->setEnabled(!field()->isUiReadOnly(uiConfigName)); - m_lineEdit->setEnabled(!field()->isUiReadOnly(uiConfigName)); PdmUiLineEditorAttribute leab; diff --git a/cafUserInterface/cafPdmUiListEditor.cpp b/cafUserInterface/cafPdmUiListEditor.cpp index 993a38f0a4..0f49e05141 100644 --- a/cafUserInterface/cafPdmUiListEditor.cpp +++ b/cafUserInterface/cafPdmUiListEditor.cpp @@ -111,9 +111,7 @@ void PdmUiListEditor::configureAndUpdateUi(const QString& uiConfigName) m_label->setText(uiName); } - m_label->setVisible(!field()->isUiHidden(uiConfigName)); m_label->setEnabled(!field()->isUiReadOnly(uiConfigName)); - m_listView->setEnabled(!field()->isUiReadOnly(uiConfigName)); /// Demo code Not used yet diff --git a/cafUserInterface/cafPdmUiPushButtonEditor.cpp b/cafUserInterface/cafPdmUiPushButtonEditor.cpp index 400590dbc1..b0f145ab6f 100644 --- a/cafUserInterface/cafPdmUiPushButtonEditor.cpp +++ b/cafUserInterface/cafPdmUiPushButtonEditor.cpp @@ -55,7 +55,6 @@ void PdmUiPushButtonEditor::configureAndUpdateUi(const QString& uiConfigName) m_label->setText(field()->uiName(uiConfigName)); } - m_label->setVisible(!field()->isUiHidden(uiConfigName)); m_label->setEnabled(!field()->isUiReadOnly(uiConfigName)); //m_checkBox->setEnabled(!field()->isUiReadOnly(uiConfigName)); diff --git a/cafUserInterface/cafPdmUiSliderEditor.cpp b/cafUserInterface/cafPdmUiSliderEditor.cpp index 61912dd990..22a6608cf8 100644 --- a/cafUserInterface/cafPdmUiSliderEditor.cpp +++ b/cafUserInterface/cafPdmUiSliderEditor.cpp @@ -56,9 +56,7 @@ void PdmUiSliderEditor::configureAndUpdateUi(const QString& uiConfigName) m_label->setText(field()->uiName(uiConfigName)); } - m_label->setVisible(!field()->isUiHidden(uiConfigName)); m_label->setEnabled(!field()->isUiReadOnly(uiConfigName)); - m_lineEdit->setEnabled(!field()->isUiReadOnly(uiConfigName)); m_slider->setEnabled(!field()->isUiReadOnly(uiConfigName)); From 32d67d9978556eafa14aa506373a068a8007368f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 4 Apr 2013 08:24:40 +0200 Subject: [PATCH 179/242] Updated ERT from https://github.com/Ensembles/ert/commits/master to version 4a78d88f1dc7bbc86f173c5adb825bbca29fa116 p4#: 21120 --- .../FileInterface_UnitTests/Ert-Test.cpp | 1 - .../RifEclipseOutputFileTools.cpp | 1 - ThirdParty/Ert/devel/CMakeLists.txt | 36 +- .../Ert/devel/cmake/Tests/test_dlopen.c | 5 - ThirdParty/Ert/devel/cmake/cmake_pyc | 35 + .../devel/cmake/config/ert_build_config.h.in | 36 +- ThirdParty/Ert/devel/cmake/ert_find.cmake | 4 + ThirdParty/Ert/devel/cmake/python.cmake | 16 +- ThirdParty/Ert/devel/debian/changelog | 6 + ThirdParty/Ert/devel/debian/control | 2 +- .../Ert/devel/debian/libert.ecl1.install | 1 + ThirdParty/Ert/devel/debian/rules | 2 +- .../include/ert/analysis/rml_enkf_common.h | 25 +- .../Ert/devel/libanalysis/src/CMakeLists.txt | 13 +- ThirdParty/Ert/devel/libconfig/CMakeLists.txt | 1 + .../libconfig/include/ert/config/config.h | 70 +- .../include/ert/config/config_content_item.h | 66 + .../include/ert/config/config_content_node.h | 61 + .../include/ert/config/config_error.h | 45 + .../include/ert/config/config_path_elm.h | 44 + .../include/ert/config/config_root_path.h | 40 + .../include/ert/config/config_schema_item.h | 123 ++ .../Ert/devel/libconfig/src/CMakeLists.txt | 14 +- ThirdParty/Ert/devel/libconfig/src/config.c | 1409 ++++------------- .../devel/libconfig/src/config_content_item.c | 291 ++++ .../devel/libconfig/src/config_content_node.c | 229 +++ .../Ert/devel/libconfig/src/config_error.c | 86 + .../Ert/devel/libconfig/src/config_get.c | 114 ++ .../Ert/devel/libconfig/src/config_path_elm.c | 135 ++ .../devel/libconfig/src/config_root_path.c | 97 ++ .../devel/libconfig/src/config_schema_item.c | 536 +++++++ .../Ert/devel/libconfig/tests/CMakeLists.txt | 49 + .../libconfig/tests/config_append_test.c | 47 + .../Ert/devel/libconfig/tests/config_config.c | 36 + .../libconfig/tests/config_content_item.c | 58 + .../libconfig/tests/config_content_node.c | 76 + .../Ert/devel/libconfig/tests/config_error.c | 43 + .../libconfig/tests/config_include_test.c | 133 ++ .../devel/libconfig/tests/config_node_test.c | 55 + .../devel/libconfig/tests/config_path_elm.c | 92 ++ .../devel/libconfig/tests/config_root_path.c | 88 + .../libconfig/tests/config_schema_item.c | 48 + .../devel/libconfig/tests/config_typeFail.c | 67 + .../Ert/devel/libconfig/tests/config_typeOK.c | 55 + .../devel/libconfig/tests/data/append_test | 4 + .../libconfig/tests/data/content_item_test | 1 + .../devel/libconfig/tests/data/include_test | 3 + .../devel/libconfig/tests/data/path/include1 | 5 + .../tests/data/path/subpath/include2 | 1 + .../tests/data/path/subpath/include3 | 1 + .../data/path/subpath/subsubpath/include4 | 1 + .../devel/libconfig/tests/data/type_testFail | 6 + .../devel/libconfig/tests/data/type_testOK | 4 + ThirdParty/Ert/devel/libecl/CMakeLists.txt | 7 +- .../devel/libecl/applications/CMakeLists.txt | 37 +- .../devel/libecl/applications/ecl_quantile.c | 53 +- .../Ert/devel/libecl/applications/esummary.c | 140 +- .../devel/libecl/include/ert/ecl/ecl_grid.h | 2 +- .../Ert/devel/libecl/include/ert/ecl/ecl_kw.h | 1 + .../libecl/include/ert/ecl/ecl_kw_grdecl.h | 1 + .../ert/ecl/{ecl_intehead.h => ecl_rsthead.h} | 28 +- .../devel/libecl/include/ert/ecl/ecl_sum.h | 3 + .../libecl/include/ert/ecl/ecl_sum_data.h | 3 + .../devel/libecl/include/ert/ecl/ecl_util.h | 3 + .../libecl/include/ert/ecl/smspec_node.h | 1 + .../Ert/devel/libecl/src/CMakeLists.txt | 15 +- ThirdParty/Ert/devel/libecl/src/ecl_file.c | 2 +- ThirdParty/Ert/devel/libecl/src/ecl_grid.c | 12 +- .../Ert/devel/libecl/src/ecl_intehead.c | 79 - ThirdParty/Ert/devel/libecl/src/ecl_kw.c | 28 +- .../Ert/devel/libecl/src/ecl_kw_grdecl.c | 19 +- .../Ert/devel/libecl/src/ecl_rst_file.c | 1 - ThirdParty/Ert/devel/libecl/src/ecl_rstfile.c | 4 +- ThirdParty/Ert/devel/libecl/src/ecl_rsthead.c | 155 ++ ThirdParty/Ert/devel/libecl/src/ecl_sum.c | 8 + .../Ert/devel/libecl/src/ecl_sum_data.c | 48 +- ThirdParty/Ert/devel/libecl/src/ecl_util.c | 64 + ThirdParty/Ert/devel/libecl/src/smspec_node.c | 25 +- .../Ert/devel/libecl/tests/CMakeLists.txt | 43 +- ThirdParty/Ert/devel/libecl/tests/ecl_dualp.c | 76 + .../Ert/devel/libecl/tests/ecl_grid_simple.c | 36 + .../Ert/devel/libecl/tests/ecl_kw_equal.c | 65 + .../Ert/devel/libecl/tests/ecl_kw_grdecl.c | 70 + .../Ert/devel/libecl/tests/ecl_rsthead.c | 108 ++ .../Ert/devel/libecl/tests/ecl_sum_test.c | 66 + .../devel/libecl/tests/ecl_util_month_range.c | 124 ++ .../Ert/devel/libecl_well/CMakeLists.txt | 6 +- .../libecl_well/applications/CMakeLists.txt | 10 +- .../libecl_well/applications/well_info_test.c | 1 - .../include/ert/ecl_well/well_conn.h | 8 +- .../include/ert/ecl_well/well_state.h | 1 - .../Ert/devel/libecl_well/src/CMakeLists.txt | 11 +- .../Ert/devel/libecl_well/src/well_conn.c | 45 +- .../Ert/devel/libecl_well/src/well_info.c | 6 +- .../Ert/devel/libecl_well/src/well_state.c | 21 +- .../Ert/devel/libecl_well/src/well_ts.c | 51 +- .../devel/libecl_well/tests/CMakeLists.txt | 16 + .../Ert/devel/libecl_well/tests/well_dualp.c | 65 + .../devel/libecl_well/tests/well_lgr_load.c | 66 + .../Ert/devel/libecl_well/tests/well_ts.c | 71 + ThirdParty/Ert/devel/libenkf/CMakeLists.txt | 7 +- .../libenkf/applications/ert_gui/bin/gert | 56 +- .../ert_gui/lib/ert_gui/gert_main.py | 5 +- .../lib/ert_gui/pages/config/analysis.py | 23 +- .../lib/ert_gui/pages/config/eclipse.py | 22 +- .../lib/ert_gui/pages/config/ensemble.py | 54 +- .../ert_gui/pages/config/jobs/jobsdialog.py | 29 - .../lib/ert_gui/pages/config/observations.py | 8 +- .../pages/config/parameters/datapanel.py | 2 +- .../pages/config/parameters/fieldpanel.py | 2 +- .../config/parameters/parametermodels.py | 2 +- .../ert_gui/lib/ert_gui/pages/config/plot.py | 15 - .../lib/ert_gui/pages/config/queuesystem.py | 18 - .../lib/ert_gui/pages/config/simulation.py | 45 +- .../pages/config/simulations/runpathpanel.py | 2 +- .../lib/ert_gui/pages/config/systemenv.py | 27 - .../lib/ert_gui/pages/init/initandcopy.py | 22 +- .../lib/ert_gui/pages/init/initpanel.py | 14 +- .../lib/ert_gui/pages/plot/ensemblefetcher.py | 9 +- .../lib/ert_gui/pages/plot/plotdata.py | 23 +- .../lib/ert_gui/pages/plot/plotfigure.py | 2 +- .../lib/ert_gui/pages/plot/plotgenerator.py | 2 +- .../lib/ert_gui/pages/plot/plotpanel.py | 3 +- .../lib/ert_gui/pages/plot/plotrenderer.py | 2 +- .../lib/ert_gui/pages/plot/plotsettings.py | 2 +- .../lib/ert_gui/pages/plot/plotview.py | 2 +- .../lib/ert_gui/pages/plot/rftfetcher.py | 7 +- .../ert_gui/lib/ert_gui/pages/run/runpanel.py | 1 - .../lib/ert_gui/pages/run/simulation.py | 3 +- .../ert_gui/pages/run/simulationsdialog.py | 3 +- .../lib/ert_gui/widgets/helpedwidget.py | 2 +- .../applications/ert_tui/CMakeLists.txt | 13 +- .../applications/ert_tui/enkf_tui_QC.c | 20 +- .../applications/ert_tui/enkf_tui_export.c | 75 - .../applications/ert_tui/enkf_tui_init.c | 3 +- .../applications/ert_tui/enkf_tui_main.c | 4 +- .../applications/ert_tui/enkf_tui_misc.c | 5 +- .../applications/ert_tui/enkf_tui_plot.c | 105 +- .../applications/ert_tui/enkf_tui_plot.h | 9 + .../applications/ert_tui/enkf_tui_plot_rft.c | 303 ++-- .../applications/ert_tui/enkf_tui_ranking.c | 47 +- .../applications/ert_tui/enkf_tui_run.c | 132 +- .../applications/ert_tui/enkf_tui_util.c | 17 + .../applications/ert_tui/enkf_tui_util.h | 3 + .../applications/ert_tui/enkf_tui_workflow.c | 115 ++ .../applications/ert_tui/enkf_tui_workflow.h | 24 + .../applications/ert_tui/ert_tui_jobs.c | 26 + .../devel/libenkf/applications/ert_tui/main.c | 64 +- .../applications/ert_tui/upgrade_fs104.c | 6 +- .../include/ert/enkf/analysis_config.h | 12 +- .../include/ert/enkf/analysis_iter_config.h | 41 + .../libenkf/include/ert/enkf/config_keys.h | 41 +- .../libenkf/include/ert/enkf/ecl_config.h | 7 +- .../include/ert/enkf/ecl_refcase_list.h | 49 + .../libenkf/include/ert/enkf/enkf_defaults.h | 63 +- .../devel/libenkf/include/ert/enkf/enkf_fs.h | 2 + .../libenkf/include/ert/enkf/enkf_main.h | 21 +- .../devel/libenkf/include/ert/enkf/enkf_obs.h | 7 +- .../libenkf/include/ert/enkf/enkf_state.h | 5 +- .../libenkf/include/ert/enkf/enkf_types.h | 3 +- .../include/ert/enkf/ensemble_config.h | 4 + .../libenkf/include/ert/enkf/ert_report.h | 3 +- .../include/ert/enkf/ert_report_list.h | 6 +- .../libenkf/include/ert/enkf/ert_template.h | 3 + .../include/ert/enkf/ert_workflow_list.h | 58 + .../libenkf/include/ert/enkf/local_config.h | 2 +- .../libenkf/include/ert/enkf/plot_config.h | 6 +- .../libenkf/include/ert/enkf/qc_config.h | 40 - .../libenkf/include/ert/enkf/qc_module.h | 50 + .../libenkf/include/ert/enkf/rng_config.h | 23 +- .../libenkf/include/ert/enkf/runpath_list.h | 46 + .../libenkf/include/ert/enkf/site_config.h | 5 +- .../devel/libenkf/include/ert/enkf/time_map.h | 17 +- .../Ert/devel/libenkf/src/CMakeLists.txt | 16 +- .../Ert/devel/libenkf/src/analysis_config.c | 147 +- .../devel/libenkf/src/analysis_iter_config.c | 130 ++ ThirdParty/Ert/devel/libenkf/src/ecl_config.c | 177 ++- .../Ert/devel/libenkf/src/ecl_refcase_list.c | 397 +++++ ThirdParty/Ert/devel/libenkf/src/enkf_fs.c | 27 +- ThirdParty/Ert/devel/libenkf/src/enkf_main.c | 659 ++++---- .../Ert/devel/libenkf/src/enkf_main_jobs.c | 63 + ThirdParty/Ert/devel/libenkf/src/enkf_obs.c | 28 +- ThirdParty/Ert/devel/libenkf/src/enkf_state.c | 85 +- .../Ert/devel/libenkf/src/ensemble_config.c | 448 +++--- ThirdParty/Ert/devel/libenkf/src/ert_report.c | 11 +- .../Ert/devel/libenkf/src/ert_report_list.c | 74 +- .../Ert/devel/libenkf/src/ert_template.c | 27 + .../Ert/devel/libenkf/src/ert_workflow_list.c | 239 +++ .../Ert/devel/libenkf/src/field_config.c | 19 +- ThirdParty/Ert/devel/libenkf/src/gen_kw.c | 4 +- ThirdParty/Ert/devel/libenkf/src/gen_obs.c | 9 +- .../Ert/devel/libenkf/src/local_config.c | 26 +- .../Ert/devel/libenkf/src/member_config.c | 4 +- .../Ert/devel/libenkf/src/model_config.c | 69 +- .../Ert/devel/libenkf/src/plot_config.c | 90 +- ThirdParty/Ert/devel/libenkf/src/qc_config.c | 64 - ThirdParty/Ert/devel/libenkf/src/qc_module.c | 160 ++ ThirdParty/Ert/devel/libenkf/src/rng_config.c | 48 +- .../Ert/devel/libenkf/src/runpath_list.c | 199 +++ .../Ert/devel/libenkf/src/site_config.c | 230 +-- ThirdParty/Ert/devel/libenkf/src/time_map.c | 184 ++- ThirdParty/Ert/devel/libenkf/src/trans_func.c | 8 +- .../Ert/devel/libenkf/tests/CMakeLists.txt | 65 + .../libenkf/tests/data/config/ert_report_list | 3 + .../Ert/devel/libenkf/tests/data/config/rng | 6 + .../libenkf/tests/data/ensemble/GEN_PARAM | 1 + .../Ert/devel/libenkf/tests/enkf_ecl_config.c | 54 + .../libenkf/tests/enkf_ecl_config_config.c | 55 + .../Ert/devel/libenkf/tests/enkf_ensemble.c | 46 + .../libenkf/tests/enkf_ensemble_GEN_PARAM.c | 55 + .../devel/libenkf/tests/enkf_iter_config.c | 79 + .../Ert/devel/libenkf/tests/enkf_main.c | 33 + .../devel/libenkf/tests/enkf_model_config.c | 31 + .../devel/libenkf/tests/enkf_refcase_list.c | 128 ++ .../devel/libenkf/tests/enkf_report_list.c | 44 + ThirdParty/Ert/devel/libenkf/tests/enkf_rng.c | 118 ++ .../devel/libenkf/tests/enkf_runpath_list.c | 126 ++ .../devel/libenkf/tests/enkf_site_config.c | 73 + .../Ert/devel/libenkf/tests/enkf_time_map.c | 133 ++ .../include/ert/util/CMakeLists.txt | 9 +- .../devel/libert_util/include/ert/util/hash.h | 1 + .../libert_util/include/ert/util/latex.h | 4 +- .../devel/libert_util/include/ert/util/log.h | 7 +- .../libert_util/include/ert/util/mzran.h | 1 + .../libert_util/include/ert/util/path_stack.h | 42 + .../devel/libert_util/include/ert/util/rng.h | 5 + .../include/ert/util/string_util.h | 38 + .../libert_util/include/ert/util/stringlist.h | 7 +- .../libert_util/include/ert/util/subst_func.h | 4 +- .../libert_util/include/ert/util/subst_list.h | 9 +- .../libert_util/include/ert/util/template.h | 2 +- .../libert_util/include/ert/util/test_util.h | 41 +- .../include/ert/util/time_interval.h | 53 + .../devel/libert_util/include/ert/util/util.h | 43 +- .../libert_util/include/ert/util/util_fork.h | 11 - .../libert_util/include/ert/util/vector.h | 1 + .../include/ert/util/vector_template.h | 3 + .../Ert/devel/libert_util/src/CMakeLists.txt | 31 +- ThirdParty/Ert/devel/libert_util/src/hash.c | 18 + ThirdParty/Ert/devel/libert_util/src/latex.c | 133 +- ThirdParty/Ert/devel/libert_util/src/log.c | 36 +- ThirdParty/Ert/devel/libert_util/src/menu.c | 4 +- ThirdParty/Ert/devel/libert_util/src/mzran.c | 27 +- .../Ert/devel/libert_util/src/path_stack.c | 119 ++ ThirdParty/Ert/devel/libert_util/src/rng.c | 76 +- .../Ert/devel/libert_util/src/string_util.c | 208 +++ .../Ert/devel/libert_util/src/stringlist.c | 43 +- .../Ert/devel/libert_util/src/subst_func.c | 2 +- .../Ert/devel/libert_util/src/subst_list.c | 142 +- .../Ert/devel/libert_util/src/test_util.c | 80 +- .../Ert/devel/libert_util/src/time_interval.c | 174 ++ ThirdParty/Ert/devel/libert_util/src/util.c | 668 +++++--- .../devel/libert_util/src/util_abort_gnu.c | 312 ++-- .../devel/libert_util/src/util_abort_simple.c | 14 +- .../Ert/devel/libert_util/src/util_env.c | 47 +- .../Ert/devel/libert_util/src/util_fork.c | 47 +- .../Ert/devel/libert_util/src/util_path.c | 1 - ThirdParty/Ert/devel/libert_util/src/vector.c | 18 +- .../devel/libert_util/src/vector_template.c | 21 +- .../devel/libert_util/tests/CMakeLists.txt | 83 + .../libert_util/tests/ert_util_PATH_test.c | 59 + .../libert_util/tests/ert_util_addr2line.c | 108 ++ .../libert_util/tests/ert_util_approx_equal.c | 41 + .../libert_util/tests/ert_util_before_after.c | 41 + .../libert_util/tests/ert_util_binary_split.c | 55 + .../libert_util/tests/ert_util_cwd_test.c | 37 + .../tests/ert_util_file_readable.c | 55 + .../libert_util/tests/ert_util_hash_test.c | 43 + .../libert_util/tests/ert_util_latex_test.c | 70 +- .../devel/libert_util/tests/ert_util_logh.c | 46 + .../tests/ert_util_path_stack_test.c | 81 + .../devel/libert_util/tests/ert_util_ping.c | 41 + .../libert_util/tests/ert_util_realpath.c | 52 + .../libert_util/tests/ert_util_relpath_test.c | 88 + .../devel/libert_util/tests/ert_util_rng.c | 71 + .../tests/ert_util_sprintf_escape.c | 39 + .../libert_util/tests/ert_util_strcat_test.c | 55 + .../libert_util/tests/ert_util_string_util.c | 106 ++ .../tests/ert_util_stringlist_test.c | 52 +- .../tests/ert_util_time_interval.c | 245 +++ .../tests/ert_util_type_vector_test.c | 32 + .../libert_util/tests/ert_util_vector_test.c | 52 +- .../Ert/devel/libgeometry/src/CMakeLists.txt | 10 +- .../Ert/devel/libjob_queue/CMakeLists.txt | 16 +- .../include/ert/job_queue/ext_cmd.h | 47 - .../libjob_queue/include/ert/job_queue/lsb.h | 56 + .../include/ert/job_queue/lsf_driver.h | 2 + .../include/ert/job_queue/workflow.h | 45 + .../include/ert/job_queue/workflow_job.h | 51 + .../include/ert/job_queue/workflow_joblist.h | 43 + .../Ert/devel/libjob_queue/src/CMakeLists.txt | 31 +- .../Ert/devel/libjob_queue/src/ext_cmd.c | 267 ---- .../Ert/devel/libjob_queue/src/ext_job.c | 103 +- .../Ert/devel/libjob_queue/src/job_queue.c | 7 + ThirdParty/Ert/devel/libjob_queue/src/lsb.c | 197 +++ .../Ert/devel/libjob_queue/src/lsf_driver.c | 951 ++++++++++- .../devel/libjob_queue/src/lsf_driver_dummy.c | 107 -- .../devel/libjob_queue/src/lsf_driver_impl.c | 21 +- .../Ert/devel/libjob_queue/src/rsh_driver.c | 12 +- .../Ert/devel/libjob_queue/src/workflow.c | 229 +++ .../Ert/devel/libjob_queue/src/workflow_job.c | 356 +++++ .../devel/libjob_queue/src/workflow_joblist.c | 85 + .../devel/libjob_queue/tests/CMakeLists.txt | 38 +- .../devel/libjob_queue/tests/create_file.c | 28 + .../libjob_queue/tests/data/externalFail | 5 + .../devel/libjob_queue/tests/data/externalOK | 6 + .../libjob_queue/tests/data/external_job | 5 + .../libjob_queue/tests/data/internalFail | 6 + .../devel/libjob_queue/tests/data/internalOK | 2 +- .../libjob_queue/tests/data/internal_job | 5 + .../devel/libjob_queue/tests/job_loadFail.c | 60 + .../tests/{loadOK.c => job_loadOK.c} | 17 +- .../Ert/devel/libjob_queue/tests/job_lsb.c | 47 + .../libjob_queue/tests/job_lsf_submit_test.c | 11 +- .../devel/libjob_queue/tests/job_lsf_test.c | 53 +- .../devel/libjob_queue/tests/job_queue_test.c | 40 + .../libjob_queue/tests/job_workflow_test.c | 116 ++ .../libplot/include/ert/plot/plot_dataset.h | 1 + .../Ert/devel/libplot/src/CMakeLists.txt | 11 +- .../devel/librms/applications/CMakeLists.txt | 10 +- .../Ert/devel/librms/src/CMakeLists.txt | 11 +- .../libsched/applications/CMakeLists.txt | 10 +- .../Ert/devel/libsched/src/CMakeLists.txt | 11 +- ThirdParty/Ert/devel/libsched/src/history.c | 5 +- .../Ert/devel/libsched/src/sched_kw_compdat.c | 2 +- .../devel/python/ert/config/config_enums.py | 25 + .../devel/python/ert/config/config_parser.py | 47 + .../Ert/devel/python/python/CMakeLists.txt | 2 +- .../python/python/ert/config/CMakeLists.txt | 2 +- .../devel/python/python/ert/config/config.py | 19 + .../python/python/ert/config/config_enums.py | 21 + .../python/python/ert/config/config_parser.py | 165 ++ .../Ert/devel/python/python/ert/cwrap/clib.py | 4 +- .../python/python/ert/ecl/CMakeLists.txt | 7 +- .../Ert/devel/python/python/ert/ecl/ecl.py | 1 + .../devel/python/python/ert/ecl/ecl_case.py | 19 +- .../devel/python/python/ert/ecl/ecl_file.py | 52 +- .../devel/python/python/ert/ecl/ecl_grid.py | 6 +- .../devel/python/python/ert/ecl/ecl_local.py | 72 + .../devel/python/python/ert/ecl/ecl_queue.py | 14 +- .../devel/python/python/ert/ecl/ecl_sum.py | 157 +- .../python/python/ert/enkf/analysis_config.py | 65 + .../python/python/ert/enkf/ecl_config.py | 65 + .../python/ert/enkf/enkf_config_node.py | 62 + .../devel/python/python/ert/enkf/enkf_main.py | 54 +- .../devel/python/python/ert/enkf/enkf_obs.py | 52 + .../python/python/ert/enkf/ens_config.py | 13 +- .../python/python/ert/enkf/ert_template.py | 58 + .../python/python/ert/enkf/field_config.py | 58 + .../python/python/ert/enkf/gen_data_config.py | 56 + .../python/python/ert/enkf/gen_kw_config.py | 54 + .../python/python/ert/enkf/local_config.py | 55 + .../python/python/ert/enkf/model_config.py | 62 + .../python/python/ert/enkf/plot_config.py | 65 + .../python/python/ert/enkf/site_config.py | 84 + .../lib => python/python/ert}/ert/__init__.py | 0 .../lib => python/python/ert}/ert/enums.py | 0 .../lib => python/python/ert}/ert/erttypes.py | 0 .../python/ert}/ert/ertwrapper.py | 3 +- .../Ert/devel/python/python/ert/geo/libgeo.py | 2 +- .../python/ert/job_queue/CMakeLists.txt | 2 +- .../python/python/ert/job_queue/ext_job.py | 77 + .../python/ert/job_queue/ext_joblist.py | 57 + .../python/ert/job_queue/forward_model.py | 54 + .../python/python/ert/job_queue/job_queue.py | 4 + .../python/ert/job_queue/libjob_queue.py | 98 +- .../Ert/devel/python/python/ert/util/latex.py | 20 +- .../Ert/devel/python/python/ert/util/log.py | 53 + .../python/python/ert/util/stringlist.py | 25 + .../devel/python/python/ert/util/tvector.py | 52 + .../devel/python/python/ert/well/libwell.py | 2 +- .../Ert/devel/python/test/CMakeLists.txt | 2 +- .../Ert/devel/python/test/config_test.py | 101 ++ .../Ert/devel/python/test/latex_test.py | 14 + ThirdParty/Ert/devel/python/test/local_bash | 21 +- ThirdParty/Ert/devel/python/test/local_csh | 21 +- .../Ert/devel/python/test/restart_test.py | 78 +- .../Ert/devel/python/test/stringlist_test.py | 42 +- ThirdParty/Ert/devel/python/test/sum_test.py | 55 + .../test/test-data/local/config/simple_config | 226 +++ ThirdParty/Ert/devel/python/test/test_all.py | 5 +- .../Ert/devel/python/test/tvector_test.py | 83 + ThirdParty/Ert/devel/redhat/ert.ecl.spec | 10 +- 383 files changed, 17650 insertions(+), 4776 deletions(-) delete mode 100644 ThirdParty/Ert/devel/cmake/Tests/test_dlopen.c create mode 100644 ThirdParty/Ert/devel/cmake/cmake_pyc create mode 100644 ThirdParty/Ert/devel/libconfig/include/ert/config/config_content_item.h create mode 100644 ThirdParty/Ert/devel/libconfig/include/ert/config/config_content_node.h create mode 100644 ThirdParty/Ert/devel/libconfig/include/ert/config/config_error.h create mode 100644 ThirdParty/Ert/devel/libconfig/include/ert/config/config_path_elm.h create mode 100644 ThirdParty/Ert/devel/libconfig/include/ert/config/config_root_path.h create mode 100644 ThirdParty/Ert/devel/libconfig/include/ert/config/config_schema_item.h create mode 100644 ThirdParty/Ert/devel/libconfig/src/config_content_item.c create mode 100644 ThirdParty/Ert/devel/libconfig/src/config_content_node.c create mode 100644 ThirdParty/Ert/devel/libconfig/src/config_error.c create mode 100644 ThirdParty/Ert/devel/libconfig/src/config_get.c create mode 100644 ThirdParty/Ert/devel/libconfig/src/config_path_elm.c create mode 100644 ThirdParty/Ert/devel/libconfig/src/config_root_path.c create mode 100644 ThirdParty/Ert/devel/libconfig/src/config_schema_item.c create mode 100644 ThirdParty/Ert/devel/libconfig/tests/CMakeLists.txt create mode 100644 ThirdParty/Ert/devel/libconfig/tests/config_append_test.c create mode 100644 ThirdParty/Ert/devel/libconfig/tests/config_config.c create mode 100644 ThirdParty/Ert/devel/libconfig/tests/config_content_item.c create mode 100644 ThirdParty/Ert/devel/libconfig/tests/config_content_node.c create mode 100644 ThirdParty/Ert/devel/libconfig/tests/config_error.c create mode 100644 ThirdParty/Ert/devel/libconfig/tests/config_include_test.c create mode 100644 ThirdParty/Ert/devel/libconfig/tests/config_node_test.c create mode 100644 ThirdParty/Ert/devel/libconfig/tests/config_path_elm.c create mode 100644 ThirdParty/Ert/devel/libconfig/tests/config_root_path.c create mode 100644 ThirdParty/Ert/devel/libconfig/tests/config_schema_item.c create mode 100644 ThirdParty/Ert/devel/libconfig/tests/config_typeFail.c create mode 100644 ThirdParty/Ert/devel/libconfig/tests/config_typeOK.c create mode 100644 ThirdParty/Ert/devel/libconfig/tests/data/append_test create mode 100644 ThirdParty/Ert/devel/libconfig/tests/data/content_item_test create mode 100644 ThirdParty/Ert/devel/libconfig/tests/data/include_test create mode 100644 ThirdParty/Ert/devel/libconfig/tests/data/path/include1 create mode 100644 ThirdParty/Ert/devel/libconfig/tests/data/path/subpath/include2 create mode 100644 ThirdParty/Ert/devel/libconfig/tests/data/path/subpath/include3 create mode 100644 ThirdParty/Ert/devel/libconfig/tests/data/path/subpath/subsubpath/include4 create mode 100644 ThirdParty/Ert/devel/libconfig/tests/data/type_testFail create mode 100644 ThirdParty/Ert/devel/libconfig/tests/data/type_testOK rename ThirdParty/Ert/devel/libecl/include/ert/ecl/{ecl_intehead.h => ecl_rsthead.h} (70%) delete mode 100644 ThirdParty/Ert/devel/libecl/src/ecl_intehead.c create mode 100644 ThirdParty/Ert/devel/libecl/src/ecl_rsthead.c create mode 100644 ThirdParty/Ert/devel/libecl/tests/ecl_dualp.c create mode 100644 ThirdParty/Ert/devel/libecl/tests/ecl_grid_simple.c create mode 100644 ThirdParty/Ert/devel/libecl/tests/ecl_kw_equal.c create mode 100644 ThirdParty/Ert/devel/libecl/tests/ecl_kw_grdecl.c create mode 100644 ThirdParty/Ert/devel/libecl/tests/ecl_rsthead.c create mode 100644 ThirdParty/Ert/devel/libecl/tests/ecl_sum_test.c create mode 100644 ThirdParty/Ert/devel/libecl/tests/ecl_util_month_range.c create mode 100644 ThirdParty/Ert/devel/libecl_well/tests/CMakeLists.txt create mode 100644 ThirdParty/Ert/devel/libecl_well/tests/well_dualp.c create mode 100644 ThirdParty/Ert/devel/libecl_well/tests/well_lgr_load.c create mode 100644 ThirdParty/Ert/devel/libecl_well/tests/well_ts.c create mode 100644 ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_workflow.c create mode 100644 ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_workflow.h create mode 100644 ThirdParty/Ert/devel/libenkf/include/ert/enkf/analysis_iter_config.h create mode 100644 ThirdParty/Ert/devel/libenkf/include/ert/enkf/ecl_refcase_list.h create mode 100644 ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_workflow_list.h delete mode 100644 ThirdParty/Ert/devel/libenkf/include/ert/enkf/qc_config.h create mode 100644 ThirdParty/Ert/devel/libenkf/include/ert/enkf/qc_module.h create mode 100644 ThirdParty/Ert/devel/libenkf/include/ert/enkf/runpath_list.h create mode 100644 ThirdParty/Ert/devel/libenkf/src/analysis_iter_config.c create mode 100644 ThirdParty/Ert/devel/libenkf/src/ecl_refcase_list.c create mode 100644 ThirdParty/Ert/devel/libenkf/src/enkf_main_jobs.c create mode 100644 ThirdParty/Ert/devel/libenkf/src/ert_workflow_list.c delete mode 100644 ThirdParty/Ert/devel/libenkf/src/qc_config.c create mode 100644 ThirdParty/Ert/devel/libenkf/src/qc_module.c create mode 100644 ThirdParty/Ert/devel/libenkf/src/runpath_list.c create mode 100644 ThirdParty/Ert/devel/libenkf/tests/CMakeLists.txt create mode 100644 ThirdParty/Ert/devel/libenkf/tests/data/config/ert_report_list create mode 100644 ThirdParty/Ert/devel/libenkf/tests/data/config/rng create mode 100644 ThirdParty/Ert/devel/libenkf/tests/data/ensemble/GEN_PARAM create mode 100644 ThirdParty/Ert/devel/libenkf/tests/enkf_ecl_config.c create mode 100644 ThirdParty/Ert/devel/libenkf/tests/enkf_ecl_config_config.c create mode 100644 ThirdParty/Ert/devel/libenkf/tests/enkf_ensemble.c create mode 100644 ThirdParty/Ert/devel/libenkf/tests/enkf_ensemble_GEN_PARAM.c create mode 100644 ThirdParty/Ert/devel/libenkf/tests/enkf_iter_config.c create mode 100644 ThirdParty/Ert/devel/libenkf/tests/enkf_main.c create mode 100644 ThirdParty/Ert/devel/libenkf/tests/enkf_model_config.c create mode 100644 ThirdParty/Ert/devel/libenkf/tests/enkf_refcase_list.c create mode 100644 ThirdParty/Ert/devel/libenkf/tests/enkf_report_list.c create mode 100644 ThirdParty/Ert/devel/libenkf/tests/enkf_rng.c create mode 100644 ThirdParty/Ert/devel/libenkf/tests/enkf_runpath_list.c create mode 100644 ThirdParty/Ert/devel/libenkf/tests/enkf_site_config.c create mode 100644 ThirdParty/Ert/devel/libenkf/tests/enkf_time_map.c create mode 100644 ThirdParty/Ert/devel/libert_util/include/ert/util/path_stack.h create mode 100644 ThirdParty/Ert/devel/libert_util/include/ert/util/string_util.h create mode 100644 ThirdParty/Ert/devel/libert_util/include/ert/util/time_interval.h delete mode 100644 ThirdParty/Ert/devel/libert_util/include/ert/util/util_fork.h create mode 100644 ThirdParty/Ert/devel/libert_util/src/path_stack.c create mode 100644 ThirdParty/Ert/devel/libert_util/src/string_util.c create mode 100644 ThirdParty/Ert/devel/libert_util/src/time_interval.c create mode 100644 ThirdParty/Ert/devel/libert_util/tests/ert_util_PATH_test.c create mode 100644 ThirdParty/Ert/devel/libert_util/tests/ert_util_addr2line.c create mode 100644 ThirdParty/Ert/devel/libert_util/tests/ert_util_approx_equal.c create mode 100644 ThirdParty/Ert/devel/libert_util/tests/ert_util_before_after.c create mode 100644 ThirdParty/Ert/devel/libert_util/tests/ert_util_binary_split.c create mode 100644 ThirdParty/Ert/devel/libert_util/tests/ert_util_cwd_test.c create mode 100644 ThirdParty/Ert/devel/libert_util/tests/ert_util_file_readable.c create mode 100644 ThirdParty/Ert/devel/libert_util/tests/ert_util_hash_test.c create mode 100644 ThirdParty/Ert/devel/libert_util/tests/ert_util_logh.c create mode 100644 ThirdParty/Ert/devel/libert_util/tests/ert_util_path_stack_test.c create mode 100644 ThirdParty/Ert/devel/libert_util/tests/ert_util_ping.c create mode 100644 ThirdParty/Ert/devel/libert_util/tests/ert_util_realpath.c create mode 100644 ThirdParty/Ert/devel/libert_util/tests/ert_util_relpath_test.c create mode 100644 ThirdParty/Ert/devel/libert_util/tests/ert_util_rng.c create mode 100644 ThirdParty/Ert/devel/libert_util/tests/ert_util_sprintf_escape.c create mode 100644 ThirdParty/Ert/devel/libert_util/tests/ert_util_strcat_test.c create mode 100644 ThirdParty/Ert/devel/libert_util/tests/ert_util_string_util.c create mode 100644 ThirdParty/Ert/devel/libert_util/tests/ert_util_time_interval.c delete mode 100644 ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/ext_cmd.h create mode 100644 ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/lsb.h create mode 100644 ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/workflow.h create mode 100644 ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/workflow_job.h create mode 100644 ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/workflow_joblist.h delete mode 100644 ThirdParty/Ert/devel/libjob_queue/src/ext_cmd.c create mode 100644 ThirdParty/Ert/devel/libjob_queue/src/lsb.c delete mode 100644 ThirdParty/Ert/devel/libjob_queue/src/lsf_driver_dummy.c create mode 100644 ThirdParty/Ert/devel/libjob_queue/src/workflow.c create mode 100644 ThirdParty/Ert/devel/libjob_queue/src/workflow_job.c create mode 100644 ThirdParty/Ert/devel/libjob_queue/src/workflow_joblist.c create mode 100644 ThirdParty/Ert/devel/libjob_queue/tests/create_file.c create mode 100644 ThirdParty/Ert/devel/libjob_queue/tests/data/externalFail create mode 100644 ThirdParty/Ert/devel/libjob_queue/tests/data/externalOK create mode 100644 ThirdParty/Ert/devel/libjob_queue/tests/data/external_job create mode 100644 ThirdParty/Ert/devel/libjob_queue/tests/data/internalFail create mode 100644 ThirdParty/Ert/devel/libjob_queue/tests/data/internal_job create mode 100644 ThirdParty/Ert/devel/libjob_queue/tests/job_loadFail.c rename ThirdParty/Ert/devel/libjob_queue/tests/{loadOK.c => job_loadOK.c} (61%) create mode 100644 ThirdParty/Ert/devel/libjob_queue/tests/job_lsb.c create mode 100644 ThirdParty/Ert/devel/libjob_queue/tests/job_queue_test.c create mode 100644 ThirdParty/Ert/devel/libjob_queue/tests/job_workflow_test.c create mode 100644 ThirdParty/Ert/devel/python/ert/config/config_enums.py create mode 100644 ThirdParty/Ert/devel/python/ert/config/config_parser.py create mode 100644 ThirdParty/Ert/devel/python/python/ert/config/config_enums.py create mode 100644 ThirdParty/Ert/devel/python/python/ert/config/config_parser.py create mode 100644 ThirdParty/Ert/devel/python/python/ert/ecl/ecl_local.py create mode 100644 ThirdParty/Ert/devel/python/python/ert/enkf/analysis_config.py create mode 100644 ThirdParty/Ert/devel/python/python/ert/enkf/ecl_config.py create mode 100644 ThirdParty/Ert/devel/python/python/ert/enkf/enkf_config_node.py create mode 100644 ThirdParty/Ert/devel/python/python/ert/enkf/enkf_obs.py create mode 100644 ThirdParty/Ert/devel/python/python/ert/enkf/ert_template.py create mode 100644 ThirdParty/Ert/devel/python/python/ert/enkf/field_config.py create mode 100644 ThirdParty/Ert/devel/python/python/ert/enkf/gen_data_config.py create mode 100644 ThirdParty/Ert/devel/python/python/ert/enkf/gen_kw_config.py create mode 100644 ThirdParty/Ert/devel/python/python/ert/enkf/local_config.py create mode 100644 ThirdParty/Ert/devel/python/python/ert/enkf/model_config.py create mode 100644 ThirdParty/Ert/devel/python/python/ert/enkf/plot_config.py create mode 100644 ThirdParty/Ert/devel/python/python/ert/enkf/site_config.py rename ThirdParty/Ert/devel/{libenkf/applications/ert_gui/lib => python/python/ert}/ert/__init__.py (100%) rename ThirdParty/Ert/devel/{libenkf/applications/ert_gui/lib => python/python/ert}/ert/enums.py (100%) rename ThirdParty/Ert/devel/{libenkf/applications/ert_gui/lib => python/python/ert}/ert/erttypes.py (100%) rename ThirdParty/Ert/devel/{libenkf/applications/ert_gui/lib => python/python/ert}/ert/ertwrapper.py (98%) create mode 100644 ThirdParty/Ert/devel/python/python/ert/job_queue/ext_job.py create mode 100644 ThirdParty/Ert/devel/python/python/ert/job_queue/ext_joblist.py create mode 100644 ThirdParty/Ert/devel/python/python/ert/job_queue/forward_model.py create mode 100644 ThirdParty/Ert/devel/python/python/ert/util/log.py create mode 100644 ThirdParty/Ert/devel/python/test/config_test.py create mode 100644 ThirdParty/Ert/devel/python/test/test-data/local/config/simple_config create mode 100644 ThirdParty/Ert/devel/python/test/tvector_test.py diff --git a/ApplicationCode/FileInterface/FileInterface_UnitTests/Ert-Test.cpp b/ApplicationCode/FileInterface/FileInterface_UnitTests/Ert-Test.cpp index 390ec2cf56..4041d3884f 100644 --- a/ApplicationCode/FileInterface/FileInterface_UnitTests/Ert-Test.cpp +++ b/ApplicationCode/FileInterface/FileInterface_UnitTests/Ert-Test.cpp @@ -23,7 +23,6 @@ #include #include -#include #include #include #include diff --git a/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp b/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp index fa6c63bb75..4be4484dbc 100644 --- a/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp @@ -20,7 +20,6 @@ #include "util.h" #include "ecl_file.h" -#include "ecl_intehead.h" #include "ecl_kw_magic.h" #include diff --git a/ThirdParty/Ert/devel/CMakeLists.txt b/ThirdParty/Ert/devel/CMakeLists.txt index 263f31744a..99eb2b8d12 100644 --- a/ThirdParty/Ert/devel/CMakeLists.txt +++ b/ThirdParty/Ert/devel/CMakeLists.txt @@ -4,12 +4,14 @@ project( ERT C CXX ) set( ERT_VERSION_MAJOR 1 ) set( ERT_VERSION_MINOR 0 ) -option( BUILD_ERT "Build the full ERT application - Linux only" OFF) -option( BUILD_ENS_PLOT "Build small Eclipse plotting program - no" OFF) -option( BUILD_TESTS "Should the tests be built" OFF) -option( BUILD_APPLICATONS "Should we build small utility applications" OFF) -option( BUILD_ECL_SUMMARY "Build the commandline application ecl_summary" OFF) -option( BUILD_PYTHON "Run py_compile on the python wrappers" OFF) +option( BUILD_ERT "Build the full ERT application - Linux only" OFF) +option( BUILD_ENS_PLOT "Build small Eclipse plotting program - no" OFF) +option( BUILD_TESTS "Should the tests be built" OFF) +option( BUILD_APPLICATIONS "Should we build small utility applications" OFF) +option( BUILD_ECL_SUMMARY "Build the commandline application ecl_summary" OFF) +option( BUILD_PYTHON "Run py_compile on the python wrappers" OFF) +option( INSTALL_ERT "Should anything be installed when issuing make install?" ON) + include( CheckFunctionExists ) ENABLE_TESTING() @@ -22,7 +24,7 @@ elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows") add_definitions( -DERT_WINDOWS ) endif() -set( CMAKE_C_FLAGS "-g -O2 -Wall -std=gnu99 -fno-leading-underscore" ) +set( CMAKE_C_FLAGS "-g -O2 -Wall -std=gnu99" ) set( CMAKE_CXX_FLAGS "-g -O2 -Wall" ) include(cmake/ert_check.cmake) @@ -35,16 +37,13 @@ set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin) if (MSVC) - set(SHARED_LIB OFF) + set( LIBRARY_TYPE STATIC ) + set( SHARED_LIB OFF ) else() - option( SHARED_LIB "Build shared libraries" ON) + set( LIBRARY_TYPE SHARED ) + set( SHARED_LIB ON ) endif() -if (SHARED_LIB) - set( LIBRARY_TYPE SHARED ) -else() - set( LIBRARY_TYPE STATIC ) -endif() @@ -57,9 +56,11 @@ if (ERT_LINUX) set( NEED_LIBM TRUE ) set( LINK_STATIC FALSE ) add_definitions( -DHAVE_PROC ) + set( NEED_LIBDL ON ) else() set( NEED_LIBM FALSE ) set( LINK_STATIC TRUE ) + set( NEED_LIBDL OFF ) endif() @@ -92,13 +93,6 @@ add_subdirectory( libecl_well ) #----------------------------------------------------------------- if (BUILD_ERT) #----------------------------------------------------------------- - try_compile( DLOPEN ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_dlopen.c ) - if (DLOPEN) - set(NEED_LIBDL OFF) - else() - set(NEED_LIBDL ON) - endif() - option(USE_LSF "Include support for LSF" ON) include_directories( ${PROJECT_SOURCE_DIR}/libconfig/include ) diff --git a/ThirdParty/Ert/devel/cmake/Tests/test_dlopen.c b/ThirdParty/Ert/devel/cmake/Tests/test_dlopen.c deleted file mode 100644 index 83b3f7bc67..0000000000 --- a/ThirdParty/Ert/devel/cmake/Tests/test_dlopen.c +++ /dev/null @@ -1,5 +0,0 @@ -#include - -int main( int argc , char ** argv) { - dlopen( NULL , 0 ); -} diff --git a/ThirdParty/Ert/devel/cmake/cmake_pyc b/ThirdParty/Ert/devel/cmake/cmake_pyc new file mode 100644 index 0000000000..03fd6507e2 --- /dev/null +++ b/ThirdParty/Ert/devel/cmake/cmake_pyc @@ -0,0 +1,35 @@ +#!/usr/bin/env python +import py_compile +import os +import os.path +import sys + +# Small 'python compiler' used in the build system for ert. The +# commandline arguments should be: +# +# cmake_pyc.py src1.py src2.py src3.py /path/to/pyc/files +# +# The input source files can contain a path component like +# path/src1.py, but the path will not be recreated in the target +# domain. + + +def compile_file(src_file , target_file): + path = os.path.dirname( target_file ) + if not os.path.exists( path ): + os.makedirs( path ) + try: + py_compile.compile( src_file , cfile = target_file , doraise = True) + except Exception,error: + sys.exit(1) + + +target_path = sys.argv[-1] +for src_file in sys.argv[1:-1]: + compile_file( src_file , "%s/%sc" % (target_path , os.path.basename(src_file))) + +sys.exit(0) + + + + diff --git a/ThirdParty/Ert/devel/cmake/config/ert_build_config.h.in b/ThirdParty/Ert/devel/cmake/config/ert_build_config.h.in index 2fa0b98789..88df980d5e 100644 --- a/ThirdParty/Ert/devel/cmake/config/ert_build_config.h.in +++ b/ThirdParty/Ert/devel/cmake/config/ert_build_config.h.in @@ -1,18 +1,18 @@ -#cmakedefine HAVE_PTHREAD -#cmakedefine HAVE_EXECINFO -#cmakedefine HAVE_FORK -#cmakedefine HAVE_ZLIB -#cmakedefine HAVE_LSF -#cmakedefine HAVE_REALPATH -#cmakedefine HAVE_SYMLINK -#cmakedefine HAVE_READLINKAT -#cmakedefine HAVE_GETUID -#cmakedefine HAVE_LOCALTIME_R -#cmakedefine HAVE_LOCKF -#cmakedefine HAVE_SETENV -#cmakedefine HAVE_GLOB -#cmakedefine MKDIR_POSIX -#cmakedefine HAVE_FNMATCH -#cmakedefine NEED_BLAS -#cmakedefine HAVE_OPENMP -#cmakedefine HAVE_FTRUNCATE +#cmakedefine HAVE_PTHREAD 1 +#cmakedefine HAVE_EXECINFO 1 +#cmakedefine HAVE_FORK 1 +#cmakedefine HAVE_ZLIB 1 +#cmakedefine HAVE_LSF 1 +#cmakedefine HAVE_REALPATH 1 +#cmakedefine HAVE_SYMLINK 1 +#cmakedefine HAVE_READLINKAT 1 +#cmakedefine HAVE_GETUID 1 +#cmakedefine HAVE_LOCALTIME_R 1 +#cmakedefine HAVE_LOCKF 1 +#cmakedefine HAVE_SETENV 1 +#cmakedefine HAVE_GLOB 1 +#cmakedefine MKDIR_POSIX 1 +#cmakedefine HAVE_FNMATCH 1 +#cmakedefine NEED_BLAS 1 +#cmakedefine HAVE_OPENMP 1 +#cmakedefine HAVE_FTRUNCATE 1 diff --git a/ThirdParty/Ert/devel/cmake/ert_find.cmake b/ThirdParty/Ert/devel/cmake/ert_find.cmake index 4d7d1efb66..3057b8baf1 100644 --- a/ThirdParty/Ert/devel/cmake/ert_find.cmake +++ b/ThirdParty/Ert/devel/cmake/ert_find.cmake @@ -52,6 +52,8 @@ if (LATEX_PATH) else() set( WITH_LATEX OFF ) endif() +#-----------------------------------------------------------------f +find_program(PING_PATH NAMES ping) #----------------------------------------------------------------- find_path( EXECINFO_HEADER execinfo.h /usr/include ) if (EXECINFO_HEADER) @@ -63,6 +65,8 @@ if (GETOPT_HEADER) add_definitions( -DHAVE_GETOPT ) endif() #----------------------------------------------------------------- +find_path( UNISTD_HEADER unistd.h /usr/include ) + if (ERT_WINDOWS) find_library( SHLWAPI_LIBRARY NAMES Shlwapi ) endif() diff --git a/ThirdParty/Ert/devel/cmake/python.cmake b/ThirdParty/Ert/devel/cmake/python.cmake index cb53d7103f..a9b386e294 100644 --- a/ThirdParty/Ert/devel/cmake/python.cmake +++ b/ThirdParty/Ert/devel/cmake/python.cmake @@ -3,15 +3,17 @@ macro(add_python_target tgt PYTHON_INSTALL_PATH ARGN) foreach(file ${ARGN}) set(OUT ${CMAKE_CURRENT_BINARY_DIR}/${file}.pyc) list(APPEND OUT_FILES ${OUT}) +#------------------------------------------------------ ADD_CUSTOM_COMMAND( - OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${file}.pyc - COMMAND python -m py_compile - ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.py - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - COMMAND mv - ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.pyc ${CMAKE_CURRENT_BINARY_DIR} + OUTPUT ${OUT} + COMMAND ${PROJECT_SOURCE_DIR}/cmake/cmake_pyc + ARGS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.py ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PATH} ) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${file}.pyc DESTINATION ${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PATH}) +#------------------------------------------------------ + if (INSTALL_ERT) + install(FILES ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PATH}/${file}.pyc DESTINATION ${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PATH}) + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${file}.py DESTINATION ${CMAKE_INSTALL_PREFIX}/${PYTHON_INSTALL_PATH}) + endif() endforeach(file) list(REMOVE_DUPLICATES OUT_FILES) ADD_CUSTOM_TARGET( diff --git a/ThirdParty/Ert/devel/debian/changelog b/ThirdParty/Ert/devel/debian/changelog index f86efe7fe7..963e48161a 100644 --- a/ThirdParty/Ert/devel/debian/changelog +++ b/ThirdParty/Ert/devel/debian/changelog @@ -1,3 +1,9 @@ +libert.ecl (1.0-2) precise; urgency=low + + * Mark -dev package as architecture independent + + -- Arne Morten Kvarving Tue, 19 Feb 2013 10:03:04 +0100 + libert.ecl (1.0-1) unstable; urgency=low * Initial release diff --git a/ThirdParty/Ert/devel/debian/control b/ThirdParty/Ert/devel/debian/control index 7ea4d426b8..1a46a19dce 100644 --- a/ThirdParty/Ert/devel/debian/control +++ b/ThirdParty/Ert/devel/debian/control @@ -10,7 +10,7 @@ Vcs-Browser: https://github.com/Ensembles/ert Package: libert.ecl-dev Section: libdevel -Architecture: any +Architecture: all Depends: libert.ecl1 (= ${binary:Version}) Description: The Ensemble based Reservoir Tool -- Development files ERT - Ensemble based Reservoir Tool is a tool for managing en ensemble diff --git a/ThirdParty/Ert/devel/debian/libert.ecl1.install b/ThirdParty/Ert/devel/debian/libert.ecl1.install index 3ddde58419..00c8fc1fd2 100644 --- a/ThirdParty/Ert/devel/debian/libert.ecl1.install +++ b/ThirdParty/Ert/devel/debian/libert.ecl1.install @@ -1 +1,2 @@ usr/lib/*/lib*.so.* +usr/bin/* diff --git a/ThirdParty/Ert/devel/debian/rules b/ThirdParty/Ert/devel/debian/rules index 7f4ddf48bd..265d328965 100644 --- a/ThirdParty/Ert/devel/debian/rules +++ b/ThirdParty/Ert/devel/debian/rules @@ -13,4 +13,4 @@ dh $@ override_dh_auto_configure: - dh_auto_configure -- -DSHARED_LIB=1 + dh_auto_configure -- -DSHARED_LIB=1 -DBUILD_ECL_SUMMARY=1 -DCMAKE_BUILD_TYPE=Release diff --git a/ThirdParty/Ert/devel/libanalysis/include/ert/analysis/rml_enkf_common.h b/ThirdParty/Ert/devel/libanalysis/include/ert/analysis/rml_enkf_common.h index eeca1c0404..fcb0d38e0b 100644 --- a/ThirdParty/Ert/devel/libanalysis/include/ert/analysis/rml_enkf_common.h +++ b/ThirdParty/Ert/devel/libanalysis/include/ert/analysis/rml_enkf_common.h @@ -2,23 +2,22 @@ #ifndef __RML_ENKF_COMMON_H__ #define __RML_ENKF_COMMON_H__ - - #include -#include -#include + +#include +#include void rml_enkf_common_initA__( matrix_type * A , - matrix_type * S , - matrix_type * Cd , - matrix_type * E , - matrix_type * D , - double truncation, - double lamda, - matrix_type * Ud, - double * Wd, - matrix_type * VdT); + matrix_type * S , + matrix_type * Cd , + matrix_type * E , + matrix_type * D , + double truncation, + double lamda, + matrix_type * Ud, + double * Wd, + matrix_type * VdT); #endif diff --git a/ThirdParty/Ert/devel/libanalysis/src/CMakeLists.txt b/ThirdParty/Ert/devel/libanalysis/src/CMakeLists.txt index ffaedd6bf9..2346c6e9f0 100644 --- a/ThirdParty/Ert/devel/libanalysis/src/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libanalysis/src/CMakeLists.txt @@ -16,12 +16,15 @@ endif() set( CMAKE_SHARED_MODULE_PREFIX "" ) add_library( std_enkf MODULE std_enkf.c ) add_library( sqrt_enkf MODULE sqrt_enkf.c ) +add_library( rml_enkf MODULE rml_enkf.c rml_enkf_common.c ) #----------------------------------------------------------------- -install(TARGETS analysis DESTINATION ${CMAKE_INSTALL_LIBDIR}) -foreach(header ${header_files}) - install(FILES ../include/ert/analysis/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/analysis) -endforeach() - +if (INSTALL_ERT) + install(TARGETS analysis DESTINATION ${CMAKE_INSTALL_LIBDIR}) + install(TARGETS rml_enkf DESTINATION ${CMAKE_INSTALL_LIBDIR}) + foreach(header ${header_files}) + install(FILES ../include/ert/analysis/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/analysis) + endforeach() +endif() diff --git a/ThirdParty/Ert/devel/libconfig/CMakeLists.txt b/ThirdParty/Ert/devel/libconfig/CMakeLists.txt index d4fb658258..da0dfb169f 100644 --- a/ThirdParty/Ert/devel/libconfig/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libconfig/CMakeLists.txt @@ -1 +1,2 @@ add_subdirectory( src ) +add_subdirectory( tests ) diff --git a/ThirdParty/Ert/devel/libconfig/include/ert/config/config.h b/ThirdParty/Ert/devel/libconfig/include/ert/config/config.h index 007bf7fa5d..08b110b46a 100644 --- a/ThirdParty/Ert/devel/libconfig/include/ert/config/config.h +++ b/ThirdParty/Ert/devel/libconfig/include/ert/config/config.h @@ -18,61 +18,52 @@ #ifndef __CONFIG_H__ #define __CONFIG_H__ + #ifdef __cplusplus extern "C" { #endif #include +#include #include #include #include +#include +#include +#include + #define ECL_COM_KW "--" #define ENKF_COM_KW "--" -/** - Types used for validation of config items. -*/ -typedef enum {CONFIG_STRING = 0, - CONFIG_INT = 1, - CONFIG_FLOAT = 2, - CONFIG_FILE = 9, /* These file does not need to exist - but includes are handled. */ - CONFIG_EXISTING_FILE = 3, - CONFIG_EXISTING_DIR = 4, - CONFIG_BOOLEAN = 5, - CONFIG_CONFIG = 6, - CONFIG_BYTESIZE = 7, - CONFIG_EXECUTABLE = 8 , - CONFIG_INVALID = 1000 } config_item_types; -typedef struct config_struct config_type; -typedef struct config_schema_item_struct config_schema_item_type; + + +typedef struct config_struct config_type; + char ** config_alloc_active_list(const config_type *, int *); void config_free(config_type *); config_type * config_alloc( ); char ** config_alloc_active_list(const config_type * , int * ); - void config_parse(config_type * , const char * , const char * , const char * , const char * , bool , bool ); + bool config_parse(config_type * , const char * , const char * , const char * , const char * , config_schema_unrecognized_enum unrecognized_behaviour , bool ); bool config_has_schema_item(const config_type * config , const char * kw); void config_clear(config_type * config); /*****************************************************************/ - void config_schema_item_set_envvar_expansion( config_schema_item_type * item , bool expand_envvar ); - bool config_item_set(const config_type * , const char * ); - void config_schema_item_free__ (void * ); - void config_schema_item_free( config_schema_item_type * ); - config_schema_item_type * config_schema_item_alloc(const char * , bool , bool); config_schema_item_type * config_get_schema_item(const config_type *, const char *); + bool config_item_set(const config_type * , const char * ); void config_add_alias(config_type * , const char * , const char * ); void config_install_message(config_type * , const char * , const char * ); const char * config_safe_get(const config_type * , const char *); char * config_alloc_joined_string(const config_type * , const char * , const char * ); void config_add_define( config_type * config , const char * key , const char * value ); - + + /* bool config_schema_item_is_set(const config_schema_item_type * ); void config_schema_item_set_argc_minmax(config_schema_item_type * , int , int , int type_map_size , const config_item_types * ); void config_schema_item_set_common_selection_set(config_schema_item_type * , int argc , const char ** argv); @@ -80,17 +71,12 @@ typedef struct config_schema_item_struct config_schema_item_type; void config_schema_item_set_required_children(config_schema_item_type * , stringlist_type * ); void config_schema_item_set_required_children_on_value(config_schema_item_type * , const char * , stringlist_type * ); void config_schema_item_add_required_children(config_schema_item_type * item , const char * child_key); + */ + + config_schema_item_type * config_add_schema_item(config_type * config, + const char * kw, + bool required); - config_schema_item_type * config_add_schema_item(config_type *, - const char * , - bool , - bool); - - - bool config_has_keys(const config_type *, - const char **, - int , - bool ); const char * config_safe_iget(const config_type * config , const char *kw, int occurence , int index); const char * config_iget(const config_type * , const char * , int occurence , int index); @@ -100,21 +86,29 @@ typedef struct config_schema_item_struct config_schema_item_type; stringlist_type * config_alloc_complete_stringlist(const config_type* , const char * ); stringlist_type * config_alloc_stringlist(const config_type * config , const char * ); hash_type * config_alloc_hash(const config_type * , const char * ); - const stringlist_type * config_get_stringlist_ref(const config_type * , const char * ); - stringlist_type * config_iget_stringlist_ref(const config_type * , const char * , int ); - bool config_has_set_item(const config_type * , const char * ); + const stringlist_type * config_iget_stringlist_ref(const config_type * , const char * , int ); int config_get_occurences(const config_type * , const char * ); int config_get_occurence_size( const config_type * config , const char * kw , int occurence); - + bool config_has_content_item( const config_type * config , const char * input_kw); + config_content_item_type * config_get_content_item( const config_type * config , const char * input_kw); config_schema_item_type * config_add_key_value( config_type * config , const char * key , bool required , config_item_types item_type); bool config_get_value_as_bool(const config_type * config , const char * kw); int config_get_value_as_int(const config_type * config , const char * kw); double config_get_value_as_double(const config_type * config , const char * kw); + const char * config_get_value_as_abspath( const config_type * config , const char * kw); + const char * config_get_value_as_relpath( const config_type * config , const char * kw); + const char * config_get_value_as_path( const config_type * config , const char * kw); const char * config_get_value(const config_type * config , const char * kw); - void config_fprintf_item_list(const config_type * config , FILE * stream); const char * config_get_config_file( const config_type * config , bool abs_path); + void config_fprintf_errors( const config_type * config , bool add_count , FILE * stream ); + + int config_get_schema_size( const config_type * config ); + int config_get_content_size( const config_type * config ); + const config_content_node_type * config_iget_content_node( const config_type * config , int index ); + config_content_node_type * config_get_value_node( const config_type * config , const char * kw); + config_error_type * config_get_errors( const config_type * config ); #ifdef __cplusplus } diff --git a/ThirdParty/Ert/devel/libconfig/include/ert/config/config_content_item.h b/ThirdParty/Ert/devel/libconfig/include/ert/config/config_content_item.h new file mode 100644 index 0000000000..da4dd393bc --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/include/ert/config/config_content_item.h @@ -0,0 +1,66 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'config_content_item.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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. +*/ + + +#ifndef __CONFIG_CONTENT_ITEM_H__ +#define __CONFIG_CONTENT_ITEM_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#include +#include +#include +#include + +typedef struct config_content_item_struct config_content_item_type; + + int config_content_item_get_size(const config_content_item_type * item); + config_content_node_type * config_content_item_get_last_node(const config_content_item_type * item); + config_content_node_type * config_content_item_iget_node(const config_content_item_type * item , int index); + const config_content_node_type * config_content_item_get_last_node_const(const config_content_item_type * item); + const config_content_node_type * config_content_item_iget_node_const(const config_content_item_type * item , int index); + char * config_content_item_ialloc_joined_string(const config_content_item_type * item , const char * sep , int occurence); + char * config_content_item_alloc_joined_string(const config_content_item_type * item , const char * sep); + const stringlist_type * config_content_item_iget_stringlist_ref(const config_content_item_type * item, int occurence); + const stringlist_type * config_content_item_get_stringlist_ref(const config_content_item_type * item); + stringlist_type * config_content_item_alloc_complete_stringlist(const config_content_item_type * item, bool copy); + stringlist_type * config_content_item_alloc_stringlist(const config_content_item_type * item, bool copy); + hash_type * config_content_item_alloc_hash(const config_content_item_type * item , bool copy); + const char * config_content_item_iget(const config_content_item_type * item , int occurence , int index); + bool config_content_item_iget_as_bool(const config_content_item_type * item, int occurence , int index); + int config_content_item_iget_as_int(const config_content_item_type * item, int occurence , int index); + double config_content_item_iget_as_double(const config_content_item_type * item, int occurence , int index); + void config_content_item_clear( config_content_item_type * item ); + void config_content_item_free( config_content_item_type * item ); + void config_content_item_free__( void * arg ); + config_content_item_type * config_content_item_alloc( const config_schema_item_type * schema , const config_path_elm_type * path_elm); + void config_content_item_validate(const config_content_item_type * item, config_error_type * error); + config_content_node_type * config_content_item_alloc_node( const config_content_item_type * item , const config_path_elm_type * path_elm); + const config_schema_item_type * config_content_item_get_schema( const config_content_item_type * item ); + const config_path_elm_type * config_content_item_get_path_elm( const config_content_item_type * item ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ThirdParty/Ert/devel/libconfig/include/ert/config/config_content_node.h b/ThirdParty/Ert/devel/libconfig/include/ert/config/config_content_node.h new file mode 100644 index 0000000000..b318bff85b --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/include/ert/config/config_content_node.h @@ -0,0 +1,61 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'config_content_node.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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. +*/ + + +#ifndef __CONFIG_CONTENT_NODE_H__ +#define __CONFIG_CONTENT_NODE_H__ + +#ifdef __cplusplus +define extern "C" { +#endif + +#include + +#include +#include + +typedef struct config_content_node_struct config_content_node_type; + + config_content_node_type * config_content_node_alloc( const config_schema_item_type * schema , const config_path_elm_type * cwd); + void config_content_node_add_value(config_content_node_type * node , const char * value); + void config_content_node_set(config_content_node_type * node , const stringlist_type * token_list); + char * config_content_node_alloc_joined_string(const config_content_node_type * node, const char * sep); + void config_content_node_free(config_content_node_type * node); + void config_content_node_free__(void * arg); + const char * config_content_node_get_full_string( config_content_node_type * node , const char * sep ); + const char * config_content_node_iget(const config_content_node_type * node , int index); + bool config_content_node_iget_as_bool(const config_content_node_type * node , int index); + int config_content_node_iget_as_int(const config_content_node_type * node , int index); + double config_content_node_iget_as_double(const config_content_node_type * node , int index); + const char * config_content_node_iget_as_path(config_content_node_type * node , int index); + const char * config_content_node_iget_as_abspath( config_content_node_type * node , int index); + const char * config_content_node_iget_as_relpath( config_content_node_type * node , int index); + const stringlist_type * config_content_node_get_stringlist( const config_content_node_type * node ); + const char * config_content_node_safe_iget(const config_content_node_type * node , int index); + int config_content_node_get_size( const config_content_node_type * node ); + const char * config_content_node_get_kw( const config_content_node_type * node ); + void config_content_node_assert_key_value( const config_content_node_type * node ); + const config_path_elm_type * config_content_node_get_path_elm( const config_content_node_type * node ); + void config_content_node_init_opt_hash( const config_content_node_type * node , hash_type * opt_hash , int elm_offset); + void config_content_node_fprintf( const config_content_node_type * node , FILE * stream ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ThirdParty/Ert/devel/libconfig/include/ert/config/config_error.h b/ThirdParty/Ert/devel/libconfig/include/ert/config/config_error.h new file mode 100644 index 0000000000..c6314a4b97 --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/include/ert/config/config_error.h @@ -0,0 +1,45 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'config_error.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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. +*/ + +#ifndef __CONFIG_ERROR_H__ +#define __CONFIG_ERROR_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +typedef struct config_error_struct config_error_type; + + + config_error_type * config_error_alloc(); + config_error_type * config_error_alloc_copy( const config_error_type * src_error); + void config_error_free(config_error_type * error); + const char * config_error_iget(const config_error_type * error , int index); + void config_error_add( config_error_type * error , char * new_error ); + void config_error_clear( config_error_type * error ); + int config_error_count( const config_error_type * error ); + void config_error_fprintf( const config_error_type * error , bool add_count , FILE * stream ); + bool config_error_equal( const config_error_type * error1 , const config_error_type * error2); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ThirdParty/Ert/devel/libconfig/include/ert/config/config_path_elm.h b/ThirdParty/Ert/devel/libconfig/include/ert/config/config_path_elm.h new file mode 100644 index 0000000000..e4ab4210ee --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/include/ert/config/config_path_elm.h @@ -0,0 +1,44 @@ +/* + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'config_path_elm.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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. +*/ + +#ifndef __CONFIG_PATH_ELM_H__ +#define __CONFIG_PATH_ELM_H__ + +#ifdef __cplusplus +extern "C" +#endif + +#include + +typedef struct config_path_elm_struct config_path_elm_type; + +void config_path_elm_free( config_path_elm_type * path_elm ); +void config_path_elm_free__( void * arg ); +config_path_elm_type * config_path_elm_alloc( const config_root_path_type * root_path , const char * path); +const char * config_path_elm_get_abspath( const config_path_elm_type * path_elm ); +const char * config_path_elm_get_relpath( const config_path_elm_type * path_elm ); +const config_root_path_type * config_path_elm_get_rootpath( const config_path_elm_type * path_elm ); +char * config_path_elm_alloc_abspath(const config_path_elm_type * path_elm , const char * input_path); +char * config_path_elm_alloc_relpath(const config_path_elm_type * path_elm , const char * input_path); +char * config_path_elm_alloc_path(const config_path_elm_type * path_elm , const char * input_path); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ThirdParty/Ert/devel/libconfig/include/ert/config/config_root_path.h b/ThirdParty/Ert/devel/libconfig/include/ert/config/config_root_path.h new file mode 100644 index 0000000000..09289ec398 --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/include/ert/config/config_root_path.h @@ -0,0 +1,40 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'config_root_path.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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. +*/ + +#ifndef __CONFIG_ROOT_PATH_H__ +#define __CONFIG_ROOT_PATH_H__ + +#ifdef __cplusplus +extern "C" +#endif + + +typedef struct config_root_path_struct config_root_path_type; + +void config_root_path_free( config_root_path_type * root_path ); +config_root_path_type * config_root_path_alloc( const char * input_path ); + +const char * config_root_path_get_input_path( const config_root_path_type * root_path ); +const char * config_root_path_get_rel_path( const config_root_path_type * root_path ); +const char * config_root_path_get_abs_path( const config_root_path_type * root_path ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ThirdParty/Ert/devel/libconfig/include/ert/config/config_schema_item.h b/ThirdParty/Ert/devel/libconfig/include/ert/config/config_schema_item.h new file mode 100644 index 0000000000..50eb65e187 --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/include/ert/config/config_schema_item.h @@ -0,0 +1,123 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'config_schema_item.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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. +*/ + + +#ifndef __CONFIG_SCHEMA_ITEM_H__ +#define __CONFIG_SCHEMA_ITEM_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include +#include + +/** + Types used for validation of config items. +*/ +typedef enum {CONFIG_STRING = 1, + CONFIG_INT = 2, + CONFIG_FLOAT = 4, + CONFIG_PATH = 8, + CONFIG_EXISTING_PATH = 16, + CONFIG_BOOL = 32, + CONFIG_CONFIG = 64, + CONFIG_BYTESIZE = 128, + CONFIG_EXECUTABLE = 256 , + CONFIG_INVALID = 512 } config_item_types; + +#define CONFIG_ITEM_TYPE_ENUM_DEFS \ +{.value = 1 , .name="CONFIG_STRING"}, \ +{.value = 2 , .name="CONFIG_INT"}, \ +{.value = 4 , .name="CONFIG_FLOAT"}, \ +{.value = 8 , .name="CONFIG_PATH"}, \ +{.value = 16 , .name="CONFIG_EXISTING_PATH"}, \ +{.value = 32 , .name="CONFIG_BOOL"}, \ +{.value = 64 , .name="CONFIG_CONFIG"}, \ +{.value = 128 , .name="CONFIG_BYTESIZE"}, \ +{.value = 256 , .name="CONFIG_EXECUTABLE"}, \ +{.value = 512 , .name="CONFIG_INVALID"} +#define CONFIG_ITEM_TYPE_ENUM_SIZE 10 + + + typedef enum { + CONFIG_UNRECOGNIZED_IGNORE = 0, + CONFIG_UNRECOGNIZED_WARN = 1, + CONFIG_UNRECOGNIZED_ERROR = 2 + } config_schema_unrecognized_enum; + + +#define CONFIG_SCHEMA_UNRECOGNIZED_ENUM_DEFS \ +{.value = 0 , .name="CONFIG_UNRECOGNIZED_IGNORE"}, \ +{.value = 1 , .name="CONFIG_UNRECOGNIZED_WARN"}, \ +{.value = 2 , .name="CONFIG_UNRECOGNIZED_ERROR"} +#define CONFIG_SCHEMA_UNRECOGNIZED_ENUM_SIZE 3 + + + + +#define CONFIG_DEFAULT_ARG_MIN -1 +#define CONFIG_DEFAULT_ARG_MAX -1 + + + + typedef struct config_schema_item_struct config_schema_item_type; + + + config_schema_item_type * config_schema_item_alloc(const char * kw , bool required); + bool config_schema_item_validate_set(const config_schema_item_type * item , + stringlist_type * token_list , + const char * config_file, + const config_path_elm_type * path_elm, + config_error_type * error_list); + + void config_schema_item_free( config_schema_item_type * item); + void config_schema_item_free__ (void * void_item); + + + void config_schema_item_set_common_selection_set(config_schema_item_type * item , int argc , const char ** argv); + void config_schema_item_set_indexed_selection_set(config_schema_item_type * item , int index , int argc , const char ** argv); + void config_schema_item_set_required_children(config_schema_item_type * item , stringlist_type * stringlist); + void config_schema_item_add_required_children(config_schema_item_type * item , const char * child_key); + void config_schema_item_set_envvar_expansion( config_schema_item_type * item , bool expand_envvar ); + void config_schema_item_set_argc_minmax(config_schema_item_type * item , + int argc_min , + int argc_max); + void config_schema_item_assure_type(const config_schema_item_type * item , int index , int type_mask); + + int config_schema_item_num_required_children(const config_schema_item_type * item); + const char * config_schema_item_iget_required_child( const config_schema_item_type * item , int index); + const char * config_schema_item_get_kw( const config_schema_item_type * item ); + bool config_schema_item_required( const config_schema_item_type * item ); + bool config_schema_item_expand_envvar( const config_schema_item_type * item ); + void config_schema_item_get_argc( const config_schema_item_type * item , int *argc_min , int *argc_max); + bool config_schema_item_has_required_children_value( const config_schema_item_type * item ); + stringlist_type * config_schema_item_get_required_children_value(const config_schema_item_type * item , const char * value); + + void config_schema_item_iset_type( config_schema_item_type * item , int index , config_item_types type); + config_item_types config_schema_item_iget_type(const config_schema_item_type * item , int index ); + void config_schema_item_set_default_type( config_schema_item_type * item , config_item_types type); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ThirdParty/Ert/devel/libconfig/src/CMakeLists.txt b/ThirdParty/Ert/devel/libconfig/src/CMakeLists.txt index e0c31cfab9..555a39c4cd 100644 --- a/ThirdParty/Ert/devel/libconfig/src/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libconfig/src/CMakeLists.txt @@ -1,12 +1,14 @@ -set( source_files config.c conf.c conf_util.c conf_data.c) -set( header_files config.h conf.h conf_data.h) +set( source_files config.c config_error.c config_schema_item.c config_content_item.c config_content_node.c config_root_path.c config_path_elm.c conf.c conf_util.c conf_data.c) +set( header_files config.h config_error.h config_schema_item.h config_content_item.h config_content_node.h config_root_path.h config_path_elm.h conf.h conf_data.h) add_library( config ${LIBRARY_TYPE} ${source_files} ) set_target_properties( config PROPERTIES VERSION 1.0 SOVERSION 1.0 ) target_link_libraries( config ert_util ) -install(TARGETS config DESTINATION ${CMAKE_INSTALL_LIBDIR}) -foreach(header ${header_files}) - install(FILES ../include/ert/config/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/config) -endforeach() +if (INSTALL_ERT) + install(TARGETS config DESTINATION ${CMAKE_INSTALL_LIBDIR}) + foreach(header ${header_files}) + install(FILES ../include/ert/config/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/config) + endforeach() +endif() diff --git a/ThirdParty/Ert/devel/libconfig/src/config.c b/ThirdParty/Ert/devel/libconfig/src/config.c index 1eb45b0336..e3df9254d7 100644 --- a/ThirdParty/Ert/devel/libconfig/src/config.c +++ b/ThirdParty/Ert/devel/libconfig/src/config.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include @@ -29,13 +30,17 @@ #include #include #include +#include #include +#include +#include +#include +#include +#include +#include -#define CLEAR_STRING "__RESET__" - - - +#define CLEAR_STRING "__RESET__" @@ -113,879 +118,57 @@ In this case the whole config object will contain three items, corresponding to the keywords OUTFILE, INPUT and OPTIONS. The two first will again only contain one node each, whereas the OPTIONS item will contain three nodes, corresponding to the three times the keyword -"OPTIONS" appear in the config file. Observe that *IF* the OPTIONS -item had been added with append_arg == false, only the last occurence, -corresponding to 'optimize cache=1' would be present. - +"OPTIONS" appear in the config file. */ -typedef struct validate_struct validate_type; - -/** - This is a 'support-struct' holding various pieces of information - needed during the validation process. Observe the following about - validation: - - 1. It is atomic, in the sense that if you try to an item like this: - - KW ARG1 ARG2 ARG3 - - where ARG1 and ARG2 are valid, whereas there is something wrong - with ARG3, NOTHING IS SET. - - 2. Validation is a two-step process, the first step is run when an - item is parsed. This includes checking: - - o The number of argument. - o That the arguments have the right type. - o That the values match the selection set. - - The second validation step is done when the pasing is complete, - in this pass we check dependencies - i.e. required_children and - required_children_on_value. - - - Observe that nothing has-to be set in this struct. There are some dependencies: - - 1. Only _one_ of common_selection_set and indexed_selection_set - can be set. - - 2. If setting indexed_selection_set or type_map, you MUST set - argc_max first. -*/ - -typedef struct config_item_node_struct config_item_node_type; -typedef struct config_content_item_struct config_content_item_type; - - -struct validate_struct { - int argc_min; /* The minimum number of arguments: -1 means no lower limit. */ - int argc_max; /* The maximum number of arguments: -1 means no upper limit. */ - set_type * common_selection_set; /* A selection set which will apply uniformly to all the arguments. */ - set_type ** indexed_selection_set; /* A selection set which will apply for specifi (indexed) arguments. */ - config_item_types * type_map; /* A list of types for the items - can be NULL. Set along with argc_minmax(); */ - int type_map_size; - stringlist_type * required_children; /* A list of item's which must also be set (if this item is set). (can be NULL) */ - hash_type * required_children_value; /* A list of item's which must also be set - depending on the value of this item. (can be NULL) (This one is complex). */ -}; -#define CONFIG_SCHEMA_ITEM_ID 6751 -struct config_schema_item_struct { - UTIL_TYPE_ID_DECLARATION; - char * kw; /* The kw which identifies this item· */ - - bool append_arg; /* Should the values be appended if a keyword appears several times in the config file. */ - bool required_set; - stringlist_type * required_children; /* A list of item's which must also be set (if this item is set). (can be NULL) */ - hash_type * required_children_value; /* A list of item's which must also be set - depending on the value of this item. (can be NULL) */ - validate_type * validate; /* Information need during validation. */ - bool expand_envvar; /* Should environment variables like $HOME be expanded?*/ -}; + -#define CONFIG_CONTENT_ITEM_ID 8876752 -struct config_content_item_struct { - UTIL_TYPE_ID_DECLARATION; - const config_schema_item_type * schema; - int alloc_size; /* The number of nodes which have been allocated. */ - int node_size; /* The number of active nodes.*/ - config_item_node_type ** nodes; /* A vector of config_item_node_type instances. */ - bool currently_set; /* Has a value been assigned to this keyword. */ - -}; - - - -struct config_item_node_struct { - stringlist_type * stringlist; /* The values which have been set. */ - char * config_cwd; /* The currently active cwd (relative or absolute) of the parser when this item is set. */ -}; struct config_struct { + vector_type * content_list; /* Vector of content_content_node instances. */ hash_type * content_items; hash_type * schema_items; - stringlist_type * parse_errors; /* A stringlist containg the errors found when parsing.*/ + config_error_type * parse_errors; set_type * parsed_files; /* A set of config files whcih have been parsed - to protect against circular includes. */ hash_type * messages; /* Can print a (warning) message when a keyword is encountered. */ subst_list_type * define_list; char * config_file; /* The last parsed file - NULL if no file is parsed-. */ char * abs_path; + config_root_path_type * invoke_path; + vector_type * path_elm_storage; + vector_type * path_elm_stack; }; -/*****************************************************************/ -static void config_add_and_free_error(config_type * config , char * error_message); -/*****************************************************************/ -static validate_type * validate_alloc() { - validate_type * validate = util_malloc(sizeof * validate ); - validate->argc_min = -1; - validate->argc_max = -1; - validate->common_selection_set = NULL; - validate->indexed_selection_set = NULL; - validate->type_map = NULL; - validate->type_map_size = 0; - validate->required_children = NULL; - validate->required_children_value = NULL; - - return validate; -} - - -static void validate_free(validate_type * validate) { - if (validate->common_selection_set != NULL) set_free(validate->common_selection_set); - if (validate->indexed_selection_set != NULL) { - for (int i = 0; i < validate->argc_max; i++) - if (validate->indexed_selection_set[i] != NULL) - set_free(validate->indexed_selection_set[i]); - free(validate->indexed_selection_set); - } - if (validate->type_map != NULL) free(validate->type_map); - if (validate->required_children != NULL) stringlist_free(validate->required_children); - if (validate->required_children_value != NULL) hash_free(validate->required_children_value); - free(validate); -} - -static void validate_set_argc_minmax(validate_type * validate , int argc_min , int argc_max, int type_map_size , const config_item_types * type_map) { - if (validate->argc_min != -1) - util_abort("%s: sorry - current implementation does not allow repeated calls to: %s \n",__func__ , __func__); - - if (argc_min == -1) - argc_min = 0; - - validate->argc_min = argc_min; - validate->argc_max = argc_max; - - { - int internal_type_size = 0; /* Should end up in the range [argc_min,argc_max] */ - - if (argc_max > 0) - internal_type_size = argc_max; - else - internal_type_size = argc_min; - - if (internal_type_size > 0) { - validate->indexed_selection_set = util_calloc( internal_type_size , sizeof * validate->indexed_selection_set ); - for (int iarg=0; iarg < internal_type_size; iarg++) - validate->indexed_selection_set[iarg] = NULL; - } - } - - if (type_map != NULL) { - validate->type_map_size = type_map_size; - validate->type_map = util_alloc_copy(type_map , type_map_size * sizeof * type_map ); - } - -} - - - -static void validate_set_common_selection_set(validate_type * validate , int argc , const char ** argv) { - if (validate->common_selection_set != NULL) - set_free(validate->common_selection_set); - validate->common_selection_set = set_alloc( argc , argv ); -} - - -static void validate_set_indexed_selection_set(validate_type * validate , int index , int argc , const char ** argv) { - - if (validate->indexed_selection_set == NULL) - util_abort("%s: must call xxx_set_argc_minmax() first - aborting \n",__func__); - - if (index >= validate->argc_min) - util_abort("%s: When not not setting argc_max selection set can only be applied to indices up to argc_min\n",__func__); - - if (validate->indexed_selection_set[index] != NULL) - set_free(validate->indexed_selection_set[index]); - - validate->indexed_selection_set[index] = set_alloc(argc , argv); -} - - - - -static char * __alloc_relocated__(const char * config_cwd , const char * value) { - char * file; - - if (util_is_abs_path(value)) - file = util_alloc_string_copy( value ); - else - file = util_alloc_filename(config_cwd , value , NULL); - - return file; -} - -/*****************************************************************/ - -static config_item_node_type * config_item_node_alloc() { - config_item_node_type * node = util_malloc(sizeof * node ); - node->stringlist = stringlist_alloc_new(); - node->config_cwd = NULL; - return node; -} - - -static void config_item_node_set(config_item_node_type * node , const stringlist_type * token_list) { - int argc = stringlist_get_size( token_list ) - 1; - for (int iarg=0; iarg < argc; iarg++) - stringlist_append_copy( node->stringlist , stringlist_iget( token_list , iarg + 1)); -} - - - -static char * config_item_node_alloc_joined_string(const config_item_node_type * node, const char * sep) { - return stringlist_alloc_joined_string(node->stringlist , sep); -} - - -static void config_item_node_free(config_item_node_type * node) { - stringlist_free(node->stringlist); - util_safe_free(node->config_cwd); - free(node); -} - - - - - - - -static void config_item_node_clear(config_item_node_type * node) { - stringlist_clear( node->stringlist ); - util_safe_free(node->config_cwd); - node->config_cwd = NULL; -} - - - - - - - - - -void config_schema_item_assure_type(const config_schema_item_type * item , int index , config_item_types item_type) { - if (index < item->validate->type_map_size) { - bool OK = false; - - if (item->validate->type_map != NULL) - if (item->validate->type_map[index] == item_type) - OK = true; - - if (!OK) - util_abort("%s: failed - wrong installed type \n" , __func__); - } -} - - - - - - - - - - - - - - - - - - -config_schema_item_type * config_schema_item_alloc(const char * kw , bool required , bool append_arg) { - config_schema_item_type * item = util_malloc(sizeof * item ); - UTIL_TYPE_ID_INIT( item , CONFIG_SCHEMA_ITEM_ID); - item->kw = util_alloc_string_copy(kw); - - item->append_arg = append_arg; - item->required_set = required; - item->required_children = NULL; - item->required_children_value = NULL; - item->expand_envvar = true; /* Default is to expand $VAR expressions; can be turned off with - config_schema_item_set_envvar_expansion( item , false ); */ - item->validate = validate_alloc(); - return item; -} - - - -/* - Observe that this function is a bit funny - because it will - actually free the incoming message. -*/ - -static void config_add_and_free_error(config_type * config , char * error_message) { - if (error_message != NULL) { - int error_nr = stringlist_get_size(config->parse_errors) + 1; - stringlist_append_owned_ref(config->parse_errors , util_alloc_sprintf(" %02d: %s" , error_nr , error_message)); - free(error_message); - } -} - - - -/** - This function validates the setting of an item. If the item is OK NULL is returned, - otherwise an error message is returned. -*/ - -static bool config_schema_item_validate_set(config_type * config , const config_schema_item_type * item , stringlist_type * token_list , const char * config_file, const char * config_cwd) { - bool OK = true; - int argc = stringlist_get_size( token_list ) - 1; - if (item->validate->argc_min >= 0) { - if (argc < item->validate->argc_min) { - OK = false; - if (config_file != NULL) - config_add_and_free_error(config , util_alloc_sprintf("Error when parsing config_file:\"%s\" Keyword:%s must have at least %d arguments.",config_file , item->kw , item->validate->argc_min)); - else - config_add_and_free_error(config , util_alloc_sprintf("Error:: Keyword:%s must have at least %d arguments.",item->kw , item->validate->argc_min)); - } - } - - if (item->validate->argc_max >= 0) { - if (argc > item->validate->argc_max) { - OK = false; - if (config_file != NULL) - config_add_and_free_error(config , util_alloc_sprintf("Error when parsing config_file:\"%s\" Keyword:%s must have maximum %d arguments.",config_file , item->kw , item->validate->argc_max)); - else - config_add_and_free_error(config , util_alloc_sprintf("Error:: Keyword:%s must have maximum %d arguments.",item->kw , item->validate->argc_max)); - } - } - - /* - OK - now we have verified that the number of arguments is correct. Then - we start actually looking at the values. - */ - - if (OK) { - /* Validating selection set - first common, then indexed */ - if (item->validate->common_selection_set) { - for (int iarg = 0; iarg < argc; iarg++) { - if (!set_has_key(item->validate->common_selection_set , stringlist_iget( token_list , iarg + 1))) { - config_add_and_free_error(config , util_alloc_sprintf("%s: is not a valid value for: %s.",stringlist_iget( token_list , iarg + 1) , item->kw)); - OK = false; - } - } - } else if (item->validate->indexed_selection_set != NULL) { - for (int iarg = 0; iarg < argc; iarg++) { - if ((item->validate->argc_max > 0) || (iarg < item->validate->argc_min)) { /* Without this test we might go out of range on the indexed selection set. */ - if (item->validate->indexed_selection_set[iarg] != NULL) { - if (!set_has_key(item->validate->indexed_selection_set[iarg] , stringlist_iget( token_list , iarg + 1))) { - config_add_and_free_error(config , util_alloc_sprintf("%s: is not a valid value for item %d of \'%s\'.",stringlist_iget( token_list , iarg + 1) , iarg + 1 , item->kw)); - OK = false; - } - } - } - } - } - - /* - Observe that the following code might rewrite the content of - argv for arguments referring to path locations. - */ - - - /* Validate the TYPE of the various argumnents */ - if (item->validate->type_map != NULL) { - for (int iarg = 0; iarg < argc; iarg++) { - if (iarg < item->validate->type_map_size) { - const char * value = stringlist_iget(token_list , iarg + 1); - switch (item->validate->type_map[iarg]) { - case(CONFIG_STRING): /* This never fails ... */ - break; - case(CONFIG_EXECUTABLE): - { - /* - 1. If the supplied value is an abolute path - do nothing. - 2. If the supplied is _not_ an absolute path: - - a. Try if the relocated exists - then use that. - b. Else - try if the util_alloc_PATH_executable() exists. - */ - if (!util_is_abs_path( value )) { - char * relocated = __alloc_relocated__(config_cwd , value); - char * path_exe = util_alloc_PATH_executable( value ); - - if (util_file_exists(relocated)) { - if (util_is_executable(relocated)) - stringlist_iset_copy( token_list , iarg , relocated); - } else if (path_exe != NULL) - stringlist_iset_copy( token_list , iarg , path_exe); - else - config_add_and_free_error(config , util_alloc_sprintf("Could not locate executable:%s ", value)); - - free(relocated); - util_safe_free(path_exe); - } else { - if (!util_is_executable( value )) - config_add_and_free_error(config , util_alloc_sprintf("Could not locate executable:%s ", value)); - } - } - break; - case(CONFIG_INT): - if (!util_sscanf_int( value , NULL )) - config_add_and_free_error(config , util_alloc_sprintf("Failed to parse:%s as an integer.",value)); - break; - case(CONFIG_FLOAT): - if (!util_sscanf_double( value , NULL )) - config_add_and_free_error(config , util_alloc_sprintf("Failed to parse:%s as a floating point number.", value)); - break; - case(CONFIG_EXISTING_FILE): - { - char * file = __alloc_relocated__(config_cwd , value); - if (!util_file_exists(file)) - config_add_and_free_error(config , util_alloc_sprintf("Can not find file %s in %s ",value , config_cwd)); - else - stringlist_iset_copy( token_list , iarg + 1 , file); - free( file ); - } - break; - case(CONFIG_FILE): - { - char * file = __alloc_relocated__(config_cwd , value); - stringlist_iset_copy( token_list , iarg + 1 , file); - free( file ); - } - break; - case(CONFIG_EXISTING_DIR): - { - char * dir = __alloc_relocated__(config_cwd , value); - if (!util_is_directory(value)) - config_add_and_free_error(config , util_alloc_sprintf("Can not find directory: %s. ",value)); - else - stringlist_iset_copy( token_list , iarg + 1 , dir); - free( dir ); - } - break; - case(CONFIG_BOOLEAN): - if (!util_sscanf_bool( value , NULL )) - config_add_and_free_error(config , util_alloc_sprintf("Failed to parse:%s as a boolean.", value)); - break; - case(CONFIG_BYTESIZE): - if (!util_sscanf_bytesize( value , NULL)) - config_add_and_free_error(config , util_alloc_sprintf("Failed to parse:\"%s\" as number of bytes." , value)); - break; - default: - util_abort("%s: config_item_type:%d not recognized \n",__func__ , item->validate->type_map[iarg]); - } - } - } - } - } - return OK; -} - - - - - - - - - - - - -void config_schema_item_free( config_schema_item_type * item) { - free(item->kw); - if (item->required_children != NULL) stringlist_free(item->required_children); - if (item->required_children_value != NULL) hash_free(item->required_children_value); - validate_free(item->validate); - free(item); -} - - - -static UTIL_SAFE_CAST_FUNCTION( config_schema_item , CONFIG_SCHEMA_ITEM_ID) - -void config_schema_item_free__ (void * void_item) { - config_schema_item_type * item = config_schema_item_safe_cast( void_item ); - config_schema_item_free( item ); -} - - -bool config_content_item_is_set(const config_content_item_type * item) { - return item->currently_set; -} - -void config_schema_item_set_common_selection_set(config_schema_item_type * item , int argc , const char ** argv) { - validate_set_common_selection_set(item->validate , argc , argv); -} - -void config_schema_item_set_indexed_selection_set(config_schema_item_type * item , int index , int argc , const char ** argv) { - validate_set_indexed_selection_set(item->validate , index , argc , argv); -} - - -void config_schema_item_set_required_children(config_schema_item_type * item , stringlist_type * stringlist) { - item->required_children = stringlist_alloc_deep_copy(stringlist); -} - -void config_schema_item_add_required_children(config_schema_item_type * item , const char * child_key) { - if (item->required_children == NULL) - item->required_children = stringlist_alloc_new(); - - stringlist_append_copy( item->required_children , child_key ); -} - - - -/** - This works in the following way: - - if item == value { - All children in child_list must also be set. - } - - -*/ - -void config_schema_item_set_required_children_on_value(config_schema_item_type * item , const char * value , stringlist_type * child_list) { - if (item->required_children_value == NULL) - item->required_children_value = hash_alloc(); - hash_insert_hash_owned_ref( item->required_children_value , value , stringlist_alloc_deep_copy(child_list) , stringlist_free__); -} - - - -/** - This function is used to set the minimum and maximum number of - arguments for an item. In addition you can pass in a pointer to an - array of config_schema_item_types values which will be used for validation - of the input. This vector must be argc_max elements long; it can be - NULL. -*/ - - -void config_schema_item_set_argc_minmax(config_schema_item_type * item , int argc_min , int argc_max, int type_map_size , const config_item_types * type_map) { - validate_set_argc_minmax(item->validate , argc_min , argc_max , type_map_size , type_map); -} - - - -void config_schema_item_set_envvar_expansion( config_schema_item_type * item , bool expand_envvar ) { - item->expand_envvar = expand_envvar; -} - - - -/*****************************************************************/ -/* section:content_item */ - -/** - This function counts the number of times a config item has been - set. Referring again to the example at the top: - - config_content_item_get_occurences( "KEY1" ) - - will return 2. However, if the item has been added with append_arg - set to false, this function can only return zero or one. -*/ - - -static int config_content_item_get_occurences(const config_content_item_type * item) { - return item->node_size; -} - - -static config_item_node_type * config_content_item_iget_node(const config_content_item_type * item , int index) { - if (index < 0 || index >= item->node_size) - util_abort("%s: error - asked for node nr:%d available: [0,%d> \n",__func__ , index , item->node_size); - return item->nodes[index]; -} - - -static char * config_content_item_ialloc_joined_string(const config_content_item_type * item , const char * sep , int occurence) { - config_item_node_type * node = config_content_item_iget_node(item , occurence); - return config_item_node_alloc_joined_string(node , sep); -} - - - -static char * config_content_item_alloc_joined_string(const config_content_item_type * item , const char * sep) { - const int occurences = config_content_item_get_occurences( item ); - char * joined_string = NULL; - - for (int i =0; i < occurences ; i++) { - joined_string = util_strcat_realloc( joined_string , config_content_item_ialloc_joined_string(item , sep , i)); - if (i < (occurences - 1)) - joined_string = util_strcat_realloc( joined_string , sep ); - } - - return joined_string; -} - -static stringlist_type * config_content_item_iget_stringlist_ref(const config_content_item_type * item, int occurence) { - config_item_node_type * node = config_content_item_iget_node(item , occurence); - return node->stringlist; -} - - -static const stringlist_type * config_content_item_get_stringlist_ref(const config_content_item_type * item) { - if (item->schema->append_arg) - util_abort("%s: this function can only be used on items added with append_arg == FALSE\n" , __func__); - return config_content_item_iget_stringlist_ref(item , 0); -} - - -/** - If copy == false - the stringlist will break down when/if the - config object is freed - your call. -*/ - -static stringlist_type * config_content_item_alloc_complete_stringlist(const config_content_item_type * item, bool copy) { - int inode; - stringlist_type * stringlist = stringlist_alloc_new(); - for (inode = 0; inode < item->node_size; inode++) { - - if (copy) - stringlist_append_stringlist_copy( stringlist , item->nodes[inode]->stringlist ); - else - stringlist_append_stringlist_ref( stringlist , item->nodes[inode]->stringlist ); - - } - - return stringlist; -} - - -/** - If copy == false - the stringlist will break down when/if the - config object is freed - your call. -*/ - -static stringlist_type * config_content_item_alloc_stringlist(const config_content_item_type * item, bool copy) { - if (item->schema->append_arg) { - util_abort("%s: item:%s must be initialized with append_arg == false for this call. \n",__func__); - return NULL; - } else { - stringlist_type * stringlist = stringlist_alloc_new(); - - if (copy) - stringlist_append_stringlist_copy( stringlist , item->nodes[0]->stringlist ); - else - stringlist_append_stringlist_ref( stringlist , item->nodes[0]->stringlist ); - - return stringlist; - } -} - - -/** - If copy == false - the hash will break down when/if the - config object is freed - your call. -*/ - -static hash_type * config_content_item_alloc_hash(const config_content_item_type * item , bool copy) { - hash_type * hash = hash_alloc(); - int inode; - for (inode = 0; inode < item->node_size; inode++) { - const config_item_node_type * node = item->nodes[inode]; - - if (copy) { - hash_insert_hash_owned_ref(hash , - stringlist_iget(node->stringlist , 0) , - util_alloc_string_copy(stringlist_iget(node->stringlist , 1)) , - free); - } else - hash_insert_ref(hash , stringlist_iget(node->stringlist , 0) , stringlist_iget(node->stringlist , 1)); - - } - return hash; -} - - - - -static void config_content_item_realloc_nodes(config_content_item_type * item , int new_size) { - const int old_size = item->alloc_size; - item->nodes = util_realloc(item->nodes , sizeof * item->nodes * new_size ); - item->alloc_size = new_size; - { - int i; - for (i=old_size; i < new_size; i++) - item->nodes[i] = NULL; - } -} - - - - - -/* - This function will fail item has not been allocated - append_arg == false. -*/ - -static const char * config_content_item_iget(const config_content_item_type * item , int occurence , int index) { - config_item_node_type * node = config_content_item_iget_node(item , occurence); - return stringlist_iget( node->stringlist , index ); -} - - - -static bool config_content_item_iget_as_bool(const config_content_item_type * item, int occurence , int index) { - bool value; - config_schema_item_assure_type(item->schema , index , CONFIG_BOOLEAN); - util_sscanf_bool( config_content_item_iget(item , occurence ,index) , &value ); - return value; -} - - -static int config_content_item_iget_as_int(const config_content_item_type * item, int occurence , int index) { - int value; - config_schema_item_assure_type(item->schema , index , CONFIG_INT); - util_sscanf_int( config_content_item_iget(item , occurence , index) , &value ); - return value; -} - - -static double config_content_item_iget_as_double(const config_content_item_type * item, int occurence , int index) { - double value; - config_schema_item_assure_type(item->schema , index , CONFIG_FLOAT); - util_sscanf_double( config_content_item_iget(item , occurence , index) , &value ); - return value; -} - - -static void config_content_item_validate(config_type * config , const config_content_item_type * item) { - const config_schema_item_type * schema_item = item->schema; - if (item->currently_set) { - if (schema_item->required_children != NULL) { - int i; - for (i = 0; i < stringlist_get_size(schema_item->required_children); i++) { - if (!config_has_set_item(config , stringlist_iget(schema_item->required_children , i))) { - char * error_message = util_alloc_sprintf("When:%s is set - you also must set:%s.",schema_item->kw , stringlist_iget(schema_item->required_children , i)); - config_add_and_free_error(config , error_message); - } - } - } - - if (schema_item->required_children_value != NULL) { - int inode; - for (inode = 0; inode < config_content_item_get_occurences(item); inode++) { - config_item_node_type * node = config_content_item_iget_node(item , inode); - stringlist_type * values = node->stringlist; - int is; - - for (is = 0; is < stringlist_get_size(values); is++) { - const char * value = stringlist_iget(values , is); - if (hash_has_key(schema_item->required_children_value , value)) { - stringlist_type * children = hash_get(schema_item->required_children_value , value); - int ic; - for (ic = 0; ic < stringlist_get_size( children ); ic++) { - const char * req_child = stringlist_iget( children , ic ); - if (!config_has_set_item(config , req_child )) { - char * error_message = util_alloc_sprintf("When:%s is set to:%s - you also must set:%s.",schema_item->kw , value , req_child ); - config_add_and_free_error(config , error_message); - } - } - } - } - } - } - } else if (schema_item->required_set) { /* The item is not set ... */ - char * error_message = util_alloc_sprintf("Item:%s must be set - parsing:%s",schema_item->kw , config->abs_path); - config_add_and_free_error(config , error_message); - } -} /** Adds a new node as side-effect ... */ -static config_item_node_type * config_content_item_get_new_node(config_content_item_type * item) { - if (item->node_size == item->alloc_size) - config_content_item_realloc_nodes(item , item->alloc_size * 2); - { - config_item_node_type * new_node = config_item_node_alloc(); - item->nodes[item->node_size] = new_node; - item->node_size++; - return new_node; - } +static config_content_node_type * config_get_new_content_node(config_type * config , config_content_item_type * item) { + config_content_node_type * new_node = config_content_item_alloc_node( item , config_content_item_get_path_elm( item )); + vector_append_ref( config->content_list , new_node ); + return new_node; } -static config_item_node_type * config_content_item_get_first_node(config_content_item_type * item) { - - if (item->node_size == 0) - config_content_item_get_new_node(item); - - return config_content_item_iget_node(item , 0); -} - -/** - Used to reset an item is the special string 'CLEAR_STRING' - is found as the only argument: - - OPTION V1 - OPTION V2 V3 V4 - OPTION __RESET__ - OPTION V6 - - In this case OPTION will get the value 'V6'. The example given - above is a bit contrived; this option is designed for situations - where several config files are parsed serially; and the user can - not/will not update the first. -*/ - -static void config_content_item_clear( config_content_item_type * item ) { - int i; - for (i = 0; i < item->node_size; i++) - config_item_node_free( item->nodes[i] ); - util_safe_free(item->nodes); - item->nodes = NULL; - item->node_size = 0; - item->currently_set = false; - config_content_item_realloc_nodes(item , 1); -} -static void config_content_item_free( config_content_item_type * item ) { - int i; - for (i = 0; i < item->node_size; i++) - config_item_node_free( item->nodes[i] ); - free(item->nodes); - free(item); -} - - -static UTIL_SAFE_CAST_FUNCTION( config_content_item , CONFIG_CONTENT_ITEM_ID); - - -static void config_content_item_free__( void * arg ) { - config_content_item_type * content_item = config_content_item_safe_cast( arg ); - config_content_item_free( content_item ); -} - - -static config_content_item_type * config_content_item_alloc( const config_schema_item_type * schema ) { - config_content_item_type * content_item = util_malloc( sizeof * content_item ); - UTIL_TYPE_ID_INIT( content_item , CONFIG_CONTENT_ITEM_ID ); - content_item->schema = schema; - - content_item->alloc_size = 0; - content_item->node_size = 0; - content_item->nodes = NULL; - content_item->currently_set = false; - config_content_item_realloc_nodes(content_item , 1); - return content_item; -} - /* @@ -998,23 +181,17 @@ static config_content_item_type * config_content_item_alloc( const config_schema calling scope will free it. */ -static void config_content_item_set_arg__(config_type * config , config_content_item_type * item , stringlist_type * token_list , const char * config_file , const char * config_cwd) { +static void config_content_item_set_arg__(config_type * config , config_content_item_type * item , stringlist_type * token_list , + const config_path_elm_type * path_elm , + const char * config_file ) { + int argc = stringlist_get_size( token_list ) - 1; if (argc == 1 && (strcmp(stringlist_iget(token_list , 1) , CLEAR_STRING) == 0)) { config_content_item_clear(item); } else { - config_item_node_type * node; - const config_schema_item_type * schema_item = item->schema; + const config_schema_item_type * schema_item = config_content_item_get_schema( item ); - if (schema_item->append_arg) - node = config_content_item_get_new_node(item); - else { - node = config_content_item_get_first_node(item); - config_item_node_clear(node); - } - - /* Filtering based on DEFINE statements */ if (subst_list_get_size( config->define_list ) > 0) { int iarg; @@ -1026,7 +203,7 @@ static void config_content_item_set_arg__(config_type * config , config_content_ /* Filtering based on environment variables */ - if (schema_item->expand_envvar) { + if (config_schema_item_expand_envvar( schema_item )) { int iarg; for (iarg = 0; iarg < argc; iarg++) { int env_offset = 0; @@ -1046,15 +223,12 @@ static void config_content_item_set_arg__(config_type * config , config_content_ } while (env_var != NULL); } } - - if (config_schema_item_validate_set(config , schema_item , token_list , config_file, config_cwd)) { - config_item_node_set(node , token_list); - item->currently_set = true; - if (config_cwd != NULL) - node->config_cwd = util_alloc_string_copy( config_cwd ); - else - node->config_cwd = util_alloc_cwd( ); /* For use from external scope. */ + { + if (config_schema_item_validate_set(schema_item , token_list , config_file, path_elm , config->parse_errors)) { + config_content_node_type * node = config_get_new_content_node(config , item); + config_content_node_set(node , token_list); + } } } } @@ -1068,38 +242,48 @@ static void config_content_item_set_arg__(config_type * config , config_content_ config_type * config_alloc() { - config_type *config = util_malloc(sizeof * config ); + config_type *config = util_malloc(sizeof * config ); + config->content_list = vector_alloc_new(); + config->path_elm_storage = vector_alloc_new(); + config->path_elm_stack = vector_alloc_new(); + config->schema_items = hash_alloc(); config->content_items = hash_alloc(); - config->parse_errors = stringlist_alloc_new(); + config->parse_errors = config_error_alloc(); config->parsed_files = set_alloc_empty(); config->messages = hash_alloc(); config->define_list = subst_list_alloc( NULL ); config->config_file = NULL; config->abs_path = NULL; + config->invoke_path = NULL; return config; } + + static void config_clear_content_items( config_type * config ) { - hash_iter_type * item_iter = hash_iter_alloc( config->content_items ); - while (!hash_iter_is_complete( item_iter )) { - config_content_item_type * item = hash_iter_get_next_value( item_iter ); - config_content_item_clear( item ); - } - hash_iter_free( item_iter ); + hash_free( config->content_items ); + config->content_items = hash_alloc(); + vector_clear( config->content_list ); } void config_clear(config_type * config) { - stringlist_clear(config->parse_errors); + config_error_clear(config->parse_errors); set_clear(config->parsed_files); subst_list_clear( config->define_list ); config_clear_content_items( config ); - + vector_clear( config->path_elm_storage ); + vector_clear( config->path_elm_stack ); + util_safe_free( config->config_file ); util_safe_free( config->abs_path ); + if (config->invoke_path != NULL) { + config_root_path_free( config->invoke_path ); + config->invoke_path = NULL; + } config->config_file = NULL; config->abs_path = NULL; } @@ -1107,10 +291,13 @@ void config_clear(config_type * config) { void config_free(config_type * config) { - stringlist_free( config->parse_errors ); + config_error_free( config->parse_errors ); set_free(config->parsed_files); subst_list_free( config->define_list ); + vector_free( config->path_elm_storage ); + vector_free( config->path_elm_stack ); + vector_free( config->content_list ); hash_free(config->schema_items); hash_free(config->content_items); hash_free(config->messages); @@ -1139,10 +326,9 @@ static void config_insert_schema_item(config_type * config , const char * kw , c config_schema_item_type * config_add_schema_item(config_type * config , const char * kw, - bool required , - bool append_arg) { + bool required) { - config_schema_item_type * item = config_schema_item_alloc( kw , required , append_arg); + config_schema_item_type * item = config_schema_item_alloc( kw , required ); config_insert_schema_item(config , kw , item , false); return item; } @@ -1153,15 +339,15 @@ config_schema_item_type * config_add_schema_item(config_type * config , This is a minor wrapper for adding an item with the properties. 1. It has argc_minmax = {1,1} - 2. It has append == false. The value can than be extracted with config_get_value() and config_get_value_as_xxxx functions. */ config_schema_item_type * config_add_key_value( config_type * config , const char * key , bool required , config_item_types item_type) { - config_schema_item_type * item = config_add_schema_item( config , key , required , false ); - config_schema_item_set_argc_minmax( item , 1 , 1 , 1 , (const config_item_types [1]) { item_type }); + config_schema_item_type * item = config_add_schema_item( config , key , required ); + config_schema_item_set_argc_minmax( item , 1 , 1 ); + config_schema_item_iset_type( item , 0 , item_type ); return item; } @@ -1177,26 +363,56 @@ config_schema_item_type * config_get_schema_item(const config_type * config , co } /* - Will add if not exists. Due to the possibility of aliases we must go - through the canonical keyword which is internalized in the schema_item. + Due to the possibility of aliases we must go through the canonical + keyword which is internalized in the schema_item. */ -static config_content_item_type * config_get_content_item( const config_type * config , const char * input_kw) { + +static config_content_item_type * config_add_content_item( const config_type * config , const char * input_kw, const config_path_elm_type * path_elm) { config_schema_item_type * schema_item = config_get_schema_item( config , input_kw ); - const char * kw = schema_item->kw; + const char * kw = config_schema_item_get_kw( schema_item ); + config_content_item_type * content_item = config_content_item_alloc( schema_item , path_elm ); + hash_insert_hash_owned_ref( config->content_items , kw , content_item , config_content_item_free__ ); - if (!hash_has_key( config->content_items , kw)) { - config_content_item_type * content_item = config_content_item_alloc( schema_item ); - hash_insert_hash_owned_ref( config->content_items , kw , content_item , config_content_item_free__ ); - } - - return hash_get( config->content_items , kw ); + return content_item; } +bool config_has_content_item( const config_type * config , const char * input_kw) { + if (config_has_schema_item( config , input_kw )) { + config_schema_item_type * schema_item = config_get_schema_item( config , input_kw ); + const char * kw = config_schema_item_get_kw( schema_item ); + return hash_has_key( config->content_items , kw ); + } else + return false; +} + + +config_content_item_type * config_get_content_item( const config_type * config , const char * input_kw) { + if (config_has_schema_item( config , input_kw )) { + config_schema_item_type * schema_item = config_get_schema_item( config , input_kw ); + const char * kw = config_schema_item_get_kw( schema_item ); + + if (hash_has_key( config->content_items , kw )) + return hash_get( config->content_items , kw ); + else + return NULL; + + } else + return NULL; +} + + + bool config_item_set(const config_type * config , const char * kw) { - config_content_item_type * content_item = config_get_content_item( config , kw ); - return config_content_item_is_set( content_item ); + if (config_has_content_item(config , kw)) { + const config_content_item_type * item = config_get_content_item( config , kw ); + if (config_content_item_get_size( item )) + return true; + else + return false; // The item exists - but it has size zero. + } else + return false; } @@ -1218,7 +434,7 @@ char ** config_alloc_active_list(const config_type * config, int * _active_size) int i; for( i = 0; i < complete_size; i++) { - if (config_content_item_is_set(config_get_content_item(config , complete_key_list[i]) )) { + if (config_has_content_item( config , complete_key_list[i])) { active_key_list = util_stringlist_append_copy(active_key_list , active_size , complete_key_list[i]); active_size++; } @@ -1231,27 +447,102 @@ char ** config_alloc_active_list(const config_type * config, int * _active_size) +static void config_validate_content_item(const config_type * config , const config_content_item_type * item) { + const config_schema_item_type * schema_item = config_content_item_get_schema( item ); + const char * schema_kw = config_schema_item_get_kw( schema_item ); + + { + int i; + for (i = 0; i < config_schema_item_num_required_children(schema_item); i++) { + const char * required_child = config_schema_item_iget_required_child( schema_item , i ); + if (!config_item_set(config , required_child)) { + char * error_message = util_alloc_sprintf("When:%s is set - you also must set:%s.",schema_kw , required_child); + config_error_add( config->parse_errors , error_message ); + } + } + + if (config_schema_item_has_required_children_value( schema_item )) { + int inode; + for (inode = 0; inode < config_content_item_get_size(item); inode++) { + config_content_node_type * node = config_content_item_iget_node(item , inode); + const stringlist_type * values = config_content_node_get_stringlist( node ); + int is; + + for (is = 0; is < stringlist_get_size(values); is++) { + const char * value = stringlist_iget(values , is); + stringlist_type * required_children = config_schema_item_get_required_children_value( schema_item , value ); + + if (required_children != NULL) { + int ic; + for (ic = 0; ic < stringlist_get_size( required_children ); ic++) { + const char * req_child = stringlist_iget( required_children , ic ); + if (!config_item_set(config , req_child )) { + char * error_message = util_alloc_sprintf("When:%s is set to:%s - you also must set:%s.",schema_kw , value , req_child ); + config_error_add( config->parse_errors , error_message ); + } + } + } + } + } + } + } +} + + + static void config_validate(config_type * config, const char * filename) { int size = hash_get_size(config->schema_items); char ** key_list = hash_alloc_keylist(config->schema_items); int ikey; for (ikey = 0; ikey < size; ikey++) { - const config_content_item_type * item = config_get_content_item(config , key_list[ikey]); - config_content_item_validate(config , item); + if (config_has_content_item( config , key_list[ikey])) { + const config_content_item_type * item = config_get_content_item(config , key_list[ikey]); + config_validate_content_item(config , item ); + } else { + const config_schema_item_type * schema_item = config_get_schema_item( config , key_list[ikey]); + if (config_schema_item_required( schema_item)) { /* The item is not set ... */ + const char * schema_kw = config_schema_item_get_kw( schema_item ); + char * error_message = util_alloc_sprintf("Item:%s must be set - parsing:%s",schema_kw , config->abs_path); + config_error_add( config->parse_errors , error_message ); + } + } } util_free_stringlist(key_list , size); - - if (stringlist_get_size(config->parse_errors) > 0) { - fprintf(stderr,"Parsing errors in configuration file \'%s\':\n" , filename); - stringlist_fprintf(config->parse_errors , "\n", stderr); - util_exit(""); - } - } +static config_path_elm_type * config_add_path_elm( config_type * config , const char * path ) { + const config_path_elm_type * current_path_elm; + + if (vector_get_size( config->path_elm_stack ) == 0) + current_path_elm = NULL; + else + current_path_elm = vector_get_last_const(config->path_elm_stack); + + { + config_path_elm_type * new_path_elm; + + { + char * rel_path = NULL; + if (path != NULL) { + if (current_path_elm == NULL) + rel_path = util_alloc_rel_path( config_root_path_get_abs_path(config->invoke_path) , path); + else + rel_path = config_path_elm_alloc_relpath( current_path_elm , path ); + } + new_path_elm = config_path_elm_alloc( config->invoke_path , rel_path ); + util_safe_free( rel_path ); + } + vector_append_owned_ref( config->path_elm_storage , new_path_elm , config_path_elm_free__); + vector_append_ref( config->path_elm_stack , new_path_elm ); + return new_path_elm; + } +} + + + /** This function parses the config file 'filename', and updated the internal state of the config object as parsing proceeds. If @@ -1319,101 +610,106 @@ static void config_validate(config_type * config, const char * filename) { After parsing we will have an entry: "NAME" , "Bjarne" , "28" , "Dogs". - The key-value pairs internalized during the config parsing are NOT + The key-value pairs internalized during the config parsing are NOT returned to the calling scope in any way. */ static void config_parse__(config_type * config , - const char * config_cwd , - const char * _config_file, + path_stack_type * path_stack , + const char * config_input , const char * comment_string , const char * include_kw , const char * define_kw , - bool warn_unrecognized, + config_schema_unrecognized_enum unrecognized, bool validate) { - char * config_file = util_alloc_filename(config_cwd , _config_file , NULL); - char * abs_filename = util_alloc_realpath(config_file); - parser_type * parser = parser_alloc(" \t" , "\"", NULL , NULL , "--" , "\n"); - if (!set_add_key(config->parsed_files , abs_filename)) - util_exit("%s: file:%s already parsed - circular include ? \n",__func__ , config_file); - else { + /* Guard against circular includes. */ + { + char * abs_filename = util_alloc_realpath(config_input); + if (!set_add_key(config->parsed_files , abs_filename)) + util_exit("%s: file:%s already parsed - circular include ? \n",__func__ , abs_filename); + free( abs_filename ); + } + config_path_elm_type * current_path_elm; + + char * config_file; + { + /* Extract the path component of the current input file and chdir() */ + char * config_path; + { + char * config_base; + char * config_ext; + util_alloc_file_components( config_input , &config_path , &config_base , &config_ext); + config_file = util_alloc_filename( NULL , config_base , config_ext ); + free( config_base ); + util_safe_free( config_ext ); + } + current_path_elm = config_add_path_elm( config , config_path ); + path_stack_push_cwd( path_stack ); + if (config_path != NULL) { + chdir( config_path ); + free( config_path ); + } + } + + + { + parser_type * parser = parser_alloc(" \t" , "\"", NULL , NULL , "--" , "\n"); FILE * stream = util_fopen(config_file , "r"); bool at_eof = false; - + while (!at_eof) { int active_tokens; stringlist_type * token_list; char *line_buffer; - + line_buffer = util_fscanf_alloc_line(stream , &at_eof); if (line_buffer != NULL) { token_list = parser_tokenize_buffer(parser , line_buffer , true); active_tokens = stringlist_get_size( token_list ); - + /* - util_split_string(line_buffer , " \t" , &tokens , &token_list); - active_tokens = tokens; - for (i = 0; i < tokens; i++) { + util_split_string(line_buffer , " \t" , &tokens , &token_list); + active_tokens = tokens; + for (i = 0; i < tokens; i++) { char * comment_ptr = NULL; if(comment_string != NULL) - comment_ptr = strstr(token_list[i] , comment_string); + comment_ptr = strstr(token_list[i] , comment_string); if (comment_ptr != NULL) { - if (comment_ptr == token_list[i]) - active_tokens = i; - else - active_tokens = i + 1; - break; + if (comment_ptr == token_list[i]) + active_tokens = i; + else + active_tokens = i + 1; + break; } } */ - + if (active_tokens > 0) { const char * kw = stringlist_iget( token_list , 0 ); - + /*Treating the include keyword. */ if (include_kw != NULL && (strcmp(include_kw , kw) == 0)) { if (active_tokens != 2) util_abort("%s: keyword:%s must have exactly one argument. \n",__func__ ,include_kw); { - char *include_path = NULL; - char *extension = NULL; - char *include_file = NULL; - - { - char * tmp_path; - char * tmp_file; - util_alloc_file_components(stringlist_iget(token_list , 1) , &tmp_path , &tmp_file , &extension); - - /* Allocating a new path with current config_cwd and the (relative) path to the new config_file */ - if (tmp_path == NULL) - include_path = util_alloc_string_copy( config_cwd ); - else { - if (!util_is_abs_path(tmp_path)) - include_path = util_alloc_filename(config_cwd , tmp_path , NULL); - else - include_path = util_alloc_string_copy(tmp_path); - } - - include_file = util_alloc_filename(NULL , tmp_file , extension); - free(tmp_file); - free(tmp_path); - } - - config_parse__(config , include_path , include_file , comment_string , include_kw , define_kw , warn_unrecognized, false); /* Recursive call */ - util_safe_free(include_file); - util_safe_free(include_path); + const char *include_file = stringlist_iget( token_list , 1); + if (util_file_exists( include_file )) + config_parse__(config , path_stack , include_file , comment_string , include_kw , define_kw , unrecognized, false); /* Recursive call */ + else + config_error_add(config->parse_errors , util_alloc_sprintf("%s file:%s not found" , include_kw , include_file)); } } else if ((define_kw != NULL) && (strcmp(define_kw , kw) == 0)) { + /* Treating the define keyword. */ if (active_tokens < 3) util_abort("%s: keyword:%s must have exactly one (or more) arguments. \n",__func__ , define_kw); { char * key = util_alloc_string_copy( stringlist_iget(token_list ,1) ); char * value = stringlist_alloc_joined_substring( token_list , 2 , active_tokens , " "); - + { char * filtered_value = subst_list_alloc_filtered_string( config->define_list , value); config_add_define( config , key , filtered_value ); @@ -1425,15 +721,26 @@ static void config_parse__(config_type * config , } else { if (hash_has_key(config->messages , kw)) printf("%s \n", (const char *) hash_get(config->messages , kw)); - + if (!config_has_schema_item(config , kw)) { - if (warn_unrecognized) - fprintf(stderr,"** Warning keyword:%s not recognized when parsing:%s --- \n" , kw , config_file); + if (unrecognized == CONFIG_UNRECOGNIZED_WARN) + fprintf(stderr,"** Warning keyword:%s not recognized when parsing:%s --- \n" , kw , config_input); + else if (unrecognized == CONFIG_UNRECOGNIZED_ERROR) + config_error_add(config->parse_errors , util_alloc_sprintf("Keyword:%s is not recognized" , kw)); + } - + if (config_has_schema_item(config , kw)) { - config_content_item_type * content_item = config_get_content_item( config , kw ); - config_content_item_set_arg__(config , content_item , token_list , config_file , config_cwd); + char * config_cwd; + util_alloc_file_components( config_file , &config_cwd , NULL , NULL ); + + if (!config_has_content_item( config , kw )) + config_add_content_item( config , kw , current_path_elm ); + + { + config_content_item_type * content_item = config_get_content_item( config , kw ); + config_content_item_set_arg__(config , content_item , token_list , current_path_elm , config_file ); + } } } } @@ -1441,24 +748,32 @@ static void config_parse__(config_type * config , free(line_buffer); } } - if (validate) config_validate(config , config_file); + if (validate) + config_validate(config , config_file); fclose(stream); + parser_free( parser ); } - parser_free( parser ); - free(abs_filename); free(config_file); + path_stack_pop( path_stack ); + vector_pop( config->path_elm_stack ); } static void config_set_config_file( config_type * config , const char * config_file ) { config->config_file = util_realloc_string_copy( config->config_file , config_file ); - util_safe_free(config->abs_path); config->abs_path = util_alloc_abs_path( config_file ); } +static void config_set_invoke_path( config_type * config ) { + if (config->invoke_path != NULL) + config_root_path_free( config->invoke_path ); + config->invoke_path = config_root_path_alloc( NULL ); +} + + const char * config_get_config_file( const config_type * config , bool abs_path) { if (abs_path) return config->abs_path; @@ -1467,56 +782,35 @@ const char * config_get_config_file( const config_type * config , bool abs_path) } -void config_parse(config_type * config , - const char * filename, - const char * comment_string , - const char * include_kw , - const char * define_kw , - bool warn_unrecognized, - bool validate) { - char * config_path; - char * config_file; - char * tmp_file; - char * extension; - util_alloc_file_components(filename , &config_path , &tmp_file , &extension); - config_set_config_file( config , filename ); - config_file = util_alloc_filename(NULL , tmp_file , extension); - config_parse__(config , config_path , config_file , comment_string , include_kw , define_kw , warn_unrecognized , validate); - - util_safe_free(tmp_file); - util_safe_free(extension); - util_safe_free(config_path); - util_safe_free(config_file); +void config_fprintf_errors( const config_type * config , bool add_count , FILE * stream ) { + config_error_fprintf( config->parse_errors , add_count , stderr ); } -bool config_has_keys(const config_type * config, const char **ext_keys, int ext_num_keys, bool exactly) -{ - int i; - - int config_num_keys; - char ** config_keys; - - config_keys = config_alloc_active_list(config, &config_num_keys); - - if(exactly && (config_num_keys != ext_num_keys)) - { - util_free_stringlist(config_keys,config_num_keys); - return false; - } - - for(i=0; iparse_errors , util_alloc_sprintf("Could not open file:%s for parsing" , filename)); + + if (config_error_count( config->parse_errors ) == 0) + return true; // No errors + else + return false; // There were parse errors. } @@ -1535,7 +829,6 @@ bool config_has_keys(const config_type * config, const char **ext_keys, int ext_ parameter. But to ensure that the get is unambigous we set the following requirements to the item corresponding to 'kw': - * It has been added with append_arg == false. * argc_minmax has been set to 1,1 If this is not the case - we die. @@ -1586,6 +879,7 @@ const char * config_iget(const config_type * config , const char * kw, int occur } + /** This function will return NULL is the item has not been set, however it must be installed with config_add_schema_item(). @@ -1593,73 +887,18 @@ const char * config_iget(const config_type * config , const char * kw, int occur const char * config_safe_iget(const config_type * config , const char *kw, int occurence , int index) { const char * value = NULL; - config_content_item_type * item = config_get_content_item(config , kw); - if (config_content_item_is_set(item)) { - if (occurence < config_content_item_get_occurences( item )) { - config_item_node_type * node = config_content_item_iget_node( item , occurence ); - value = stringlist_safe_iget( node->stringlist , index); + if (config_has_content_item( config , kw )) { + config_content_item_type * item = config_get_content_item(config , kw); + if (occurence < config_content_item_get_size( item )) { + config_content_node_type * node = config_content_item_iget_node( item , occurence ); + value = config_content_node_safe_iget( node , index ); } } return value; } -static void assert_key_value(const config_schema_item_type * item) { - if (!((item->validate->argc_min == 1) && (item->validate->argc_min == 1))) - util_abort("%s: item:%s before calling config_get_value() functions *without* index you must set argc_min == argc_max = 1 \n",__func__ , item->kw); - - if (item->append_arg) - util_abort("%s: must have append_arg == false for _get_value functions \n",__func__); -} - -/** - The config_get_value_??() functions are simpler wrappers for: - - 1. Check that item has been added with append==false and - arg_minmax = {1,1}, i.e. it has typically been added with - config_add_key_value(). - - 2. Call config_iget_?? with both the occurence and index values - set to 0. -*/ - -bool config_get_value_as_bool(const config_type * config , const char * kw) { - config_content_item_type * item = config_get_content_item(config , kw); - assert_key_value( item->schema ); - return config_content_item_iget_as_bool(item , 0 , 0); -} - -int config_get_value_as_int(const config_type * config , const char * kw) { - config_content_item_type * item = config_get_content_item(config , kw); - assert_key_value( item->schema ); - return config_content_item_iget_as_int(item , 0 , 0); -} - -double config_get_value_as_double(const config_type * config , const char * kw) { - config_content_item_type * item = config_get_content_item(config , kw); - assert_key_value( item->schema ); - return config_content_item_iget_as_double(item , 0 , 0); -} - -const char * config_get_value(const config_type * config , const char * kw) { - config_content_item_type * item = config_get_content_item(config , kw); - assert_key_value( item->schema ); - return config_content_item_iget(item , 0 , 0); -} - - - - - -const stringlist_type * config_get_stringlist_ref(const config_type * config , const char * kw) { - config_content_item_type * item = config_get_content_item(config , kw); - - return config_content_item_get_stringlist_ref(item); -} - - - -stringlist_type * config_iget_stringlist_ref(const config_type * config , const char * kw, int occurence) { +const stringlist_type * config_iget_stringlist_ref(const config_type * config , const char * kw, int occurence) { config_content_item_type * item = config_get_content_item(config , kw); return config_content_item_iget_stringlist_ref(item , occurence); @@ -1688,7 +927,8 @@ stringlist_type * config_alloc_complete_stringlist(const config_type* config , c /** - It is enforced that kw-item has been added with append_arg == false. + In the case the keyword has been mentioned several times the last + occurence will be returned. */ stringlist_type * config_alloc_stringlist(const config_type * config , const char * kw) { config_content_item_type * item = config_get_content_item(config , kw); @@ -1710,18 +950,25 @@ char * config_alloc_joined_string(const config_type * config , const char * kw, /** - Return the number of times a keyword has been set - dies on unknown 'kw'; + Return the number of times a keyword has been set - dies on unknown + 'kw'. If the append_arg attribute has been set to false the + function will return 0 or 1 irrespective of how many times the item + has been set in the config file. */ + int config_get_occurences(const config_type * config, const char * kw) { - return config_content_item_get_occurences(config_get_content_item(config , kw)); + if (config_has_content_item( config , kw )) + return config_content_item_get_size(config_get_content_item(config , kw)); + else + return 0; } int config_get_occurence_size( const config_type * config , const char * kw , int occurence) { config_content_item_type * item = config_get_content_item(config , kw); - config_item_node_type * node = config_content_item_iget_node( item , occurence ); - return stringlist_get_size( node->stringlist ); + config_content_node_type * node = config_content_item_iget_node( item , occurence ); + return config_content_node_get_size( node ); } @@ -1734,7 +981,7 @@ ENV LD_LIBARRY_PATH /some/other/path ENV MALLOC STRICT .... -the returned hash table will be: {"PATH": "/som/path", "LD_LIBARRY_PATH": "/some/other_path" , "MALLOC": "STRICT"} +the returned hash table will be: {"PATH": "/some/path", "LD_LIBARRY_PATH": "/some/other_path" , "MALLOC": "STRICT"} It is enforced that: @@ -1754,13 +1001,6 @@ hash_type * config_alloc_hash(const config_type * config , const char * kw) { -bool config_has_set_item(const config_type * config , const char * kw) { - if (config_has_schema_item(config , kw)) { - config_content_item_type * item = config_get_content_item(config , kw); - return config_content_item_is_set(item); - } else - return false; -} /** @@ -1784,21 +1024,8 @@ void config_install_message(config_type * config , const char * kw, const char * } -void config_fprintf_item_list(const config_type * config , FILE * stream) { - stringlist_type * items = hash_alloc_stringlist( config->schema_items ); - stringlist_sort( items , NULL ); - { - int i; - for (i=0; i < stringlist_get_size( items ); i++) - fprintf(stream , "%s \n",stringlist_iget( items , i)); - } - - stringlist_free( items ); -} - - -/*****************************************************************/ +#include "config_get.c" diff --git a/ThirdParty/Ert/devel/libconfig/src/config_content_item.c b/ThirdParty/Ert/devel/libconfig/src/config_content_item.c new file mode 100644 index 0000000000..4b07fcbe7b --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/src/config_content_item.c @@ -0,0 +1,291 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'config_content_item.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + + +#define CONFIG_CONTENT_ITEM_ID 8876752 +struct config_content_item_struct { + UTIL_TYPE_ID_DECLARATION; + const config_schema_item_type * schema; + vector_type * nodes; + const config_path_elm_type * path_elm; +}; + + + + + + + + +/*****************************************************************/ + +/** + This function counts the number of times a config item has been + set. Referring again to the example at the top: + + config_content_item_get_occurences( "KEY1" ) + + will return 2. +*/ + + + +int config_content_item_get_size(const config_content_item_type * item) { + return vector_get_size( item->nodes ); +} + + +config_content_node_type * config_content_item_get_last_node(const config_content_item_type * item) { + return vector_get_last( item->nodes ); +} + +config_content_node_type * config_content_item_iget_node(const config_content_item_type * item , int index) { + return vector_iget( item->nodes , index ); +} + +const config_content_node_type * config_content_item_get_last_node_const(const config_content_item_type * item) { + return vector_get_last( item->nodes ); +} + +const config_content_node_type * config_content_item_iget_node_const(const config_content_item_type * item , int index) { + return vector_iget( item->nodes , index ); +} + + +char * config_content_item_ialloc_joined_string(const config_content_item_type * item , const char * sep , int occurence) { + const config_content_node_type * node = config_content_item_iget_node(item , occurence); + return config_content_node_alloc_joined_string(node , sep); +} + + + +char * config_content_item_alloc_joined_string(const config_content_item_type * item , const char * sep) { + const int occurences = config_content_item_get_size( item ); + char * joined_string = NULL; + + for (int i =0; i < occurences ; i++) { + joined_string = util_strcat_realloc( joined_string , config_content_item_ialloc_joined_string(item , sep , i)); + if (i < (occurences - 1)) + joined_string = util_strcat_realloc( joined_string , sep ); + } + + return joined_string; +} + +const stringlist_type * config_content_item_iget_stringlist_ref(const config_content_item_type * item, int occurence) { + const config_content_node_type * node = config_content_item_iget_node(item , occurence); + return config_content_node_get_stringlist( node ); +} + + +const stringlist_type * config_content_item_get_stringlist_ref(const config_content_item_type * item) { + const config_content_node_type * node = config_content_item_get_last_node( item ); + return config_content_node_get_stringlist( node ); +} + + +/** + If copy == false - the stringlist will break down when/if the + config object is freed - your call. +*/ + +stringlist_type * config_content_item_alloc_complete_stringlist(const config_content_item_type * item, bool copy) { + int inode; + stringlist_type * stringlist = stringlist_alloc_new(); + for (inode = 0; inode < vector_get_size( item->nodes ); inode++) { + const config_content_node_type * node = config_content_item_iget_node(item , inode); + const stringlist_type * src_list = config_content_node_get_stringlist( node ); + + if (copy) + stringlist_append_stringlist_copy( stringlist , src_list ); + else + stringlist_append_stringlist_ref( stringlist , src_list ); + + } + + return stringlist; +} + + +/** + If copy == false - the stringlist will break down when/if the + config object is freed - your call. +*/ + +stringlist_type * config_content_item_alloc_stringlist(const config_content_item_type * item, bool copy) { + const config_content_node_type * node = config_content_item_get_last_node( item ); + stringlist_type * stringlist = stringlist_alloc_new(); + const stringlist_type * src_list = config_content_node_get_stringlist( node ); + + if (copy) + stringlist_append_stringlist_copy( stringlist , src_list ); + else + stringlist_append_stringlist_ref( stringlist , src_list ); + + return stringlist; +} + + +/** + If copy == false - the hash will break down when/if the + config object is freed - your call. +*/ + +hash_type * config_content_item_alloc_hash(const config_content_item_type * item , bool copy) { + hash_type * hash = hash_alloc(); + if (item != NULL) { + int inode; + for (inode = 0; inode < vector_get_size( item->nodes ); inode++) { + const config_content_node_type * node = config_content_item_iget_node(item , inode); + const stringlist_type * src_list = config_content_node_get_stringlist( node ); + const char * key = stringlist_iget(src_list , 0); + const char * value = stringlist_iget(src_list , 1); + + if (copy) { + hash_insert_hash_owned_ref(hash , + key , + util_alloc_string_copy(value) , + free); + } else + hash_insert_ref(hash , key , value ); + + } + } + return hash; +} + + +/******************************************************************/ + + + + +const char * config_content_item_iget(const config_content_item_type * item , int occurence , int index) { + const config_content_node_type * node = config_content_item_iget_node(item , occurence); + const stringlist_type * src_list = config_content_node_get_stringlist( node ); + return stringlist_iget( src_list , index ); +} + +bool config_content_item_iget_as_bool(const config_content_item_type * item, int occurence , int index) { + bool value; + config_schema_item_assure_type(item->schema , index , CONFIG_BOOL); + util_sscanf_bool( config_content_item_iget(item , occurence ,index) , &value ); + return value; +} + + + + +int config_content_item_iget_as_int(const config_content_item_type * item, int occurence , int index) { + int value; + config_schema_item_assure_type(item->schema , index , CONFIG_INT); + util_sscanf_int( config_content_item_iget(item , occurence , index) , &value ); + return value; +} + + +double config_content_item_iget_as_double(const config_content_item_type * item, int occurence , int index) { + double value; + config_schema_item_assure_type(item->schema , index , CONFIG_FLOAT); + util_sscanf_double( config_content_item_iget(item , occurence , index) , &value ); + return value; +} + + +/** + Used to reset an item is the special string 'CLEAR_STRING' + is found as the only argument: + + OPTION V1 + OPTION V2 V3 V4 + OPTION __RESET__ + OPTION V6 + + In this case OPTION will get the value 'V6'. The example given + above is a bit contrived; this option is designed for situations + where several config files are parsed serially; and the user can + not/will not update the first. +*/ + +void config_content_item_clear( config_content_item_type * item ) { + vector_clear( item->nodes ); +} + + + +void config_content_item_free( config_content_item_type * item ) { + vector_free( item->nodes ); + free(item); +} + + + +UTIL_SAFE_CAST_FUNCTION( config_content_item , CONFIG_CONTENT_ITEM_ID); + + + +void config_content_item_free__( void * arg ) { + config_content_item_type * content_item = config_content_item_safe_cast( arg ); + config_content_item_free( content_item ); +} + + +config_content_item_type * config_content_item_alloc( const config_schema_item_type * schema , const config_path_elm_type * path_elm) { + config_content_item_type * content_item = util_malloc( sizeof * content_item ); + UTIL_TYPE_ID_INIT( content_item , CONFIG_CONTENT_ITEM_ID ); + content_item->schema = schema; + content_item->nodes = vector_alloc_new(); + content_item->path_elm = path_elm; + return content_item; +} + + + + + +config_content_node_type * config_content_item_alloc_node( const config_content_item_type * item , const config_path_elm_type * path_elm) { + config_content_node_type * node = config_content_node_alloc( item->schema , path_elm ); + vector_append_owned_ref( item->nodes , node , config_content_node_free__); + return node; +} + + + +const config_schema_item_type * config_content_item_get_schema( const config_content_item_type * item ) { + return item->schema; +} + + + + +const config_path_elm_type * config_content_item_get_path_elm( const config_content_item_type * item ) { + return item->path_elm; +} diff --git a/ThirdParty/Ert/devel/libconfig/src/config_content_node.c b/ThirdParty/Ert/devel/libconfig/src/config_content_node.c new file mode 100644 index 0000000000..d7015802bc --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/src/config_content_node.c @@ -0,0 +1,229 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'config_content_node.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + +#include +#include +#include + +#include +#include +#include + + +#define CONFIG_CONTENT_NODE_ID 6752887 +struct config_content_node_struct { + UTIL_TYPE_ID_DECLARATION; + const config_schema_item_type * schema; + stringlist_type * stringlist; /* The values which have been set. */ + const config_path_elm_type * cwd; + stringlist_type * string_storage; +}; + + +static UTIL_SAFE_CAST_FUNCTION( config_content_node , CONFIG_CONTENT_NODE_ID ) + + + +config_content_node_type * config_content_node_alloc( const config_schema_item_type * schema , const config_path_elm_type * cwd) { + config_content_node_type * node = util_malloc(sizeof * node ); + UTIL_TYPE_ID_INIT( node , CONFIG_CONTENT_NODE_ID ); + node->stringlist = stringlist_alloc_new(); + node->cwd = cwd; + node->schema = schema; + node->string_storage = NULL; + return node; +} + + +void config_content_node_add_value(config_content_node_type * node , const char * value) { + stringlist_append_copy( node->stringlist , value); +} + + +void config_content_node_set(config_content_node_type * node , const stringlist_type * token_list) { + int argc = stringlist_get_size( token_list ) - 1; + for (int iarg=0; iarg < argc; iarg++) + config_content_node_add_value( node , stringlist_iget( token_list , iarg + 1)); +} + + + +char * config_content_node_alloc_joined_string(const config_content_node_type * node, const char * sep) { + return stringlist_alloc_joined_string(node->stringlist , sep); +} + + + +void config_content_node_free(config_content_node_type * node) { + stringlist_free(node->stringlist); + if (node->string_storage != NULL) + stringlist_free( node->string_storage ); + free(node); +} + + + +void config_content_node_free__(void * arg) { + config_content_node_type * node = config_content_node_safe_cast( arg ); + config_content_node_free( node ); +} + +static void config_content_node_push_string( config_content_node_type * node , char * string) { + if (node->string_storage == NULL) + node->string_storage = stringlist_alloc_new( ); + + stringlist_append_owned_ref( node->string_storage , string ); +} + +const char * config_content_node_get_full_string( config_content_node_type * node , const char * sep ) { + char * full_string = stringlist_alloc_joined_string(node->stringlist , sep); + config_content_node_push_string( node , full_string ); + return full_string; +} + +const char * config_content_node_iget(const config_content_node_type * node , int index) { + return stringlist_iget( node->stringlist , index ); +} + + +const char * config_content_node_safe_iget(const config_content_node_type * node , int index) { + if (index >= stringlist_get_size( node->stringlist )) + return NULL; + else + return stringlist_iget( node->stringlist , index ); +} + + +bool config_content_node_iget_as_bool(const config_content_node_type * node , int index) { + bool value; + config_schema_item_assure_type(node->schema , index , CONFIG_BOOL); + util_sscanf_bool( config_content_node_iget(node , index) , &value ); + return value; +} + + +int config_content_node_iget_as_int(const config_content_node_type * node , int index) { + int value; + config_schema_item_assure_type(node->schema , index , CONFIG_INT); + util_sscanf_int( config_content_node_iget(node , index) , &value ); + return value; +} + + + +double config_content_node_iget_as_double(const config_content_node_type * node , int index) { + double value; + config_schema_item_assure_type(node->schema , index , CONFIG_FLOAT + CONFIG_INT); + util_sscanf_double( config_content_node_iget(node , index) , &value ); + return value; +} + + + + +const char * config_content_node_iget_as_path(config_content_node_type * node , int index) { + config_schema_item_assure_type(node->schema , index , CONFIG_PATH + CONFIG_EXISTING_PATH); + { + const char * config_value = config_content_node_iget(node , index); + char * path_value = config_path_elm_alloc_path( node->cwd , config_value ); + config_content_node_push_string( node , path_value ); + + return path_value; + } +} + + +const char * config_content_node_iget_as_abspath( config_content_node_type * node , int index) { + config_schema_item_assure_type(node->schema , index , CONFIG_PATH + CONFIG_EXISTING_PATH); + { + const char * config_value = config_content_node_iget(node , index); + char * path_value = config_path_elm_alloc_abspath( node->cwd , config_value ); + config_content_node_push_string( node , path_value ); + + return path_value; + } +} + + +const char * config_content_node_iget_as_relpath( config_content_node_type * node , int index) { + config_schema_item_assure_type(node->schema , index , CONFIG_PATH + CONFIG_EXISTING_PATH); + { + const char * config_value = config_content_node_iget(node , index); + char * path_value = config_path_elm_alloc_relpath( node->cwd , config_value ); + config_content_node_push_string( node , path_value ); + + return path_value; + } +} + + +const stringlist_type * config_content_node_get_stringlist( const config_content_node_type * node ) { + return node->stringlist; +} + + +const char * config_content_node_get_kw( const config_content_node_type * node ) { + return config_schema_item_get_kw( node->schema ); +} + + + + +int config_content_node_get_size( const config_content_node_type * node ) { + return stringlist_get_size( node->stringlist ); +} + + +void config_content_node_assert_key_value( const config_content_node_type * node ) { + int argc_min , argc_max; + config_schema_item_get_argc( node->schema , &argc_min , &argc_max); + + if (!((argc_min == 1) && (argc_min == 1))) + util_abort("%s: item:%s before calling config_get_value() functions *without* index you must set argc_min == argc_max = 1 \n",__func__ , config_schema_item_get_kw( node->schema )); +} + + +const config_path_elm_type * config_content_node_get_path_elm( const config_content_node_type * node ) { + return node->cwd; +} + +/** + The node should contain elements of the type: + + KEY1:VALUE1 KEY2:Value2 XX Key3:Val3 Ignored + + Which will be inserted in the opt_hash dictionary as : {"KEY1" : + "VALUE1" , ... } Elements which do not conform to this syntax are + ignored. +*/ + + +void config_content_node_init_opt_hash( const config_content_node_type * node , hash_type * opt_hash , int elm_offset) { + int i; + for (i = elm_offset; i < config_content_node_get_size( node ); i++) + hash_add_option( opt_hash , config_content_node_iget( node , i )); +} + + +void config_content_node_fprintf( const config_content_node_type * node , FILE * stream ) { + fprintf(stream , "%s: {" , config_schema_item_get_kw( node->schema )); + stringlist_fprintf( node->stringlist , ", " , stream ); + fprintf(stream , "}\n"); +} diff --git a/ThirdParty/Ert/devel/libconfig/src/config_error.c b/ThirdParty/Ert/devel/libconfig/src/config_error.c new file mode 100644 index 0000000000..2bd344ff96 --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/src/config_error.c @@ -0,0 +1,86 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'config_error.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + +#include +#include + +#include + +struct config_error_struct { + stringlist_type * error_list; +}; + + + +config_error_type * config_error_alloc() { + config_error_type * error = util_malloc( sizeof * error ); + error->error_list = stringlist_alloc_new(); + return error; +} + + +config_error_type * config_error_alloc_copy( const config_error_type * src_error) { + config_error_type * config_error = config_error_alloc(); + stringlist_deep_copy( config_error->error_list , src_error->error_list ); + return config_error; +} + + +bool config_error_equal( const config_error_type * error1 , const config_error_type * error2) { + return stringlist_equal( error1->error_list , error2->error_list ); +} + +void config_error_free( config_error_type * error ) { + stringlist_free( error->error_list ); + free( error ); +} + + + +void config_error_add( config_error_type * error , char * new_error) { + stringlist_append_owned_ref( error->error_list , new_error ); +} + + + +void config_error_clear( config_error_type * error ) { + stringlist_clear( error->error_list ); +} + + +int config_error_count( const config_error_type * error ) { + return stringlist_get_size( error->error_list ); +} + + +const char * config_error_iget( const config_error_type * error , int index) { + return stringlist_iget( error->error_list , index ); +} + + +void config_error_fprintf( const config_error_type * error , bool add_count , FILE * stream ) { + int error_nr; + + for (error_nr = 0; error_nr < stringlist_get_size( error->error_list ); error_nr++) { + if (add_count) + fprintf(stream , " %02d: " , error_nr); + + fprintf( stream , "%s\n" , stringlist_iget( error->error_list , error_nr)); + } +} diff --git a/ThirdParty/Ert/devel/libconfig/src/config_get.c b/ThirdParty/Ert/devel/libconfig/src/config_get.c new file mode 100644 index 0000000000..6c18e882e1 --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/src/config_get.c @@ -0,0 +1,114 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'config_get.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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. +*/ + + +/*****************************************************************/ +/* All the functions in this block will operate on the last item + which has been set with a particular key value. So assuming the + config file looks like: + + KEY VALUE1 + KEY VALUE2 OPTIONAL + KEY 100 VALUE3 OPTIONAL ERROR + + these functions will all operate on the last line in the config file: + + KEY 100 VALUE3 OPTIONAL ERROR +*/ + + +config_content_node_type * config_get_value_node( const config_type * config , const char * kw) { + config_content_item_type * item = config_get_content_item(config , kw); + if (item != NULL) { + config_content_node_type * node = config_content_item_get_last_node( item ); + config_content_node_assert_key_value( node ); + return node; + } else + return NULL; // Will return NULL on unset keywords - must check NULL return value?! +} + +static config_content_node_type * config_get_value_node__( const config_type * config , const char * kw) { + config_content_node_type * node = config_get_value_node( config , kw ); + if (node == NULL) + util_abort("Tried to get value node from unset kw:%s \n",__func__ , kw ); + + return node; +} + +bool config_get_value_as_bool(const config_type * config , const char * kw) { + config_content_node_type * node = config_get_value_node__( config , kw ); + return config_content_node_iget_as_bool(node , 0); +} + +int config_get_value_as_int(const config_type * config , const char * kw) { + config_content_node_type * node = config_get_value_node__( config , kw ); + return config_content_node_iget_as_int(node , 0); +} + +double config_get_value_as_double(const config_type * config , const char * kw) { + config_content_node_type * node = config_get_value_node__( config , kw ); + return config_content_node_iget_as_double(node , 0); +} + +const char * config_get_value_as_path( const config_type * config , const char * kw) { + config_content_node_type * node = config_get_value_node__( config , kw ); + return config_content_node_iget_as_path(node , 0); +} + +const char * config_get_value_as_abspath( const config_type * config , const char * kw) { + config_content_node_type * node = config_get_value_node__( config , kw ); + return config_content_node_iget_as_abspath(node , 0); +} + +const char * config_get_value_as_relpath( const config_type * config , const char * kw) { + config_content_node_type * node = config_get_value_node__( config , kw ); + return config_content_node_iget_as_relpath(node , 0); +} + + +const char * config_get_value(const config_type * config , const char * kw) { + config_content_node_type * node = config_get_value_node__( config , kw ); + return config_content_node_iget(node , 0); +} + + +/*****************************************************************/ + +int config_get_content_size( const config_type * config ) { + return vector_get_size(config->content_list); +} + + +const config_content_node_type * config_iget_content_node( const config_type * config , int index) { + return vector_iget_const( config->content_list , index ); +} + + + + + +int config_get_schema_size( const config_type * config ) { + return hash_get_size( config->schema_items ); +} + + + + +config_error_type * config_get_errors( const config_type * config ) { + return config->parse_errors; +} diff --git a/ThirdParty/Ert/devel/libconfig/src/config_path_elm.c b/ThirdParty/Ert/devel/libconfig/src/config_path_elm.c new file mode 100644 index 0000000000..ec95f5a913 --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/src/config_path_elm.c @@ -0,0 +1,135 @@ +/* + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'config_path_elm.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include +#include + +#include +#include + +#include +#include + +#define CONFIG_PATH_ELM_TYPE_ID 7100063 + +struct config_path_elm_struct { + UTIL_TYPE_ID_DECLARATION; + char * abs_path; // This will always be absolute + char * rel_path; // This will always be relative to the root path. + const config_root_path_type * root_path; +}; + +static UTIL_SAFE_CAST_FUNCTION( config_path_elm , CONFIG_PATH_ELM_TYPE_ID ) + + +config_path_elm_type * config_path_elm_alloc( const config_root_path_type * root_path , const char * path) { + if (root_path != NULL) { + config_path_elm_type * path_elm = util_malloc( sizeof * path_elm ); + UTIL_TYPE_ID_INIT(path_elm , CONFIG_PATH_ELM_TYPE_ID); + path_elm->root_path = root_path; + if (path == NULL) { + path_elm->rel_path = NULL; + path_elm->abs_path = util_alloc_string_copy( config_root_path_get_abs_path(root_path) ); + } else { + if (util_is_abs_path( path )) { + path_elm->abs_path = util_alloc_string_copy( path ); + path_elm->rel_path = util_alloc_rel_path( config_root_path_get_abs_path(root_path) , path ); + } else { + path_elm->abs_path = util_alloc_filename( config_root_path_get_abs_path(root_path) , path , NULL ); + path_elm->rel_path = util_alloc_string_copy( path ); + } + } + return path_elm; + } else { + util_abort("%s: root_path input argument == NULL - invalid \n",__func__); + return NULL; + } +} + + + + +void config_path_elm_free( config_path_elm_type * path_elm ) { + util_safe_free( path_elm->rel_path ); + util_safe_free( path_elm->abs_path ); + free( path_elm ); +} + + + +void config_path_elm_free__( void * arg ) { + config_path_elm_type * path_elm = config_path_elm_safe_cast( arg ); + config_path_elm_free( path_elm ); +} + +const config_root_path_type * config_path_elm_get_rootpath( const config_path_elm_type * path_elm ) { + return path_elm->root_path; +} + +const char * config_path_elm_get_relpath( const config_path_elm_type * path_elm ) { + return path_elm->rel_path; +} + +const char * config_path_elm_get_abspath( const config_path_elm_type * path_elm ) { + return path_elm->abs_path; +} + + +/*****************************************************************/ + + +char * config_path_elm_alloc_path(const config_path_elm_type * path_elm , const char * path) { + if (util_is_abs_path( path )) + return util_alloc_string_copy( path ); + else { + /* This will be relative or absolute depending on the relative/absolute + status of the root_path. */ + const char * input_root = config_root_path_get_input_path( path_elm->root_path ); + if (input_root == NULL) + return util_alloc_filename( path_elm->rel_path , path , NULL); + else + return util_alloc_joined_string( (const char *[3]) { input_root , path_elm->rel_path , path } , 3 , UTIL_PATH_SEP_STRING ); + } +} + + +char * config_path_elm_alloc_relpath(const config_path_elm_type * path_elm , const char * input_path) { + if (util_is_abs_path( input_path )) + return util_alloc_rel_path( config_root_path_get_rel_path( path_elm->root_path ) , input_path); + else { + char * abs_path = config_path_elm_alloc_abspath( path_elm , input_path ); + char * rel_path = util_alloc_rel_path( config_root_path_get_abs_path( path_elm->root_path ) , abs_path ); + free( abs_path ); + return rel_path; + } +} + + +char * config_path_elm_alloc_abspath(const config_path_elm_type * path_elm , const char * input_path) { + if (util_is_abs_path( input_path )) + return util_alloc_string_copy( input_path ); + else { + char * abs_path1 = util_alloc_filename( path_elm->abs_path , input_path , NULL ); + char * abs_path = util_alloc_realpath__( abs_path1 ); // The util_alloc_realpath__() will work also for nonexsting paths + free( abs_path1 ); + return abs_path; + } +} diff --git a/ThirdParty/Ert/devel/libconfig/src/config_root_path.c b/ThirdParty/Ert/devel/libconfig/src/config_root_path.c new file mode 100644 index 0000000000..9a82d3adce --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/src/config_root_path.c @@ -0,0 +1,97 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'config_root_path.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include +#include + +#include + +#include + +struct config_root_path_struct { + char * input_path; + char * abs_path; + char * rel_path; +}; + + +/** + Input must be an existing directory, which will be used as the + root; or NULL in which case cwd will be used as root. The input + directory can be both realtive or absolute. +*/ + +config_root_path_type * config_root_path_alloc( const char * input_path ) { + if (input_path == NULL || util_is_directory( input_path )) { + config_root_path_type * root_path = util_malloc( sizeof * root_path ); + { + char * cwd = util_alloc_cwd(); + + root_path->input_path = util_alloc_string_copy( input_path ); + if (input_path == NULL) { + root_path->rel_path = NULL; + root_path->abs_path = util_alloc_string_copy( cwd ); + } else { + if (util_is_abs_path( input_path )) { + root_path->abs_path = util_alloc_string_copy( input_path ); + root_path->rel_path = util_alloc_rel_path( cwd , root_path->abs_path); + } else { + root_path->rel_path = util_alloc_string_copy( input_path ); + { + char * abs_path = util_alloc_filename( cwd , input_path , NULL ); + root_path->abs_path = util_alloc_realpath( abs_path ); + free( abs_path ); + } + } + } + free( cwd ); + } + return root_path; + } else + return NULL; +} + + +void config_root_path_free( config_root_path_type * root_path ) { + util_safe_free( root_path->rel_path ); + util_safe_free( root_path->abs_path ); + util_safe_free( root_path->input_path ); + free( root_path ); +} + +const char * config_root_path_get_input_path( const config_root_path_type * root_path ) { + return root_path->input_path; +} + + +const char * config_root_path_get_rel_path( const config_root_path_type * root_path ) { + return root_path->rel_path; +} + + +const char * config_root_path_get_abs_path( const config_root_path_type * root_path ) { + return root_path->abs_path; +} + + + + + diff --git a/ThirdParty/Ert/devel/libconfig/src/config_schema_item.c b/ThirdParty/Ert/devel/libconfig/src/config_schema_item.c new file mode 100644 index 0000000000..4945a362ad --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/src/config_schema_item.c @@ -0,0 +1,536 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'config_schema_item.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +typedef struct validate_struct validate_type; + +/** + This is a 'support-struct' holding various pieces of information + needed during the validation process. Observe the following about + validation: + + 1. It is atomic, in the sense that if you try to an item like this: + + KW ARG1 ARG2 ARG3 + + where ARG1 and ARG2 are valid, whereas there is something wrong + with ARG3, NOTHING IS SET. + + 2. Validation is a two-step process, the first step is run when an + item is parsed. This includes checking: + + o The number of argument. + o That the arguments have the right type. + o That the values match the selection set. + + The second validation step is done when the pasing is complete, + in this pass we check dependencies - i.e. required_children and + required_children_on_value. + + + Observe that nothing has-to be set in this struct. There are some dependencies: + + 1. Only _one_ of common_selection_set and indexed_selection_set + can be set. + + 2. If setting indexed_selection_set or type_map, you MUST set + argc_max first. +*/ + + +struct validate_struct { + int argc_min; /* The minimum number of arguments: -1 means no lower limit. */ + int argc_max; /* The maximum number of arguments: -1 means no upper limit. */ + set_type * common_selection_set; /* A selection set which will apply uniformly to all the arguments. */ + set_type ** indexed_selection_set; /* A selection set which will apply for specifi (indexed) arguments. */ + int_vector_type * type_map; /* A list of types for the items. Set along with argc_minmax(); */ + stringlist_type * required_children; /* A list of item's which must also be set (if this item is set). (can be NULL) */ + hash_type * required_children_value; /* A list of item's which must also be set - depending on the value of this item. (can be NULL) (This one is complex). */ +}; + + + + + +#define CONFIG_SCHEMA_ITEM_ID 6751 +struct config_schema_item_struct { + UTIL_TYPE_ID_DECLARATION; + char * kw; /* The kw which identifies this item· */ + + + bool required_set; + stringlist_type * required_children; /* A list of item's which must also be set (if this item is set). (can be NULL) */ + hash_type * required_children_value; /* A list of item's which must also be set - depending on the value of this item. (can be NULL) */ + validate_type * validate; /* Information need during validation. */ + bool expand_envvar; /* Should environment variables like $HOME be expanded?*/ +}; + + +/*****************************************************************/ + + +/*****************************************************************/ +static void validate_set_default_type( validate_type * validate , config_item_types item_type) { + int_vector_set_default(validate->type_map , item_type); +} + +static validate_type * validate_alloc() { + validate_type * validate = util_malloc(sizeof * validate ); + validate->argc_min = CONFIG_DEFAULT_ARG_MIN; + validate->argc_max = CONFIG_DEFAULT_ARG_MAX; + validate->common_selection_set = NULL; + validate->indexed_selection_set = NULL; + validate->required_children = NULL; + validate->required_children_value = NULL; + validate->type_map = int_vector_alloc(0 , 0); + validate_set_default_type( validate , CONFIG_STRING ); + return validate; +} + + +static void validate_free(validate_type * validate) { + if (validate->common_selection_set != NULL) set_free(validate->common_selection_set); + if (validate->indexed_selection_set != NULL) { + for (int i = 0; i < validate->argc_max; i++) + if (validate->indexed_selection_set[i] != NULL) + set_free(validate->indexed_selection_set[i]); + free(validate->indexed_selection_set); + } + + int_vector_free( validate->type_map ); + if (validate->required_children != NULL) stringlist_free(validate->required_children); + if (validate->required_children_value != NULL) hash_free(validate->required_children_value); + free(validate); +} + + +static void validate_iset_type( validate_type * validate , int index , config_item_types type) { + int_vector_iset( validate->type_map , index , type); +} + + +static config_item_types validate_iget_type( const validate_type * validate , int index) { + return int_vector_safe_iget( validate->type_map , index ); +} + + +static void validate_set_argc_minmax(validate_type * validate , int argc_min , int argc_max) { + if (validate->argc_min != CONFIG_DEFAULT_ARG_MIN) + util_abort("%s: sorry - current implementation does not allow repeated calls to: %s \n",__func__ , __func__); + + if (argc_min == CONFIG_DEFAULT_ARG_MIN) + argc_min = 0; + + validate->argc_min = argc_min; + validate->argc_max = argc_max; + + if ((argc_max != CONFIG_DEFAULT_ARG_MAX) && (argc_max < argc_min)) + util_abort("%s invalid arg min/max values. argc_min:%d argc_max:%d \n",__func__ , argc_min , argc_max); + + { + int internal_type_size = 0; /* Should end up in the range [argc_min,argc_max] */ + + if (argc_max > 0) + internal_type_size = argc_max; + else + internal_type_size = argc_min; + + if (internal_type_size > 0) { + validate->indexed_selection_set = util_calloc( internal_type_size , sizeof * validate->indexed_selection_set ); + for (int iarg=0; iarg < internal_type_size; iarg++) + validate->indexed_selection_set[iarg] = NULL; + } + } +} + + + +static void validate_set_common_selection_set(validate_type * validate , int argc , const char ** argv) { + if (validate->common_selection_set != NULL) + set_free(validate->common_selection_set); + validate->common_selection_set = set_alloc( argc , argv ); +} + + +static void validate_set_indexed_selection_set(validate_type * validate , int index , int argc , const char ** argv) { + + if (validate->indexed_selection_set == NULL) + util_abort("%s: must call xxx_set_argc_minmax() first - aborting \n",__func__); + + if (index >= validate->argc_min) + util_abort("%s: When not not setting argc_max selection set can only be applied to indices up to argc_min\n",__func__); + + if (validate->indexed_selection_set[index] != NULL) + set_free(validate->indexed_selection_set[index]); + + validate->indexed_selection_set[index] = set_alloc(argc , argv); +} + + +/*****************************************************************/ + + +static UTIL_SAFE_CAST_FUNCTION( config_schema_item , CONFIG_SCHEMA_ITEM_ID) + +void config_schema_item_assure_type(const config_schema_item_type * item , int index , int type_mask) { + bool OK = false; + + if (int_vector_safe_iget( item->validate->type_map , index) & type_mask) + OK = true; + + if (!OK) + util_abort("%s: failed - wrong installed type \n" , __func__); +} + + +config_schema_item_type * config_schema_item_alloc(const char * kw , bool required) { + config_schema_item_type * item = util_malloc(sizeof * item ); + UTIL_TYPE_ID_INIT( item , CONFIG_SCHEMA_ITEM_ID); + item->kw = util_alloc_string_copy(kw); + + item->required_set = required; + item->required_children = NULL; + item->required_children_value = NULL; + item->expand_envvar = true; /* Default is to expand $VAR expressions; can be turned off with + config_schema_item_set_envvar_expansion( item , false ); */ + item->validate = validate_alloc(); + return item; +} + + + +static char * __alloc_relocated__(const config_path_elm_type * path_elm , const char * value) { + char * file; + + if (util_is_abs_path(value)) + file = util_alloc_string_copy( value ); + else + file = util_alloc_filename(config_path_elm_get_relpath( path_elm ) , value , NULL); + + return file; +} + + +bool config_schema_item_validate_set(const config_schema_item_type * item , stringlist_type * token_list , const char * config_file, const config_path_elm_type * path_elm , config_error_type * error_list) { + bool OK = true; + int argc = stringlist_get_size( token_list ) - 1; + if (item->validate->argc_min >= 0) { + if (argc < item->validate->argc_min) { + OK = false; + { + char * error_message; + if (config_file != NULL) + error_message = util_alloc_sprintf("Error when parsing config_file:\"%s\" Keyword:%s must have at least %d arguments.",config_file , item->kw , item->validate->argc_min); + else + error_message = util_alloc_sprintf("Error:: Keyword:%s must have at least %d arguments.",item->kw , item->validate->argc_min); + + config_error_add( error_list , error_message ); + } + } + } + + if (item->validate->argc_max >= 0) { + if (argc > item->validate->argc_max) { + OK = false; + { + char * error_message; + + if (config_file != NULL) + error_message = util_alloc_sprintf("Error when parsing config_file:\"%s\" Keyword:%s must have maximum %d arguments.",config_file , item->kw , item->validate->argc_max); + else + error_message = util_alloc_sprintf("Error:: Keyword:%s must have maximum %d arguments.",item->kw , item->validate->argc_max); + config_error_add( error_list , error_message ); + } + } + } + + /* + OK - now we have verified that the number of arguments is correct. Then + we start actually looking at the values. + */ + if (OK) { + /* Validating selection set - first common, then indexed */ + if (item->validate->common_selection_set) { + for (int iarg = 0; iarg < argc; iarg++) { + if (!set_has_key(item->validate->common_selection_set , stringlist_iget( token_list , iarg + 1))) { + config_error_add( error_list , util_alloc_sprintf("%s: is not a valid value for: %s.",stringlist_iget( token_list , iarg + 1) , item->kw)); + OK = false; + } + } + } else if (item->validate->indexed_selection_set != NULL) { + for (int iarg = 0; iarg < argc; iarg++) { + if ((item->validate->argc_max > 0) || (iarg < item->validate->argc_min)) { /* Without this test we might go out of range on the indexed selection set. */ + if (item->validate->indexed_selection_set[iarg] != NULL) { + if (!set_has_key(item->validate->indexed_selection_set[iarg] , stringlist_iget( token_list , iarg + 1))) { + config_error_add( error_list , util_alloc_sprintf("%s: is not a valid value for item %d of \'%s\'.",stringlist_iget( token_list , iarg + 1) , iarg + 1 , item->kw)); + OK = false; + } + } + } + } + } + + /* + Observe that the following code might rewrite the content of + argv for arguments referring to path locations. + */ + + + /* Validate the TYPE of the various argumnents */ + { + for (int iarg = 0; iarg < argc; iarg++) { + const char * value = stringlist_iget(token_list , iarg + 1); + switch (validate_iget_type( item->validate , iarg)) { + case(CONFIG_STRING): /* This never fails ... */ + break; + case(CONFIG_INT): + if (!util_sscanf_int( value , NULL )) + config_error_add( error_list , util_alloc_sprintf("Failed to parse:%s as an integer.",value)); + break; + case(CONFIG_FLOAT): + if (!util_sscanf_double( value , NULL )) { + config_error_add( error_list , util_alloc_sprintf("Failed to parse:%s as a floating point number.", value)); + OK = false; + } + break; + case(CONFIG_PATH): + // As long as we do not reuqire the path to exist it is just a string. + break; + case(CONFIG_EXISTING_PATH): + { + char * path = config_path_elm_alloc_abspath( path_elm , value ); + if (!util_entry_exists(path)) { + config_error_add( error_list , util_alloc_sprintf("Can not find entry %s in %s ",value , config_path_elm_get_relpath( path_elm) )); + OK = false; + } + free( path ); + } + break; + case(CONFIG_EXECUTABLE): + { + /* + 1. If the supplied value is an abolute path - do nothing. + 2. If the supplied is _not_ an absolute path: + + a. Try if the relocated exists - then use that. + b. Else - try if the util_alloc_PATH_executable() exists. + */ + if (!util_is_abs_path( value )) { + char * relocated = __alloc_relocated__(path_elm , value); + char * path_exe = util_alloc_PATH_executable( value ); + + if (util_file_exists(relocated)) { + if (util_is_executable(relocated)) + stringlist_iset_copy( token_list , iarg , relocated); + } else if (path_exe != NULL) + stringlist_iset_copy( token_list , iarg , path_exe); + else + config_error_add( error_list , util_alloc_sprintf("Could not locate executable:%s ", value)); + + free(relocated); + util_safe_free(path_exe); + } else { + if (!util_is_executable( value )) + config_error_add( error_list , util_alloc_sprintf("Could not locate executable:%s ", value)); + } + } + break; + case(CONFIG_BOOL): + if (!util_sscanf_bool( value , NULL )) { + config_error_add( error_list , util_alloc_sprintf("Failed to parse:%s as a boolean.", value)); + OK = false; + } + break; + case(CONFIG_BYTESIZE): + if (!util_sscanf_bytesize( value , NULL)) { + config_error_add( error_list , util_alloc_sprintf("Failed to parse:\"%s\" as number of bytes." , value)); + OK = false; + } + break; + default: + util_abort("%s: config_item_type:%d not recognized \n",__func__ , validate_iget_type(item->validate , iarg)); + } + } + } + } + return OK; +} + + +void config_schema_item_free( config_schema_item_type * item) { + free(item->kw); + if (item->required_children != NULL) stringlist_free(item->required_children); + if (item->required_children_value != NULL) hash_free(item->required_children_value); + validate_free(item->validate); + free(item); +} + + +void config_schema_item_free__ (void * void_item) { + config_schema_item_type * item = config_schema_item_safe_cast( void_item ); + config_schema_item_free( item ); +} + + + +void config_schema_item_set_required_children_on_value(config_schema_item_type * item , const char * value , stringlist_type * child_list) { + if (item->required_children_value == NULL) + item->required_children_value = hash_alloc(); + hash_insert_hash_owned_ref( item->required_children_value , value , stringlist_alloc_deep_copy(child_list) , stringlist_free__); +} + + + +/** + This function is used to set the minimum and maximum number of + arguments for an item. In addition you can pass in a pointer to an + array of config_schema_item_types values which will be used for validation + of the input. This vector must be argc_max elements long; it can be + NULL. +*/ + + +void config_schema_item_set_argc_minmax(config_schema_item_type * item , + int argc_min , + int argc_max) { + + validate_set_argc_minmax(item->validate , argc_min , argc_max); + +} + +void config_schema_item_iset_type( config_schema_item_type * item , int index , config_item_types type) { + validate_iset_type( item->validate , index , type ); +} + +void config_schema_item_set_default_type( config_schema_item_type * item , config_item_types type) { + validate_set_default_type( item->validate , type ); +} + + +config_item_types config_schema_item_iget_type(const config_schema_item_type * item , int index ) { + return validate_iget_type( item->validate , index ); +} + + + + +void config_schema_item_set_envvar_expansion( config_schema_item_type * item , bool expand_envvar ) { + item->expand_envvar = expand_envvar; +} + + + +void config_schema_item_set_common_selection_set(config_schema_item_type * item , int argc , const char ** argv) { + validate_set_common_selection_set(item->validate , argc , argv); +} + +void config_schema_item_set_indexed_selection_set(config_schema_item_type * item , int index , int argc , const char ** argv) { + validate_set_indexed_selection_set(item->validate , index , argc , argv); +} + + +void config_schema_item_set_required_children(config_schema_item_type * item , stringlist_type * stringlist) { + item->required_children = stringlist_alloc_deep_copy(stringlist); +} + +void config_schema_item_add_required_children(config_schema_item_type * item , const char * child_key) { + if (item->required_children == NULL) + item->required_children = stringlist_alloc_new(); + + stringlist_append_copy( item->required_children , child_key ); +} + + +int config_schema_item_num_required_children(const config_schema_item_type * item) { + if (item->required_children == NULL) + return 0; + else + return stringlist_get_size( item->required_children ); +} + + +const char * config_schema_item_iget_required_child( const config_schema_item_type * item , int index) { + return stringlist_iget( item->required_children , index ); +} + + +const char * config_schema_item_get_kw( const config_schema_item_type * item ) { + return item->kw; +} + + +bool config_schema_item_required( const config_schema_item_type * item ) { + return item->required_set; +} + + +bool config_schema_item_expand_envvar( const config_schema_item_type * item ) { + return item->expand_envvar; +} + + +void config_schema_item_get_argc( const config_schema_item_type * item , int *argc_min , int *argc_max) { + *argc_min = item->validate->argc_min; + *argc_max = item->validate->argc_max; +} + + + +bool config_schema_item_has_required_children_value( const config_schema_item_type * item ) { + if (item->required_children_value == NULL) + return false; + else + return true; +} + + + +stringlist_type * config_schema_item_get_required_children_value(const config_schema_item_type * item , const char * value) { + return hash_safe_get( item->required_children_value , value ); +} + + +/*****************************************************************/ +/* Small functions to support enum introspection. */ + + +const char * config_schema_item_type_enum_iget( int index, int * value) { + return util_enum_iget( index , CONFIG_ITEM_TYPE_ENUM_SIZE , (const util_enum_element_type []) { CONFIG_ITEM_TYPE_ENUM_DEFS }, value); +} + + +const char * config_schema_item_unrecognized_enum_iget( int index, int * value) { + return util_enum_iget( index , CONFIG_SCHEMA_UNRECOGNIZED_ENUM_SIZE , (const util_enum_element_type []) { CONFIG_SCHEMA_UNRECOGNIZED_ENUM_DEFS }, value); +} diff --git a/ThirdParty/Ert/devel/libconfig/tests/CMakeLists.txt b/ThirdParty/Ert/devel/libconfig/tests/CMakeLists.txt new file mode 100644 index 0000000000..dde9e5e977 --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/tests/CMakeLists.txt @@ -0,0 +1,49 @@ +add_executable( config_append_test config_append_test.c ) +target_link_libraries( config_append_test config ) + +add_executable( config_node_test config_node_test.c ) +target_link_libraries( config_node_test config ) + +add_executable( config_typeOK config_typeOK.c ) +target_link_libraries( config_typeOK config ) + +add_executable( config_typeFail config_typeFail.c ) +target_link_libraries( config_typeFail config ) + +add_executable( config_path_elm config_path_elm.c ) +target_link_libraries( config_path_elm config ) + +add_executable( config_root_path config_root_path.c ) +target_link_libraries( config_root_path config ) + +add_executable( config_include_test config_include_test.c) +target_link_libraries( config_include_test config) + +add_executable( config_content_node config_content_node.c) +target_link_libraries( config_content_node config) + +add_executable( config_content_item config_content_item.c) +target_link_libraries( config_content_item config) + +add_executable( config_error config_error.c) +target_link_libraries( config_error config) +add_test( config_error ${EXECUTABLE_OUTPUT_PATH}/config_error ) + + +add_executable( config_config config_config.c) +target_link_libraries( config_config config) +add_test( config_config ${EXECUTABLE_OUTPUT_PATH}/config_config ) + +add_executable( config_schema_item config_schema_item.c) +target_link_libraries( config_schema_item config) +add_test( config_schema_item ${EXECUTABLE_OUTPUT_PATH}/config_schema_item ) + +add_test( config_typeOK ${EXECUTABLE_OUTPUT_PATH}/config_typeOK ${CMAKE_CURRENT_SOURCE_DIR}/data/type_testOK ) +add_test( config_typeFail ${EXECUTABLE_OUTPUT_PATH}/config_typeFail ${CMAKE_CURRENT_SOURCE_DIR}/data/type_testFail ) +add_test( config_append_test ${EXECUTABLE_OUTPUT_PATH}/config_append_test ${CMAKE_CURRENT_SOURCE_DIR}/data/append_test ) +add_test( config_node_test ${EXECUTABLE_OUTPUT_PATH}/config_node_test ${CMAKE_CURRENT_SOURCE_DIR}/data/append_test ) +add_test( config_path_elm ${EXECUTABLE_OUTPUT_PATH}/config_path_elm ) +add_test( config_content_node ${EXECUTABLE_OUTPUT_PATH}/config_content_node ) +add_test( config_content_item ${EXECUTABLE_OUTPUT_PATH}/config_content_item ${CMAKE_CURRENT_SOURCE_DIR}/data/content_item_test) +add_test( config_include_test ${EXECUTABLE_OUTPUT_PATH}/config_include_test ${CMAKE_CURRENT_SOURCE_DIR}/data include_test ) +add_test( config_root_path ${EXECUTABLE_OUTPUT_PATH}/config_root_path ${CMAKE_CURRENT_SOURCE_DIR}/data ) diff --git a/ThirdParty/Ert/devel/libconfig/tests/config_append_test.c b/ThirdParty/Ert/devel/libconfig/tests/config_append_test.c new file mode 100644 index 0000000000..1433f3c5f9 --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/tests/config_append_test.c @@ -0,0 +1,47 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'config_append_test.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include + +#include + +#include + + + + +int main(int argc , char ** argv) { + const char * config_file = argv[1]; + config_type * config = config_alloc(); + bool OK; + config_schema_item_type * item = config_add_schema_item(config , "APPEND" , false ); + config_schema_item_set_argc_minmax( item , 1 , 1); + + test_assert_true(config_parse(config , config_file , "--" , NULL , NULL , false , true )); + + { + test_assert_int_equal( config_get_occurences( config , "APPEND" ) , 3); + { + const char * value = config_get_value( config , "APPEND"); + test_assert_string_equal( value , "VALUE3"); + } + } + + test_assert_false( config_parse( config , "DoesNotExist" , "--" , NULL , NULL , false , true)); + exit(0); +} diff --git a/ThirdParty/Ert/devel/libconfig/tests/config_config.c b/ThirdParty/Ert/devel/libconfig/tests/config_config.c new file mode 100644 index 0000000000..f9d627c479 --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/tests/config_config.c @@ -0,0 +1,36 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'config_config.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include +#include + +#include +#include + +#include +#include + + +int main(int argc , char ** argv) { + config_type * config = config_alloc(); + config_schema_item_type * schema_item = config_add_schema_item( config , "KEYWORD" , false ); + config_free( config ); + exit(0); +} + diff --git a/ThirdParty/Ert/devel/libconfig/tests/config_content_item.c b/ThirdParty/Ert/devel/libconfig/tests/config_content_item.c new file mode 100644 index 0000000000..ee0be46be8 --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/tests/config_content_item.c @@ -0,0 +1,58 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'config_content_item.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include + +#include +#include +#include + +#include +#include +#include +#include + + +int main(int argc , char ** argv) { + const char * config_file = argv[1]; + config_type * config = config_alloc(); + + config_add_schema_item( config , "SET" , true ); + config_add_schema_item( config , "NOTSET" , false ); + + test_assert_true( config_parse( config , config_file , "--" , "INCLUDE" , NULL , CONFIG_UNRECOGNIZED_IGNORE , true )); + + test_assert_not_NULL( config_get_content_item( config , "SET" )); + test_assert_NULL( config_get_content_item( config , "NOTSET" ) ); + test_assert_NULL( config_get_content_item( config , "UNKNOWN" ) ); + + test_assert_true( config_has_schema_item( config , "SET" )); + test_assert_true( config_has_schema_item( config , "NOTSET" )); + test_assert_false( config_has_schema_item( config , "UNKNOWN" )); + + test_assert_true( config_has_content_item( config , "SET" )); + test_assert_false( config_has_content_item( config , "NOTSET" )); + test_assert_false( config_has_content_item( config , "UNKNOWN" )); + + + + + exit(0); +} + diff --git a/ThirdParty/Ert/devel/libconfig/tests/config_content_node.c b/ThirdParty/Ert/devel/libconfig/tests/config_content_node.c new file mode 100644 index 0000000000..f7289f60de --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/tests/config_content_node.c @@ -0,0 +1,76 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'config_content_node.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include + +#include +#include +#include + +#include +#include +#include + + +int main(int argc , char ** argv) { + config_schema_item_type * schema = config_schema_item_alloc("TEST" , true); + config_root_path_type * root_path = config_root_path_alloc( NULL ); + config_path_elm_type * cwd = config_path_elm_alloc( root_path , NULL ); + { + config_content_node_type * node = config_content_node_alloc( schema , cwd ); + config_content_node_add_value( node , "KEY1:VALUE1" ); + config_content_node_add_value( node , "KEY2:VALUE2" ); + config_content_node_add_value( node , "KEY3:VALUE3" ); + config_content_node_add_value( node , "KEYVALUE" ); + + test_assert_int_equal( config_content_node_get_size( node ) , 4 ); + test_assert_string_equal( config_content_node_iget( node , 0 ) , "KEY1:VALUE1" ); + test_assert_string_equal( config_content_node_iget( node , 2 ) , "KEY3:VALUE3" ); + + test_assert_string_equal( config_content_node_get_full_string( node , ",") , "KEY1:VALUE1,KEY2:VALUE2,KEY3:VALUE3,KEYVALUE"); + + { + hash_type * opt_hash = hash_alloc( ); + { + config_content_node_init_opt_hash( node , opt_hash , 0 ); + test_assert_int_equal( hash_get_size( opt_hash ) , 3 ); + test_assert_string_equal( hash_get( opt_hash , "KEY1" ) , "VALUE1" ); + test_assert_string_equal( hash_get( opt_hash , "KEY3" ) , "VALUE3" ); + } + + hash_clear( opt_hash ); + test_assert_int_equal( hash_get_size( opt_hash ) , 0 ); + config_content_node_init_opt_hash( node , opt_hash , 1 ); + test_assert_int_equal( hash_get_size( opt_hash ) , 2 ); + test_assert_string_equal( hash_get( opt_hash , "KEY2" ) , "VALUE2" ); + test_assert_string_equal( hash_get( opt_hash , "KEY3" ) , "VALUE3" ); + test_assert_false( hash_has_key( opt_hash , "KEY1" ) ); + test_assert_false( hash_has_key( opt_hash , "KEYVALUE" ) ); + hash_free( opt_hash ); + } + + + config_content_node_free( node ); + } + config_path_elm_free( cwd ); + config_root_path_free( root_path ); + config_schema_item_free( schema ); + exit(0); +} + diff --git a/ThirdParty/Ert/devel/libconfig/tests/config_error.c b/ThirdParty/Ert/devel/libconfig/tests/config_error.c new file mode 100644 index 0000000000..5312d937d9 --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/tests/config_error.c @@ -0,0 +1,43 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'config_error.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include +#include + +#include +#include + +#include + +int main(int argc , char ** argv) { + config_error_type * config_error = config_error_alloc(); + + { + config_error_type * error_copy = config_error_alloc_copy( config_error ); + + test_assert_true( config_error_equal( config_error , error_copy )); + test_assert_ptr_not_equal( config_error , error_copy ); + + config_error_free( error_copy ); + } + + config_error_free( config_error ); + exit(0); +} + diff --git a/ThirdParty/Ert/devel/libconfig/tests/config_include_test.c b/ThirdParty/Ert/devel/libconfig/tests/config_include_test.c new file mode 100644 index 0000000000..d1afa66261 --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/tests/config_include_test.c @@ -0,0 +1,133 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'config_include_test.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include +#include + +#include +#include +#include + +#include +#include + +void parse_test(config_type * config , + const char * root_path , // The new working directory - the test will start by chdir() here. + const char * config_file ) { // The config_file, either as an absolute path - or relative from root_path + +#ifdef ERT_LINUX + const char * path0 = "PATH0"; + const char * path1 = "path/PATH1"; + const char * path2 = "path/PATH2"; + const char * path3 = "path/subpath/PATH3"; + const char * path4 = "path/subpath/subsubpath/PATH4"; +#endif + + + char * config_path, *config_rel_path,*config_abs_path; + path_stack_type * path_stack = path_stack_alloc(); + + util_alloc_file_components( config_file , &config_path , NULL , NULL); + path_stack_push( path_stack , NULL ); + if (root_path != NULL) + chdir( root_path ); + + config_abs_path = util_alloc_abs_path( config_path ); + config_rel_path = util_alloc_rel_path( NULL , config_abs_path); + + { + config_clear( config ); + if (config_parse( config , config_file , "--" , "INCLUDE" , NULL , CONFIG_UNRECOGNIZED_IGNORE , true )) { + + char * relpath0 = util_alloc_filename( config_rel_path , path0, NULL); + char * relpath1 = util_alloc_filename( config_rel_path , path1, NULL); + char * relpath2 = util_alloc_filename( config_rel_path , path2, NULL); + char * relpath3 = util_alloc_filename( config_rel_path , path3, NULL); + char * relpath4 = util_alloc_filename( config_rel_path , path4, NULL); + + char * abspath0 = util_alloc_filename( config_abs_path , path0, NULL); + char * abspath1 = util_alloc_filename( config_abs_path , path1, NULL); + char * abspath2 = util_alloc_filename( config_abs_path , path2, NULL); + char * abspath3 = util_alloc_filename( config_abs_path , path3, NULL); + char * abspath4 = util_alloc_filename( config_abs_path , path4, NULL); + + test_assert_string_equal(config_get_value_as_relpath(config , "PATH0") , relpath0 ); + test_assert_string_equal(config_get_value_as_relpath(config , "PATH1") , relpath1 ); + test_assert_string_equal(config_get_value_as_relpath(config , "PATH2") , relpath2 ); + test_assert_string_equal(config_get_value_as_relpath(config , "PATH3") , relpath3 ); + test_assert_string_equal(config_get_value_as_relpath(config , "PATH4") , relpath4 ); + + test_assert_string_equal(config_get_value_as_abspath(config , "PATH0") , abspath0 ); + test_assert_string_equal(config_get_value_as_abspath(config , "PATH1") , abspath1 ); + test_assert_string_equal(config_get_value_as_abspath(config , "PATH2") , abspath2 ); + test_assert_string_equal(config_get_value_as_abspath(config , "PATH3") , abspath3 ); + test_assert_string_equal(config_get_value_as_abspath(config , "PATH4") , abspath4 ); + + } else { + config_error_type * error = config_get_errors( config ); + config_error_fprintf( error , true , stdout ); + test_error_exit("Hmm - parsing %s failed \n", config_file ); + } + } + path_stack_pop( path_stack ); +} + + +int main(int argc , char ** argv) { + const char * abs_path = argv[1]; + const char * config_file = argv[2]; + char * abs_config_file = util_alloc_filename( abs_path , config_file , NULL); + config_type * config = config_alloc(); + + { + config_schema_item_type * schema_item; + + schema_item = config_add_schema_item( config , "PATH0" , true ); + config_schema_item_set_argc_minmax( schema_item , 1 , 1 ); + config_schema_item_iset_type( schema_item , 0 , CONFIG_PATH ); + + schema_item = config_add_schema_item( config , "PATH1" , true ); + config_schema_item_set_argc_minmax( schema_item , 1 , 1 ); + config_schema_item_iset_type( schema_item , 0 , CONFIG_PATH ); + + schema_item = config_add_schema_item( config , "PATH2" , true ); + config_schema_item_set_argc_minmax( schema_item , 1 , 1 ); + config_schema_item_iset_type( schema_item , 0 , CONFIG_PATH ); + + schema_item = config_add_schema_item( config , "PATH3" , true ); + config_schema_item_set_argc_minmax( schema_item , 1 , 1 ); + config_schema_item_iset_type( schema_item , 0 , CONFIG_PATH ); + + schema_item = config_add_schema_item( config , "PATH4" , true ); + config_schema_item_set_argc_minmax( schema_item , 1 , 1 ); + config_schema_item_iset_type( schema_item , 0 , CONFIG_PATH ); + } + + parse_test( config , abs_path , config_file ); + parse_test( config , abs_path , abs_config_file ); + parse_test( config , NULL , abs_config_file ); + parse_test( config , "../../" , abs_config_file ); + + config_free( config ); + exit(0); +} + + + + diff --git a/ThirdParty/Ert/devel/libconfig/tests/config_node_test.c b/ThirdParty/Ert/devel/libconfig/tests/config_node_test.c new file mode 100644 index 0000000000..75c3c2dccd --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/tests/config_node_test.c @@ -0,0 +1,55 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'config_node_test.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include + +#include + + + +int main(int argc , char ** argv) { + const char * config_file = argv[1]; + config_type * config = config_alloc(); + bool OK; + { + config_schema_item_type * item = config_add_schema_item(config , "APPEND" , false ); + config_schema_item_set_argc_minmax( item , 1 , 1); + } + config_add_schema_item(config , "NEXT" , false ); + + OK = config_parse(config , config_file , "--" , NULL , NULL , false , true ); + + if (OK) { + if (config_get_content_size( config ) == 4) { + const config_content_node_type * node0 = config_iget_content_node( config , 0 ); + if (strcmp( config_content_node_get_kw( node0 ) , "APPEND") == 0) { + if (config_content_node_get_size(node0) == 1) { + const config_content_node_type * node3 = config_iget_content_node( config , 3 ); + if (strcmp( config_content_node_get_kw( node3 ) , "NEXT") == 0) { + if (config_content_node_get_size(node3) == 2) { + exit(0); + } else printf("Size error node3\n"); + } else printf("kw error node3 \n"); + } else printf("Size error node0\n"); + } else printf("kw error node0 kw:%s \n", config_content_node_get_kw( node0 )); + } else printf("Size error \n"); + } else printf("Parse error"); + + exit(1); +} + diff --git a/ThirdParty/Ert/devel/libconfig/tests/config_path_elm.c b/ThirdParty/Ert/devel/libconfig/tests/config_path_elm.c new file mode 100644 index 0000000000..0cd949bdcd --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/tests/config_path_elm.c @@ -0,0 +1,92 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'config_path_elm.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include +#include + +#include +#include + +#include +#include +#include + +int main(int argc , char ** argv) { +#ifdef ERT_LINUX + const char * root = "/tmp/root"; + const char * rel_path = "rel/path"; + const char * abs_path = "/tmp/root/rel/path"; + const char * rel_true = "rel/path/XXX"; + const char * abs_true = "/tmp/root/rel/path/XXX"; + const char * path_true1 = "rel/path/XXX"; + const char * path_true2 = "/tmp/root/rel/path/XXX"; + +#endif + + util_make_path( root ); + config_root_path_type * root_path = config_root_path_alloc( root ); + { + config_path_elm_type * path_elm = config_path_elm_alloc( root_path , rel_path ); + + test_assert_string_equal( config_path_elm_get_relpath( path_elm ) , rel_path ); + test_assert_string_equal( config_path_elm_get_abspath( path_elm ) , abs_path ); + + test_assert_string_equal( config_path_elm_alloc_relpath( path_elm , "XXX" ) , rel_true); + test_assert_string_equal( config_path_elm_alloc_abspath( path_elm , "XXX" ) , abs_true); + test_assert_string_equal( config_path_elm_alloc_path( path_elm , "XXX" ) , path_true2 ); + + + config_path_elm_free( path_elm ); + } + printf("test1 OK \n"); + { + config_path_elm_type * path_elm = config_path_elm_alloc( root_path , abs_path ); + + test_assert_string_equal( config_path_elm_get_relpath( path_elm ) , rel_path ); + test_assert_string_equal( config_path_elm_get_abspath( path_elm ) , abs_path ); + + test_assert_string_equal( config_path_elm_alloc_relpath( path_elm , "XXX" ) , rel_true); + test_assert_string_equal( config_path_elm_alloc_abspath( path_elm , "XXX" ) , abs_true); + test_assert_string_equal( config_path_elm_alloc_path( path_elm , "XXX" ) , path_true2 ); + + config_path_elm_free( path_elm ); + } + printf("test2 OK \n"); + config_root_path_free( root_path ); + + chdir( root ); + root_path = config_root_path_alloc( NULL ); + { + config_path_elm_type * path_elm = config_path_elm_alloc( root_path , rel_path ); + + test_assert_string_equal( config_path_elm_get_relpath( path_elm ) , rel_path ); + test_assert_string_equal( config_path_elm_get_abspath( path_elm ) , abs_path ); + + test_assert_string_equal( config_path_elm_alloc_relpath( path_elm , "XXX" ) , rel_true); + test_assert_string_equal( config_path_elm_alloc_abspath( path_elm , "XXX" ) , abs_true); + test_assert_string_equal( config_path_elm_alloc_path( path_elm , "XXX" ) , path_true1 ); + + + config_path_elm_free( path_elm ); + } + printf("test3 OK \n"); + + exit(0); +} + diff --git a/ThirdParty/Ert/devel/libconfig/tests/config_root_path.c b/ThirdParty/Ert/devel/libconfig/tests/config_root_path.c new file mode 100644 index 0000000000..e0f43a3982 --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/tests/config_root_path.c @@ -0,0 +1,88 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'config_root_path.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include + +#include +#include + +#include +#include + + +int main(int argc , char ** argv) { +#ifdef ERT_LINUX + const char * root = "/tmp/root"; + const char * rel_path = "rel/path"; + const char * abs_path = "/tmp/root/abs/path"; + const char * rel_true = "rel/path/XXX"; + const char * abs_true = "/tmp/root/rel/path/XXX"; + const char * path_true1 = "rel/path/XXX"; + const char * path_true2 = "/tmp/root/rel/path/XXX"; +#endif + + char * cwd = util_alloc_cwd(); + + { + config_root_path_type * root_path = config_root_path_alloc( NULL ); + + if (!test_string_equal( config_root_path_get_abs_path( root_path ) , cwd )) + test_error_exit("abs:path:%s expeceted:%s \n",config_root_path_get_abs_path( root_path ) , cwd ); + + if (!test_string_equal( config_root_path_get_input_path( root_path ) , NULL )) + test_error_exit("input:path:%s expeceted:%s \n",config_root_path_get_input_path( root_path ) , NULL ); + + if (!test_string_equal( config_root_path_get_rel_path( root_path ) , NULL )) + test_error_exit("rel:path:%s expeceted:%s \n",config_root_path_get_rel_path( root_path ) , NULL ); + + + config_root_path_free( root_path ); + } + + + { + config_root_path_type * root_path = config_root_path_alloc( "/does/not/exist" ); + if (root_path != NULL) + test_error_exit("Created root_path instance for not-existing input \n"); + } + + + + { + const char * input_path = argv[1]; + char * cwd = util_alloc_cwd(); + char * rel_path = util_alloc_rel_path( cwd , input_path ); + + config_root_path_type * root_path1 = config_root_path_alloc( input_path ); + config_root_path_type * root_path2 = config_root_path_alloc( rel_path ); + + if (!test_string_equal( config_root_path_get_rel_path( root_path1 ) , config_root_path_get_rel_path( root_path2 ))) + test_error_exit("Rel: %s != %s \n",config_root_path_get_rel_path( root_path1 ) , config_root_path_get_rel_path( root_path2)); + + if (!test_string_equal( config_root_path_get_abs_path( root_path1 ) , config_root_path_get_abs_path( root_path2 ))) + test_error_exit("Abs: %s != %s \n",config_root_path_get_abs_path( root_path1 ) , config_root_path_get_abs_path( root_path2 )); + + config_root_path_free( root_path1 ); + config_root_path_free( root_path2 ); + } + + + exit(0); +} + diff --git a/ThirdParty/Ert/devel/libconfig/tests/config_schema_item.c b/ThirdParty/Ert/devel/libconfig/tests/config_schema_item.c new file mode 100644 index 0000000000..69dc55238c --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/tests/config_schema_item.c @@ -0,0 +1,48 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'config_schema_item.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include + +#include + +#include + + + +int main(int argc , char ** argv) { + config_schema_item_type * schema_item = config_schema_item_alloc( "KW" , false ); + + test_assert_int_equal( config_schema_item_iget_type( schema_item , 1 ) , CONFIG_STRING ); + test_assert_int_equal( config_schema_item_iget_type( schema_item , 2 ) , CONFIG_STRING ); + + config_schema_item_iset_type( schema_item , 0 , CONFIG_INT ); + config_schema_item_iset_type( schema_item , 5 , CONFIG_BOOL ); + + + test_assert_int_equal( config_schema_item_iget_type( schema_item , 0 ) , CONFIG_INT ); + test_assert_int_equal( config_schema_item_iget_type( schema_item , 1 ) , CONFIG_STRING ); + test_assert_int_equal( config_schema_item_iget_type( schema_item , 2 ) , CONFIG_STRING ); + test_assert_int_equal( config_schema_item_iget_type( schema_item , 5 ) , CONFIG_BOOL ); + + config_schema_item_set_default_type( schema_item , CONFIG_FLOAT ); + test_assert_int_equal( config_schema_item_iget_type( schema_item , 7 ) , CONFIG_FLOAT ); + + config_schema_item_free( schema_item ); + exit(0); +} + diff --git a/ThirdParty/Ert/devel/libconfig/tests/config_typeFail.c b/ThirdParty/Ert/devel/libconfig/tests/config_typeFail.c new file mode 100644 index 0000000000..5514dd94a0 --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/tests/config_typeFail.c @@ -0,0 +1,67 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'config_typeFail.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include + +#include +#include + + +void error(char * msg) { + fprintf(stderr , msg); + exit(1); +} + + +int main(int argc , char ** argv) { + const char * config_file = argv[1]; + config_type * config = config_alloc(); + bool OK; + { + config_schema_item_type * item = config_add_schema_item(config , "TYPES_KEY" , false ); + config_schema_item_set_argc_minmax( item , 4 , 4 ); + config_schema_item_iset_type( item , 0 , CONFIG_INT ); + config_schema_item_iset_type( item , 1 , CONFIG_FLOAT ); + config_schema_item_iset_type( item , 2 , CONFIG_BOOL ); + + item = config_add_schema_item( config , "SHORT_KEY" , false ); + config_schema_item_set_argc_minmax( item , 1 , 1 ); + + item = config_add_schema_item( config , "LONG_KEY" , false ); + config_schema_item_set_argc_minmax( item , 3 , CONFIG_DEFAULT_ARG_MAX); + } + OK = config_parse(config , config_file , "--" , NULL , NULL , false , true ); + + if (OK) { + error("Parse error\n"); + } else { + config_error_type * cerror = config_get_errors( config ); + if (config_error_count( cerror ) > 0) { + int i; + for (i=0; i < config_error_count( cerror ); i++) { + printf("Error %d: %s \n",i , config_error_iget( cerror , i )); + } + } + printf("Error count:%d \n",config_error_count( cerror )); + if (config_error_count( cerror ) != 5) + error("Wrong error count\n"); + } + printf("OK \n"); + exit(0); +} + diff --git a/ThirdParty/Ert/devel/libconfig/tests/config_typeOK.c b/ThirdParty/Ert/devel/libconfig/tests/config_typeOK.c new file mode 100644 index 0000000000..83aded9a60 --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/tests/config_typeOK.c @@ -0,0 +1,55 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'config_typeOK.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include + +#include + + +void error(char * msg) { + fprintf(stderr , msg); + exit(1); +} + + +int main(int argc , char ** argv) { + const char * config_file = argv[1]; + config_type * config = config_alloc(); + bool OK; + { + config_schema_item_type * item = config_add_schema_item(config , "TYPE_KEY" , false ); + config_schema_item_set_argc_minmax( item , 4 , 4 ); + config_schema_item_iset_type( item , 0 , CONFIG_INT ); + config_schema_item_iset_type( item , 1 , CONFIG_FLOAT ); + config_schema_item_iset_type( item , 2 , CONFIG_BOOL ); + + item = config_add_schema_item( config , "SHORT_KEY" , false ); + config_schema_item_set_argc_minmax( item , 1 , 1 ); + + item = config_add_schema_item( config , "LONG_KEY" , false ); + config_schema_item_set_argc_minmax( item , 3 , CONFIG_DEFAULT_ARG_MAX ); + } + OK = config_parse(config , config_file , "--" , NULL , NULL , false , true ); + + if (OK) { + + } else error("Parse error\n"); + + exit(0); +} + diff --git a/ThirdParty/Ert/devel/libconfig/tests/data/append_test b/ThirdParty/Ert/devel/libconfig/tests/data/append_test new file mode 100644 index 0000000000..8af962aaa2 --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/tests/data/append_test @@ -0,0 +1,4 @@ +APPEND VALUE1 +APPEND VALUE2 +APPEND VALUE3 +NEXT VALUE4 VALUE5 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/libconfig/tests/data/content_item_test b/ThirdParty/Ert/devel/libconfig/tests/data/content_item_test new file mode 100644 index 0000000000..403ef6ae3e --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/tests/data/content_item_test @@ -0,0 +1 @@ +SET SetValue diff --git a/ThirdParty/Ert/devel/libconfig/tests/data/include_test b/ThirdParty/Ert/devel/libconfig/tests/data/include_test new file mode 100644 index 0000000000..9717f9dcaf --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/tests/data/include_test @@ -0,0 +1,3 @@ +PATH0 PATH0 +INCLUDE path/include1 +INCLUDE path/subpath/include2 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/libconfig/tests/data/path/include1 b/ThirdParty/Ert/devel/libconfig/tests/data/path/include1 new file mode 100644 index 0000000000..24c1ce46d0 --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/tests/data/path/include1 @@ -0,0 +1,5 @@ +PATH1 PATH1 +PATH2 PATH2 + +INCLUDE subpath/include3 +INCLUDE subpath/subsubpath/include4 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/libconfig/tests/data/path/subpath/include2 b/ThirdParty/Ert/devel/libconfig/tests/data/path/subpath/include2 new file mode 100644 index 0000000000..df203e9835 --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/tests/data/path/subpath/include2 @@ -0,0 +1 @@ +PATH2 PATH2 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/libconfig/tests/data/path/subpath/include3 b/ThirdParty/Ert/devel/libconfig/tests/data/path/subpath/include3 new file mode 100644 index 0000000000..85a8dae08a --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/tests/data/path/subpath/include3 @@ -0,0 +1 @@ +PATH3 PATH3 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/libconfig/tests/data/path/subpath/subsubpath/include4 b/ThirdParty/Ert/devel/libconfig/tests/data/path/subpath/subsubpath/include4 new file mode 100644 index 0000000000..9bb116f3a4 --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/tests/data/path/subpath/subsubpath/include4 @@ -0,0 +1 @@ +PATH4 PATH4 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/libconfig/tests/data/type_testFail b/ThirdParty/Ert/devel/libconfig/tests/data/type_testFail new file mode 100644 index 0000000000..f54ebe9a10 --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/tests/data/type_testFail @@ -0,0 +1,6 @@ +TYPES_KEY 100 0.75 rue String +TYPES_KEY 100 0.75 True String +TYPES_KEY 100 0.75X True String +TYPES_KEY 100X 0.75 True String +SHORT_KEY 100 100 +LONG_KEY 100 100 diff --git a/ThirdParty/Ert/devel/libconfig/tests/data/type_testOK b/ThirdParty/Ert/devel/libconfig/tests/data/type_testOK new file mode 100644 index 0000000000..7801b99a58 --- /dev/null +++ b/ThirdParty/Ert/devel/libconfig/tests/data/type_testOK @@ -0,0 +1,4 @@ +TYPES_KEY 100 0.75 True String +SHORT_KEY 100 +LONG_KEY 100 100 100 +LONG_KEY asc asc asc asc asc asc as asc sac asc sac sca sca sa sac \ No newline at end of file diff --git a/ThirdParty/Ert/devel/libecl/CMakeLists.txt b/ThirdParty/Ert/devel/libecl/CMakeLists.txt index acb1c9d2f4..90b94538d4 100644 --- a/ThirdParty/Ert/devel/libecl/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libecl/CMakeLists.txt @@ -1,8 +1,9 @@ add_subdirectory( src ) -if (BUILD_APPLICATONS OR BUILD_ECL_SUMMARY) - add_subdirectory( applications ) -endif() +#if (BUILD_APPLICATIONS OR BUILD_ECL_SUMMARY) +# add_subdirectory( applications ) +#endif() +add_subdirectory( applications ) if (BUILD_TESTS) add_subdirectory( tests ) endif() diff --git a/ThirdParty/Ert/devel/libecl/applications/CMakeLists.txt b/ThirdParty/Ert/devel/libecl/applications/CMakeLists.txt index 80644e6dea..afc4dba904 100644 --- a/ThirdParty/Ert/devel/libecl/applications/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libecl/applications/CMakeLists.txt @@ -4,6 +4,7 @@ if (BUILD_APPLICATIONS) add_executable( grdecl_grid grdecl_grid.c ) add_executable( summary2csv summary2csv.c ) if (ERT_LINUX) + add_executable( esummary.x esummary.c ) add_executable( convert.x convert.c ) add_executable( grdecl_test.x grdecl_test.c ) add_executable( kw_list.x kw_list.c ) @@ -14,7 +15,7 @@ if (BUILD_APPLICATIONS) add_executable( summary.x view_summary.c ) add_executable( select_test.x select_test.c ) add_executable( load_test.x load_test.c ) - set(program_list summary2csv kw_extract.x grdecl_grid make_grid sum_write load_test.x grdecl_test.x grid_dump_ascii.x select_test.x grid_dump.x convert.x kw_list.x grid_info.x summary.x) + set(program_list summary2csv esummary.x kw_extract.x grdecl_grid make_grid sum_write load_test.x grdecl_test.x grid_dump_ascii.x select_test.x grid_dump.x convert.x kw_list.x grid_info.x summary.x) else() # The stupid .x extension creates problems on windows add_executable( convert convert.c ) @@ -36,10 +37,12 @@ if (BUILD_APPLICATIONS) #----------------------------------------------------------------- set (destination ${CMAKE_INSTALL_PREFIX}/bin) - install(TARGETS ${prog} DESTINATION ${destination}) - if (INSTALL_GROUP) - install(CODE "EXECUTE_PROCESS(COMMAND chgrp ${INSTALL_GROUP} ${destination}/${prog})") - install(CODE "EXECUTE_PROCESS(COMMAND chmod g+w ${destination}/${prog})") + if (INSTALL_ERT) + install(TARGETS ${prog} DESTINATION ${destination}) + if (INSTALL_GROUP) + install(CODE "EXECUTE_PROCESS(COMMAND chgrp ${INSTALL_GROUP} ${destination}/${prog})") + install(CODE "EXECUTE_PROCESS(COMMAND chmod g+w ${destination}/${prog})") + endif() endif() endforeach() endif() @@ -47,13 +50,15 @@ endif() if (BUILD_ENS_PLOT) include_directories( ${PLPLOT_HEADER} ) add_executable( ens_plot.x ens_plot.c ) - target_link_libraries( ens_plot.x plot ecl ert_util) + target_link_libraries( ens_plot.x plot ecl) set (destination ${CMAKE_INSTALL_PREFIX}/bin) - install(TARGETS ens_plot.x DESTINATION ${destination}) - if (INSTALL_GROUP) - install(CODE "EXECUTE_PROCESS(COMMAND chgrp ${INSTALL_GROUP} ${destination}/ens_plot.x)") - install(CODE "EXECUTE_PROCESS(COMMAND chmod g+w ${destination}/ens_plot.x)") + if (INSTALL_ERT) + install(TARGETS ens_plot.x DESTINATION ${destination}) + if (INSTALL_GROUP) + install(CODE "EXECUTE_PROCESS(COMMAND chgrp ${INSTALL_GROUP} ${destination}/ens_plot.x)") + install(CODE "EXECUTE_PROCESS(COMMAND chmod g+w ${destination}/ens_plot.x)") + endif() endif() endif() @@ -61,13 +66,15 @@ endif() if (BUILD_ECL_SUMMARY) add_executable( ecl_summary view_summary.c ) - target_link_libraries( ecl_summary ecl ert_util) + target_link_libraries( ecl_summary ecl) set (destination ${CMAKE_INSTALL_PREFIX}/bin) - install(TARGETS ecl_summary DESTINATION ${destination}) - if (INSTALL_GROUP) - install(CODE "EXECUTE_PROCESS(COMMAND chgrp ${INSTALL_GROUP} ${destination}/ecl_summary)") - install(CODE "EXECUTE_PROCESS(COMMAND chmod g+w ${destination}/ecl_summary)") + if (INSTALL_ERT) + install(TARGETS ecl_summary DESTINATION ${destination}) + if (INSTALL_GROUP) + install(CODE "EXECUTE_PROCESS(COMMAND chgrp ${INSTALL_GROUP} ${destination}/ecl_summary)") + install(CODE "EXECUTE_PROCESS(COMMAND chmod g+w ${destination}/ecl_summary)") + endif() endif() endif() diff --git a/ThirdParty/Ert/devel/libecl/applications/ecl_quantile.c b/ThirdParty/Ert/devel/libecl/applications/ecl_quantile.c index d4748b4f00..a1207eb4a8 100644 --- a/ThirdParty/Ert/devel/libecl/applications/ecl_quantile.c +++ b/ThirdParty/Ert/devel/libecl/applications/ecl_quantile.c @@ -33,6 +33,8 @@ #include #include +#include +#include #include @@ -222,16 +224,23 @@ void ensemble_init( ensemble_type * ensemble , config_type * config) { thread_pool_type * tp = thread_pool_alloc( LOAD_THREADS , true ); { int i,j; - for (i=0; i < config_get_occurences( config , "CASE_LIST"); i++) { - const stringlist_type * case_list = config_iget_stringlist_ref( config , "CASE_LIST" , i ); - for (j=0; j < stringlist_get_size( case_list ); j++) - ensemble_load_from_glob( ensemble , stringlist_iget( case_list , j ) , tp); + const config_content_item_type * case_item = config_get_content_item( config , "CASE_LIST" ); + + if (case_item != NULL) { + for (j=0; j < config_content_node_get_size( case_item ); j++) { + const config_content_node_type * case_node = config_content_item_iget_node( case_item ); + for (i=0; i < config_content_node_get_size( case_node ) i++) { + const char * case_glob = config_content_node_iget( case_node , i ); + ensemble_load_from_glob( ensemble , case_glob , tp); + } + } } + } thread_pool_join( tp ); thread_pool_free( tp ); } - + { const sum_case_type * tmp = vector_iget_const( ensemble->data , 0 ); ensemble->refcase = tmp->ecl_sum; @@ -347,17 +356,21 @@ static void output_add_key( const ecl_sum_type * refcase , output_type * output void output_table_init( const ecl_sum_type * refcase, hash_type * output_table , const config_type * config ) { int i,j; - for (i=0; i < config_get_occurences( config , "OUTPUT" ); i++) { - const stringlist_type * tokens = config_iget_stringlist_ref( config , "OUTPUT" , i); - const char * file = stringlist_iget( tokens , 0 ); - const char * format_string = stringlist_iget( tokens , 1 ); - output_type * output = output_alloc( file , format_string ); + const config_content_item_type * output_item = config_get_content_item( config , "OUTPUT"); + if (output_item != NULL) { + for (i = 0; i < config_content_item_get_size( output_item ); i++) { + const config_content_node_type * output_node = config_content_item_iget_node( output_item , i ); + + const char * file = config_content_node_iget( output_node , 0 ); + const char * format_string = config_content_node_iget( output_node , 1 ); + output_type * output = output_alloc( file , format_string ); - /* All the keys are just added - without any check. */ - for (j = 2; j < stringlist_get_size( tokens ); j++) - output_add_key( refcase , output , stringlist_iget( tokens , j)); - - hash_insert_hash_owned_ref( output_table , file , output , output_free__ ); + /* All the keys are just added - without any check. */ + for (j = 2; j < config_content_node_get_size( output_node ); j++) + output_add_key( refcase , output , config_content_node_iget( output_node , j)); + + hash_insert_hash_owned_ref( output_table , file , output , output_free__ ); + } } } @@ -713,7 +726,7 @@ void config_init( config_type * config ) { { config_schema_item_type * item; item = config_add_schema_item( config , "OUTPUT" , true , true ); - config_schema_item_set_argc_minmax( item , 2 , -1 , 0 , NULL ); + config_schema_item_set_argc_minmax( item , 2 , CONFIG_DEFAULT_ARG_MAX , 0 , NULL ); config_schema_item_set_indexed_selection_set( item , 1 , 3 , (const char *[3]) { S3GRAPH_STRING , HEADER_STRING , PLAIN_STRING }); } @@ -815,16 +828,18 @@ int main( int argc , char ** argv ) { const char * config_arg = argv[1]; config_init( config ); - config_parse( config , config_arg , "--" , NULL , NULL , true , true ); - - { + if (config_parse( config , config_arg , "--" , NULL , NULL , CONFIG_UNRECOGNIZED_WARN, true )) { char * config_path; util_alloc_file_components( config_arg , &config_path , NULL , NULL); if (config_path != NULL) { chdir( config_path ); free( config_path ); } + } else { + config_fprintf_errors( config , stderr ); + exit(1); } + ensemble_init( ensemble , config ); diff --git a/ThirdParty/Ert/devel/libecl/applications/esummary.c b/ThirdParty/Ert/devel/libecl/applications/esummary.c index bd1241d65c..4ecb00b189 100644 --- a/ThirdParty/Ert/devel/libecl/applications/esummary.c +++ b/ThirdParty/Ert/devel/libecl/applications/esummary.c @@ -16,13 +16,16 @@ for more details. */ -#include #include -#include -#include #include #include -#include + +#include +#include +#include + +#include +#include void install_SIGNALS(void) { @@ -39,6 +42,8 @@ void usage() { } +#define MISSING_STRING " 0.000" + int main(int argc , char ** argv) { @@ -49,6 +54,12 @@ int main(int argc , char ** argv) { { ecl_sum_type * first_ecl_sum; /* This governs the timing */ vector_type * ecl_sum_list = vector_alloc_new(); + time_interval_type * time_union = NULL; + time_interval_type * time_intersect = NULL; + time_interval_type * time = NULL; + bool use_time_union = true; + + int load_count = 0; int nvars; char ** var_list; bool * has_var; @@ -61,51 +72,46 @@ int main(int argc , char ** argv) { char * path , * basename; ecl_sum_type * ecl_sum; util_alloc_file_components( argv[iarg] , &path , &basename , NULL); - ecl_sum = ecl_sum_fread_alloc_case( argv[iarg] , ":"); - if (iarg == 1) - first_ecl_sum = ecl_sum; /* Keep track of this - might sort the vector */ - fprintf(stderr,"Loading case: %s/%s" , path , basename); fflush(stderr); - vector_append_owned_ref( ecl_sum_list , ecl_sum , ecl_sum_free__ ); + ecl_sum = ecl_sum_fread_alloc_case( argv[iarg] , ":"); + + if (iarg == 1) { + first_ecl_sum = ecl_sum; /* Keep track of this - might sort the vector */ + time_union = time_interval_alloc_copy( ecl_sum_get_sim_time( ecl_sum )); + time_intersect = time_interval_alloc_copy( ecl_sum_get_sim_time( ecl_sum )); + + if (use_time_union) + time = time_union; + else + time = time_intersect; + vector_append_owned_ref( ecl_sum_list , ecl_sum , ecl_sum_free__ ); + } else { + const time_interval_type * ti = ecl_sum_get_sim_time( ecl_sum ); + if (time_interval_has_overlap(time , ti)) { + time_interval_intersect( time_intersect , ti ); + time_interval_extend( time_union , ti ); + + vector_append_owned_ref( ecl_sum_list , ecl_sum , ecl_sum_free__ ); + load_count++; + } else { + fprintf(stderr,"** Warning case:%s has no time overlap - discarded \n",ecl_sum_get_case( ecl_sum )); + ecl_sum_free( ecl_sum ); + } + } + iarg++; fprintf(stderr,"\n"); util_safe_free( path ); free( basename ); } } - nvars = argc - vector_get_size( ecl_sum_list ) - 1; + if (load_count == 0) + usage(); + + nvars = argc - load_count - 1; if (nvars == 0) util_exit(" --- No variables \n"); - var_list = &argv[vector_get_size( ecl_sum_list ) + 1]; + var_list = &argv[load_count + 1]; has_var = util_calloc( nvars , sizeof * has_var ); - - - /** Checking time consistency - and discarding those with unmatching time vector. */ - { - int i; - time_t_vector_type * first_time = ecl_sum_alloc_time_vector( vector_iget_const( ecl_sum_list , 0) , true ); - - for (i=1; i < vector_get_size( ecl_sum_list); i++) { - time_t_vector_type * time_vector; - const ecl_sum_type * ecl_sum = vector_iget_const( ecl_sum_list , i ); - if (ecl_sum_get_first_report_step( ecl_sum ) >= 0 ) { - time_vector = ecl_sum_alloc_time_vector( ecl_sum , true ); - int i; - for (i=0; i < util_int_min( time_t_vector_size( first_time ) , time_t_vector_size( time_vector )); i++) { - if (time_t_vector_iget( first_time , i) != time_t_vector_iget(time_vector , i)) { - vector_iset_ref( ecl_sum_list , i , NULL); - printf("Discarding case:%s due to time inconsistencies \n" , ecl_sum_get_case( ecl_sum )); - break; - } - } - time_t_vector_free( time_vector ); - } else { - vector_iset_ref( ecl_sum_list , i , NULL); - printf("Discarding case:%s - no data \n" , ecl_sum_get_case( ecl_sum )); - } - } - time_t_vector_free( first_time ); - } - /* Checking that the summary files have the various variables - @@ -131,39 +137,55 @@ int main(int argc , char ** argv) { } } } - - + + if (!time_interval_equal(time_union , time_intersect )) { + fprintf(stderr,"** Warning: not all simulations have the same length. "); + if (use_time_union) + fprintf(stderr,"Using %s for missing values.\n" , MISSING_STRING); + else + fprintf(stderr,"Only showing common time period.\n"); + } + /** The actual summary lookup. */ { - int first_report = ecl_sum_get_first_report_step( first_ecl_sum ); - int last_report = ecl_sum_get_last_report_step( first_ecl_sum ); + time_t_vector_type * date_list = time_t_vector_alloc(0,0); + time_t start_time = time_interval_get_start( time ); FILE * stream = stdout; - int iens,ivar,report; + int iens,ivar,itime; - for (report = first_report; report <= last_report; report++) { + ecl_util_init_month_range( date_list , time_interval_get_start( time ) , time_interval_get_end( time )); + for (itime = 0; itime < time_t_vector_size( date_list ); itime++) { + time_t current_time = time_t_vector_iget( date_list , itime ); for (ivar = 0; ivar < nvars; ivar++) { /* Iterating over the variables */ if (has_var[ivar]) { for (iens = 0; iens < vector_get_size( ecl_sum_list ); iens++) { /* Iterating over the ensemble members */ const ecl_sum_type * ecl_sum = vector_iget_const( ecl_sum_list , iens ); - double value = 0; - int end_index; - if (ecl_sum_has_report_step(ecl_sum , report)) { - end_index = ecl_sum_iget_report_end( ecl_sum , report ); - if (end_index >= 0) { - if (ivar == 0 && iens == 0) { /* Display time info in the first columns */ - int day,month,year; - util_set_date_values(ecl_sum_iget_sim_time(ecl_sum , end_index) , &day , &month, &year); - fprintf(stream , "%7.2f %02d/%02d/%04d " , ecl_sum_iget_sim_days(ecl_sum , end_index) , day , month , year); - } - value = ecl_sum_get_general_var(ecl_sum , end_index , var_list[ivar]); - } + + if (ivar == 0 && iens == 0) { /* Display time info in the first columns */ + int day,month,year; + util_set_date_values( current_time , &day , &month, &year); + fprintf(stream , "%7.2f %02d/%02d/%04d " , util_difftime_days( start_time , current_time ) , day , month , year); + } + + { + const time_interval_type * sim_time = ecl_sum_get_sim_time( ecl_sum ); + + if (time_interval_arg_before( sim_time , current_time)) + fprintf(stream , " %s " , MISSING_STRING); // We are before this case has data. + else if (time_interval_arg_after( sim_time , current_time)) + fprintf(stream , " %s " , MISSING_STRING); // We are after this case has data. + else { + double value = ecl_sum_get_general_var_from_sim_time(ecl_sum , current_time , var_list[ivar]); + fprintf(stream , " %12.3f " , value); + } + } - fprintf(stream , " %12.3f " , value); } } } fprintf(stream , "\n"); } + time_t_vector_free( date_list ); } vector_free( ecl_sum_list ); free( has_var ); diff --git a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_grid.h b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_grid.h index 00decbc2e2..3d65451008 100644 --- a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_grid.h +++ b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_grid.h @@ -149,7 +149,7 @@ extern "C" { double ecl_grid_get_double_property(const ecl_grid_type * ecl_grid , const ecl_kw_type * ecl_kw , int i , int j , int k); int ecl_grid_get_int_property(const ecl_grid_type * ecl_grid , const ecl_kw_type * ecl_kw , int i , int j , int k); - void ecl_grid_grdecl_fprintf_kw( const ecl_grid_type * ecl_grid , const ecl_kw_type * ecl_kw , FILE * stream , double double_default); + void ecl_grid_grdecl_fprintf_kw( const ecl_grid_type * ecl_grid , const ecl_kw_type * ecl_kw , const char * special_header , FILE * stream , double double_default); bool ecl_grid_test_lgr_consistency( const ecl_grid_type * ecl_grid ); void ecl_grid_fwrite_EGRID( ecl_grid_type * grid , const char * filename); diff --git a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_kw.h b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_kw.h index b53f614328..fe04cf3433 100644 --- a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_kw.h +++ b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_kw.h @@ -98,6 +98,7 @@ extern "C" { bool ecl_kw_numeric_equal(const ecl_kw_type *ecl_kw1, const ecl_kw_type *ecl_kw2 , double rel_diff); bool ecl_kw_block_equal( const ecl_kw_type * ecl_kw1 , const ecl_kw_type * ecl_kw2 , int cmp_elements); bool ecl_kw_data_equal( const ecl_kw_type * ecl_kw , const void * data); + bool ecl_kw_content_equal( const ecl_kw_type * ecl_kw1 , const ecl_kw_type * ecl_kw2); void ecl_kw_fskip_data__( ecl_type_enum ecl_type , int size , fortio_type * fortio); void ecl_kw_fskip_data(ecl_kw_type *ecl_kw, fortio_type *fortio); void ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio); diff --git a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_kw_grdecl.h b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_kw_grdecl.h index bd824dc599..9ed3845e0e 100644 --- a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_kw_grdecl.h +++ b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_kw_grdecl.h @@ -48,6 +48,7 @@ extern "C" { char * ecl_kw_grdecl_alloc_next_header( FILE * stream ); void ecl_kw_fprintf_grdecl(const ecl_kw_type * ecl_kw , FILE * stream); + void ecl_kw_fprintf_grdecl__(const ecl_kw_type * ecl_kw , const char * special_header , FILE * stream); #ifdef __cplusplus } diff --git a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_intehead.h b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_rsthead.h similarity index 70% rename from ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_intehead.h rename to ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_rsthead.h index 5819fccecd..a128e2adf1 100644 --- a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_intehead.h +++ b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_rsthead.h @@ -1,7 +1,7 @@ /* Copyright (C) 2011 Statoil ASA, Norway. - The file 'ecl_INTEHEAD.h' is part of ERT - Ensemble based Reservoir Tool. + The file 'ecl_RSTHEAD.h' is part of ERT - Ensemble based Reservoir Tool. ERT is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16,8 +16,8 @@ for more details. */ -#ifndef __ECL_INTEHEAD_H__ -#define __ECL_INTEHEAD_H__ +#ifndef __ECL_RSTHEAD_H__ +#define __ECL_RSTHEAD_H__ #ifdef __cplusplus extern "C" { @@ -25,9 +25,9 @@ extern "C" { #include +#include #include -#define INTEHEAD_KW "INTEHEAD" /* Long array with lots of data. */ typedef struct { int day; @@ -63,14 +63,24 @@ extern "C" { int nswlmx; // The maximum number of segmented wells int nlbrmx; // The maximum number of lateral branches pr well int nilbrz; // The number of entries pr segment in ILBR array - } ecl_intehead_type; + + // Properteies from the LOGIHEAD keyword: + bool dualp; + + + // Properties from the DOUBHEAD keyword: + double sim_days; + } ecl_rsthead_type; - void ecl_intehead_free( ecl_intehead_type * intehead ); - ecl_intehead_type * ecl_intehead_alloc( const ecl_kw_type * intehead_kw ); - time_t ecl_intehead_date( const ecl_kw_type * intehead_kw ); - void ecl_intehead_fprintf( const ecl_intehead_type * header , FILE * stream); + void ecl_rsthead_free( ecl_rsthead_type * rsthead ); + ecl_rsthead_type * ecl_rsthead_ialloc( const ecl_file_type * rst_file , int occurence); + ecl_rsthead_type * ecl_rsthead_alloc( const ecl_file_type * rst_file ); + time_t ecl_rsthead_date( const ecl_kw_type * intehead_kw ); + void ecl_rsthead_fprintf( const ecl_rsthead_type * header , FILE * stream); + void ecl_rsthead_fprintf_struct( const ecl_rsthead_type * header , FILE * stream); + bool ecl_rsthead_equal( const ecl_rsthead_type * header1 , const ecl_rsthead_type * header2); #ifdef __cplusplus } diff --git a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_sum.h b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_sum.h index 22f54b2b2e..c62fc61f42 100644 --- a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_sum.h +++ b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_sum.h @@ -30,6 +30,7 @@ extern "C" { #include #include #include +#include #include #include @@ -59,6 +60,7 @@ typedef struct ecl_sum_struct ecl_sum_type; double ecl_sum_get_from_sim_time( const ecl_sum_type * ecl_sum , time_t sim_time , const smspec_node_type * node); double ecl_sum_get_from_sim_days( const ecl_sum_type * ecl_sum , double sim_days , const smspec_node_type * node); + double ecl_sum_time2days( const ecl_sum_type * ecl_sum , time_t sim_time); void ecl_sum_set_unified( ecl_sum_type * ecl_sum , bool unified ); void ecl_sum_set_fmt_case( ecl_sum_type * ecl_sum , bool fmt_case ); @@ -158,6 +160,7 @@ typedef struct ecl_sum_struct ecl_sum_type; time_t ecl_sum_get_data_start( const ecl_sum_type * ecl_sum ); time_t ecl_sum_get_end_time( const ecl_sum_type * ecl_sum); time_t ecl_sum_get_start_time(const ecl_sum_type * ); + const time_interval_type * ecl_sum_get_sim_time( const ecl_sum_type * ecl_sum); const char * ecl_sum_get_base(const ecl_sum_type * ecl_sum ); const char * ecl_sum_get_path(const ecl_sum_type * ecl_sum ); diff --git a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_sum_data.h b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_sum_data.h index e8d9593c21..496eecb00b 100644 --- a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_sum_data.h +++ b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_sum_data.h @@ -29,6 +29,7 @@ extern "C" { #include #include #include +#include #include #include @@ -40,6 +41,7 @@ typedef struct ecl_sum_data_struct ecl_sum_data_type ; void ecl_sum_data_fread_restart( ecl_sum_data_type * data , const stringlist_type * filelist); ecl_sum_data_type * ecl_sum_data_alloc_writer( ecl_smspec_type * smspec ); ecl_sum_data_type * ecl_sum_data_alloc( ecl_smspec_type * smspec); + double ecl_sum_data_time2days( const ecl_sum_data_type * data , time_t sim_time); int ecl_sum_data_get_report_step_from_time(const ecl_sum_data_type * data , time_t sim_time); int ecl_sum_data_get_report_step_from_days(const ecl_sum_data_type * data , double days); bool ecl_sum_data_check_sim_time( const ecl_sum_data_type * data , time_t sim_time); @@ -52,6 +54,7 @@ typedef struct ecl_sum_data_struct ecl_sum_data_type ; time_t ecl_sum_data_get_data_start( const ecl_sum_data_type * data ); time_t ecl_sum_data_get_report_time( const ecl_sum_data_type * data , int report_step); double ecl_sum_data_get_first_day( const ecl_sum_data_type * data); + const time_interval_type * ecl_sum_data_get_sim_time( const ecl_sum_data_type * data); time_t ecl_sum_data_get_sim_start ( const ecl_sum_data_type * data ); time_t ecl_sum_data_get_sim_end ( const ecl_sum_data_type * data ); double ecl_sum_data_get_sim_length( const ecl_sum_data_type * data ); diff --git a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_util.h b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_util.h index 518f58be4c..371bd62870 100644 --- a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_util.h +++ b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_util.h @@ -25,6 +25,7 @@ extern "C" { #include #include +#include typedef enum { ECL_OTHER_FILE = 0 , ECL_RESTART_FILE = 1 , @@ -178,6 +179,8 @@ const char * ecl_util_get_phase_name( ecl_phase_enum phase ); const char * ecl_util_file_enum_iget( int index, int * value); int ecl_util_select_filelist( const char * path , const char * base , ecl_file_enum file_type , bool fmt_file , stringlist_type * filelist); +void ecl_util_append_month_range( time_t_vector_type * date_list , time_t start_date , time_t end_date , bool force_append_end); +void ecl_util_init_month_range( time_t_vector_type * date_list , time_t start_date , time_t end_date); #ifdef __cplusplus } diff --git a/ThirdParty/Ert/devel/libecl/include/ert/ecl/smspec_node.h b/ThirdParty/Ert/devel/libecl/include/ert/ecl/smspec_node.h index 11f3b1fde4..725376e9ca 100644 --- a/ThirdParty/Ert/devel/libecl/include/ert/ecl/smspec_node.h +++ b/ThirdParty/Ert/devel/libecl/include/ert/ecl/smspec_node.h @@ -113,6 +113,7 @@ typedef enum {ECL_SMSPEC_INVALID_VAR = 0 , void smspec_node_set_unit( smspec_node_type * smspec_node , const char * unit ); bool smspec_node_is_rate( const smspec_node_type * smspec_node ); bool smspec_node_is_total( const smspec_node_type * smspec_node ); + bool smspec_node_is_historical( const smspec_node_type * smspec_node ); bool smspec_node_need_nums( const smspec_node_type * smspec_node ); void smspec_node_fprintf( const smspec_node_type * smspec_node , FILE * stream); diff --git a/ThirdParty/Ert/devel/libecl/src/CMakeLists.txt b/ThirdParty/Ert/devel/libecl/src/CMakeLists.txt index a6e51931f1..309ccd43da 100644 --- a/ThirdParty/Ert/devel/libecl/src/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libecl/src/CMakeLists.txt @@ -2,9 +2,9 @@ include_directories( ext ) file(GLOB ext_source "ext/*.c" ) file(GLOB ext_header "ext/*.h" ) -set( source_files ecl_sum_tstep.c ecl_rst_file.c ecl_init_file.c ecl_grid_cache.c smspec_node.c ecl_kw_grdecl.c ecl_file_kw.c ecl_grav.c ecl_grav_calc.c ecl_smspec.c ecl_sum_data.c ecl_util.c ecl_kw.c ecl_sum.c fortio.c ecl_rft_file.c ecl_rft_node.c ecl_grid.c ecl_coarse_cell.c ecl_box.c ecl_io_config.c ecl_file.c ecl_region.c point.c tetrahedron.c ecl_intehead.c ecl_subsidence.c ecl_grav_common.c ${ext_source}) +set( source_files ecl_rsthead.c ecl_sum_tstep.c ecl_rst_file.c ecl_init_file.c ecl_grid_cache.c smspec_node.c ecl_kw_grdecl.c ecl_file_kw.c ecl_grav.c ecl_grav_calc.c ecl_smspec.c ecl_sum_data.c ecl_util.c ecl_kw.c ecl_sum.c fortio.c ecl_rft_file.c ecl_rft_node.c ecl_grid.c ecl_coarse_cell.c ecl_box.c ecl_io_config.c ecl_file.c ecl_region.c point.c tetrahedron.c ecl_subsidence.c ecl_grav_common.c ${ext_source}) -set( header_files ecl_sum_tstep.h ecl_rst_file.h ecl_init_file.h smspec_node.h ecl_grid_cache.h ecl_kw_grdecl.h ecl_file_kw.h ecl_grav.h ecl_grav_calc.h ecl_endian_flip.h ecl_smspec.h ecl_sum_data.h ecl_util.h ecl_kw.h ecl_sum.h fortio.h ecl_rft_file.h ecl_rft_node.h ecl_box.h ecl_coarse_cell.h ecl_grid.h ecl_io_config.h ecl_file.h ecl_region.h ecl_intehead.h ecl_kw_magic.h ecl_subsidence.h ${ext_header} ecl_grav_common.h) +set( header_files ecl_rsthead.h ecl_sum_tstep.h ecl_rst_file.h ecl_init_file.h smspec_node.h ecl_grid_cache.h ecl_kw_grdecl.h ecl_file_kw.h ecl_grav.h ecl_grav_calc.h ecl_endian_flip.h ecl_smspec.h ecl_sum_data.h ecl_util.h ecl_kw.h ecl_sum.h fortio.h ecl_rft_file.h ecl_rft_node.h ecl_box.h ecl_coarse_cell.h ecl_grid.h ecl_io_config.h ecl_file.h ecl_region.h ecl_kw_magic.h ecl_subsidence.h ${ext_header} ecl_grav_common.h) @@ -28,11 +28,12 @@ endif() target_link_libraries( ecl ert_geometry ert_util ) #----------------------------------------------------------------- -install(TARGETS ecl DESTINATION ${CMAKE_INSTALL_LIBDIR}) -foreach(header ${header_files}) - install(FILES ../include/ert/ecl/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/ecl) -endforeach() - +if (INSTALL_ERT) + install(TARGETS ecl DESTINATION ${CMAKE_INSTALL_LIBDIR}) + foreach(header ${header_files}) + install(FILES ../include/ert/ecl/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/ecl) + endforeach() +endif() diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_file.c b/ThirdParty/Ert/devel/libecl/src/ecl_file.c index a160c809ed..6777de334f 100644 --- a/ThirdParty/Ert/devel/libecl/src/ecl_file.c +++ b/ThirdParty/Ert/devel/libecl/src/ecl_file.c @@ -33,7 +33,7 @@ #include #include #include -#include +#include #include diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_grid.c b/ThirdParty/Ert/devel/libecl/src/ecl_grid.c index a94afe09a8..c1707800ac 100644 --- a/ThirdParty/Ert/devel/libecl/src/ecl_grid.c +++ b/ThirdParty/Ert/devel/libecl/src/ecl_grid.c @@ -3005,8 +3005,10 @@ int ecl_grid_get_active_fracture_index3(const ecl_grid_type * ecl_grid , int i , */ int ecl_grid_get_active_fracture_index1(const ecl_grid_type * ecl_grid , int global_index) { - if (!ecl_grid->fracture_index_map) return -1; - return ecl_grid->fracture_index_map[global_index]; + if (ecl_grid->fracture_index_map == NULL) + return -1; + else + return ecl_grid->fracture_index_map[global_index]; } @@ -3720,10 +3722,10 @@ int ecl_grid_get_region_cells(const ecl_grid_type * ecl_grid , const ecl_kw_type -void ecl_grid_grdecl_fprintf_kw( const ecl_grid_type * ecl_grid , const ecl_kw_type * ecl_kw , FILE * stream , double double_default) { +void ecl_grid_grdecl_fprintf_kw( const ecl_grid_type * ecl_grid , const ecl_kw_type * ecl_kw , const char * special_header , FILE * stream , double double_default) { int src_size = ecl_kw_get_size( ecl_kw ); if (src_size == ecl_grid->size) - ecl_kw_fprintf_grdecl( ecl_kw , stream ); + ecl_kw_fprintf_grdecl__( ecl_kw , special_header , stream ); else if (src_size == ecl_grid->total_active) { void * default_ptr = NULL; float float_default; @@ -3755,7 +3757,7 @@ void ecl_grid_grdecl_fprintf_kw( const ecl_grid_type * ecl_grid , const ecl_kw_t { ecl_kw_type * tmp_kw = ecl_kw_alloc_scatter_copy( ecl_kw , ecl_grid->size , ecl_grid->inv_index_map , default_ptr ); - ecl_kw_fprintf_grdecl( tmp_kw , stream ); + ecl_kw_fprintf_grdecl__( tmp_kw , special_header , stream ); ecl_kw_free( tmp_kw ); } } else diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_intehead.c b/ThirdParty/Ert/devel/libecl/src/ecl_intehead.c deleted file mode 100644 index cbc4777a9a..0000000000 --- a/ThirdParty/Ert/devel/libecl/src/ecl_intehead.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ecl_intehead.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - -#include - -#include -#include -#include - -static time_t intehead_date( int day , int month , int year) { - return util_make_date( day , month, year ); -} - - -time_t ecl_intehead_date( const ecl_kw_type * intehead_kw ) { - return intehead_date( ecl_kw_iget_int( intehead_kw , INTEHEAD_DAY_INDEX) , - ecl_kw_iget_int( intehead_kw , INTEHEAD_MONTH_INDEX) , - ecl_kw_iget_int( intehead_kw , INTEHEAD_YEAR_INDEX) ); -} - - - -ecl_intehead_type * ecl_intehead_alloc( const ecl_kw_type * intehead_kw ) { - ecl_intehead_type * intehead = util_malloc( sizeof * intehead ); - const int * data = (const int *) ecl_kw_get_void_ptr( intehead_kw ); - - intehead->day = data[INTEHEAD_DAY_INDEX]; - intehead->month = data[INTEHEAD_MONTH_INDEX]; - intehead->year = data[INTEHEAD_YEAR_INDEX]; - intehead->version = data[INTEHEAD_IPROG_INDEX]; - intehead->phase_sum = data[INTEHEAD_PHASE_INDEX]; - - intehead->nx = data[INTEHEAD_NX_INDEX]; - intehead->ny = data[INTEHEAD_NY_INDEX]; - intehead->nz = data[INTEHEAD_NZ_INDEX]; - intehead->nactive = data[INTEHEAD_NACTIVE_INDEX]; - - intehead->nwells = data[INTEHEAD_NWELLS_INDEX]; - intehead->niwelz = data[INTEHEAD_NIWELZ_INDEX]; - intehead->nzwelz = data[INTEHEAD_NZWELZ_INDEX]; - - intehead->niconz = data[INTEHEAD_NICONZ_INDEX]; - intehead->ncwmax = data[INTEHEAD_NCWMAX_INDEX]; - - intehead->nisegz = data[INTEHEAD_NISEGZ_INDEX]; - intehead->nsegmx = data[INTEHEAD_NSEGMX_INDEX]; - intehead->nswlmx = data[INTEHEAD_NSWLMX_INDEX]; - - // The only derived quantity - intehead->sim_time = intehead_date( intehead->day , intehead->month , intehead->year ); - return intehead; -} - - -void ecl_intehead_fprintf( const ecl_intehead_type * header , FILE * stream) { - fprintf(stream , "nx %d \n",header->nx); - fprintf(stream , "nwells %d \n",header->nwells); - fprintf(stream , "niwelz %d \n\n",header->niwelz); -} - -void ecl_intehead_free( ecl_intehead_type * intehead ) { - free( intehead ); -} diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_kw.c b/ThirdParty/Ert/devel/libecl/src/ecl_kw.c index 49b5cdc1c6..85432ec2c3 100644 --- a/ThirdParty/Ert/devel/libecl/src/ecl_kw.c +++ b/ThirdParty/Ert/devel/libecl/src/ecl_kw.c @@ -336,15 +336,25 @@ bool ecl_kw_ichar_eq(const ecl_kw_type *ecl_kw , int i , const char *value) { } +static bool ecl_kw_size_and_type_equal( const ecl_kw_type *ecl_kw1 , const ecl_kw_type * ecl_kw2 ) { + bool equal = true; + + if (ecl_kw1->size != ecl_kw2->size) + equal = false; + else if (ecl_kw1->ecl_type != ecl_kw2->ecl_type) + equal = false; + + return equal; +} + + bool ecl_kw_header_eq(const ecl_kw_type *ecl_kw1 , const ecl_kw_type * ecl_kw2) { bool equal = true; if (strcmp(ecl_kw1->header8 , ecl_kw2->header8) != 0) equal = false; - else if (ecl_kw1->size != ecl_kw2->size) - equal = false; - else if (ecl_kw1->ecl_type != ecl_kw2->ecl_type) - equal = false; + else + equal = ecl_kw_size_and_type_equal( ecl_kw1 , ecl_kw2 ); return equal; } @@ -368,6 +378,16 @@ bool ecl_kw_data_equal( const ecl_kw_type * ecl_kw , const void * data) { } +bool ecl_kw_content_equal( const ecl_kw_type * ecl_kw1 , const ecl_kw_type * ecl_kw2) { + if (ecl_kw_size_and_type_equal( ecl_kw1 , ecl_kw2)) + return ecl_kw_data_equal__( ecl_kw1 , ecl_kw2->data , ecl_kw1->size); + else + return false; +} + + + + /** This function compares two ecl_kw instances, and returns true if they are equal. diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_kw_grdecl.c b/ThirdParty/Ert/devel/libecl/src/ecl_kw_grdecl.c index 9d76f8ffc7..1fb0f3bb5a 100644 --- a/ThirdParty/Ert/devel/libecl/src/ecl_kw_grdecl.c +++ b/ThirdParty/Ert/devel/libecl/src/ecl_kw_grdecl.c @@ -633,8 +633,19 @@ ecl_kw_type * ecl_kw_fscanf_alloc_current_grdecl( FILE * stream , ecl_type_enum /*****************************************************************/ -void ecl_kw_fprintf_grdecl(const ecl_kw_type * ecl_kw , FILE * stream) { - fprintf(stream,"%s\n" , ecl_kw_get_header(ecl_kw)); + +/* + This method allows to write with a different header, + i.e. PORO_XXXX. This header is even allowed to break the 8 character + length limit; i.e. loading it back naively will fail. +*/ + +void ecl_kw_fprintf_grdecl__(const ecl_kw_type * ecl_kw , const char * special_header , FILE * stream) { + if (special_header) + fprintf(stream,"%s\n" , special_header); + else + fprintf(stream,"%s\n" , ecl_kw_get_header(ecl_kw)); + { fortio_type * fortio = fortio_alloc_FILE_wrapper(NULL , false , true , stream); /* Endian flip should *NOT* be used */ ecl_kw_fwrite_data(ecl_kw , fortio); @@ -644,3 +655,7 @@ void ecl_kw_fprintf_grdecl(const ecl_kw_type * ecl_kw , FILE * stream) { } +void ecl_kw_fprintf_grdecl(const ecl_kw_type * ecl_kw , FILE * stream) { + ecl_kw_fprintf_grdecl__(ecl_kw , NULL , stream ); +} + diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_rst_file.c b/ThirdParty/Ert/devel/libecl/src/ecl_rst_file.c index 85bff601ef..6549e85922 100644 --- a/ThirdParty/Ert/devel/libecl/src/ecl_rst_file.c +++ b/ThirdParty/Ert/devel/libecl/src/ecl_rst_file.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_rstfile.c b/ThirdParty/Ert/devel/libecl/src/ecl_rstfile.c index d64d6c3efc..a87989410d 100644 --- a/ThirdParty/Ert/devel/libecl/src/ecl_rstfile.c +++ b/ThirdParty/Ert/devel/libecl/src/ecl_rstfile.c @@ -158,7 +158,7 @@ static time_t file_map_iget_restart_sim_date(const file_map_type * file_map , in if (seqnum_map != NULL) { ecl_kw_type * intehead_kw = file_map_iget_named_kw( seqnum_map , INTEHEAD_KW , 0); - sim_time = ecl_intehead_date( intehead_kw ); + sim_time = ecl_rsthead_date( intehead_kw ); file_map_free( seqnum_map ); } @@ -175,7 +175,7 @@ static int file_map_find_sim_time(const file_map_type * file_map , time_t sim_ti int index = 0; while (index < int_vector_size( intehead_index_list )) { const ecl_kw_type * intehead_kw = file_map_iget_kw( file_map , int_vector_iget( intehead_index_list , index )); - if (ecl_intehead_date( intehead_kw ) == sim_time) { + if (ecl_rsthead_date( intehead_kw ) == sim_time) { seqnum_index = index; break; } diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_rsthead.c b/ThirdParty/Ert/devel/libecl/src/ecl_rsthead.c new file mode 100644 index 0000000000..05995747cc --- /dev/null +++ b/ThirdParty/Ert/devel/libecl/src/ecl_rsthead.c @@ -0,0 +1,155 @@ +/* + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ecl_rsthead.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + +#include + +#include +#include +#include +#include + + +static time_t rsthead_date( int day , int month , int year) { + return util_make_date( day , month, year ); +} + + +time_t ecl_rsthead_date( const ecl_kw_type * intehead_kw ) { + return rsthead_date( ecl_kw_iget_int( intehead_kw , INTEHEAD_DAY_INDEX) , + ecl_kw_iget_int( intehead_kw , INTEHEAD_MONTH_INDEX) , + ecl_kw_iget_int( intehead_kw , INTEHEAD_YEAR_INDEX) ); +} + + + + +ecl_rsthead_type * ecl_rsthead_ialloc( const ecl_file_type * rst_file , int occurence) { + if (ecl_file_get_num_named_kw( rst_file , INTEHEAD_KW) > occurence) { + const ecl_kw_type * intehead_kw = ecl_file_iget_named_kw( rst_file , INTEHEAD_KW , occurence); + const ecl_kw_type * logihead_kw = ecl_file_iget_named_kw( rst_file , LOGIHEAD_KW , occurence); + const ecl_kw_type * doubhead_kw = ecl_file_iget_named_kw( rst_file , DOUBHEAD_KW , occurence); + + ecl_rsthead_type * rsthead = util_malloc( sizeof * rsthead ); + + { + const int * data = (const int *) ecl_kw_get_void_ptr( intehead_kw ); + + rsthead->day = data[INTEHEAD_DAY_INDEX]; + rsthead->month = data[INTEHEAD_MONTH_INDEX]; + rsthead->year = data[INTEHEAD_YEAR_INDEX]; + rsthead->version = data[INTEHEAD_IPROG_INDEX]; + rsthead->phase_sum = data[INTEHEAD_PHASE_INDEX]; + + rsthead->nx = data[INTEHEAD_NX_INDEX]; + rsthead->ny = data[INTEHEAD_NY_INDEX]; + rsthead->nz = data[INTEHEAD_NZ_INDEX]; + rsthead->nactive = data[INTEHEAD_NACTIVE_INDEX]; + + rsthead->nwells = data[INTEHEAD_NWELLS_INDEX]; + rsthead->niwelz = data[INTEHEAD_NIWELZ_INDEX]; + rsthead->nzwelz = data[INTEHEAD_NZWELZ_INDEX]; + + rsthead->niconz = data[INTEHEAD_NICONZ_INDEX]; + rsthead->ncwmax = data[INTEHEAD_NCWMAX_INDEX]; + + rsthead->nisegz = data[INTEHEAD_NISEGZ_INDEX]; + rsthead->nsegmx = data[INTEHEAD_NSEGMX_INDEX]; + rsthead->nswlmx = data[INTEHEAD_NSWLMX_INDEX]; + + // The only derived quantity + rsthead->sim_time = rsthead_date( rsthead->day , rsthead->month , rsthead->year ); + } + rsthead->dualp = ecl_kw_iget_bool( logihead_kw , LOGIHEAD_DUALP_INDEX); + rsthead->sim_days = ecl_kw_iget_double( doubhead_kw , DOUBHEAD_DAYS_INDEX ); + + return rsthead; + } else + return NULL; +} + + +ecl_rsthead_type * ecl_rsthead_alloc( const ecl_file_type * rst_file) { + return ecl_rsthead_ialloc( rst_file , 0 ); +} + + +void ecl_rsthead_fprintf( const ecl_rsthead_type * header , FILE * stream) { + fprintf(stream , "nx %d \n",header->nx); + fprintf(stream , "nwells %d \n",header->nwells); + fprintf(stream , "niwelz %d \n\n",header->niwelz); +} + + +bool ecl_rsthead_equal( const ecl_rsthead_type * header1 , const ecl_rsthead_type * header2) { + bool equal = true; + equal = equal && (header1->day == header2->day); + equal = equal && (header1->year == header2->year); + equal = equal && (header1->month == header2->month); + equal = equal && (header1->sim_time == header2->sim_time); + equal = equal && (header1->version == header2->version); + equal = equal && (header1->phase_sum == header2->phase_sum); + equal = equal && (header1->nx == header2->nx); + equal = equal && (header1->ny == header2->ny); + equal = equal && (header1->nz == header2->nz); + equal = equal && (header1->nactive == header2->nactive); + equal = equal && (header1->nwells == header2->nwells); + equal = equal && (header1->niwelz == header2->niwelz); + equal = equal && (header1->nzwelz == header2->nzwelz); + equal = equal && (header1->niconz == header2->niconz); + equal = equal && (header1->ncwmax == header2->ncwmax); + equal = equal && (header1->nisegz == header2->nisegz); + equal = equal && (header1->nsegmx == header2->nsegmx); + equal = equal && (header1->nswlmx == header2->nswlmx); + equal = equal && (header1->nlbrmx == header2->nlbrmx); + equal = equal && (header1->nilbrz == header2->nilbrz); + equal = equal && (header1->dualp == header2->dualp); + equal = equal && util_double_approx_equal(header1->sim_days , header2->sim_days ); + + return equal; +} + +void ecl_rsthead_fprintf_struct( const ecl_rsthead_type * header , FILE * stream) { + fprintf(stream , "{.day = %d,\n",header->day); + fprintf(stream , ".year = %d,\n",header->year); + fprintf(stream , ".month = %d,\n",header->month); + fprintf(stream , ".sim_time = %ld,\n",header->sim_time); + fprintf(stream , ".version = %d,\n",header->version); + fprintf(stream , ".phase_sum = %d,\n",header->phase_sum); + fprintf(stream , ".nx = %d,\n",header->nx); + fprintf(stream , ".ny = %d,\n",header->ny); + fprintf(stream , ".nz = %d,\n",header->nz); + fprintf(stream , ".nactive = %d,\n",header->nactive); + fprintf(stream , ".nwells = %d,\n",header->nwells); + fprintf(stream , ".niwelz = %d,\n",header->niwelz); + fprintf(stream , ".nzwelz = %d,\n",header->nzwelz); + fprintf(stream , ".niconz = %d,\n",header->niconz); + fprintf(stream , ".ncwmax = %d,\n",header->ncwmax); + fprintf(stream , ".nisegz = %d,\n",header->nisegz); + fprintf(stream , ".nsegmx = %d,\n",header->nsegmx); + fprintf(stream , ".nswlmx = %d,\n",header->nswlmx); + fprintf(stream , ".nlbrmx = %d,\n",header->nlbrmx); + fprintf(stream , ".nilbrz = %d,\n",header->nilbrz); + fprintf(stream , ".dualp = %d,\n",header->dualp); + fprintf(stream , ".sim_days = %g};\n",header->sim_days); +} + + +void ecl_rsthead_free( ecl_rsthead_type * rsthead ) { + free( rsthead ); +} diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_sum.c b/ThirdParty/Ert/devel/libecl/src/ecl_sum.c index 21b5f02ddc..f07e1de355 100644 --- a/ThirdParty/Ert/devel/libecl/src/ecl_sum.c +++ b/ThirdParty/Ert/devel/libecl/src/ecl_sum.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -402,6 +403,9 @@ double ecl_sum_get_from_sim_days( const ecl_sum_type * ecl_sum , double sim_days return ecl_sum_data_get_from_sim_days( ecl_sum->data , sim_days , node ); } +double ecl_sum_time2days( const ecl_sum_type * ecl_sum , time_t sim_time) { + return ecl_sum_data_time2days( ecl_sum->data , sim_time ); +} @@ -810,6 +814,10 @@ time_t ecl_sum_iget_sim_time( const ecl_sum_type * ecl_sum , int index ) { return ecl_sum_data_iget_sim_time( ecl_sum->data , index ); } +const time_interval_type * ecl_sum_get_sim_time( const ecl_sum_type * ecl_sum) { + return ecl_sum_data_get_sim_time( ecl_sum->data ); +} + time_t ecl_sum_get_data_start( const ecl_sum_type * ecl_sum ) { return ecl_sum_data_get_data_start( ecl_sum->data ); } diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_sum_data.c b/ThirdParty/Ert/devel/libecl/src/ecl_sum_data.c index 101a4990aa..ab087a0a27 100644 --- a/ThirdParty/Ert/devel/libecl/src/ecl_sum_data.c +++ b/ThirdParty/Ert/devel/libecl/src/ecl_sum_data.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -212,10 +213,6 @@ struct ecl_sum_data_struct { int first_ministep; int last_ministep; double days_start; - time_t data_start_time; /* This is the first time_t we have data for; will typically - agree with sim_start, - but in the case of restarts it will be after sim_start. */ - time_t sim_end; double sim_length; int_vector_type * report_first_index ; /* Indexed by report_step - giving first internal_index in report_step. */ int_vector_type * report_last_index; /* Indexed by report_step - giving last internal_index in report_step. */ @@ -224,6 +221,9 @@ struct ecl_sum_data_struct { time_t __min_time; /* An internal member used during the load of restarted cases; see doc in ecl_sum_data_append_tstep. */ bool index_valid; + time_interval_type * sim_time; /* The time interval sim_time goes from the first time value where we have + data to the end of the simulation. In the case of restarts the start + value might disagree with the simulation start reported by the smspec file. */ }; @@ -236,6 +236,7 @@ struct ecl_sum_data_struct { vector_free( data->data ); int_vector_free( data->report_first_index ); int_vector_free( data->report_last_index ); + time_interval_free( data->sim_time ); free(data); } @@ -253,12 +254,11 @@ static void ecl_sum_data_clear_index( ecl_sum_data_type * data ) { data->first_report_step = 1024 * 1024; data->last_report_step = -1024 * 1024; data->days_start = 0; - data->data_start_time = -1; - data->sim_end = -1; data->sim_length = -1; data->first_ministep = -1; data->last_ministep = -1; data->index_valid = false; + time_interval_reopen( data->sim_time ); } @@ -270,7 +270,7 @@ ecl_sum_data_type * ecl_sum_data_alloc(ecl_smspec_type * smspec) { data->report_first_index = int_vector_alloc( 0 , -1 ); /* This -1 value is hard-wired around in the place - not good. */ data->report_last_index = int_vector_alloc( 0 , -1 ); - + data->sim_time = time_interval_alloc_open(); ecl_sum_data_clear_index( data ); return data; @@ -437,10 +437,11 @@ void ecl_sum_data_fwrite( const ecl_sum_data_type * data , const char * ecl_case +const time_interval_type * ecl_sum_data_get_sim_time( const ecl_sum_data_type * data) { return data->sim_time; } -time_t ecl_sum_data_get_sim_end (const ecl_sum_data_type * data ) { return data->sim_end; } +time_t ecl_sum_data_get_sim_end (const ecl_sum_data_type * data ) { return time_interval_get_end( data->sim_time ); } -time_t ecl_sum_data_get_data_start ( const ecl_sum_data_type * data ) { return data->data_start_time; } +time_t ecl_sum_data_get_data_start ( const ecl_sum_data_type * data ) { return time_interval_get_start( data->sim_time ); } double ecl_sum_data_get_first_day( const ecl_sum_data_type * data) { return data->days_start; } @@ -469,10 +470,10 @@ double ecl_sum_data_get_sim_length( const ecl_sum_data_type * data ) { */ bool ecl_sum_data_check_sim_time( const ecl_sum_data_type * data , time_t sim_time) { - if ((sim_time < data->data_start_time) || (sim_time > data->sim_end)) - return false; - else + if (time_interval_contains( data->sim_time , sim_time ) || (sim_time == time_interval_get_end( data->sim_time))) return true; + else + return false; } @@ -524,14 +525,15 @@ bool ecl_sum_data_check_sim_days( const ecl_sum_data_type * data , double sim_da static int ecl_sum_data_get_index_from_sim_time( const ecl_sum_data_type * data , time_t sim_time) { - time_t data_start_time = data->data_start_time; + time_t data_start_time = time_interval_get_start( data->sim_time ); + time_t sim_end = time_interval_get_end( data->sim_time ); - if ((sim_time < data_start_time) || (sim_time > data->sim_end)) { + if (!ecl_sum_data_check_sim_time( data , sim_time )) { fprintf(stderr , "Simulation start: "); util_fprintf_date( ecl_smspec_get_start_time( data->smspec ) , stderr ); fprintf(stderr , "Data start......: "); util_fprintf_date( data_start_time , stderr ); - fprintf(stderr , "Simulation end .: "); util_fprintf_date( data->sim_end , stderr ); + fprintf(stderr , "Simulation end .: "); util_fprintf_date( sim_end , stderr ); fprintf(stderr , "Requested date .: "); util_fprintf_date( sim_time , stderr ); - util_abort("%s: invalid time_t instance:%d interval: [%d,%d]\n",__func__, sim_time , data_start_time , data->sim_end); + util_abort("%s: invalid time_t instance:%d interval: [%d,%d]\n",__func__, sim_time , data_start_time , sim_end); } /* @@ -705,9 +707,9 @@ static void ecl_sum_data_append_tstep__( ecl_sum_data_type * data , int ministep static void ecl_sum_data_update_end_info( ecl_sum_data_type * sum_data ) { const ecl_sum_tstep_type * last_ministep = vector_get_last_const( sum_data->data ); - sum_data->last_ministep = ecl_sum_tstep_get_ministep( last_ministep ); + sum_data->last_ministep = ecl_sum_tstep_get_ministep( last_ministep ); sum_data->sim_length = ecl_sum_tstep_get_sim_days( last_ministep ); - sum_data->sim_end = ecl_sum_tstep_get_sim_time( last_ministep ); + time_interval_update_end( sum_data->sim_time , ecl_sum_tstep_get_sim_time( last_ministep )); } static int cmp_ministep( const void * arg1 , const void * arg2) { @@ -749,7 +751,7 @@ static void ecl_sum_data_build_index( ecl_sum_data_type * sum_data ) { will be a difference. */ sum_data->days_start = ecl_sum_tstep_get_sim_days( first_ministep ); - sum_data->data_start_time = ecl_sum_tstep_get_sim_time( first_ministep ); + time_interval_update_start( sum_data->sim_time , ecl_sum_tstep_get_sim_time( first_ministep )); } ecl_sum_data_update_end_info( sum_data ); @@ -1199,7 +1201,8 @@ int ecl_sum_data_get_report_step_from_days(const ecl_sum_data_type * data , doub int ecl_sum_data_get_report_step_from_time(const ecl_sum_data_type * data , time_t sim_time) { - if ((sim_time < data->data_start_time) || (sim_time > data->sim_end)) + + if (!ecl_sum_data_check_sim_time(data , sim_time)) return -1; { @@ -1232,6 +1235,11 @@ int ecl_sum_data_get_report_step_from_time(const ecl_sum_data_type * data , time } +double ecl_sum_data_time2days( const ecl_sum_data_type * data , time_t sim_time) { + time_t start_time = ecl_smspec_get_start_time( data->smspec ); + return util_difftime_days( start_time , sim_time ); +} + double ecl_sum_data_get_from_sim_days( const ecl_sum_data_type * data , double sim_days , const smspec_node_type * smspec_node) { time_t sim_time = ecl_smspec_get_start_time( data->smspec ); util_inplace_forward_days( &sim_time , sim_days ); diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_util.c b/ThirdParty/Ert/devel/libecl/src/ecl_util.c index 5be479866b..b41e6a4d4f 100644 --- a/ThirdParty/Ert/devel/libecl/src/ecl_util.c +++ b/ThirdParty/Ert/devel/libecl/src/ecl_util.c @@ -1322,6 +1322,70 @@ bool ecl_util_valid_basename( const char * basename ) { } +/* + Will append time_t values corresponding to the first day in every + month in the open interval (start_date , end_date). Iff start_date + corresponds to the first date in a month the list will start with + start_date, otherwise the list will start with the first day in the + month following after start_date. + + If end_date corresponds to the first day of the month the list will + end with end_date, otherwise it will ende with the first day in the + month prior to end_date: + + (1,1,2000) , (10,3,2000) => {(1,1,2000) , (1,2,2000) , (1,3,2000) } + (10,1,2000) , (1,4,2000) => {(1,2,2000) , (1,3,2000) , (1,4,2000) } + + All time_t values added to the date list will be pure dates, + i.e. the time part will be 00:00:00; that also applies to start_date + and end_date where possible time parts will be normalized away prior + to insertion. +*/ + + +void ecl_util_append_month_range( time_t_vector_type * date_list , time_t start_date , time_t end_date , bool force_append_end) { + start_date = util_make_pure_date( start_date ); + end_date = util_make_pure_date( end_date ); + + if (util_is_first_day_in_month( start_date)) + time_t_vector_append( date_list , start_date ); + + { + time_t current_date = start_date; + while (true) { + int month,year; + util_set_date_values( current_date , NULL , &month , &year); + if (month == 12) { + month = 1; + year += 1; + } else + month += 1; + + current_date = util_make_date( 1 , month , year ); + if (current_date < end_date) + time_t_vector_append( date_list , current_date ); + else { + if (current_date == end_date) + time_t_vector_append( date_list , current_date ); + else if (force_append_end) + time_t_vector_append( date_list , end_date ); + break; + } + } + } +} + + + +void ecl_util_init_month_range( time_t_vector_type * date_list , time_t start_date , time_t end_date) { + time_t_vector_reset( date_list ); + if (!util_is_first_day_in_month( start_date )) + time_t_vector_append( date_list , util_make_pure_date(start_date)); + + ecl_util_append_month_range( date_list , start_date , end_date , true ); +} + + /*****************************************************************/ /* Small functions to support enum introspection. */ diff --git a/ThirdParty/Ert/devel/libecl/src/smspec_node.c b/ThirdParty/Ert/devel/libecl/src/smspec_node.c index 36250fee60..20b0f70ce5 100644 --- a/ThirdParty/Ert/devel/libecl/src/smspec_node.c +++ b/ThirdParty/Ert/devel/libecl/src/smspec_node.c @@ -65,6 +65,7 @@ struct smspec_node_struct { bool rate_variable; /* Is this a rate variable (i.e. WOPR) or a state variable (i.e. BPR). Relevant when doing time interpolation. */ bool total_variable; /* Is this a total variable like WOPT? */ bool need_nums; /* Do we use the NUMS vector - relevant for storing. */ + bool historical; /* Does the name end with 'H'? */ int params_index; /* The index of this variable (applies to all the vectors - in particular the PARAMS vectors of the summary files *.Snnnn / *.UNSMRY ). */ float default_value; /* Default value for this variable. */ }; @@ -234,8 +235,12 @@ static void smspec_node_set_invalid_flags( smspec_node_type * smspec_node) { smspec_node->rate_variable = false; smspec_node->total_variable = false; smspec_node->need_nums = false; + smspec_node->historical = false; } +static char LAST_CHAR(const char * s) { + return s[ strlen(s) - 1]; +} static void smspec_node_set_flags( smspec_node_type * smspec_node) { /* @@ -249,7 +254,7 @@ static void smspec_node_set_flags( smspec_node_type * smspec_node) { int ivar; for (ivar = 0; ivar < num_rate_vars; ivar++) { const char * var_substring = &smspec_node->keyword[1]; - if (util_string_equal( rate_vars[ivar] , var_substring)) { + if (strncmp( rate_vars[ivar] , var_substring , strlen( rate_vars[ivar] )) == 0) { is_rate = true; break; } @@ -257,6 +262,11 @@ static void smspec_node_set_flags( smspec_node_type * smspec_node) { smspec_node->rate_variable = is_rate; } + { + if (LAST_CHAR(smspec_node->keyword) == 'H') + smspec_node->historical = true; + } + /* This code checks in a predefined list whether a certain WGNAMES variable represents a total accumulated quantity. Only the last three @@ -265,7 +275,7 @@ static void smspec_node_set_flags( smspec_node_type * smspec_node) { The list below is all the keyowrds with 'Total' in the information from the tables 2.7 - 2.11 in the ECLIPSE fileformat documentation. Have - skipped some of the most exotic keywords (AND ALL THE HISTORICAL). + skipped some of the most exotic keywords. */ { bool is_total = false; @@ -278,7 +288,12 @@ static void smspec_node_set_flags( smspec_node_type * smspec_node) { int ivar; for (ivar = 0; ivar < num_total_vars; ivar++) { const char * var_substring = &smspec_node->keyword[1]; - if (util_string_equal( total_vars[ivar] , var_substring)) { + /* + We want to mark both FOPT and FOPTH as historical variables; + we use strncmp() to make certain that the trailing 'H' is + not included in the comparison. + */ + if (strncmp( total_vars[ivar] , var_substring , strlen( total_vars[ivar] )) == 0) { is_total = true; break; } @@ -761,6 +776,10 @@ bool smspec_node_is_total( const smspec_node_type * smspec_node ){ return smspec_node->total_variable; } +bool smspec_node_is_historical( const smspec_node_type * smspec_node ){ + return smspec_node->historical; +} + const char * smspec_node_get_unit( const smspec_node_type * smspec_node) { return smspec_node->unit; diff --git a/ThirdParty/Ert/devel/libecl/tests/CMakeLists.txt b/ThirdParty/Ert/devel/libecl/tests/CMakeLists.txt index 8b87e485be..b4beb6f651 100644 --- a/ThirdParty/Ert/devel/libecl/tests/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libecl/tests/CMakeLists.txt @@ -1,18 +1,55 @@ add_executable( ecl_coarse_test ecl_coarse_test.c ) target_link_libraries( ecl_coarse_test ecl ) +add_test( ecl_coarse_test ${EXECUTABLE_OUTPUT_PATH}/ecl_coarse_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/LGCcase/LGC_TESTCASE2 ) + add_executable( ecl_restart_test ecl_restart_test.c ) target_link_libraries( ecl_restart_test ecl ) +add_test( ecl_restart_test ${EXECUTABLE_OUTPUT_PATH}/ecl_restart_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST ) + + add_executable( ecl_lgr_test ecl_lgr_test.c ) target_link_libraries( ecl_lgr_test ecl ) - -add_test( ecl_coarse_test ${EXECUTABLE_OUTPUT_PATH}/ecl_coarse_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/LGCcase/LGC_TESTCASE2 ) -add_test( ecl_restart_test ${EXECUTABLE_OUTPUT_PATH}/ecl_restart_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST ) add_test( ecl_lgr_test1 ${EXECUTABLE_OUTPUT_PATH}/ecl_lgr_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/10kcase/TEST10K_FLT_LGR_NNC.EGRID) add_test( ecl_lgr_test2 ${EXECUTABLE_OUTPUT_PATH}/ecl_lgr_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/10kcase/TEST10K_FLT_LGR_NNC.GRID) + +add_executable( ecl_grid_simple ecl_grid_simple.c ) +target_link_libraries( ecl_grid_simple ecl ) +add_test( ecl_grid_simple ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_simple ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID ) + + +add_executable( ecl_kw_grdecl ecl_kw_grdecl.c ) +target_link_libraries( ecl_kw_grdecl ecl ) +add_test( ecl_kw_grdecl ${EXECUTABLE_OUTPUT_PATH}/ecl_kw_grdecl ) + +add_executable( ecl_kw_equal ecl_kw_equal.c ) +target_link_libraries( ecl_kw_equal ecl ) +add_test( ecl_kw_equal ${EXECUTABLE_OUTPUT_PATH}/ecl_kw_equal ) + + +add_executable( ecl_dualp ecl_dualp.c ) +target_link_libraries( ecl_dualp ecl ) +add_test( ecl_dualp ${EXECUTABLE_OUTPUT_PATH}/ecl_dualp ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/LGCcase/LGC_TESTCASE2 ) + +add_executable( ecl_util_month_range ecl_util_month_range.c ) +target_link_libraries( ecl_util_month_range ecl ) +add_test( ecl_util_month_range ${EXECUTABLE_OUTPUT_PATH}/ecl_util_month_range ) + +add_executable( ecl_sum_test ecl_sum_test.c ) +target_link_libraries( ecl_sum_test ecl ) +add_test( ecl_sum_test ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE ) + +add_executable( ecl_rsthead ecl_rsthead.c ) +target_link_libraries( ecl_rsthead ecl ) +add_test( ecl_rsthead ${EXECUTABLE_OUTPUT_PATH}/ecl_rsthead ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST + ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/DualPoro/DUALPORO.X0005 ) + set_property( TEST ecl_coarse_test PROPERTY LABELS Statoil ) set_property( TEST ecl_restart_test PROPERTY LABELS Statoil ) set_property( TEST ecl_lgr_test1 PROPERTY LABELS Statoil ) set_property( TEST ecl_lgr_test2 PROPERTY LABELS Statoil ) +set_property( TEST ecl_grid_simple PROPERTY LABELS Statoil ) +set_property( TEST ecl_dualp PROPERTY LABELS Statoil ) +set_property( TEST ecl_sum_test PROPERTY LABELS Statoil ) diff --git a/ThirdParty/Ert/devel/libecl/tests/ecl_dualp.c b/ThirdParty/Ert/devel/libecl/tests/ecl_dualp.c new file mode 100644 index 0000000000..5b5da737f3 --- /dev/null +++ b/ThirdParty/Ert/devel/libecl/tests/ecl_dualp.c @@ -0,0 +1,76 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'ecl_dualp.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include + +#include + +#include +#include +#include +#include + +int main(int argc , char ** argv) { + const char * case_path = argv[1]; + char * grid_file = ecl_util_alloc_filename( NULL , case_path , ECL_EGRID_FILE , false , 0 ); + char * init_file = ecl_util_alloc_filename( NULL , case_path , ECL_INIT_FILE , false , 0 ); + char * rst_file = ecl_util_alloc_filename( NULL , case_path , ECL_RESTART_FILE , false , 0 ); + + ecl_grid_type * ecl_grid = ecl_grid_alloc( grid_file ); + ecl_file_type * RST_file = ecl_file_open( rst_file ); + ecl_file_type * INIT_file = ecl_file_open( init_file ); + ecl_file_type * GRID_file = ecl_file_open( grid_file ); + + { + ecl_kw_type * actnum = ecl_file_iget_named_kw( GRID_file , "ACTNUM" , 0 ); + ecl_kw_type * swat = ecl_file_iget_named_kw( RST_file , "SWAT" , 0 ); + ecl_kw_type * permx = ecl_file_iget_named_kw( INIT_file , "PERMX" , 0 ); + int fracture_size = ecl_grid_get_nactive_fracture( ecl_grid ); + int matrix_size = ecl_grid_get_nactive( ecl_grid ); + + test_assert_int_equal( fracture_size + matrix_size , ecl_kw_get_size( swat )); + test_assert_int_equal( fracture_size + matrix_size , ecl_kw_get_size( permx )); + + { + int gi; + int matrix_index = 0; + int fracture_index = 0; + + for (gi = 0; gi < ecl_grid_get_global_size( ecl_grid ); gi++) { + if (ecl_kw_iget_int( actnum , gi ) & ACTIVE_MATRIX) { + test_assert_int_equal( ecl_grid_get_active_index1( ecl_grid , gi ) , matrix_index); + test_assert_int_equal( ecl_grid_get_global_index1A( ecl_grid , matrix_index ) , gi); + matrix_index++; + } + + if (ecl_kw_iget_int( actnum , gi ) & ACTIVE_FRACTURE) { + test_assert_int_equal( ecl_grid_get_active_fracture_index1( ecl_grid , gi ) , fracture_index); + test_assert_int_equal( ecl_grid_get_global_index1F( ecl_grid , fracture_index ) , gi); + fracture_index++; + } + } + } + } + + + ecl_file_close( RST_file ); + ecl_file_close( INIT_file ); + ecl_grid_free( ecl_grid ); + + exit(0); +} diff --git a/ThirdParty/Ert/devel/libecl/tests/ecl_grid_simple.c b/ThirdParty/Ert/devel/libecl/tests/ecl_grid_simple.c new file mode 100644 index 0000000000..37bcbbf180 --- /dev/null +++ b/ThirdParty/Ert/devel/libecl/tests/ecl_grid_simple.c @@ -0,0 +1,36 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'ecl_grid_simple.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include + +#include + +#include + + + +int main(int argc , char ** argv) { + const char * grid_file = argv[1]; + ecl_grid_type * ecl_grid = ecl_grid_alloc( grid_file ); + + test_assert_int_equal( ecl_grid_get_nactive_fracture( ecl_grid ) , 0 ); + test_assert_int_equal( ecl_grid_get_active_fracture_index1( ecl_grid , 10 ) , -1 ); + + ecl_grid_free( ecl_grid ); + exit(0); +} diff --git a/ThirdParty/Ert/devel/libecl/tests/ecl_kw_equal.c b/ThirdParty/Ert/devel/libecl/tests/ecl_kw_equal.c new file mode 100644 index 0000000000..4ec147e84e --- /dev/null +++ b/ThirdParty/Ert/devel/libecl/tests/ecl_kw_equal.c @@ -0,0 +1,65 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'ecl_kw_equal.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include + +#include +#include +#include + + +int main(int argc , char ** argv) { + ecl_kw_type * ecl_kw1 = ecl_kw_alloc( "KW" , 10 , ECL_INT_TYPE ); + int data[10]; + int i; + for (i=0; i < 10; i++) { + ecl_kw_iset_int(ecl_kw1 , i , i ); + data[i] = i; + } + + { + ecl_kw_type * ecl_kw2 = ecl_kw_alloc_copy( ecl_kw1 ); + + test_assert_true( ecl_kw_equal( ecl_kw1 , ecl_kw2 )); + + ecl_kw_iset_int( ecl_kw2 , 1 , 77 ); + test_assert_false( ecl_kw_equal( ecl_kw1 , ecl_kw2 )); + ecl_kw_iset_int( ecl_kw2 , 1 , 1 ); + test_assert_true( ecl_kw_equal( ecl_kw1 , ecl_kw2 )); + + ecl_kw_set_header_name( ecl_kw2 , "TEST" ); + test_assert_false( ecl_kw_equal( ecl_kw1 , ecl_kw2 )); + test_assert_true( ecl_kw_content_equal( ecl_kw1 , ecl_kw2 )); + ecl_kw_free( ecl_kw2 ); + } + + { + ecl_kw_type * ecl_ikw = ecl_kw_alloc_new_shared( "KW" , 10 , ECL_INT_TYPE , data); + ecl_kw_type * ecl_fkw = ecl_kw_alloc_new_shared( "KW" , 10 , ECL_FLOAT_TYPE , data); + + test_assert_true( ecl_kw_content_equal( ecl_kw1 , ecl_ikw )); + test_assert_false( ecl_kw_content_equal( ecl_kw1 , ecl_fkw )); + } + + test_assert_true( ecl_kw_data_equal( ecl_kw1 , data )); + data[0] = 99; + test_assert_false( ecl_kw_data_equal( ecl_kw1 , data )); + + + +} diff --git a/ThirdParty/Ert/devel/libecl/tests/ecl_kw_grdecl.c b/ThirdParty/Ert/devel/libecl/tests/ecl_kw_grdecl.c new file mode 100644 index 0000000000..5b68d278eb --- /dev/null +++ b/ThirdParty/Ert/devel/libecl/tests/ecl_kw_grdecl.c @@ -0,0 +1,70 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'ecl_kw_grdecl.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include + +#include +#include +#include + +int main(int argc , char ** argv) { + int i; + ecl_kw_type * ecl_kw = ecl_kw_alloc("HEAD" , 10 , ECL_INT_TYPE); + + for (i=0; i < 10; i++) + ecl_kw_iset_int(ecl_kw , i , i ); + + { + FILE * stream = util_fopen( "FILE.grdecl" , "w"); + + ecl_kw_fprintf_grdecl(ecl_kw , stream ); + fclose(stream); + + stream = util_fopen( "FILE.grdecl" , "r"); + { + ecl_kw_type * ecl_kw2 = ecl_kw_fscanf_alloc_grdecl( stream , "HEAD" , 10 , ECL_INT_TYPE); + + test_assert_not_NULL( ecl_kw2 ); + test_assert_true( ecl_kw_equal( ecl_kw , ecl_kw2)); + ecl_kw_free( ecl_kw2 ); + } + fclose( stream ); + + stream = util_fopen( "FILE.grdecl" , "w"); + ecl_kw_fprintf_grdecl__(ecl_kw , "HEAD1234" , stream ); + fclose( stream ); + + stream = util_fopen( "FILE.grdecl" , "r"); + { + ecl_kw_type * ecl_kw2 = ecl_kw_fscanf_alloc_grdecl( stream , "HEAD" , 10 , ECL_INT_TYPE); + + test_assert_NULL( ecl_kw2 ); + ecl_kw2 = ecl_kw_fscanf_alloc_grdecl( stream , "HEAD1234" , 10 , ECL_INT_TYPE); + test_assert_not_NULL( ecl_kw2 ); + + test_assert_string_equal( ecl_kw_get_header( ecl_kw2 ) , "HEAD1234" ); + test_assert_true( ecl_kw_content_equal( ecl_kw , ecl_kw2 )); + ecl_kw_free( ecl_kw2 ); + } + fclose( stream ); + + } + ecl_kw_free( ecl_kw ); + + exit(0); +} diff --git a/ThirdParty/Ert/devel/libecl/tests/ecl_rsthead.c b/ThirdParty/Ert/devel/libecl/tests/ecl_rsthead.c new file mode 100644 index 0000000000..0c99f0fd6a --- /dev/null +++ b/ThirdParty/Ert/devel/libecl/tests/ecl_rsthead.c @@ -0,0 +1,108 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'ecl_rst_header.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include + +#include + +#include +#include +#include +#include +#include + + +void test_file( const char * filename , int occurence , bool exists , const ecl_rsthead_type * true_header) { + ecl_file_type * rst_file = ecl_file_open( filename ); + ecl_rsthead_type * rst_head = ecl_rsthead_ialloc( rst_file , occurence); + + if (exists) { + test_assert_not_NULL( rst_head ); + + if (occurence == 0) { + ecl_rsthead_type * rst_head0 = ecl_rsthead_alloc( rst_file ); + + test_assert_true( ecl_rsthead_equal( rst_head , rst_head0 )); + ecl_rsthead_free( rst_head0 ); + } + test_assert_true( ecl_rsthead_equal( rst_head , true_header )); + + ecl_rsthead_free( rst_head ); + } else + test_assert_NULL( rst_head ); + +} + + +int main(int argc , char ** argv) { + ecl_rsthead_type true1 = {.day = 1, + .year = 2000, + .month = 1, + .sim_time = (time_t) 946681200, + .version = 100, + .phase_sum = 7, + .nx = 40, + .ny = 64, + .nz = 14, + .nactive = 34770, + .nwells = 3, + .niwelz = 145, + .nzwelz = 3, + .niconz = 20, + .ncwmax = 120, + .nisegz = 18, + .nsegmx = 1, + .nswlmx = 1, + .nlbrmx = -1, + .nilbrz = -1, + .dualp = 0, + .sim_days = 0}; + + ecl_rsthead_type true2 = {.day = 22, + .year = 1990, + .month = 1, + .sim_time = (time_t) 632962800, + .version = 100, + .phase_sum = 7, + .nx = 4, + .ny = 4, + .nz = 4, + .nactive = 64, + .nwells = 3, + .niwelz = 147, + .nzwelz = 3, + .niconz = 20, + .ncwmax = 13, + .nisegz = 18, + .nsegmx = 1, + .nswlmx = 1, + .nlbrmx = -1, + .nilbrz = -1, + .dualp = 1, + .sim_days = 21}; + + const char * unified_file = argv[1]; + const char * Xfile = argv[2]; + + + test_file( unified_file , 0 , true , &true1 ); + test_file( unified_file , 100 , false , NULL ); + test_file( Xfile , 0 , true , &true2 ); + + exit(0); +} diff --git a/ThirdParty/Ert/devel/libecl/tests/ecl_sum_test.c b/ThirdParty/Ert/devel/libecl/tests/ecl_sum_test.c new file mode 100644 index 0000000000..beb85d875d --- /dev/null +++ b/ThirdParty/Ert/devel/libecl/tests/ecl_sum_test.c @@ -0,0 +1,66 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'ecl_sum_test.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include + +#include +#include +#include + +#include + + +void test_time_range( const ecl_sum_type * ecl_sum ) { + // Hardcoded Gurbat case values + time_t start = util_make_date( 1,1,2000); + time_t end = util_make_date( 31,12,2004 ); + + test_assert_time_t_equal( ecl_sum_get_start_time( ecl_sum ) , start ); + test_assert_time_t_equal( ecl_sum_get_end_time( ecl_sum ) , end ); + test_assert_time_t_equal( ecl_sum_get_data_start(ecl_sum) , start); +} + + +void test_days( const ecl_sum_type * ecl_sum ) { + time_t date1 = util_make_date( 1,1,2000); + time_t date2 = util_make_date( 31,12,2004 ); + time_t date3 = util_make_date( 2,1,2000 ); + + double days1 = ecl_sum_time2days( ecl_sum , date1 ); + double days2 = ecl_sum_time2days( ecl_sum , date2); + double days3 = ecl_sum_time2days( ecl_sum , date3 ); + + test_assert_double_equal( days1 , 0 ); + test_assert_double_equal( days2 , 1826 ); + test_assert_double_equal( days3 , 1 ); +} + + + + + +int main( int argc , char ** argv) { + const char * casename = argv[1]; + + ecl_sum_type * ecl_sum = ecl_sum_fread_alloc_case( casename , ":"); + + test_time_range( ecl_sum ); + test_days( ecl_sum ); + + exit(0); +} diff --git a/ThirdParty/Ert/devel/libecl/tests/ecl_util_month_range.c b/ThirdParty/Ert/devel/libecl/tests/ecl_util_month_range.c new file mode 100644 index 0000000000..f95c8ba6cf --- /dev/null +++ b/ThirdParty/Ert/devel/libecl/tests/ecl_util_month_range.c @@ -0,0 +1,124 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'ecl_util_month_range.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include + +#include +#include +#include + +#include + + + +void test_body( time_t_vector_type * date_list , int offset) { + int i; + for (i=offset; i < (time_t_vector_size( date_list ) - 1); i++) { + int month,year; + time_t current_date = time_t_vector_iget( date_list , i ); + test_assert_true( util_is_first_day_in_month( current_date )); + util_set_date_values( current_date , NULL , &month , &year); + if (i > offset) { + time_t prev_date = time_t_vector_iget( date_list , i - 1 ); + int prev_month , prev_year; + util_set_date_values( prev_date , NULL , &prev_month , &prev_year); + + if (prev_year == year) + test_assert_int_equal( month , prev_month + 1); + else { + test_assert_int_equal( month , 1); + test_assert_int_equal( prev_month , 12); + test_assert_int_equal( year - prev_year , 1); + } + } + test_assert_time_t_equal( current_date , util_make_pure_date( current_date )); + } +} + + +void test_append( const char * name , time_t_vector_type * date_list , time_t date1 , time_t date2, bool force_append_end) { + int offset = time_t_vector_size( date_list ); + + printf("%s ...",name); + fflush( stdout ); + + ecl_util_append_month_range( date_list , date1 , date2 , force_append_end); + + // The start: + test_assert_true( util_make_pure_date(date1) <= time_t_vector_iget( date_list , offset)); + + // The body: + test_body( date_list , offset ); + + // The tail: + if ( force_append_end ) + test_assert_time_t_equal( time_t_vector_get_last( date_list ) , util_make_pure_date(date2)); + else + test_assert_true( util_is_first_day_in_month( time_t_vector_get_last( date_list ))); + + + printf(" OK \n"); +} + + +void test_init( const char * name , time_t_vector_type * date_list , time_t start_date , time_t end_date) { + printf("%s ...",name); + fflush( stdout ); + { + ecl_util_init_month_range( date_list , start_date , end_date ); + test_assert_time_t_equal( time_t_vector_get_first( date_list ) , util_make_pure_date( start_date )); + test_body( date_list , 1 ); + test_assert_time_t_equal( time_t_vector_get_last( date_list ) , util_make_pure_date(end_date )); + } + printf(" OK \n"); +} + + +int main(int argc , char ** argv) { + time_t date1 = util_make_datetime(0,2,0,1,1,2000); + time_t date2 = util_make_datetime(0,3,0,1,1,2005); + time_t date3 = util_make_datetime(0,4,0,10,1,2000); + time_t date4 = util_make_datetime(0,5,0,10,1,2005); + + + + { + time_t_vector_type * date_list = time_t_vector_alloc(0 ,0 ); + test_append( "Append Test1" , date_list , date1 , date2 , true); + test_append( "Append Test2" , date_list , date1 , date2 , false); + test_append( "Append Test3" , date_list , date1 , date4 , true); + test_append( "Append Test4" , date_list , date1 , date4 , false); + test_append( "Append Test5" , date_list , date3 , date2 , true); + test_append( "Append Test6" , date_list , date3 , date2 , false); + test_append( "Append Test7" , date_list , date3 , date4 , true); + test_append( "Append Test8" , date_list , date3 , date4 , false); + time_t_vector_free( date_list ); + } + { + time_t_vector_type * date_list = time_t_vector_alloc(0 ,0 ); + + test_init( "Init Test1" , date_list , date1 , date2 ); + test_init( "Init Test2" , date_list , date1 , date4 ); + test_init( "Init Test3" , date_list , date3 , date2 ); + test_init( "Init Test4" , date_list , date3 , date4 ); + + time_t_vector_free( date_list ); + } + + exit(0); +} diff --git a/ThirdParty/Ert/devel/libecl_well/CMakeLists.txt b/ThirdParty/Ert/devel/libecl_well/CMakeLists.txt index c5e65c48a3..3edab07684 100644 --- a/ThirdParty/Ert/devel/libecl_well/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libecl_well/CMakeLists.txt @@ -3,6 +3,6 @@ if (BUILD_APPLICATONS) add_subdirectory( applications ) endif() -#if (BUILD_TESTS) -# add_subdirectory( tests ) -#endif() +if (BUILD_TESTS) + add_subdirectory( tests ) +endif() diff --git a/ThirdParty/Ert/devel/libecl_well/applications/CMakeLists.txt b/ThirdParty/Ert/devel/libecl_well/applications/CMakeLists.txt index b7fb0639dc..4e4b78d7d6 100644 --- a/ThirdParty/Ert/devel/libecl_well/applications/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libecl_well/applications/CMakeLists.txt @@ -12,9 +12,11 @@ foreach(prog ${program_list}) set (destination ${CMAKE_INSTALL_PREFIX}/bin) endif() - install(TARGETS ${prog} DESTINATION ${destination}) - if (INSTALL_GROUP) - install(CODE "EXECUTE_PROCESS(COMMAND chgrp ${INSTALL_GROUP} ${destination}/${prog})") - install(CODE "EXECUTE_PROCESS(COMMAND chmod g+w ${destination}/${prog})") + if (INSTALL_ERT) + install(TARGETS ${prog} DESTINATION ${destination}) + if (INSTALL_GROUP) + install(CODE "EXECUTE_PROCESS(COMMAND chgrp ${INSTALL_GROUP} ${destination}/${prog})") + install(CODE "EXECUTE_PROCESS(COMMAND chmod g+w ${destination}/${prog})") + endif() endif() endforeach() diff --git a/ThirdParty/Ert/devel/libecl_well/applications/well_info_test.c b/ThirdParty/Ert/devel/libecl_well/applications/well_info_test.c index b66fd9e66d..a6f368c206 100644 --- a/ThirdParty/Ert/devel/libecl_well/applications/well_info_test.c +++ b/ThirdParty/Ert/devel/libecl_well/applications/well_info_test.c @@ -23,7 +23,6 @@ #include #include -#include #include #include #include diff --git a/ThirdParty/Ert/devel/libecl_well/include/ert/ecl_well/well_conn.h b/ThirdParty/Ert/devel/libecl_well/include/ert/ecl_well/well_conn.h index d4b56920ba..f6b1194cca 100644 --- a/ThirdParty/Ert/devel/libecl_well/include/ert/ecl_well/well_conn.h +++ b/ThirdParty/Ert/devel/libecl_well/include/ert/ecl_well/well_conn.h @@ -27,7 +27,7 @@ extern "C" { #include -#include +#include typedef enum { well_conn_dirX = 1, @@ -43,8 +43,8 @@ extern "C" { void well_conn_free( well_conn_type * conn); void well_conn_free__( void * arg ); - well_conn_type * well_conn_alloc( const ecl_kw_type * icon_kw , const ecl_kw_type * iseg_kw , const ecl_intehead_type * header , int well_nr , int seg_well_nr , int conn_nr); - well_conn_type * well_conn_alloc_wellhead( const ecl_kw_type * iwel_kw , const ecl_intehead_type * header , int well_nr); + well_conn_type * well_conn_alloc( const ecl_kw_type * icon_kw , const ecl_kw_type * iseg_kw , const ecl_rsthead_type * header , int well_nr , int seg_well_nr , int conn_nr); + well_conn_type * well_conn_alloc_wellhead( const ecl_kw_type * iwel_kw , const ecl_rsthead_type * header , int well_nr); int well_conn_get_branch(const well_conn_type * conn); int well_conn_get_i(const well_conn_type * conn); @@ -53,6 +53,8 @@ extern "C" { well_conn_dir_enum well_conn_get_dir(const well_conn_type * conn); bool well_conn_open( const well_conn_type * conn ); int well_conn_get_segment( const well_conn_type * conn ); + bool well_conn_fracture_connection( const well_conn_type * conn); + bool well_conn_matrix_connection( const well_conn_type * conn); #ifdef __cplusplus } diff --git a/ThirdParty/Ert/devel/libecl_well/include/ert/ecl_well/well_state.h b/ThirdParty/Ert/devel/libecl_well/include/ert/ecl_well/well_state.h index 423e57c40c..0db96bc313 100644 --- a/ThirdParty/Ert/devel/libecl_well/include/ert/ecl_well/well_state.h +++ b/ThirdParty/Ert/devel/libecl_well/include/ert/ecl_well/well_state.h @@ -27,7 +27,6 @@ extern "C" { #include #include -#include #include #include diff --git a/ThirdParty/Ert/devel/libecl_well/src/CMakeLists.txt b/ThirdParty/Ert/devel/libecl_well/src/CMakeLists.txt index fda632db5c..59182ea3c8 100644 --- a/ThirdParty/Ert/devel/libecl_well/src/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libecl_well/src/CMakeLists.txt @@ -10,10 +10,11 @@ set_target_properties( ecl_well PROPERTIES VERSION 1.0 SOVERSION 1.0 ) target_link_libraries( ecl_well ecl ) #----------------------------------------------------------------- -install(TARGETS ecl_well DESTINATION ${CMAKE_INSTALL_LIBDIR}) -foreach(header ${header_files}) - install(FILES ../include/ert/ecl_well/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/ecl_well) -endforeach() - +if (INSTALL_ERT) + install(TARGETS ecl_well DESTINATION ${CMAKE_INSTALL_LIBDIR}) + foreach(header ${header_files}) + install(FILES ../include/ert/ecl_well/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/ecl_well) + endforeach() +endif() diff --git a/ThirdParty/Ert/devel/libecl_well/src/well_conn.c b/ThirdParty/Ert/devel/libecl_well/src/well_conn.c index bd733d09a1..0d10cd786d 100644 --- a/ThirdParty/Ert/devel/libecl_well/src/well_conn.c +++ b/ThirdParty/Ert/devel/libecl_well/src/well_conn.c @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -37,7 +38,8 @@ struct well_conn_struct { int k; well_conn_dir_enum dir; bool open; - int segment; // -1: Ordinary well + int segment; // -1: Ordinary well + bool matrix_connection; // k >= nz => fracture (and k -= nz ) /*-----------------------------------------------------------------*/ /* If the segment field == -1 - i.e. an ordinary well, the outlet_segment is rubbish and should not be consulted. @@ -47,10 +49,23 @@ struct well_conn_struct { }; +static void well_conn_set_k( well_conn_type * conn , const ecl_rsthead_type * header , int icon_k) { + conn->k = icon_k; + conn->matrix_connection = true; + + if (header->dualp) { + int geometric_nz = header->nz / 2; + if (icon_k >= geometric_nz) { + conn->k -= geometric_nz; + conn->matrix_connection = false; + } + } +} -well_conn_type * well_conn_alloc_wellhead( const ecl_kw_type * iwel_kw , const ecl_intehead_type * header , int well_nr) { + +well_conn_type * well_conn_alloc_wellhead( const ecl_kw_type * iwel_kw , const ecl_rsthead_type * header , int well_nr) { const int iwel_offset = header->niwelz * well_nr; int conn_i = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_HEADI_ITEM ); @@ -59,8 +74,11 @@ well_conn_type * well_conn_alloc_wellhead( const ecl_kw_type * iwel_kw , const e conn->i = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_HEADI_ITEM ) - 1; conn->j = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_HEADJ_ITEM ) - 1; - conn->k = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_HEADK_ITEM ) - 1; - + { + int icon_k = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_HEADK_ITEM ) - 1; + well_conn_set_k( conn , header , icon_k); + } + conn->open = true; // This is not really specified anywhere. conn->branch = 0; conn->segment = 0; @@ -72,12 +90,16 @@ well_conn_type * well_conn_alloc_wellhead( const ecl_kw_type * iwel_kw , const e } -static well_conn_type * well_conn_alloc__( const ecl_kw_type * icon_kw , int icon_offset) { +static well_conn_type * well_conn_alloc__( const ecl_kw_type * icon_kw , const ecl_rsthead_type * header , int icon_offset) { well_conn_type * conn = util_malloc( sizeof * conn ); conn->i = ecl_kw_iget_int( icon_kw , icon_offset + ICON_I_ITEM ) - 1; conn->j = ecl_kw_iget_int( icon_kw , icon_offset + ICON_J_ITEM ) - 1; - conn->k = ecl_kw_iget_int( icon_kw , icon_offset + ICON_K_ITEM ) - 1; + { + int icon_k = ecl_kw_iget_int( icon_kw , icon_offset + ICON_K_ITEM ) - 1; + well_conn_set_k( conn , header , icon_k); + } + conn->segment = ecl_kw_iget_int( icon_kw , icon_offset + ICON_SEGMENT_ITEM ) - 1; conn->outlet_segment = -999; @@ -91,7 +113,7 @@ static well_conn_type * well_conn_alloc__( const ecl_kw_type * icon_kw , int ico */ well_conn_type * well_conn_alloc( const ecl_kw_type * icon_kw , const ecl_kw_type * iseg_kw , - const ecl_intehead_type * header , + const ecl_rsthead_type * header , int well_nr , int seg_well_nr , int conn_nr ) { @@ -99,7 +121,7 @@ well_conn_type * well_conn_alloc( const ecl_kw_type * icon_kw , const int icon_offset = header->niconz * ( header->ncwmax * well_nr + conn_nr ); int IC = ecl_kw_iget_int( icon_kw , icon_offset + ICON_IC_ITEM ); if (IC > 0) { - well_conn_type * conn = well_conn_alloc__( icon_kw , icon_offset ); + well_conn_type * conn = well_conn_alloc__( icon_kw , header , icon_offset ); { int int_status = ecl_kw_iget_int( icon_kw , icon_offset + ICON_STATUS_ITEM ); if (int_status > 0) @@ -204,4 +226,11 @@ int well_conn_get_segment( const well_conn_type * conn ) { return conn->segment; } +bool well_conn_fracture_connection( const well_conn_type * conn) { + return !conn->matrix_connection; +} + +bool well_conn_matrix_connection( const well_conn_type * conn) { + return conn->matrix_connection; +} diff --git a/ThirdParty/Ert/devel/libecl_well/src/well_info.c b/ThirdParty/Ert/devel/libecl_well/src/well_info.c index 37eb6a036a..6bbf38d48f 100644 --- a/ThirdParty/Ert/devel/libecl_well/src/well_info.c +++ b/ThirdParty/Ert/devel/libecl_well/src/well_info.c @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include #include @@ -287,14 +287,14 @@ static void well_info_add_state( well_info_type * well_info , well_state_type * */ void well_info_add_wells( well_info_type * well_info , ecl_file_type * rst_file , int report_nr) { - ecl_intehead_type * global_header = ecl_intehead_alloc( ecl_file_iget_named_kw( rst_file , INTEHEAD_KW , 0 )); + ecl_rsthead_type * global_header = ecl_rsthead_alloc( rst_file ); int well_nr; for (well_nr = 0; well_nr < global_header->nwells; well_nr++) { well_state_type * well_state = well_state_alloc( rst_file , report_nr , well_nr ); if (well_state != NULL) well_info_add_state( well_info , well_state ); } - ecl_intehead_free( global_header ); + ecl_rsthead_free( global_header ); } /** diff --git a/ThirdParty/Ert/devel/libecl_well/src/well_state.c b/ThirdParty/Ert/devel/libecl_well/src/well_state.c index dc855b7883..cd7cadf552 100644 --- a/ThirdParty/Ert/devel/libecl_well/src/well_state.c +++ b/ThirdParty/Ert/devel/libecl_well/src/well_state.c @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include #include @@ -96,7 +96,7 @@ well_path_type * well_state_add_path( well_state_type * well_state , const ecl_f } -void well_state_add_wellhead( well_state_type * well_state , const ecl_intehead_type * header , const ecl_kw_type * iwel_kw , int well_nr , const char * grid_name , int grid_nr) { +void well_state_add_wellhead( well_state_type * well_state , const ecl_rsthead_type * header , const ecl_kw_type * iwel_kw , int well_nr , const char * grid_name , int grid_nr) { well_conn_type * wellhead = well_conn_alloc_wellhead( iwel_kw , header , well_nr ); if (wellhead != NULL) { @@ -113,7 +113,7 @@ void well_state_add_wellhead( well_state_type * well_state , const ecl_intehead_ */ static void well_state_add_connections( well_state_type * well_state , const ecl_file_type * rst_file , int grid_nr, int well_nr ) { - ecl_intehead_type * header = ecl_intehead_alloc( ecl_file_iget_named_kw( rst_file , INTEHEAD_KW , 0 )); + ecl_rsthead_type * header = ecl_rsthead_alloc( rst_file ); const ecl_kw_type * icon_kw = ecl_file_iget_named_kw( rst_file , ICON_KW , 0); const ecl_kw_type * iwel_kw = ecl_file_iget_named_kw( rst_file , IWEL_KW , 0); const int iwel_offset = header->niwelz * well_nr; @@ -152,7 +152,7 @@ static void well_state_add_connections( well_state_type * well_state , const ec well_path_add_conn( path , conn ); } } - ecl_intehead_free( header ); + ecl_rsthead_free( header ); } /* @@ -167,6 +167,7 @@ static int well_state_get_lgr_well_nr( const well_state_type * well_state , cons int well_nr = -1; if (ecl_file_has_kw( ecl_file , ZWEL_KW)) { + ecl_rsthead_type * header = ecl_rsthead_alloc( ecl_file ); // const ecl_kw_type * zwel_kw = ecl_file_iget_named_kw( ecl_file , ZWEL_KW , 0); int num_wells = ecl_kw_get_size( zwel_kw ); well_nr = 0; @@ -174,7 +175,8 @@ static int well_state_get_lgr_well_nr( const well_state_type * well_state , cons bool found = false; { - char * lgr_well_name = util_alloc_strip_copy( ecl_kw_iget_ptr( zwel_kw , well_nr) ); + char * lgr_well_name = util_alloc_strip_copy( ecl_kw_iget_ptr( zwel_kw , well_nr * header->nzwelz) ); + if ( strcmp( well_state->name , lgr_well_name) == 0) found = true; else @@ -189,7 +191,9 @@ static int well_state_get_lgr_well_nr( const well_state_type * well_state , cons well_nr = -1; break; } + } + ecl_rsthead_free( header ); } return well_nr; } @@ -197,8 +201,8 @@ static int well_state_get_lgr_well_nr( const well_state_type * well_state , cons well_state_type * well_state_alloc( ecl_file_type * ecl_file , int report_nr , int global_well_nr) { if (ecl_file_has_kw( ecl_file , IWEL_KW)) { - well_state_type * well_state = NULL; - ecl_intehead_type * global_header = ecl_intehead_alloc( ecl_file_iget_named_kw( ecl_file , INTEHEAD_KW , 0 )); + well_state_type * well_state = NULL; + ecl_rsthead_type * global_header = ecl_rsthead_alloc( ecl_file ); const ecl_kw_type * global_iwel_kw = ecl_file_iget_named_kw( ecl_file , IWEL_KW , 0); const ecl_kw_type * global_zwel_kw = ecl_file_iget_named_kw( ecl_file , ZWEL_KW , 0); @@ -263,7 +267,6 @@ well_state_type * well_state_alloc( ecl_file_type * ecl_file , int report_nr , ecl_file_subselect_block( ecl_file , LGR_KW , lgr_nr ); // { // Restrict the file view int well_nr = well_state_get_lgr_well_nr( well_state , ecl_file); // to one LGR block. - // if (well_nr >= 0) // well_state_add_connections( well_state , ecl_file , lgr_nr + 1, well_nr ); // } // @@ -272,7 +275,7 @@ well_state_type * well_state_alloc( ecl_file_type * ecl_file , int report_nr , } } } - ecl_intehead_free( global_header ); + ecl_rsthead_free( global_header ); return well_state; } else /* This seems a bit weird - have come over E300 restart files without the IWEL keyword. */ diff --git a/ThirdParty/Ert/devel/libecl_well/src/well_ts.c b/ThirdParty/Ert/devel/libecl_well/src/well_ts.c index 8604aff2e0..dbf15442d5 100644 --- a/ThirdParty/Ert/devel/libecl_well/src/well_ts.c +++ b/ThirdParty/Ert/devel/libecl_well/src/well_ts.c @@ -101,6 +101,7 @@ static well_node_type * well_node_alloc( well_state_type * well_state) { static UTIL_SAFE_CAST_FUNCTION( well_node , WELL_NODE_TYPE_ID ) +static UTIL_SAFE_CAST_FUNCTION_CONST( well_node , WELL_NODE_TYPE_ID ) static void well_node_free( well_node_type * well_node ) { @@ -113,6 +114,20 @@ static void well_node_free__( void * arg ) { well_node_free( node ); } +static int well_node_time_cmp( const void * arg1 , const void * arg2) { + const well_node_type * node1 = well_node_safe_cast_const( arg1 ); + const well_node_type * node2 = well_node_safe_cast_const( arg2 ); + + if (node1->sim_time < node2->sim_time) + return -1; + else if (node1->sim_time == node2->sim_time) + return 0; + else + return 1; + +} + + /*****************************************************************/ static well_ts_type * well_ts_alloc_empty( ) { @@ -144,13 +159,13 @@ static int well_ts_get_index__( const well_ts_type * well_ts , int report_step , if (use_report) { if (report_step < first_node->report_nr) - return 0; // Before the start + return -1; // Before the start if (report_step >= last_node->report_nr) return size - 1; // After end } else { if (sim_time < first_node->sim_time) - return 0; // Before the start + return -1; // Before the start if (sim_time >= last_node->sim_time) return size - 1; // After end @@ -247,33 +262,15 @@ static int well_ts_get_index( const well_ts_type * well_ts , int report_step , t void well_ts_add_well( well_ts_type * well_ts , well_state_type * well_state ) { well_node_type * new_node = well_node_alloc( well_state ); + vector_append_owned_ref( well_ts->ts , new_node , well_node_free__ ); - if (vector_get_size( well_ts->ts ) == 0) - // The first element in the vector - vector_append_owned_ref( well_ts->ts , new_node , well_node_free__ ); - else { + if (vector_get_size( well_ts->ts ) > 1) { const well_node_type * last_node = vector_get_last_const(well_ts->ts ); - if (new_node->sim_time > last_node->sim_time) - // This is the fast path which will apply when the well_state objects - // are added in a time-ordered fashion. - vector_append_owned_ref( well_ts->ts , new_node , well_node_free__ ); - else { - // Use binary search through the vector to determine the - // new location - int index = well_ts_get_index( well_ts , new_node->report_nr , -1 , true); - if (index < 0) - index = 0; - - { - const well_node_type * exnode = vector_iget_const( well_ts->ts , index ); - if (exnode->report_nr == new_node->report_nr) - // Replace the exsisting node - vector_iset_owned_ref( well_ts->ts , index , new_node , well_node_free__ ); - else - // Insert a new node - pushing the existing to the right. - vector_insert_owned_ref( well_ts->ts , index , new_node , well_node_free__ ); - } - } + if (new_node->sim_time < last_node->sim_time) + // The new node is chronologically before the previous node; + // i.e. we must sort the nodes in time. This should probably happen + // quite seldom: + vector_sort( well_ts->ts , well_node_time_cmp ); } } diff --git a/ThirdParty/Ert/devel/libecl_well/tests/CMakeLists.txt b/ThirdParty/Ert/devel/libecl_well/tests/CMakeLists.txt new file mode 100644 index 0000000000..27427e453c --- /dev/null +++ b/ThirdParty/Ert/devel/libecl_well/tests/CMakeLists.txt @@ -0,0 +1,16 @@ +add_executable( well_ts well_ts.c ) +target_link_libraries( well_ts ecl_well ) +add_test( well_ts ${EXECUTABLE_OUTPUT_PATH}/well_ts ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/CO2case/BASE_CASE ) +set_property( TEST well_ts PROPERTY LABELS Statoil ) + + +add_executable( well_dualp well_dualp.c ) +target_link_libraries( well_dualp ecl_well ) +add_test( well_dualp ${EXECUTABLE_OUTPUT_PATH}/well_dualp ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST + ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/DualPoro/DUALPORO.X0005 ) + + +add_executable( well_lgr_load well_lgr_load.c ) +target_link_libraries( well_lgr_load ecl_well ) +add_test( well_lgr_load ${EXECUTABLE_OUTPUT_PATH}/well_lgr_load ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/0.9.2_LGR/BASE_REF_XY3Z1_T30_WI.X0003) +set_property( TEST well_lgr_load PROPERTY LABELS Statoil ) diff --git a/ThirdParty/Ert/devel/libecl_well/tests/well_dualp.c b/ThirdParty/Ert/devel/libecl_well/tests/well_dualp.c new file mode 100644 index 0000000000..cfe901c298 --- /dev/null +++ b/ThirdParty/Ert/devel/libecl_well/tests/well_dualp.c @@ -0,0 +1,65 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'well_dualp.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include + +#include +#include +#include + +#include +#include +#include +#include + +#include + + +void test_rstfile( const char * filename , bool fracture_connection) { + ecl_file_type * rst_file = ecl_file_open( filename ); + const ecl_kw_type * iwel_kw = ecl_file_iget_named_kw( rst_file , IWEL_KW , 0); + ecl_rsthead_type * header = ecl_rsthead_alloc( rst_file ); + + well_conn_type * wellhead = well_conn_alloc_wellhead( iwel_kw , header , 0 ); + + if (fracture_connection) { + test_assert_true( well_conn_fracture_connection( wellhead )); + test_assert_false( well_conn_matrix_connection( wellhead )); + } else { + test_assert_false( well_conn_fracture_connection( wellhead )); + test_assert_true( well_conn_matrix_connection( wellhead )); + } + + test_assert_true( well_conn_get_k( wellhead ) < header->nz ); + + ecl_rsthead_free( header ); + well_conn_free( wellhead ); + ecl_file_close( rst_file ); +} + + +int main(int argc , char ** argv) { + const char * matrix_rstfile = argv[1]; + const char * fracture_rstfile = argv[2]; + + test_rstfile( fracture_rstfile , true); + test_rstfile( matrix_rstfile , false ); + + exit(0); +} diff --git a/ThirdParty/Ert/devel/libecl_well/tests/well_lgr_load.c b/ThirdParty/Ert/devel/libecl_well/tests/well_lgr_load.c new file mode 100644 index 0000000000..d3a3b477c6 --- /dev/null +++ b/ThirdParty/Ert/devel/libecl_well/tests/well_lgr_load.c @@ -0,0 +1,66 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'well_lgr_load.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + + + +int main( int argc , char ** argv) { + signal(SIGSEGV , util_abort_signal); /* Segmentation violation, i.e. overwriting memory ... */ + signal(SIGTERM , util_abort_signal); /* If killing the enkf program with SIGTERM (the default kill signal) you will get a backtrace. + Killing with SIGKILL (-9) will not give a backtrace.*/ + signal(SIGABRT , util_abort_signal); /* Signal abort. */ + { + well_info_type * well_info = well_info_alloc( NULL ); + int i; + for (i=1; i < argc; i++) { + printf("Loading file: %s \n",argv[i]); + well_info_load_rstfile( well_info , argv[i]); + } + + // List all wells: + { + int iwell; + for (iwell = 0; iwell < well_info_get_num_wells( well_info ); iwell++) { + well_ts_type * well_ts = well_info_get_ts( well_info , well_info_iget_well_name( well_info , iwell)); + well_state_type * well_state = well_ts_get_last_state( well_ts ); + + well_state_summarize( well_state , stdout ); + printf("\n"); + } + } + well_info_free( well_info ); + } + + exit(0); +} diff --git a/ThirdParty/Ert/devel/libecl_well/tests/well_ts.c b/ThirdParty/Ert/devel/libecl_well/tests/well_ts.c new file mode 100644 index 0000000000..33b1d4c0fb --- /dev/null +++ b/ThirdParty/Ert/devel/libecl_well/tests/well_ts.c @@ -0,0 +1,71 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'well_ts.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include + +#include +#include +#include + +#include + +#include + + +int main(int argc , char ** argv) { + const char * case_path = argv[1]; + stringlist_type * file_list = stringlist_alloc_new( ); + ecl_util_select_filelist( NULL , case_path , ECL_RESTART_FILE , false , file_list); + + printf("Searching in:%s \n",case_path); + test_assert_int_equal( 4 , stringlist_get_size( file_list )); + stringlist_sort( file_list , (string_cmp_ftype *) util_strcmp_int ); + + + { + int i; + for (i=0; i < stringlist_get_size( file_list); i++) { + char * ext; + char * target_ext = util_alloc_sprintf("X%04d" , i); + util_alloc_file_components( stringlist_iget( file_list , i ) , NULL , NULL , &ext); + + test_assert_string_equal( ext , target_ext); + free( ext ); + free( target_ext ); + } + } + { + well_info_type * well_info = well_info_alloc( NULL ); + int i; + for (i=0; i < stringlist_get_size( file_list ); i++) + well_info_load_rstfile( well_info , stringlist_iget(file_list , i)); + well_info_free( well_info ); + } + + { + well_info_type * well_info = well_info_alloc( NULL ); + int i; + stringlist_reverse( file_list ); + for (i=0; i < stringlist_get_size( file_list ); i++) + well_info_load_rstfile( well_info , stringlist_iget(file_list , i)); + well_info_free( well_info ); + } + + + exit(0); +} diff --git a/ThirdParty/Ert/devel/libenkf/CMakeLists.txt b/ThirdParty/Ert/devel/libenkf/CMakeLists.txt index 9db4a4c5e8..d6f06317db 100644 --- a/ThirdParty/Ert/devel/libenkf/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libenkf/CMakeLists.txt @@ -1,6 +1,5 @@ add_subdirectory( src ) add_subdirectory( applications/ert_tui ) - -#if (BUILD_TESTS) -# add_subdirectory( tests ) -#endif() +if (BUILD_TESTS) + add_subdirectory( tests ) +endif() diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/bin/gert b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/bin/gert index 8259885d13..b7878a3c89 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/bin/gert +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/bin/gert @@ -1,58 +1,14 @@ #!/bin/bash - - -if [ -z "$1" ] -then - echo - echo "A configuration file must be specified, or if you want to create a new" - echo "configuration: enter the path to the new (non-existing) configuration file." - echo " ertgui.sh ert_configuration_file" - echo - echo "Options (for debugging):" - echo " gert debug ert_configuration_file" - echo " gert strace ert_configuration_file" - echo " gert local .... will use the Python code in your working copy" - echo - exit -fi - -# -# setup the SDP environment -# export ERT_SITE_CONFIG=/project/res/etc/ERT/site-config -export QT_EXPERIMENTAL=1 -export PYTHON_EXPERIMENTAL=1 -source /project/res/SDP_bashrc > /dev/null -set PYTHON=2.4 ; source /prog/sdpsoft/environment.sh > /dev/null +BASEDIR=$(dirname $0) +export PYTHONPATH=~/ert/ert/devel/python/python:$BASEDIR/../lib:$PYTHONPATH +export GERT_SHARE_PATH=$BASEDIR/../share +export LD_LIBRARY_PATH=~/ert/ert/build/lib64:$LD_LIBRARY_PATH +ert_gui_dir=$BASEDIR/../lib/ert_gui/ -export ERT_LD_PATH=$SDP_BINDIST/lib/python/lib - -ORIGINAL_DIRECTORY=$PWD - -if [ "$1" = "local" ] -then - # The user has given "local" as the first argument, meaning that we should - # run based on Python code in the users current working directory, and not - # the centraly installed code. - BASEDIR=$(dirname $0) - export ert_gui_dir=$BASEDIR/../ - shift -else - export ert_gui_dir=$SDP_BINDIST/lib/python/gert -fi echo "Loading python GUI code from.......:" $ert_gui_dir echo "-----------------------------------------------------------------" -if [ "$1" = "debug" ] -then - export CONFIG_FILE="$2" - gdb python --command=$ert_gui_dir/bin/gdbcommands -elif [ "$1" = "strace" ] -then - strace -e trace=file python $ert_gui_dir/code/main.py "$2" -else - python $ert_gui_dir/code/main.py "$1" -fi +python $ert_gui_dir/gert_main.py "$1" -cd "$ORIGINAL_DIRECTORY" diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/gert_main.py b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/gert_main.py index 8ee008e0fc..828d8f4483 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/gert_main.py +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/gert_main.py @@ -114,6 +114,8 @@ from PyQt4 import QtGui, QtCore import sys import os +from ert.ert.ertwrapper import ErtWrapper + import ert_gui.widgets.util import ert_gui.widgets.help ert_gui.widgets.help.help_prefix = os.getenv("GERT_SHARE_PATH")+ "/help/" @@ -130,7 +132,6 @@ from ert_gui.pages.init.initpanel import InitPanel from ert_gui.pages.run.runpanel import RunPanel from ert_gui.pages.config.configpages import ConfigPages from ert_gui.pages.plot.plotpanel import PlotPanel -from ert.ertwrapper import ErtWrapper from ert_gui.widgets.helpedwidget import ContentModel from ert_gui.widgets.util import resourceImage, resourceIcon @@ -186,7 +187,7 @@ window.setSaveFunction(ert.save) splash.showMessage("Creating GUI...", color=QtCore.Qt.white) app.processEvents() -window.addPage("Configuration", resourceIcon("config"), ConfigPages(window)) +#window.addPage("Configuration", resourceIcon("config"), ConfigPages(window)) window.addPage("Init", resourceIcon("db"), InitPanel(window)) window.addPage("Run", resourceIcon("run"), RunPanel(window)) window.addPage("Plots", resourceIcon("plot"), PlotPanel()) diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/analysis.py b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/analysis.py index da2e6697c6..1a6d312eb4 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/analysis.py +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/analysis.py @@ -19,41 +19,30 @@ # Analysis tab # ---------------------------------------------------------------------------------------------- from ert_gui.widgets.checkbox import CheckBox -import ert.ertwrapper as ertwrapper from ert_gui.widgets.spinnerwidgets import IntegerSpinner, DoubleSpinner, DoubleSpinner import ert_gui.widgets.tablewidgets from ert_gui.widgets.pathchooser import PathChooser from ert_gui.widgets.combochoice import ComboChoice from PyQt4 import QtGui +import ert.enkf def createAnalysisPage(configPanel, parent): configPanel.startPage("Analysis") r = configPanel.addRow(CheckBox(parent, "ENKF rerun", "config/analysis/enkf_rerun", "Perform rerun")) - r.initialize = lambda ert : [ert.prototype("int analysis_config_get_rerun(long)"), - ert.prototype("void analysis_config_set_rerun(long, bool)")] r.getter = lambda ert : ert.enkf.analysis_config_get_rerun(ert.analysis_config) r.setter = lambda ert, value : ert.enkf.analysis_config_set_rerun(ert.analysis_config, value) r = configPanel.addRow(IntegerSpinner(parent, "Rerun start", "config/analysis/rerun_start", 0, 100000)) - r.initialize = lambda ert : [ert.prototype("int analysis_config_get_rerun_start(long)"), - ert.prototype("void analysis_config_set_rerun_start(long, int)")] r.getter = lambda ert : ert.enkf.analysis_config_get_rerun_start(ert.analysis_config) r.setter = lambda ert, value : ert.enkf.analysis_config_set_rerun_start(ert.analysis_config, value) r = configPanel.addRow(PathChooser(parent, "ENKF schedule file", "config/analysis/enkf_sched_file")) - r.initialize = lambda ert : [ert.prototype("char* model_config_get_enkf_sched_file(long)"), - ert.prototype("long enkf_main_get_model_config(long)"), - ert.prototype("void model_config_set_enkf_sched_file(long, char*)")] r.getter = lambda ert : ert.enkf.model_config_get_enkf_sched_file(ert.enkf.enkf_main_get_model_config(ert.main)) r.setter = lambda ert, value : ert.enkf.model_config_set_enkf_sched_file(ert.enkf.enkf_main_get_model_config(ert.main), str(value)) r = configPanel.addRow(ert_gui.widgets.tablewidgets.KeywordList(parent, "Local config", "config/analysis/local_config")) r.newKeywordPopup = lambda list : QtGui.QFileDialog.getOpenFileName(r, "Select a path", "") - r.initialize = lambda ert : [ert.prototype("long local_config_get_config_files(long)"), - ert.prototype("long enkf_main_get_local_config(long)"), - ert.prototype("void local_config_clear_config_files(long)"), - ert.prototype("void local_config_add_config_file(long, char*)")] def get_local_config_files(ert): local_config = ert.enkf.enkf_main_get_local_config(ert.main) @@ -72,8 +61,6 @@ def createAnalysisPage(configPanel, parent): r.setter = add_config_file r = configPanel.addRow(PathChooser(parent, "Update log", "config/analysis/update_log")) - r.initialize = lambda ert : [ert.prototype("char* analysis_config_get_log_path(long)"), - ert.prototype("void analysis_config_set_log_path(long, char*)")] r.getter = lambda ert : ert.enkf.analysis_config_get_log_path(ert.analysis_config) r.setter = lambda ert, value : ert.enkf.analysis_config_set_log_path(ert.analysis_config, str(value)) @@ -81,14 +68,10 @@ def createAnalysisPage(configPanel, parent): configPanel.startGroup("EnKF") r = configPanel.addRow(DoubleSpinner(parent, "Alpha", "config/analysis/enkf_alpha", 0, 100000, 2)) - r.initialize = lambda ert : [ert.prototype("double analysis_config_get_alpha(long)"), - ert.prototype("void analysis_config_set_alpha(long, double)")] r.getter = lambda ert : ert.enkf.analysis_config_get_alpha(ert.analysis_config) r.setter = lambda ert, value : ert.enkf.analysis_config_set_alpha(ert.analysis_config, value) r = configPanel.addRow(CheckBox(parent, "Merge Observations", "config/analysis/enkf_merge_observations", "Perform merge")) - r.initialize = lambda ert : [ert.prototype("bool analysis_config_get_merge_observations(long)"), - ert.prototype("void analysis_config_set_merge_observations(long, int)")] r.getter = lambda ert : ert.enkf.analysis_config_get_merge_observations(ert.analysis_config) r.setter = lambda ert, value : ert.enkf.analysis_config_set_merge_observations(ert.analysis_config, value) @@ -96,15 +79,11 @@ def createAnalysisPage(configPanel, parent): enkf_mode_type = {"ENKF_STANDARD" : 10, "ENKF_SQRT" : 20} enkf_mode_type_inverted = {10 : "ENKF_STANDARD" , 20 : "ENKF_SQRT"} r = configPanel.addRow(ComboChoice(parent, enkf_mode_type.keys(), "Mode", "config/analysis/enkf_mode")) - r.initialize = lambda ert : [ert.prototype("int analysis_config_get_enkf_mode(long)"), - ert.prototype("void analysis_config_set_enkf_mode(long, int)")] r.getter = lambda ert : enkf_mode_type_inverted[ert.enkf.analysis_config_get_enkf_mode(ert.analysis_config)] r.setter = lambda ert, value : ert.enkf.analysis_config_set_enkf_mode(ert.analysis_config, enkf_mode_type[str(value)]) r = configPanel.addRow(DoubleSpinner(parent, "Truncation", "config/analysis/enkf_truncation", 0, 1, 2)) - r.initialize = lambda ert : [ert.prototype("double analysis_config_get_truncation(long)"), - ert.prototype("void analysis_config_set_truncation(long, double)")] r.getter = lambda ert : ert.enkf.analysis_config_get_truncation(ert.analysis_config) r.setter = lambda ert, value : ert.enkf.analysis_config_set_truncation(ert.analysis_config, value) diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/eclipse.py b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/eclipse.py index 303629ca30..4a5504dc27 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/eclipse.py +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/eclipse.py @@ -20,60 +20,43 @@ # ---------------------------------------------------------------------------------------------- from ert_gui.widgets.pathchooser import PathChooser from ert_gui.widgets.tablewidgets import KeywordTable, KeywordList -import ert.ertwrapper as ertwrapper from ert_gui.widgets.configpanel import ConfigPanel +import ert.enkf def createEclipsePage(configPanel, parent): configPanel.startPage("Eclipse") r = configPanel.addRow(PathChooser(parent, "Eclipse Base", "config/eclipse/eclbase", path_format=True)) - r.initialize = lambda ert : [ert.prototype("char* ecl_config_get_eclbase(long)"), - ert.prototype("void enkf_main_set_eclbase(long, char*)")] r.getter = lambda ert : ert.enkf.ecl_config_get_eclbase(ert.ecl_config) r.setter = lambda ert, value : ert.enkf.enkf_main_set_eclbase(ert.main , str(value)) r = configPanel.addRow(PathChooser(parent, "Data file", "config/eclipse/data_file", show_files=True)) - r.initialize = lambda ert : [ert.prototype("char* ecl_config_get_data_file(long)"), - ert.prototype("void enkf_main_set_data_file(long, char*)")] r.getter = lambda ert : ert.enkf.ecl_config_get_data_file(ert.ecl_config) r.setter = lambda ert, value : ert.enkf.enkf_main_set_data_file(ert.main , str(value)) r = configPanel.addRow(PathChooser(parent, "Grid", "config/eclipse/grid", show_files=True)) - r.initialize = lambda ert : [ert.prototype("char* ecl_config_get_gridfile(long)"), - ert.prototype("void ecl_config_set_grid(long, char*)")] r.getter = lambda ert : ert.enkf.ecl_config_get_gridfile(ert.ecl_config) r.setter = lambda ert, value : ert.enkf.ecl_config_set_grid(ert.ecl_config, str(value)) r = configPanel.addRow(PathChooser(parent, "Schedule file" , "config/eclipse/schedule_file" , show_files = True)) - r.initialize = lambda ert : [ert.prototype("char* ecl_config_get_schedule_file(long)"), - ert.prototype("void ecl_config_set_schedule_file(long, char*)")] r.getter = lambda ert : ert.enkf.ecl_config_get_schedule_file(ert.ecl_config) r.setter = lambda ert, value : ert.enkf.ecl_config_set_schedule_file(ert.ecl_config, str(value)) r = configPanel.addRow(PathChooser(parent, "Init section", "config/eclipse/init_section", show_files=True)) - r.initialize = lambda ert : [ert.prototype("char* ecl_config_get_init_section(long)"), - ert.prototype("void ecl_config_set_init_section(long, char*)")] r.getter = lambda ert : ert.enkf.ecl_config_get_init_section(ert.ecl_config) r.setter = lambda ert, value : ert.enkf.ecl_config_set_init_section(ert.ecl_config, str(value)) r = configPanel.addRow(PathChooser(parent, "Refcase", "config/eclipse/refcase", show_files=True)) - r.initialize = lambda ert : [ert.prototype("char* ecl_config_get_refcase_name(long)"), - ert.prototype("void ecl_config_load_refcase(long, char*)")] r.getter = lambda ert : ert.enkf.ecl_config_get_refcase_name(ert.ecl_config) r.setter = lambda ert, value : ert.enkf.ecl_config_load_refcase(ert.ecl_config, str(value)) r = configPanel.addRow(PathChooser(parent, "Schedule prediction file", "config/eclipse/schedule_prediction_file", show_files=True)) - r.initialize = lambda ert : [ert.prototype("char* enkf_main_get_schedule_prediction_file(long)"), - ert.prototype("void enkf_main_set_schedule_prediction_file(long, char*)")] r.getter = lambda ert : ert.enkf.enkf_main_get_schedule_prediction_file(ert.main) r.setter = lambda ert, value : ert.enkf.enkf_main_set_schedule_prediction_file(ert.main, ert.nonify( value )) r = configPanel.addRow(KeywordTable(parent, "Data keywords", "config/eclipse/data_kw")) - r.initialize = lambda ert : [ert.prototype("long enkf_main_get_data_kw(long)"), - ert.prototype("void enkf_main_clear_data_kw(long)"), - ert.prototype("void enkf_main_add_data_kw(long, char*, char*)")] r.getter = lambda ert : ert.getSubstitutionList(ert.enkf.enkf_main_get_data_kw(ert.main)) def add_data_kw(ert, listOfKeywords): @@ -93,9 +76,6 @@ def createEclipsePage(configPanel, parent): internalPanel.startPage("Static keywords") r = internalPanel.addRow(KeywordList(parent, "", "config/eclipse/add_static_kw")) - r.initialize = lambda ert : [ert.prototype("long ecl_config_get_static_kw_list(long)"), - ert.prototype("void ecl_config_clear_static_kw(long)"), - ert.prototype("void ecl_config_add_static_kw(long, char*)")] r.getter = lambda ert : ert.getStringList(ert.enkf.ecl_config_get_static_kw_list(ert.ecl_config)) def add_static_kw(ert, listOfKeywords): diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/ensemble.py b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/ensemble.py index ecb9a8177c..ba40fec8f1 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/ensemble.py +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/ensemble.py @@ -20,19 +20,16 @@ # ---------------------------------------------------------------------------------------------- from PyQt4 import QtGui, QtCore from ert_gui.widgets.spinnerwidgets import IntegerSpinner -import ert.ertwrapper as ertwrapper from parameters.parameterpanel import ParameterPanel, enums from parameters.parametermodels import SummaryModel, DataModel, FieldModel, KeywordModel -from ert.enums import field_type -from ert.enums import truncation_type -from ert.enums import gen_data_file_format +from ert.ert.enums import field_type +from ert.ert.enums import truncation_type +from ert.ert.enums import gen_data_file_format def createEnsemblePage(configPanel, parent): configPanel.startPage("Ensemble") r = configPanel.addRow(IntegerSpinner(parent, "Number of realizations", "config/ensemble/num_realizations", 1, 10000)) - r.initialize = lambda ert : [ert.prototype("int enkf_main_get_ensemble_size(long)"), - ert.prototype("void enkf_main_resize_ensemble(int)")] r.getter = lambda ert : ert.enkf.enkf_main_get_ensemble_size(ert.main) r.setter = lambda ert, value : ert.enkf.enkf_main_resize_ensemble(ert.main, value) @@ -44,51 +41,6 @@ def createEnsemblePage(configPanel, parent): r = configPanel.addRow(ParameterPanel(parent, "", "")) # no help file necessary parent.connect(r, QtCore.SIGNAL("contentsChanged()"), lambda : r.modelEmit("ensembleUpdated()")) - def initialize(ert): - ert.prototype("long ensemble_config_get_node(long, char*)") - ert.prototype("long ensemble_config_alloc_keylist(long)") - ert.prototype("long ensemble_config_add_summary(long, char*)") - ert.prototype("long ensemble_config_add_gen_kw(long, char*)") - ert.prototype("long ensemble_config_add_gen_data(long, char*)") - ert.prototype("long ensemble_config_add_field(long, char*, long)") - - ert.prototype("void enkf_main_del_node(long, char*)") - ert.prototype("long ecl_config_get_grid(long)") - - ert.prototype("long enkf_config_node_get_impl_type(long)") - ert.prototype("long enkf_config_node_get_ref(long)") - ert.prototype("bool enkf_config_node_is_valid(long)") - ert.prototype("char* enkf_config_node_get_min_std_file(long)") - ert.prototype("char* enkf_config_node_get_enkf_outfile(long)") - ert.prototype("char* enkf_config_node_get_enkf_infile(long)") - ert.prototype("void enkf_config_node_update_gen_kw(long, char*, char*, char*, char*, char*)") - ert.prototype("void enkf_config_node_update_state_field(long, int, double, double)") - ert.prototype("void enkf_config_node_update_parameter_field(long, char*, char*, char*, int, double, double, char*, char*)") - ert.prototype("void enkf_config_node_update_general_field(long, char*, char*, char*, char*, int, double, double, char*, char*, char*)") - ert.prototype("void enkf_config_node_update_gen_data(long, int, int, char*, char*, char*, char*, char*, char*)") - - ert.prototype("char* gen_kw_config_get_template_file(long)") - ert.prototype("char* gen_kw_config_get_init_file_fmt(long)") - ert.prototype("char* gen_kw_config_get_parameter_file(long)") - - ert.prototype("long gen_data_config_get_output_format(long)") - ert.prototype("long gen_data_config_get_input_format(long)") - ert.prototype("char* gen_data_config_get_template_file(long)") - ert.prototype("char* gen_data_config_get_template_key(long)") - ert.prototype("char* gen_data_config_get_init_file_fmt(long)") - - ert.prototype("int field_config_get_type(long)") - ert.prototype("int field_config_get_truncation_mode(long)") - ert.prototype("double field_config_get_truncation_min(long)") - ert.prototype("double field_config_get_truncation_max(long)") - ert.prototype("char* field_config_get_init_transform_name(long)") - ert.prototype("char* field_config_get_output_transform_name(long)") - ert.prototype("char* field_config_get_init_file_fmt(long)") - - - - r.initialize = initialize - def getEnsembleParameters(ert): keys = ert.getStringList(ert.enkf.ensemble_config_alloc_keylist(ert.ensemble_config), free_after_use=True) diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/jobs/jobsdialog.py b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/jobs/jobsdialog.py index b87614badb..468009b714 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/jobs/jobsdialog.py +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/jobs/jobsdialog.py @@ -22,7 +22,6 @@ from ert_gui.widgets.tablewidgets import KeywordTable from ert_gui.widgets.tablewidgets import KeywordList from ert_gui.widgets.stringbox import StringBox import os -from ert.ertwrapper import c_char_p, c_int from ert_gui.widgets.spinnerwidgets import IntegerSpinner import ert_gui.widgets.util from ert_gui.widgets.helpedwidget import ContentModelProxy @@ -158,34 +157,6 @@ class JobConfigPanel(ConfigPanel): self.addRow(widget, label) - def initialize(self, ert): - if not self.initialized: - ert.prototype("long site_config_get_installed_jobs(long)") - ert.prototype("char* ext_job_get_stdin_file(long)",lib=ert.job_queue) - ert.prototype("void ext_job_set_stdin_file(long, char*)", lib=ert.job_queue) - ert.prototype("char* ext_job_get_stdout_file(long)", lib=ert.job_queue) - ert.prototype("void ext_job_set_stdout_file(long, char*)", lib=ert.job_queue) - ert.prototype("char* ext_job_get_stderr_file(long)", lib=ert.job_queue) - ert.prototype("void ext_job_set_stderr_file(long, char*)", lib=ert.job_queue) - ert.prototype("char* ext_job_get_target_file(long)", lib=ert.job_queue) - ert.prototype("void ext_job_set_target_file(long, char*)", lib=ert.job_queue) - ert.prototype("char* ext_job_get_executable(long)", lib=ert.job_queue) - ert.prototype("void ext_job_set_executable(long, char*)", lib=ert.job_queue) - ert.prototype("char* ext_job_get_private_args_as_string(long)", lib=ert.job_queue) - ert.prototype("void ext_job_set_private_args_from_string(long, char*)", lib=ert.job_queue) - ert.prototype("int ext_job_get_max_running(long)", lib=ert.job_queue) - ert.prototype("void ext_job_set_max_running(long, int)", lib=ert.job_queue) - ert.prototype("int ext_job_get_max_running_minutes(long)", lib=ert.job_queue) - ert.prototype("void ext_job_set_max_running_minutes(long, int)", lib=ert.job_queue) - ert.prototype("long ext_job_get_environment(long)", lib=ert.job_queue) - ert.prototype("void ext_job_add_environment(long, char*, char*)", lib=ert.job_queue) - ert.prototype("void ext_job_clear_environment(long)", lib=ert.job_queue) - ert.prototype("void ext_job_save(long)", lib=ert.job_queue) - ert.prototype("long ext_joblist_get_job(long, char*)", lib=ert.job_queue) - - self.initialized = True - - def setJob(self, job): self.job = job diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/observations.py b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/observations.py index 5b95a406e9..e7f0609726 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/observations.py +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/observations.py @@ -20,15 +20,13 @@ # ---------------------------------------------------------------------------------------------- from ert_gui.widgets.combochoice import ComboChoice from ert_gui.widgets.pathchooser import PathChooser -from ert.enums import history_source_type +from ert.ert.enums import history_source_type from ert_gui.widgets.reloadbutton import ReloadButton def createObservationsPage(configPanel, parent): configPanel.startPage("Observations") r = configPanel.addRow(ComboChoice(parent, history_source_type.values(), "History source", "config/observations/history_source")) - r.initialize = lambda ert : [ert.prototype("int model_config_get_history_source(long)"), - ert.prototype("void model_config_set_history_source(long, int)")] def get_history_source(ert): history_source = ert.enkf.model_config_get_history_source(ert.model_config) @@ -44,9 +42,6 @@ def createObservationsPage(configPanel, parent): r = configPanel.addRow(PathChooser(parent, "Observations config", "config/observations/obs_config", True)) - r.initialize = lambda ert : [ert.prototype("long enkf_main_get_obs(long)"), - ert.prototype("char* enkf_obs_get_config_file(long)"), - ert.prototype("void enkf_main_load_obs(long, char*)")] def get_obs(ert): obs = ert.enkf.enkf_main_get_obs(ert.main) @@ -61,7 +56,6 @@ def createObservationsPage(configPanel, parent): r = configPanel.addRow(ReloadButton(parent, "Reload Observations", "config/observations/reload_observation", "Reload")) - r.initialize = lambda ert : [ert.prototype("void enkf_main_reload_obs(long)")] r.getter = lambda ert : ert.enkf.enkf_main_reload_obs(ert.main) diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/parameters/datapanel.py b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/parameters/datapanel.py index 90e79683bc..3c7ba91618 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/parameters/datapanel.py +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/parameters/datapanel.py @@ -20,7 +20,7 @@ from ert_gui.widgets.combochoice import ComboChoice from ert_gui.widgets.stringbox import DoubleBox from ert_gui.widgets.pathchooser import PathChooser from parametermodels import DataModel -import ert.enums as enums +import ert.ert.enums as enums import ert_gui.widgets.helpedwidget class DataPanel(QtGui.QFrame): diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/parameters/fieldpanel.py b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/parameters/fieldpanel.py index b5a25b3ed9..6120bc5575 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/parameters/fieldpanel.py +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/parameters/fieldpanel.py @@ -20,7 +20,7 @@ from ert_gui.widgets.combochoice import ComboChoice from ert_gui.widgets.stringbox import DoubleBox from ert_gui.widgets.pathchooser import PathChooser from parametermodels import FieldModel -from ert.enums import field_type +from ert.ert.enums import field_type from ert_gui.widgets.helpedwidget import ContentModel class FieldPanel(QtGui.QFrame): diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/parameters/parametermodels.py b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/parameters/parametermodels.py index e5cfc9afde..69e6876e08 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/parameters/parametermodels.py +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/parameters/parametermodels.py @@ -15,7 +15,7 @@ # for more details. -from ert.enums import enkf_impl_type, field_type +from ert.ert.enums import enkf_impl_type, field_type from PyQt4.QtCore import QObject from PyQt4.Qt import SIGNAL diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/plot.py b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/plot.py index 1476286ac0..268e8d4391 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/plot.py +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/plot.py @@ -22,50 +22,35 @@ from ert_gui.widgets.pathchooser import PathChooser from ert_gui.widgets.combochoice import ComboChoice from ert_gui.widgets.spinnerwidgets import IntegerSpinner -import ert.ertwrapper as ertwrapper def createPlotPage(configPanel, parent): configPanel.startPage("Plot") r = configPanel.addRow(PathChooser(parent, "Output path", "config/plot/path")) - r.initialize = lambda ert : [ert.prototype("char* plot_config_get_path(long)"), - ert.prototype("void plot_config_set_path(long, char*)")] r.getter = lambda ert : ert.enkf.plot_config_get_path(ert.plot_config) r.setter = lambda ert, value : ert.enkf.plot_config_set_path(ert.plot_config, str(value)) r = configPanel.addRow(ComboChoice(parent, ["PLPLOT", "TEXT"], "Driver", "config/plot/plot_driver")) - r.initialize = lambda ert : [ert.prototype("char* plot_config_get_driver(long)"), - ert.prototype("void plot_config_set_driver(long, char*)")] r.getter = lambda ert : ert.enkf.plot_config_get_driver(ert.plot_config) r.setter = lambda ert, value : ert.enkf.plot_config_set_driver(ert.plot_config, str(value)) r = configPanel.addRow(IntegerSpinner(parent, "Errorbar max", "config/plot/plot_errorbar_max", 1, 10000000)) - r.initialize = lambda ert : [ert.prototype("int plot_config_get_errorbar_max(long)"), - ert.prototype("void plot_config_set_errorbar_max(long, int)")] r.getter = lambda ert : ert.enkf.plot_config_get_errorbar_max(ert.plot_config) r.setter = lambda ert, value : ert.enkf.plot_config_set_errorbar_max(ert.plot_config, value) r = configPanel.addRow(IntegerSpinner(parent, "Width", "config/plot/width", 1, 10000)) - r.initialize = lambda ert : [ert.prototype("int plot_config_get_width(long)"), - ert.prototype("void plot_config_set_width(long, int)")] r.getter = lambda ert : ert.enkf.plot_config_get_width(ert.plot_config) r.setter = lambda ert, value : ert.enkf.plot_config_set_width(ert.plot_config, value) r = configPanel.addRow(IntegerSpinner(parent, "Height", "config/plot/plot_height", 1, 10000)) - r.initialize = lambda ert : [ert.prototype("int plot_config_get_height(long)"), - ert.prototype("void plot_config_set_height(long, int)")] r.getter = lambda ert : ert.enkf.plot_config_get_height(ert.plot_config) r.setter = lambda ert, value : ert.enkf.plot_config_set_height(ert.plot_config, value) r = configPanel.addRow(PathChooser(parent, "Image Viewer", "config/plot/image_viewer", True)) - r.initialize = lambda ert : [ert.prototype("char* plot_config_get_viewer(long)"), - ert.prototype("void plot_config_set_viewer(long, char*)")] r.getter = lambda ert : ert.enkf.plot_config_get_viewer(ert.plot_config) r.setter = lambda ert, value : ert.enkf.plot_config_set_viewer(ert.plot_config, str(value)) r = configPanel.addRow(ComboChoice(parent, ["bmp", "jpg", "png", "tif"], "Image type", "config/plot/image_type")) - r.initialize = lambda ert : [ert.prototype("char* plot_config_get_image_type(long)"), - ert.prototype("void plot_config_set_image_type(long, char*)")] r.getter = lambda ert : ert.enkf.plot_config_get_image_type(ert.plot_config) r.setter = lambda ert, value : ert.enkf.plot_config_set_image_type(ert.plot_config, str(value)) diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/queuesystem.py b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/queuesystem.py index f024cf463d..9f82da1f5e 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/queuesystem.py +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/queuesystem.py @@ -20,7 +20,6 @@ # ---------------------------------------------------------------------------------------------- from ert_gui.widgets.configpanel import ConfigPanel from ert_gui.widgets.combochoice import ComboChoice -import ert.ertwrapper as ertwrapper from ert_gui.widgets.stringbox import StringBox from ert_gui.widgets.pathchooser import PathChooser from ert_gui.widgets.spinnerwidgets import IntegerSpinner @@ -30,8 +29,6 @@ def createQueueSystemPage(configPanel, parent): configPanel.startPage("Queue System") r = configPanel.addRow(ComboChoice(parent, ["LSF", "RSH", "LOCAL"], "Queue system", "config/queue_system/queue_system")) - r.initialize = lambda ert : [ert.prototype("char* site_config_get_queue_name(long)"), - ert.prototype("void site_config_set_job_queue(long, char*)")] r.getter = lambda ert : ert.enkf.site_config_get_queue_name(ert.site_config) r.setter = lambda ert, value : ert.enkf.site_config_set_job_queue(ert.site_config, str(value)) @@ -40,20 +37,14 @@ def createQueueSystemPage(configPanel, parent): internalPanel.startPage("LSF") r = internalPanel.addRow(StringBox(parent, "LSF Queue", "config/queue_system/lsf_queue")) - r.initialize = lambda ert : [ert.prototype("char* site_config_get_lsf_queue(long)"), - ert.prototype("void site_config_set_lsf_queue(long, char*)")] r.getter = lambda ert : ert.enkf.site_config_get_lsf_queue(ert.site_config) r.setter = lambda ert, value : ert.enkf.site_config_set_lsf_queue(ert.site_config, str(value)) r = internalPanel.addRow(IntegerSpinner(parent, "Max running", "config/queue_system/max_running_lsf", 1, 1000)) - r.initialize = lambda ert : [ert.prototype("int site_config_get_max_running_lsf(long)"), - ert.prototype("void site_config_set_max_running_lsf(long, int)")] r.getter = lambda ert : ert.enkf.site_config_get_max_running_lsf(ert.site_config) r.setter = lambda ert, value : ert.enkf.site_config_set_max_running_lsf(ert.site_config, value) r = internalPanel.addRow(StringBox(parent, "Resources", "config/queue_system/lsf_resources")) - r.initialize = lambda ert : [ert.prototype("char* site_config_get_lsf_request(long)"), - ert.prototype("void site_config_set_lsf_request(long, char*)")] r.getter = lambda ert : ert.enkf.site_config_get_lsf_request(ert.site_config) r.setter = lambda ert, value : ert.enkf.site_config_set_lsf_request(ert.site_config, str(value)) @@ -63,22 +54,15 @@ def createQueueSystemPage(configPanel, parent): internalPanel.startPage("RSH") r = internalPanel.addRow(PathChooser(parent, "Command", "config/queue_system/rsh_command", show_files=True, must_exist=True, is_executable_file=True)) - r.initialize = lambda ert : [ert.prototype("char* site_config_get_rsh_command(long)"), - ert.prototype("void site_config_set_rsh_command(long, char*)")] r.getter = lambda ert : ert.enkf.site_config_get_rsh_command(ert.site_config) r.setter = lambda ert, value : ert.enkf.site_config_set_rsh_command(ert.site_config, str(value)) r = internalPanel.addRow(IntegerSpinner(parent, "Max running", "config/queue_system/max_running_rsh", 1, 1000)) - r.initialize = lambda ert : [ert.prototype("int site_config_get_max_running_rsh(long)"), - ert.prototype("void site_config_set_max_running_rsh(long, int)")] r.getter = lambda ert : ert.enkf.site_config_get_max_running_rsh(ert.site_config) r.setter = lambda ert, value : ert.enkf.site_config_set_max_running_rsh(ert.site_config, value) r = internalPanel.addRow(KeywordTable(parent, "Host List", "config/queue_system/rsh_host_list", "Host", "Number of jobs")) - r.initialize = lambda ert : [ert.prototype("long site_config_get_rsh_host_list(long)"), - ert.prototype("void site_config_clear_rsh_host_list(long)"), - ert.prototype("void site_config_add_rsh_host(long, char*, int)")] r.getter = lambda ert : ert.getHash(ert.enkf.site_config_get_rsh_host_list(ert.site_config), True) def add_rsh_host(ert, listOfKeywords): @@ -100,8 +84,6 @@ def createQueueSystemPage(configPanel, parent): internalPanel.startPage("LOCAL") r = internalPanel.addRow(IntegerSpinner(parent, "Max running", "config/queue_system/max_running_local", 1, 1000)) - r.initialize = lambda ert : [ert.prototype("int site_config_get_max_running_local(long)"), - ert.prototype("void site_config_set_max_running_local(long, int)")] r.getter = lambda ert : ert.enkf.site_config_get_max_running_local(ert.site_config) r.setter = lambda ert, value : ert.enkf.site_config_set_max_running_local(ert.site_config, value) diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/simulation.py b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/simulation.py index 8013e26d55..db12479cca 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/simulation.py +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/simulation.py @@ -20,7 +20,6 @@ # ---------------------------------------------------------------------------------------------- from PyQt4 import QtCore from ert_gui.widgets.spinnerwidgets import IntegerSpinner -import ert.ertwrapper as ertwrapper from ert_gui.widgets.tablewidgets import KeywordTable from ert_gui.widgets.pathchooser import PathChooser from ert_gui.widgets.checkbox import CheckBox @@ -28,7 +27,7 @@ from ert_gui.widgets.configpanel import ConfigPanel from ert_gui.widgets.stringbox import StringBox from jobs.forwardmodelpanel import ForwardModelPanel from simulations.runpathpanel import RunpathMemberList, RunpathMemberPanel -from ert.enums import keep_runpath_type +from ert.ert.enums import keep_runpath_type from simulations.runtemplatepanel import RunTemplatePanel import ert_gui.widgets.helpedwidget import os @@ -38,29 +37,17 @@ def createSimulationsPage(configPanel, parent): r = configPanel.addRow(IntegerSpinner(parent, "Max submit", "config/simulation/max_submit", 1, 10000)) - r.initialize = lambda ert : [ert.prototype("int site_config_get_max_submit(long)"), - ert.prototype("void site_config_set_max_submit(long, int)")] r.getter = lambda ert : ert.enkf.site_config_get_max_submit(ert.site_config) r.setter = lambda ert, value : ert.enkf.site_config_set_max_submit(ert.site_config, value) r = configPanel.addRow(IntegerSpinner(parent, "Max resample", "config/simulation/max_resample", 1, 10000)) - r.initialize = lambda ert : [ert.prototype("int model_config_get_max_resample(long)"), - ert.prototype("void model_config_set_max_resample(long, int)")] r.getter = lambda ert : ert.enkf.model_config_get_max_resample(ert.model_config) r.setter = lambda ert, value : ert.enkf.model_config_set_max_resample(ert.model_config, value) r = configPanel.addRow(ForwardModelPanel(parent)) - r.initialize = lambda ert: [ert.prototype("long model_config_get_forward_model(long)"), - ert.prototype("long site_config_get_installed_jobs(long)"), - ert.prototype("long ext_joblist_alloc_list(long)", lib=ert.job_queue), - ert.prototype("char* ext_job_get_private_args_as_string(long)", lib=ert.job_queue), - ert.prototype("char* ext_job_get_help_text(long)", lib=ert.job_queue), - ert.prototype("void forward_model_clear(long)", lib=ert.job_queue), - ert.prototype("long forward_model_add_job(long, char*)", lib=ert.job_queue), - ert.prototype("void ext_job_set_private_args_from_string(long, char*)", lib=ert.job_queue), - ert.prototype("long forward_model_alloc_joblist(long)", lib=ert.job_queue),] + def get_forward_model(ert): site_config = ert.site_config @@ -106,8 +93,7 @@ def createSimulationsPage(configPanel, parent): r = configPanel.addRow(PathChooser(parent, "Case table", "config/simulation/case_table")) - r.initialize = lambda ert : [ert.prototype("char* model_config_get_case_table_file(long)"), - ert.prototype("void enkf_main_set_case_table(long, char*)")] + def get_case_table(ert): return ert.enkf.model_config_get_case_table_file(ert.model_config) @@ -120,8 +106,6 @@ def createSimulationsPage(configPanel, parent): r = configPanel.addRow(PathChooser(parent, "License path", "config/simulation/license_path")) - r.initialize = lambda ert : [ert.prototype("char* site_config_get_license_root_path(long)"), - ert.prototype("void site_config_set_license_root_path(long, char*)")] r.getter = lambda ert : ert.enkf.site_config_get_license_root_path(ert.site_config) def ls(string): @@ -139,8 +123,6 @@ def createSimulationsPage(configPanel, parent): internalPanel.startPage("Runpath") r = internalPanel.addRow(PathChooser(parent, "Runpath", "config/simulation/runpath", path_format=True)) - r.initialize = lambda ert : [ert.prototype("char* model_config_get_runpath_as_char(long)"), - ert.prototype("void model_config_set_runpath_fmt(long, char*)")] r.getter = lambda ert : ert.enkf.model_config_get_runpath_as_char(ert.model_config) r.setter = lambda ert, value : ert.enkf.model_config_set_runpath_fmt(ert.model_config, str(value)) @@ -148,17 +130,12 @@ def createSimulationsPage(configPanel, parent): r = internalPanel.addRow(CheckBox(parent, "Pre clear", "config/simulation/pre_clear_runpath", "Perform pre clear")) - r.initialize = lambda ert : [ert.prototype("bool enkf_main_get_pre_clear_runpath(long)"), - ert.prototype("void enkf_main_set_pre_clear_runpath(long, bool)")] r.getter = lambda ert : ert.enkf.enkf_main_get_pre_clear_runpath(ert.main) r.setter = lambda ert, value : ert.enkf.enkf_main_set_pre_clear_runpath(ert.main, value) r = internalPanel.addRow(RunpathMemberPanel(widgetLabel="Retain runpath", helpLabel="config/simulation/runpath_retain")) - r.initialize = lambda ert : [ert.prototype("int enkf_main_get_ensemble_size(long)"), - ert.prototype("int enkf_main_iget_keep_runpath(long, int)"), - ert.prototype("void enkf_main_iset_keep_runpath(long, int, long)"),] def get_runpath_retain_state(ert): ensemble_size = ert.enkf.enkf_main_get_ensemble_size(ert.main) @@ -183,23 +160,15 @@ def createSimulationsPage(configPanel, parent): internalPanel.startPage("Run Template") r = internalPanel.addRow(RunTemplatePanel(parent)) - r.initialize = lambda ert : [ert.prototype("long enkf_main_get_templates(long)"), - ert.prototype("long ert_templates_alloc_list(long)"), - ert.prototype("long ert_templates_get_template(long, char*)"), - ert.prototype("char* ert_template_get_template_file(long)"), - ert.prototype("char* ert_template_get_target_file(long)"), - ert.prototype("char* ert_template_get_args_as_string(long)"), - ert.prototype("void ert_templates_clear(long)"), - ert.prototype("void ert_templates_add_template(long, char*, char*, char*, char*)"),] def get_run_templates(ert): templates = ert.enkf.enkf_main_get_templates(ert.main) - template_list = ert.enkf.ert_templates_alloc_list(templates) + template_list = ert.enkf.ert_template_alloc_list(templates) template_names = ert.getStringList(template_list, free_after_use=True) result = [] for name in template_names: - template = ert.enkf.ert_templates_get_template(templates, name) + template = ert.enkf.ert_template_get_template(templates, name) template_file = ert.enkf.ert_template_get_template_file(template) target_file = ert.enkf.ert_template_get_target_file(template) arguments = ert.enkf.ert_template_get_args_as_string(template) @@ -210,10 +179,10 @@ def createSimulationsPage(configPanel, parent): def set_run_templates(ert, template_list): templates_pointer = ert.enkf.enkf_main_get_templates(ert.main) - ert.enkf.ert_templates_clear(templates_pointer) + ert.enkf.ert_template_clear(templates_pointer) for template in template_list: - ert.enkf.ert_templates_add_template(templates_pointer, template[0], template[1], template[2], template[3]) + ert.enkf.ert_template_add_template(templates_pointer, template[0], template[1], template[2], template[3]) r.setter = set_run_templates diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/simulations/runpathpanel.py b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/simulations/runpathpanel.py index 0aba75f1db..63b8a99a16 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/simulations/runpathpanel.py +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/simulations/runpathpanel.py @@ -16,7 +16,7 @@ from PyQt4 import QtGui, QtCore -from ert.enums import keep_runpath_type +from ert.ert.enums import keep_runpath_type from ert_gui.widgets.helpedwidget import HelpedWidget from ert_gui.pages.run.legend import Legend diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/systemenv.py b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/systemenv.py index 2a31ab8a06..e9c4f663d6 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/systemenv.py +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/systemenv.py @@ -21,7 +21,6 @@ from ert_gui.widgets.pathchooser import PathChooser from ert_gui.widgets.configpanel import ConfigPanel from ert_gui.widgets.tablewidgets import KeywordTable, KeywordList -import ert.ertwrapper as ertwrapper from PyQt4 import QtGui, QtCore from jobs.jobspanel import JobsPanel, Job import os @@ -35,15 +34,12 @@ def createSystemPage(configPanel, parent): # the site configuration file; this should only be a label - not # user editable. r = configPanel.addRow(ActiveLabel(None, "Site Config", "", "Not specified.")) - r.initialize = lambda ert: [ert.prototype("char* enkf_main_get_site_config_file(long)")] r.getter = lambda ert : ert.enkf.enkf_main_get_site_config_file(ert.main) r.modelConnect("casesUpdated()", r.fetchContent) r = configPanel.addRow(PathChooser(parent, "Job script", "config/systemenv/job_script", True)) - r.initialize = lambda ert : [ert.prototype("char* site_config_get_job_script(long)"), - ert.prototype("void site_config_set_job_script(long, char*)")] r.getter = lambda ert : ert.enkf.site_config_get_job_script(ert.site_config) r.setter = lambda ert, value : ert.enkf.site_config_set_job_script(ert.site_config, str(value)) @@ -51,9 +47,6 @@ def createSystemPage(configPanel, parent): internalPanel.startPage("setenv") r = internalPanel.addRow(KeywordTable(parent, "", "config/systemenv/setenv")) - r.initialize = lambda ert : [ert.prototype("long site_config_get_env_hash(long)"), - ert.prototype("void site_config_clear_env(long)"), - ert.prototype("void site_config_setenv(long, char*, char*)")] r.getter = lambda ert : ert.getHash(ert.enkf.site_config_get_env_hash(ert.site_config)) def setenv(ert, value): @@ -68,10 +61,6 @@ def createSystemPage(configPanel, parent): internalPanel.startPage("Update path") r = internalPanel.addRow(KeywordTable(parent, "", "config/systemenv/update_path")) - r.initialize = lambda ert : [ert.prototype("long site_config_get_path_variables(long)"), - ert.prototype("long site_config_get_path_values(long)"), - ert.prototype("void site_config_clear_pathvar(long)"), - ert.prototype("void site_config_update_pathvar(long, char*, char*)")] def get_update_path(ert): paths = ert.getStringList(ert.enkf.site_config_get_path_variables(ert.site_config)) values = ert.getStringList(ert.enkf.site_config_get_path_values(ert.site_config)) @@ -94,18 +83,6 @@ def createSystemPage(configPanel, parent): internalPanel.startPage("Jobs") r = internalPanel.addRow(JobsPanel(parent)) - r.initialize = lambda ert : [ert.prototype("long site_config_get_installed_jobs(long)"), - ert.prototype("char* site_config_get_license_root_path(long)"), - ert.prototype("int ext_job_is_private(long)", lib=ert.job_queue), - ert.prototype("char* ext_job_get_config_file(long)", lib=ert.job_queue), - ert.prototype("void ext_job_set_config_file(long, char*)", lib=ert.job_queue), - ert.prototype("long ext_job_alloc(char*, char*, int)", lib=ert.job_queue), - ert.prototype("long ext_job_fscanf_alloc(char*, char*, int, char*)", lib=ert.job_queue), - ert.prototype("long ext_joblist_get_job(long, char*)", lib=ert.job_queue), - ert.prototype("int ext_joblist_del_job(long, char*)", lib=ert.job_queue), - ert.prototype("int ext_joblist_has_job(long, char*)", lib=ert.job_queue), - ert.prototype("void ext_joblist_add_job(long, char*, long)", lib=ert.job_queue), - ert.prototype("long ext_joblist_get_jobs(long)", lib=ert.job_queue)] def get_jobs(ert): jl = ert.enkf.site_config_get_installed_jobs(ert.site_config) h = ert.job_queue.ext_joblist_get_jobs(jl) @@ -169,14 +146,10 @@ def createSystemPage(configPanel, parent): configPanel.addRow(internalPanel) r = configPanel.addRow(PathChooser(parent, "Log file", "config/systemenv/log_file", True)) - r.initialize = lambda ert : [ert.prototype("char* log_get_filename(long)", lib=ert.util), - ert.prototype("void log_reset_filename(long, char*)", lib=ert.util)] r.getter = lambda ert : ert.util.log_get_filename(ert.logh) r.setter = lambda ert, value : ert.util.log_reset_filename(ert.logh, value) r = configPanel.addRow(ert_gui.widgets.spinnerwidgets.IntegerSpinner(parent, "Log level", "config/systemenv/log_level", 0, 1000)) - r.initialize = lambda ert : [ert.prototype("int log_get_level(long)", lib=ert.util), - ert.prototype("void log_set_level(long, int)", lib=ert.util)] r.getter = lambda ert : ert.util.log_get_level(ert.logh) r.setter = lambda ert, value : ert.util.log_set_level(ert.logh, value) diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/init/initandcopy.py b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/init/initandcopy.py index 2c1272a85a..092c4bd9f0 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/init/initandcopy.py +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/init/initandcopy.py @@ -16,10 +16,9 @@ from ert_gui.widgets.helpedwidget import HelpedWidget -from ert import ertwrapper from PyQt4 import QtGui, QtCore from ert_gui.widgets.util import resourceIcon, ListCheckPanel, ValidatedTimestepCombo, getItemsFromList -from ert.enums import ert_state_enum +from ert.ert.enums import ert_state_enum class ParametersAndMembers(HelpedWidget): @@ -218,15 +217,6 @@ class ParametersAndMembers(HelpedWidget): def initialize(self, ert): - ert.prototype("long ensemble_config_alloc_keylist_from_var_type(long, int)") - ert.prototype("int enkf_main_initialize_from_scratch(long, long, int, int)") - ert.prototype("int enkf_main_get_ensemble_size(long)") - ert.prototype("long enkf_main_get_fs(long)") - ert.prototype("char* enkf_fs_get_read_dir(long)") - ert.prototype("long enkf_fs_alloc_dirlist(long)") - ert.prototype("int enkf_main_get_history_length(long)") - ert.prototype("void enkf_main_initialize_from_existing__(long, char*, int, int, long, char*, long)") - ert.prototype("void enkf_main_copy_ensemble(long, char*, int, int, char*, int, int, long, char*, long)") self.initialized = True @@ -249,12 +239,12 @@ class ParametersAndMembers(HelpedWidget): members = ert.enkf.enkf_main_get_ensemble_size(ert.main) fs = ert.enkf.enkf_main_get_fs(ert.main) - currentCase = ert.enkf.enkf_fs_get_read_dir(fs) - - caseList = ert.enkf.enkf_fs_alloc_dirlist(fs) - list = ert.getStringList(caseList) - ert.freeStringList(caseList) + currentCase = "default" #ert.enkf.enkf_fs_get_read_dir(fs) + #caseList = ert.enkf.enkf_fs_alloc_dirlist(fs) + #list = ert.getStringList(caseList) + #ert.freeStringList(caseList) + list = ["default"] historyLength = ert.enkf.enkf_main_get_history_length(ert.main) return {"parameters" : parameters, diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/init/initpanel.py b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/init/initpanel.py index ed8382f392..67289b9da6 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/init/initpanel.py +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/init/initpanel.py @@ -18,7 +18,7 @@ from PyQt4 import QtGui, QtCore from ert_gui.widgets.tablewidgets import KeywordList from ert_gui.widgets.validateddialog import ValidatedDialog -import ert.ertwrapper as ertwrapper +import ert.ert.ertwrapper as ertwrapper from ert_gui.widgets.combochoice import ComboChoice @@ -43,10 +43,10 @@ class InitPanel(QtGui.QFrame): def get_case_list(ert): fs = ert.enkf.enkf_main_get_fs(ert.main) - caseList = ert.enkf.enkf_fs_alloc_dirlist(fs) + caseList = ["default"] #ert.enkf.enkf_fs_alloc_dirlist(fs) - list = ert.getStringList(caseList) - ert.freeStringList(caseList) + list = caseList #ert.getStringList(caseList) + #ert.freeStringList(caseList) return list self.get_case_list = get_case_list # convenience: used by several functions @@ -104,9 +104,6 @@ class InitPanel(QtGui.QFrame): def initialize_cases(ert): ert.prototype("long enkf_main_get_fs(long)") - ert.prototype("char* enkf_fs_get_read_dir(long)") - ert.prototype("void enkf_fs_select_read_dir(long, char*)") - ert.prototype("void enkf_fs_select_write_dir(long, char*, bool)") self.currentCase.updateList(self.get_case_list(ert)) @@ -114,7 +111,8 @@ class InitPanel(QtGui.QFrame): def get_current_case(ert): fs = ert.enkf.enkf_main_get_fs(ert.main) - currentCase = ert.enkf.enkf_fs_get_read_dir(fs) + tmp = self.get_case_list(ert) + currentCase = tmp[0] #ert.enkf.enkf_fs_get_read_dir(fs) #print "The selected case is: " + currentCase return currentCase diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/ensemblefetcher.py b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/ensemblefetcher.py index 49d5ccb6a4..5e366ad39d 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/ensemblefetcher.py +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/ensemblefetcher.py @@ -18,11 +18,11 @@ from fetcher import PlotDataFetcherHandler from ert_gui.pages.config.parameters.parametermodels import FieldModel, SummaryModel, KeywordModel, DataModel -import ert.ertwrapper as ertwrapper -import ert.enums as enums +import ert.ert.ertwrapper as ertwrapper +import ert.ert.enums as enums from PyQt4.QtGui import QWidget, QFormLayout, QSpinBox, QComboBox from PyQt4.QtCore import SIGNAL -from ert.erttypes import time_t +from ert.ert.erttypes import time_t import numpy class EnsembleFetcher(PlotDataFetcherHandler): @@ -45,8 +45,7 @@ class EnsembleFetcher(PlotDataFetcherHandler): self.connect(self.data_configuration, SIGNAL('configurationChanged()'), emitter) def initialize(self, ert): - ert.prototype("long ensemble_config_get_node(long, char*)") - ert.prototype("bool ensemble_config_has_key(long, char*)") + ert.prototype("long enkf_main_get_fs(long)") ert.prototype("int enkf_main_get_ensemble_size(long)") diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/plotdata.py b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/plotdata.py index 4b9c2cc6b4..d5c9670b3a 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/plotdata.py +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/plotdata.py @@ -15,15 +15,14 @@ # for more details. -from ert.erttypes import time_t +from ert.ert.erttypes import time_t from ert_gui.widgets.helpedwidget import ContentModel from ert_gui.widgets.util import print_timing, resourceIcon from ert_gui.pages.config.parameters.parametermodels import DataModel, KeywordModel, FieldModel, SummaryModel from ert_gui.pages.config.parameters.parameterpanel import Parameter -import ert.ertwrapper as ertwrapper -import ert.enums as enums +import ert.ert.enums as enums import sys -from ert.enums import obs_impl_type +from ert.ert.enums import obs_impl_type from ensemblefetcher import EnsembleFetcher from rftfetcher import RFTFetcher @@ -232,8 +231,6 @@ class PlotContextDataFetcher(ContentModel): ContentModel.__init__(self) def initialize(self, ert): - ert.prototype("long ensemble_config_alloc_keylist(long)") - ert.prototype("long ensemble_config_get_node(long, char*)") ert.prototype("long enkf_config_node_get_impl_type(long)") ert.prototype("long enkf_config_node_get_ref(long)") @@ -299,11 +296,12 @@ class PlotContextDataFetcher(ContentModel): data.errorbar_max = ert.enkf.plot_config_get_errorbar_max(ert.plot_config) fs = ert.enkf.enkf_main_get_fs(ert.main) - current_case = ert.enkf.enkf_fs_get_read_dir(fs) + current_case = "default" #ert.enkf.enkf_fs_get_read_dir(fs) data.plot_config_path = ert.enkf.plot_config_get_path(ert.plot_config) - data.plot_path = ert.enkf.plot_config_get_path(ert.plot_config) + "/" + current_case - + #data.plot_path = ert.enkf.plot_config_get_path(ert.plot_config) + "/" + current_case + data.plot_path = "PLOTXXX" + enkf_obs = ert.enkf.enkf_main_get_obs(ert.main) key_list = ert.enkf.enkf_obs_alloc_typed_keylist(enkf_obs, obs_impl_type.FIELD_OBS.value()) field_obs = ert.getStringList(key_list, free_after_use=True) @@ -313,10 +311,11 @@ class PlotContextDataFetcher(ContentModel): data.parameters.append(p) - case_list_pointer = ert.enkf.enkf_fs_alloc_dirlist(fs) - case_list = ert.getStringList(case_list_pointer) + #case_list_pointer = ert.enkf.enkf_fs_alloc_dirlist(fs) + #case_list = ert.getStringList(case_list_pointer) + case_list = ["default"] data.current_case = current_case - ert.freeStringList(case_list_pointer) + #ert.freeStringList(case_list_pointer) for case in case_list: data.case_list.append(case) diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/plotfigure.py b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/plotfigure.py index 189d7b4de1..9221f08117 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/plotfigure.py +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/plotfigure.py @@ -20,7 +20,7 @@ import matplotlib.lines import matplotlib.text import numpy -import ert.erttypes as erttypes +import ert.ert.erttypes as erttypes import plotsettings from plotrenderer import DefaultPlotRenderer diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/plotgenerator.py b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/plotgenerator.py index 1387a6440d..8c6e7d0aab 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/plotgenerator.py +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/plotgenerator.py @@ -26,7 +26,7 @@ from plotsettingsxml import PlotSettingsLoader from plotsettings import PlotSettings from plotdata import PlotContextDataFetcher, PlotDataFetcher from ert_gui.pages.config.parameters.parametermodels import SummaryModel, KeywordModel -import ert.enums as enums +import ert.ert.enums as enums class PlotGenerator(QFrame): diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/plotpanel.py b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/plotpanel.py index a98922b91f..c2b23c770b 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/plotpanel.py +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/plotpanel.py @@ -18,7 +18,6 @@ from PyQt4 import QtGui, QtCore from ert_gui.pages.config.parameters.parameterpanel import Parameter from ert_gui.pages.plot.plotview import PlotView -import ert.ertwrapper as ertwrapper import ert_gui.pages.config.parameters.parameterpanel import ert_gui.widgets.helpedwidget from ert_gui.widgets.helpedwidget import ContentModel @@ -36,7 +35,7 @@ from plotconfig import PlotConfigPanel from PyQt4.QtGui import QTabWidget, QFormLayout, QFrame, QVBoxLayout, QHBoxLayout, QCheckBox, QPushButton, QToolButton, QMainWindow from PyQt4.QtGui import QCalendarWidget import plotsettings -import ert.erttypes as erttypes +import ert.ert.erttypes as erttypes class PlotPanel(QtGui.QWidget): def __init__(self): diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/plotrenderer.py b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/plotrenderer.py index c307baacf3..41f43338fd 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/plotrenderer.py +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/plotrenderer.py @@ -16,7 +16,7 @@ from matplotlib.dates import AutoDateLocator, datetime, matplotlib -import ert.erttypes as erttypes +import ert.ert.erttypes as erttypes class PlotRenderer: """An abstract plotter that plots data""" diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/plotsettings.py b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/plotsettings.py index 2f51b61fce..4b58fb0587 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/plotsettings.py +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/plotsettings.py @@ -17,7 +17,7 @@ from plotconfig import PlotConfig import matplotlib -from ert.erttypes import time_t +from ert.ert.erttypes import time_t import datetime from PyQt4.QtCore import QObject, SIGNAL diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/plotview.py b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/plotview.py index a21b30f730..5f74965471 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/plotview.py +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/plotview.py @@ -19,7 +19,7 @@ from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas import datetime import time -from ert.erttypes import time_t +from ert.ert.erttypes import time_t from ert_gui.widgets.util import print_timing from plotdata import PlotData diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/rftfetcher.py b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/rftfetcher.py index d9983491e8..08d1da4521 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/rftfetcher.py +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/plot/rftfetcher.py @@ -16,10 +16,10 @@ from fetcher import PlotDataFetcherHandler -import ert.ertwrapper as ertwrapper -import ert.enums as enums +import ert.ert.ertwrapper as ertwrapper +import ert.ert.enums as enums import plotdata -from ert.enums import ert_state_enum, obs_impl_type +from ert.ert.enums import ert_state_enum, obs_impl_type import numpy class RFTFetcher(PlotDataFetcherHandler): @@ -45,7 +45,6 @@ class RFTFetcher(PlotDataFetcherHandler): ert.prototype("int obs_vector_get_num_active(long)") ert.prototype("bool obs_vector_iget_active(long, int)") - ert.prototype("long ensemble_config_get_node(long, char*)") ert.prototype("long enkf_config_node_get_ref(long)") ert.prototype("int* field_obs_get_i(long)") diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/run/runpanel.py b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/run/runpanel.py index d2b8a9adde..dfc44d7eb0 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/run/runpanel.py +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/run/runpanel.py @@ -16,7 +16,6 @@ from PyQt4 import QtGui, QtCore -from ert import ertwrapper from ert_gui.widgets.helpedwidget import HelpedWidget, ContentModel from ert_gui.widgets.util import resourceIcon, ListCheckPanel, ValidatedTimestepCombo, createSpace, getItemsFromList, frange diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/run/simulation.py b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/run/simulation.py index 332f9b56df..25b3b57d70 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/run/simulation.py +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/run/simulation.py @@ -19,8 +19,7 @@ from __future__ import division from PyQt4 import QtGui, QtCore from ert_gui.widgets.util import resourceIcon, resourceStateIcon, shortTime import time -import ert.ertwrapper as ertwrapper -from ert.enums import ert_job_status_type +from ert.ert.enums import ert_job_status_type class SimulationList(QtGui.QListWidget): diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/run/simulationsdialog.py b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/run/simulationsdialog.py index 6095c91c91..9f41bd57b6 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/run/simulationsdialog.py +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/run/simulationsdialog.py @@ -22,9 +22,8 @@ from simulation import SimulationItemDelegate, SimulationList, SimulationItem, S import threading import time -import ert.ertwrapper as ertwrapper from ert_gui.widgets.util import getItemsFromList -from ert.enums import ert_job_status_type +from ert.ert.enums import ert_job_status_type from PyQt4.QtGui import QApplication class SimulationsDialog(QtGui.QDialog): diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/widgets/helpedwidget.py b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/widgets/helpedwidget.py index e0b6f082b5..ce46086536 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/widgets/helpedwidget.py +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/widgets/helpedwidget.py @@ -20,7 +20,7 @@ import help import sys from util import resourceIcon, resourceImage import inspect -import ert.enums as enums +import ert.ert.enums as enums def abstract(): """Abstract keyword that indicate an abstract function""" diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/CMakeLists.txt b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/CMakeLists.txt index 3525d95cf8..c6391119d3 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/CMakeLists.txt @@ -4,7 +4,7 @@ include_directories( ${PLPLOT_HEADER} ) set( SITE_CONFIG_FILE /project/res/etc/ERT/site-config CACHE FILEPATH "Path to global ERT Configuration file") set( src_list main.c enkf_tui_main.c enkf_tui_fs.c enkf_tui_ranking.c enkf_tui_misc.c enkf_tui_table.c enkf_tui_plot.c enkf_tui_plot_rft.c enkf_tui_plot_util.c - enkf_tui_run.c enkf_tui_util.c enkf_tui_init.c enkf_tui_export.c enkf_tui_analysis.c enkf_tui_QC.c enkf_tui_help.c enkf_tui_simple.c ert_tui_jobs.c) + enkf_tui_run.c enkf_tui_util.c enkf_tui_init.c enkf_tui_export.c enkf_tui_analysis.c enkf_tui_QC.c enkf_tui_help.c enkf_tui_simple.c ert_tui_jobs.c enkf_tui_workflow.c) #exec_program( svnversion ${PROJECT_SOURCE_DIR} OUTPUT_VARIABLE SVN_VERSION) #exec_program( date OUTPUT_VARIABLE COMPILE_TIME_STAMP) @@ -38,8 +38,11 @@ else() set (destination ${CMAKE_INSTALL_PREFIX}/bin) endif() -install(TARGETS ert DESTINATION ${destination}) -if (INSTALL_GROUP) - install(CODE "EXECUTE_PROCESS(COMMAND chgrp ${INSTALL_GROUP} ${destination}/ert)") - install(CODE "EXECUTE_PROCESS(COMMAND chmod g+w ${destination}/ert)") + +if (INSTALL_ERT) + install(TARGETS ert DESTINATION ${destination}) + if (INSTALL_GROUP) + install(CODE "EXECUTE_PROCESS(COMMAND chgrp ${INSTALL_GROUP} ${destination}/ert)") + install(CODE "EXECUTE_PROCESS(COMMAND chmod g+w ${destination}/ert)") + endif() endif() diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_QC.c b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_QC.c index 4430ae126f..a0eaab0505 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_QC.c +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_QC.c @@ -56,6 +56,7 @@ #include #include + void enkf_tui_QC_plot_get_PC( enkf_main_type * enkf_main , int step1 , int step2 , state_enum state , const local_obsset_type * obsset , double truncation , int ncomp , matrix_type * PC , matrix_type * PC_obs) { @@ -109,6 +110,7 @@ void enkf_tui_QC_plot_get_PC( enkf_main_type * enkf_main , int step1 , int step2 } + void enkf_tui_QC_plot_PC( void * arg ) { enkf_main_type * enkf_main = enkf_main_safe_cast( arg ); local_config_type * local_config = enkf_main_get_local_config( enkf_main ); @@ -189,6 +191,14 @@ void enkf_tui_QC_plot_PC( void * arg ) { } +void enkf_tui_QC_run_workflow( void * arg ) { + enkf_main_type * enkf_main = enkf_main_safe_cast( arg ); + qc_module_type * qc_module = enkf_main_get_qc_module( enkf_main ); + + qc_module_run_workflow( qc_module , enkf_main ); +} + + void enkf_tui_QC_menu(void * arg) { @@ -201,7 +211,15 @@ void enkf_tui_QC_menu(void * arg) { { menu_type * menu = menu_alloc("Quality check of prior" , "Back" , "bB"); - menu_add_item(menu , "Plot of prior principal components" , "pP" , enkf_tui_QC_plot_PC , enkf_main , NULL); + menu_item_type * plot_PC_item = menu_add_item( menu , "Plot of prior principal components" , "pP" , enkf_tui_QC_plot_PC , enkf_main , NULL); + menu_item_type * run_QC_workflow_item = menu_add_item( menu , "Run QC workflow" , "rR" , enkf_tui_QC_run_workflow , enkf_main , NULL); + + if (!enkf_main_have_obs( enkf_main )) + menu_item_disable( plot_PC_item ); + + if (!enkf_main_has_QC_workflow( enkf_main )) + menu_item_disable( run_QC_workflow_item ); + menu_run(menu); menu_free(menu); } diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_export.c b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_export.c index 3434eb8b59..17d88f2a8f 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_export.c +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_export.c @@ -417,79 +417,6 @@ void enkf_tui_export_time(void * enkf_main) { } -void enkf_tui_export_python_module(void * arg ) { - enkf_main_type * enkf_main = enkf_main_safe_cast( arg ); - const ensemble_config_type * ensemble_config = enkf_main_get_ensemble_config(enkf_main); - const int ens_size = enkf_main_get_ensemble_size( enkf_main ); - enkf_fs_type * fs = enkf_main_get_fs(enkf_main); - char ** kw_list; - char * keyword_string; - char * step_string; - char * module_name; - char * module_file; - int * step_list; - int num_step , num_kw; - - util_printf_prompt("Keywords to export" , PROMPT_LEN , '=' , "=> "); - keyword_string = util_alloc_stdin_line(); - util_printf_prompt("Timesteps to export" , PROMPT_LEN , '=' , "=> "); - step_string = util_alloc_stdin_line(); - util_printf_prompt("Name of python module" , PROMPT_LEN , '=' , "=> "); - module_name = util_alloc_stdin_line(); - module_file = util_alloc_sprintf("%s.py" , module_name ); - step_list = util_sscanf_alloc_active_list( step_string , &num_step ); - util_split_string( keyword_string , " " , &num_kw , &kw_list); - { - FILE * stream = util_fopen(module_file , "w"); - int ikw; - fprintf(stream , "data = ["); - for (ikw = 0; ikw < num_kw; ikw++) { - char * index_key; - const enkf_config_node_type * config_node = ensemble_config_user_get_node( ensemble_config , kw_list[ikw] , &index_key); - if (config_node == NULL) - fprintf(stderr,"Warning: could not locate node: %s \n", kw_list[ikw]); - else { - enkf_node_type * node = enkf_node_alloc( config_node ); - node_id_type node_id; - - node_id.state = FORECAST; - for (int istep = 0; istep < num_step; istep++) { - node_id.report_step = istep; - int step = step_list[istep]; - fprintf(stream , "(\"%s\" , %d , [" , kw_list[ikw] , step); - for (int iens = 0; iens < ens_size; iens++) { - double value; - node_id.iens = iens; - enkf_node_user_get( node , fs , index_key , node_id , &value); - - fprintf(stream , "%g " , value); - if (iens < (ens_size -1 )) - fprintf(stream , ","); - else - fprintf(stream , "]"); - - } - if ((istep == (num_step - 1)) && (ikw == (num_kw - 1))) - fprintf(stream , ")]"); - else - fprintf(stream , "),\n"); - } - free(index_key); - enkf_node_free( node ); - } - } - fclose(stream); - } - - - util_free_stringlist( kw_list , num_kw ); - free(module_name); - free(module_file); - free( step_list ); - free( step_string ); - free( keyword_string ); -} - /*****************************************************************/ void enkf_tui_export_fieldP(void * arg) { @@ -773,8 +700,6 @@ void enkf_tui_export_menu(void * arg) { menu_add_separator(menu); menu_add_item(menu , "Export P( a =< x < b )" , "sS" , enkf_tui_export_fieldP , enkf_main , NULL); menu_add_separator(menu); - menu_add_item(menu , "Export Python module of" , "yY" , enkf_tui_export_python_module , enkf_main , NULL); - menu_add_separator(menu); menu_add_item(menu , "Export cell values to text file(s)" , "cC" , enkf_tui_export_cell , enkf_main , NULL); menu_add_item(menu , "Export line profile of a field to text file(s)" , "pP" , enkf_tui_export_profile , enkf_main , NULL); menu_add_item(menu , "Export time development in one cell to text file(s)" , "tT" , enkf_tui_export_time , enkf_main , NULL); diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_init.c b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_init.c index 4f4eb68df8..3e936e9be5 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_init.c +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_init.c @@ -45,6 +45,7 @@ void enkf_tui_init(enkf_main_type * enkf_main, bool all_members , bool all_param const ensemble_config_type * ensemble_config = enkf_main_get_ensemble_config(enkf_main); int ens_size = enkf_main_get_ensemble_size( enkf_main ); int iens1, iens2; + bool force_init = true; bool iens_valid = false; /* iens2 should be interpreted as __inclusive__ */ @@ -89,7 +90,7 @@ void enkf_tui_init(enkf_main_type * enkf_main, bool all_members , bool all_param } if (param_list != NULL) { - enkf_main_initialize_from_scratch(enkf_main , param_list , iens1 , iens2); + enkf_main_initialize_from_scratch(enkf_main , param_list , iens1 , iens2 , force_init); stringlist_free( param_list ); } } diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_main.c b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_main.c index 335777710a..3743bbe61f 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_main.c +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_main.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -57,12 +58,13 @@ void enkf_tui_main_menu(enkf_main_type * enkf_main) { menu_add_item(menu , "Manage cases" , "cC" , enkf_tui_fs_menu , enkf_main , NULL); menu_add_item(menu , "Run, restart or analyse experiment" , "rR" , enkf_tui_run_menu , enkf_main , NULL); - menu_add_item(menu , "Prior quality check" , "uU" , enkf_tui_QC_menu , enkf_main , NULL); + menu_add_item(menu , "Quality check" , "uU" , enkf_tui_QC_menu , enkf_main , NULL); menu_add_item(menu , "Plot results" , "pP" , enkf_tui_plot_menu , enkf_main , NULL); menu_add_item(menu , "Rank results" , "aA" , enkf_tui_ranking_menu , enkf_main , NULL); menu_add_item(menu , "Export data to other formats" , "eE" , enkf_tui_export_menu , enkf_main , NULL); menu_add_item(menu , "Table of results" , "tT" , enkf_tui_table_menu , enkf_main , NULL); menu_add_item(menu , "Miscellanous" , "mM" , enkf_tui_misc_menu , enkf_main , NULL); + menu_add_item(menu , "Workflows" , "wW" , enkf_tui_workflow_menu , enkf_main , NULL); menu_add_item(menu , "Help" , "hH" , enkf_tui_help_menu_main , enkf_main , NULL); menu_add_item(menu , "Simple menu" , "sS" , enkf_tui_simple_menu , enkf_main , NULL); menu_run(menu); diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_misc.c b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_misc.c index d03a71af36..790cbe26da 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_misc.c +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_misc.c @@ -15,13 +15,12 @@ See the GNU General Public License at for more details. */ +#include +#include #include #include -#include -#include - #include #include #include diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_plot.c b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_plot.c index 74886e4ff7..46bd5acdd7 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_plot.c +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_plot.c @@ -55,6 +55,7 @@ #include #include #include +#include #include #include @@ -74,6 +75,7 @@ base_name: The filename of the current plot. */ +#define NUM_REFCASE_POINTS 75 static void __plot_add_data(plot_type * plot , const char * label , int N , const double * x , const double *y) { @@ -122,14 +124,14 @@ void enkf_tui_plot_PC( enkf_main_type * enkf_main , const char * plot_name , con -static void enkf_tui_plot_ensemble__(enkf_main_type * enkf_main , - const enkf_config_node_type * config_node , - const char * user_key , - const char * key_index , - int step1 , int step2 , - bool prediction_mode , - int iens1 , int iens2 , - state_enum plot_state) { +void enkf_tui_plot_ensemble__(enkf_main_type * enkf_main , + const enkf_config_node_type * config_node , + const char * user_key , + const char * key_index , + int step1 , int step2 , + bool prediction_mode , + int iens1 , int iens2 , + state_enum plot_state) { enkf_fs_type * fs = enkf_main_get_fs(enkf_main); enkf_obs_type * enkf_obs = enkf_main_get_obs( enkf_main ); @@ -137,10 +139,10 @@ static void enkf_tui_plot_ensemble__(enkf_main_type * enkf_main , bool plot_dates = true; const int errorbar_max_obsnr = plot_config_get_errorbar_max( plot_config ); - const char * data_file = plot_config_get_plot_refcase( plot_config ); const bool plot_errorbars = plot_config_get_plot_errorbar( plot_config ); const bool add_observations = true; const bool logy = plot_config_get_logy( plot_config ); + const bool plot_refcase = plot_config_get_plot_refcase( plot_config ); bool show_plot = false; char * plot_file = enkf_tui_plot_alloc_plot_file( plot_config , enkf_main_get_current_fs( enkf_main ), user_key ); time_map_type * time_map = enkf_fs_get_time_map( fs ); @@ -149,8 +151,7 @@ static void enkf_tui_plot_ensemble__(enkf_main_type * enkf_main , msg_type * msg; bool_vector_type * has_data = bool_vector_alloc( 0 , false ); int iens , step; - bool plot_refcase = true; - + /* { enkf_plot_data_type * plot_data = enkf_main_alloc_plot_data( enkf_main ); @@ -164,10 +165,8 @@ static void enkf_tui_plot_ensemble__(enkf_main_type * enkf_main , enkf_plot_data_free( plot_data ); } */ - - if ( strcmp( data_file , "" ) == 0) - plot_refcase = false; + if (plot_dates) plot = enkf_tui_plot_alloc(plot_config , "" , /* y akse */ "" ,user_key,plot_file); else @@ -423,46 +422,41 @@ static void enkf_tui_plot_ensemble__(enkf_main_type * enkf_main , double_vector_free( obs_value ); } } - /*REFCASE PLOTTING*/ - if(plot_refcase){ - if( util_file_exists( data_file )){ - double_vector_type * refcase_value = double_vector_alloc( 0 , 0 ); - double_vector_type * refcase_time = double_vector_alloc( 0 , 0 ); - plot_dataset_type * d = plot_alloc_new_dataset( plot ,"refcase" , PLOT_XY ); - plot_dataset_set_style( d , LINE ); - plot_dataset_set_line_color( d , RED); - char *base; - char *header_file; - stringlist_type * summary_file_list = stringlist_alloc_new(); - char *path; - ecl_sum_type *ecl_sum; - util_alloc_file_components( data_file , &path , &base , NULL ); - ecl_util_alloc_summary_files( path , base , NULL , &header_file , summary_file_list); - ecl_sum = ecl_sum_fread_alloc( header_file , summary_file_list , ":" ); - for ( int i = 0; i < double_vector_size(x); i++ ){ - time_t sim_time = ( time_t ) double_vector_iget( x , i ); - if( ecl_sum_has_general_var( ecl_sum , user_key ) && ecl_sum_check_sim_time( ecl_sum , sim_time)){ - double_vector_append( refcase_value , ecl_sum_get_general_var_from_sim_time( ecl_sum, sim_time , user_key)); - double_vector_append( refcase_time , sim_time ); + /*REFCASE PLOTTING*/ + + if (plot_refcase && time_map_get_size( time_map) ) { + ecl_config_type * ecl_config = enkf_main_get_ecl_config( enkf_main ); + ecl_refcase_list_type * refcase_list = ecl_config_get_refcase_list( ecl_config ); + int num_refcase = ecl_refcase_list_get_size( refcase_list ); + + for( int iref=0; iref < num_refcase; iref++) { + ecl_sum_type * refcase = ecl_refcase_list_iget_case( refcase_list , iref ); + if ( ecl_sum_has_general_var( refcase , user_key)) { + char * refcase_label = util_alloc_sprintf("Refcase%d" , iref); + plot_dataset_type * d = plot_alloc_new_dataset( plot , refcase_label , PLOT_XY ); + int color_nr = iref % (PLOT_NUM_COLORS - 1) + 1; // Color_nr == 0 is white; we skip that. + + plot_dataset_set_style( d , LINE ); + plot_dataset_set_line_color( d , color_nr ); + plot_dataset_set_line_width(d , 2.0 ); + + for ( int i = 0; i < time_map_get_size( time_map ); i++ ){ + time_t sim_time = ( time_t ) time_map_iget( time_map , i ); + if (ecl_sum_check_sim_time( refcase , sim_time)) { + double days = ecl_sum_time2days( refcase , sim_time ); + double value = ecl_sum_get_general_var_from_sim_time( refcase , sim_time , user_key); + + if (plot_dates) + plot_dataset_append_point_xy( d , sim_time , value); + else + plot_dataset_append_point_xy( d , days , value); + } } + + free( refcase_label ); } - - util_safe_free(header_file); - util_safe_free(base); - util_safe_free(path); - ecl_sum_free(ecl_sum); - - for (int i = 0; i < double_vector_size( refcase_time ); i++) { - double days = double_vector_iget( refcase_time , i); - double value = double_vector_iget( refcase_value , i); - plot_dataset_append_point_xy( d , days , value); - } - double_vector_free( refcase_value ); - double_vector_free( refcase_time ); } - else - printf("\nCannot find refcase data file: \n%s\n", data_file); } double_vector_free( x ); @@ -479,7 +473,6 @@ static void enkf_tui_plot_ensemble__(enkf_main_type * enkf_main , printf( "No data to plot for:%s \n" , user_key); plot_free( plot ); } - free( plot_file ); bool_vector_free( has_data ); } @@ -753,6 +746,7 @@ static void * enkf_tui_plot_ensemble_mt( void * void_arg ) { } + void enkf_tui_plot_all_summary__( enkf_main_type * enkf_main , int iens1 , int iens2 , int step1 , int step2 , bool prediction_mode) { /* This code is prepared for multithreaded creation of plots; @@ -805,10 +799,9 @@ void enkf_tui_plot_all_summary__( enkf_main_type * enkf_main , int iens1 , int i + void enkf_tui_plot_all_summary(void * arg) { enkf_main_type * enkf_main = enkf_main_safe_cast( arg ); - const ensemble_config_type * ensemble_config = enkf_main_get_ensemble_config(enkf_main); - const plot_config_type * plot_config = enkf_main_get_plot_config( enkf_main ); int iens1 , iens2 , step1 , step2; bool prediction_mode; @@ -822,12 +815,14 @@ void enkf_tui_plot_all_summary(void * arg) { if(step1 != -2) step2 = enkf_tui_util_scanf_int_with_default_return_to_menu( "Stop plotting at report step [Enter: default: everything] (M: return to menu)" , PROMPT_LEN , &prediction_mode); } + if (step1 != -2 && step2 != -2){ enkf_tui_util_scanf_iens_range("Realizations members to plot(0 - %d) [default: all]" , enkf_main_get_ensemble_size( enkf_main ) , PROMPT_LEN , &iens1 , &iens2); - enkf_tui_plot_all_summary__( enkf_main , iens1 , iens2 , step1 , step2 , prediction_mode); + enkf_tui_plot_all_summary__( enkf_main , iens1 , iens2 , step1 , step2 , prediction_mode ); } } - + + diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_plot.h b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_plot.h index dfc4954689..52c5391c33 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_plot.h +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_plot.h @@ -29,4 +29,13 @@ void enkf_tui_plot_menu(void * ); void enkf_tui_plot_PC( enkf_main_type * enkf_main , const char * plot_name , const matrix_type * PC , const matrix_type * PC_obs); void enkf_tui_plot_reports(void *); void enkf_tui_plot_all_summary__( enkf_main_type * enkf_main , int iens1 , int iens2 , int step1 , int step2 , bool prediction_mode); + +void enkf_tui_plot_ensemble__(enkf_main_type * enkf_main , + const enkf_config_node_type * config_node , + const char * user_key , + const char * key_index , + int step1 , int step2 , + bool prediction_mode , + int iens1 , int iens2 , + state_enum plot_state); #endif diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_plot_rft.c b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_plot_rft.c index 20cd1ffe19..9b4940b319 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_plot_rft.c +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_plot_rft.c @@ -215,166 +215,173 @@ void enkf_tui_plot_RFTS__(enkf_main_type * enkf_main , void enkf_tui_plot_RFT_simIn(enkf_main_type * enkf_main, path_fmt_type * runpathformat, const path_fmt_type * caseformat, char * wellname , time_t recording_time, bool isMD){ - const int ens_size = enkf_main_get_ensemble_size( enkf_main ); - const plot_config_type * plot_config = enkf_main_get_plot_config( enkf_main ); - const char * data_file = plot_config_get_plot_refcase( plot_config ); - bool plot_refcase = true; - if ( strcmp( data_file , "" ) == 0) - plot_refcase = false; - /* - Start by reading RFT measurment - */ - double_vector_type * UTM_x = double_vector_alloc( 0 , 0); - double_vector_type * UTM_y = double_vector_alloc( 0 , 0); - double_vector_type * MD = double_vector_alloc( 0 , 0); - double_vector_type * TVD_z = double_vector_alloc( 0 , 0); - double_vector_type * RFT_obs = double_vector_alloc( 0 , 0); - int lines = enkf_tui_plot_read_rft_obs(enkf_main, wellname, UTM_x, UTM_y, MD, TVD_z, RFT_obs); - /* - Find ijk-list - */ - char * caseending = path_fmt_alloc_path(caseformat, false, 0); //Use the grid in ensmember 0 - char * casename = path_fmt_alloc_file(runpathformat , false, 0, caseending); - ecl_grid_type * grid = ecl_grid_load_case( casename ); - int_vector_type * i_values = int_vector_alloc( lines , 0 ); - int_vector_type * j_values = int_vector_alloc( lines , 0 ); - int_vector_type * k_values = int_vector_alloc( lines , 0 ); - int_vector_type * active = int_vector_alloc( lines , 0 ); - for (int nobs =0; nobs -1){ - int cell_index = ecl_rft_node_lookup_ijk( rft_refcase_node , int_vector_iget(i_values,nobs), int_vector_iget(j_values,nobs),int_vector_iget(k_values,nobs) ); //lookup cell - if(cell_index > -1){ - double pressure_value = ecl_rft_node_iget_pressure( rft_refcase_node , cell_index); // Pressure - double_vector_append(RFT_refcase, pressure_value); - bool_vector_append(refcase_has_data, true); - } - else{ - double_vector_append(RFT_refcase, 0.0); - bool_vector_append(refcase_has_data, false); - } - } - else { + ecl_grid_free(grid); + + /* + Find refcase rfts + */ + double_vector_type * RFT_refcase = double_vector_alloc( 0 , 0); + bool_vector_type * refcase_has_data = bool_vector_alloc(0, false); + const char * refcase_file_name = ecl_rft_file_alloc_case_filename( ecl_sum_get_case( refcase )); + + if (refcase_file_name == NULL){ + if( plot_refcase ) + util_abort("%s: Cannot find eclipse RFT file",__func__ , refcase_file_name); + + } + ecl_rft_file_type * rft_refcase_file = ecl_rft_file_alloc( refcase_file_name ); + if (refcase_file_name == NULL){ + if( plot_refcase ) + util_abort("%s: Cannot find eclipse RFT file",__func__ , refcase_file_name); + + } + const ecl_rft_node_type * rft_refcase_node = ecl_rft_file_get_well_time_rft( rft_refcase_file , wellname , recording_time); + if(rft_refcase_node == NULL){ + if( plot_refcase ) + printf("No RFT information exists for %s in refcase.\n", wellname); + + for( int nobs = 0; nobs < lines; nobs++){ double_vector_append(RFT_refcase, 0.0); bool_vector_append(refcase_has_data, false); } } - } - ecl_rft_file_free(rft_refcase_file); - /* - Get the simulated RFTs - */ - vector_type * pressure_container = vector_alloc_new(); - vector_type * has_data_container = vector_alloc_new(); - char * caseending1 = path_fmt_alloc_path(caseformat, false, 0); - char * casename1 = path_fmt_alloc_file(runpathformat , false, 0, caseending1); - const char * case_file_name1 = ecl_rft_file_alloc_case_filename(casename1 ); - bool eclipse_rft_exists = false; - if (case_file_name1 == NULL){ - util_abort("%s: Cannot find eclipse RFT file",__func__ , case_file_name1); - } - else{ - eclipse_rft_exists = true; - for (int iens = 0; iens -1){ - int cell_index = ecl_rft_node_lookup_ijk( rftnode , int_vector_iget(i_values,nobs), int_vector_iget(j_values,nobs),int_vector_iget(k_values,nobs) ); //lookup cell - double pressure_value = ecl_rft_node_iget_pressure( rftnode , cell_index); // Pressure - double_vector_iset(simulated_pressures,nobs , pressure_value); - if(cell_index > -1) - bool_vector_iset(has_data, nobs, true); - else - bool_vector_iset(has_data, nobs, false); + else{ + for( int nobs = 0; nobs < lines; nobs++){ + if( int_vector_iget(active,nobs) > -1){ + int cell_index = ecl_rft_node_lookup_ijk( rft_refcase_node , + int_vector_iget(i_values,nobs) , + int_vector_iget(j_values,nobs) , + int_vector_iget(k_values,nobs) ); //lookup cell + + if(cell_index > -1){ + double pressure_value = ecl_rft_node_iget_pressure( rft_refcase_node , cell_index); // Pressure + double_vector_append(RFT_refcase, pressure_value); + bool_vector_append(refcase_has_data, true); } - else { - double_vector_iset(simulated_pressures,nobs ,0.0); - bool_vector_iset(has_data, nobs, false); + else{ + double_vector_append(RFT_refcase, 0.0); + bool_vector_append(refcase_has_data, false); } } + else { + double_vector_append(RFT_refcase, 0.0); + bool_vector_append(refcase_has_data, false); + } } - ecl_rft_file_free(rftfile); - vector_append_owned_ref( pressure_container , simulated_pressures , double_vector_free__ ); - vector_append_owned_ref( has_data_container , has_data , bool_vector_free__ ); } + ecl_rft_file_free(rft_refcase_file); + /* + Get the simulated RFTs + */ + vector_type * pressure_container = vector_alloc_new(); + vector_type * has_data_container = vector_alloc_new(); + char * caseending1 = path_fmt_alloc_path(caseformat, false, 0); + char * casename1 = path_fmt_alloc_file(runpathformat , false, 0, caseending1); + const char * case_file_name1 = ecl_rft_file_alloc_case_filename(casename1 ); + bool eclipse_rft_exists = false; + if (case_file_name1 == NULL){ + util_abort("%s: Cannot find eclipse RFT file",__func__ , case_file_name1); + } + else{ + eclipse_rft_exists = true; + for (int iens = 0; iens -1){ + int cell_index = ecl_rft_node_lookup_ijk( rftnode , int_vector_iget(i_values,nobs), int_vector_iget(j_values,nobs),int_vector_iget(k_values,nobs) ); //lookup cell + double pressure_value = ecl_rft_node_iget_pressure( rftnode , cell_index); // Pressure + double_vector_iset(simulated_pressures,nobs , pressure_value); + if(cell_index > -1) + bool_vector_iset(has_data, nobs, true); + else + bool_vector_iset(has_data, nobs, false); + } + else { + double_vector_iset(simulated_pressures,nobs ,0.0); + bool_vector_iset(has_data, nobs, false); + } + } + } + ecl_rft_file_free(rftfile); + vector_append_owned_ref( pressure_container , simulated_pressures , double_vector_free__ ); + vector_append_owned_ref( has_data_container , has_data , bool_vector_free__ ); + } + } + /* + Do the actual plotting + */ + if(isMD) + enkf_tui_plot_RFTS__( enkf_main , wellname , MD, RFT_obs, RFT_refcase, refcase_has_data, pressure_container, active, eclipse_rft_exists, has_data_container, isMD); + else + enkf_tui_plot_RFTS__( enkf_main , wellname , TVD_z, RFT_obs, RFT_refcase, refcase_has_data, pressure_container, active, eclipse_rft_exists, has_data_container, isMD); + double_vector_free( UTM_x ); + double_vector_free( UTM_y ); + double_vector_free( MD ); + double_vector_free( TVD_z ); + double_vector_free( RFT_obs ); + double_vector_free( RFT_refcase ); + bool_vector_free( refcase_has_data ); + vector_free( pressure_container ); + vector_free( has_data_container ); + free( caseending ); + free( caseending1 ); + free( casename ); + free( casename1 ); + int_vector_free( i_values ); + int_vector_free( j_values ); + int_vector_free( k_values ); + int_vector_free( active ); } - /* - Do the actual plotting - */ - if(isMD) - enkf_tui_plot_RFTS__( enkf_main , wellname , MD, RFT_obs, RFT_refcase, refcase_has_data, pressure_container, active, eclipse_rft_exists, has_data_container, isMD); - else - enkf_tui_plot_RFTS__( enkf_main , wellname , TVD_z, RFT_obs, RFT_refcase, refcase_has_data, pressure_container, active, eclipse_rft_exists, has_data_container, isMD); - double_vector_free( UTM_x ); - double_vector_free( UTM_y ); - double_vector_free( MD ); - double_vector_free( TVD_z ); - double_vector_free( RFT_obs ); - double_vector_free( RFT_refcase ); - bool_vector_free( refcase_has_data ); - vector_free( pressure_container ); - vector_free( has_data_container ); - free( caseending ); - free( caseending1 ); - free( casename ); - free( casename1 ); - int_vector_free( i_values ); - int_vector_free( j_values ); - int_vector_free( k_values ); - int_vector_free( active ); -}; +} int enkf_tui_plot_read_rft_config(const char * rft_config_file, stringlist_type * wellnames, time_t_vector_type * dates){ diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_ranking.c b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_ranking.c index 0c63082b8d..d6d2a36423 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_ranking.c +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_ranking.c @@ -107,14 +107,13 @@ static void enkf_tui_ranking_create_data__( void * arg , bool sort_increasing) { ranking_table_type * ranking_table = enkf_main_get_ranking_table( enkf_main ); enkf_fs_type * fs = enkf_main_get_fs( enkf_main ); ensemble_config_type * ensemble_config = enkf_main_get_ensemble_config( enkf_main ); - //const int history_length = enkf_main_get_history_length( enkf_main ); + time_map_type * time_map = enkf_fs_get_time_map( fs ); const int prompt_len = 60; const char * prompt1 = "Data key to use for ranking"; - const char * prompt2 = "Report step of data"; + const char * prompt2 = "Report step of data [Blank: last step]"; const char * ranking_name = "Name of new ranking"; const char * store_prompt = "Name of file to store ranking [Blank - no store]"; - int step; state_enum state = FORECAST; char * user_key; @@ -123,26 +122,32 @@ static void enkf_tui_ranking_create_data__( void * arg , bool sort_increasing) { if (user_key != NULL) { util_printf_prompt( prompt2 , prompt_len , '=' , "=> "); { - char * step_char = util_alloc_stdin_line(); - if (step_char == NULL) - step = 0; - else { - if (util_sscanf_int( step_char , &step )) { - const enkf_config_node_type * config_node; - char * key_index; - config_node = ensemble_config_user_get_node( ensemble_config , user_key , &key_index); - if (config_node) { - util_printf_prompt(ranking_name , prompt_len , '=' , "=> "); - char * ranking_key = util_alloc_stdin_line(); - if (ranking_key != NULL) { - ranking_table_add_data_ranking( ranking_table , sort_increasing , ranking_key , user_key , key_index , fs , config_node, step , state ); - ranking_table_display_ranking( ranking_table , ranking_key ); - } - util_safe_free( ranking_key ); - } + int step = -1; + { + char * step_char = util_alloc_stdin_line(); + + if (step_char == NULL) + step = time_map_get_last_step( time_map ); + else { + util_sscanf_int( step_char , &step ); + free( step_char ); + } + } + + if (step >= 0) { + const enkf_config_node_type * config_node; + char * key_index; + config_node = ensemble_config_user_get_node( ensemble_config , user_key , &key_index); + if (config_node) { + util_printf_prompt(ranking_name , prompt_len , '=' , "=> "); + char * ranking_key = util_alloc_stdin_line(); + if (ranking_key != NULL) { + ranking_table_add_data_ranking( ranking_table , sort_increasing , ranking_key , user_key , key_index , fs , config_node, step , state ); + ranking_table_display_ranking( ranking_table , ranking_key ); + } + util_safe_free( ranking_key ); } } - util_safe_free( step_char ); } } util_safe_free( user_key ); diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_run.c b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_run.c index c3578336e3..13dcaafe40 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_run.c +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_run.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include @@ -34,6 +35,8 @@ #include #include #include +#include +#include #include #include @@ -42,7 +45,7 @@ #include /* -Set runpath runtime - disabled. + Set runpath runtime - disabled. static void enkf_tui_run_set_runpath(void * arg) { arg_pack_type * arg_pack = arg_pack_safe_cast( arg ); @@ -112,6 +115,7 @@ void enkf_tui_run_smoother(void * arg) { } + void enkf_tui_run_iterated_ES(void * enkf_main) { const int ens_size = enkf_main_get_ensemble_size( enkf_main ); const int last_report = enkf_main_get_history_length( enkf_main ); @@ -120,13 +124,14 @@ void enkf_tui_run_iterated_ES(void * enkf_main) { model_config_type * model_config = enkf_main_get_model_config( enkf_main ); const ecl_config_type * ecl_config = enkf_main_get_ecl_config( enkf_main ); const analysis_config_type * analysis_config = enkf_main_get_analysis_config( enkf_main ); + analysis_iter_config_type * iter_config = analysis_config_get_iter_config( analysis_config ); analysis_module_type * module = analysis_config_get_active_module( analysis_config ); int step1 = 0; int step2 ; int_vector_type * step_list = int_vector_alloc(0,0); bool_vector_type * iactive = bool_vector_alloc(0 , true); int iter = 0; - int num_iter = 16; + int num_iter = analysis_iter_config_get_num_iterations( iter_config ); stringlist_type * node_list = ensemble_config_alloc_keylist_from_var_type( enkf_main_get_ensemble_config(enkf_main) , PARAMETER ); if (ecl_config_has_schedule( ecl_config )) @@ -141,24 +146,25 @@ void enkf_tui_run_iterated_ES(void * enkf_main) { bool_vector_iset( iactive , ens_size - 1 , true ); while (true) { - /* { - char * user = getenv("USER"); - char * runpath_fmt = util_alloc_sprintf("/scratch/ert/%s/iteratedES/%d/run%%d" , user , iter); - model_config_set_runpath_fmt( model_config , runpath_fmt ); - free( runpath_fmt ); - } - */ - - char * target_fs_name = util_alloc_sprintf("smoother-%d" , iter); - enkf_fs_type * target_fs = enkf_main_get_alt_fs(enkf_main , target_fs_name , false , true ); - enkf_main_run_exp(enkf_main , iactive , step1 , step1 , FORECAST); - enkf_main_smoother_update(enkf_main , step_list , target_fs); { - - + const char * runpath_fmt = analysis_iter_config_iget_runpath_fmt( iter_config , iter); + if (runpath_fmt != NULL) { + char * runpath_key = util_alloc_sprintf( "runpath-%d" , iter); + model_config_add_runpath( model_config , runpath_key , runpath_fmt); + model_config_select_runpath( model_config , runpath_key ); + free( runpath_key ); + } + } + + enkf_main_run_exp(enkf_main , iactive , true , step1 , step1 , FORECAST); + { + char * target_fs_name = analysis_iter_config_iget_case( iter_config , iter ); + enkf_fs_type * target_fs = enkf_main_get_alt_fs(enkf_main , target_fs_name , false , true ); + enkf_main_smoother_update(enkf_main , step_list , target_fs); + enkf_main_copy_ensemble( enkf_main , enkf_main_get_current_fs( enkf_main ), - step2 , + 0 , // Smoother update will write on step 0 ANALYZED , target_fs, step1 , @@ -167,15 +173,17 @@ void enkf_tui_run_iterated_ES(void * enkf_main) { NULL , node_list ); - enkf_main_select_fs(enkf_main , target_fs ); + + enkf_main_set_fs(enkf_main , target_fs , enkf_fs_get_case_name( target_fs )); + free( target_fs_name ); } - - free( target_fs_name ); - iter= analysis_module_get_int(module, "ITER"); + //iter = analysis_module_get_int(module, "ITER"); + iter++; if (iter == num_iter) break; } int_vector_free( step_list ); + bool_vector_free( iactive ); } } @@ -195,26 +203,27 @@ void enkf_tui_run_iterated_ES(void * enkf_main) { void enkf_tui_run_exp(void * enkf_main) { - const int ens_size = enkf_main_get_ensemble_size( enkf_main ); - bool_vector_type * iactive = bool_vector_alloc(0,true); - bool_vector_iset( iactive , ens_size - 1 , true ); + const int ens_size = enkf_main_get_ensemble_size( enkf_main ); + bool_vector_type * iactive = bool_vector_alloc(0,false); state_enum init_state = ANALYZED; int start_report = 0; int init_step_parameters = 0; - char * select_string; { + char * prompt = util_alloc_sprintf("Which realizations to simulate (Ex: 1,3-5) [M to return to menu] : " , ens_size); + char * select_string; + util_printf_prompt(prompt , PROMPT_LEN , '=' , "=> "); select_string = util_alloc_stdin_line(); - if (select_string != NULL) { - util_sscanf_active_range( select_string , ens_size - 1 , bool_vector_get_ptr( iactive) ); - free( select_string ); - } + enkf_tui_util_sscanf_active_list( iactive , select_string , ens_size); + + util_safe_free( select_string ); free( prompt ); } - enkf_main_run_exp(enkf_main , iactive , init_step_parameters , start_report , init_state); + if (bool_vector_count_equal(iactive , true)) + enkf_main_run_exp(enkf_main , iactive , true , init_step_parameters , start_report , init_state); bool_vector_free(iactive); } @@ -223,10 +232,8 @@ void enkf_tui_run_exp(void * enkf_main) { void enkf_tui_run_create_runpath__(void * __enkf_main) { enkf_main_type * enkf_main = enkf_main_safe_cast(__enkf_main); - const int ens_size = enkf_main_get_ensemble_size( enkf_main ); - bool_vector_type * iactive = bool_vector_alloc(0,true); - bool_vector_iset( iactive , ens_size - 1 , true ); - + const int ens_size = enkf_main_get_ensemble_size( enkf_main ); + bool_vector_type * iactive = bool_vector_alloc(0,false); state_enum init_state = ANALYZED; int start_report = 0; @@ -234,14 +241,15 @@ void enkf_tui_run_create_runpath__(void * __enkf_main) { { char * prompt = util_alloc_sprintf("Which realizations to create[ensemble size:%d] : " , ens_size); char * select_string; + util_printf_prompt(prompt , PROMPT_LEN , '=' , "=> "); select_string = util_alloc_stdin_line(); - util_sscanf_active_range( select_string , ens_size - 1 , bool_vector_get_ptr( iactive) ); + enkf_tui_util_sscanf_active_list( iactive , select_string , ens_size ); + + util_safe_free( select_string ); free( prompt ); - free( select_string ); } - - enkf_main_run_exp(enkf_main , iactive , init_step_parameters , start_report , init_state); + enkf_main_run_exp(enkf_main , iactive , false , init_step_parameters , start_report , init_state); bool_vector_free(iactive); } @@ -259,9 +267,9 @@ void enkf_tui_run_manual_load__( void * arg ) { const int last_report = -1; const int ens_size = enkf_main_get_ensemble_size( enkf_main ); int step1,step2; - bool * iactive = util_calloc(ens_size , sizeof * iactive ); + bool_vector_type * iactive = bool_vector_alloc( 0 , false ); run_mode_type run_mode = ENSEMBLE_EXPERIMENT; - + enkf_main_init_run(enkf_main , run_mode); /* This is ugly */ step1 = 0; @@ -271,15 +279,16 @@ void enkf_tui_run_manual_load__( void * arg ) { char * select_string; util_printf_prompt(prompt , PROMPT_LEN , '=' , "=> "); select_string = util_alloc_stdin_line(); - util_sscanf_active_range( select_string , ens_size - 1 , iactive); + + enkf_tui_util_sscanf_active_list( iactive , select_string , ens_size ); + util_safe_free( select_string ); + free( prompt ); - free( select_string ); } - - { + if (bool_vector_count_equal( iactive , true )) { int iens; arg_pack_type ** arg_list = util_calloc( ens_size , sizeof * arg_list ); thread_pool_type * tp = thread_pool_alloc( 4 , true ); /* num_cpu - HARD coded. */ @@ -288,7 +297,7 @@ void enkf_tui_run_manual_load__( void * arg ) { arg_pack_type * arg_pack = arg_pack_alloc(); arg_list[iens] = arg_pack; - if (iactive[iens]) { + if (bool_vector_iget(iactive , iens)) { enkf_state_type * enkf_state = enkf_main_iget_state( enkf_main , iens ); arg_pack_append_ptr( arg_pack , enkf_state); /* 0: */ @@ -299,15 +308,30 @@ void enkf_tui_run_manual_load__( void * arg ) { arg_pack_append_bool( arg_pack , true ); /* 5: Interactive */ arg_pack_append_owned_ptr( arg_pack , stringlist_alloc_new() , stringlist_free__); /* 6: List of interactive mode messages. */ thread_pool_add_job( tp , enkf_state_internalize_results_mt , arg_pack); + } } thread_pool_join( tp ); thread_pool_free( tp ); printf("\n"); - + + { + qc_module_type * qc_module = enkf_main_get_qc_module( enkf_main ); + runpath_list_type * runpath_list = qc_module_get_runpath_list( qc_module ); + + for (iens = 0; iens < ens_size; iens++) { + if (bool_vector_iget(iactive , iens)) { + const enkf_state_type * state = enkf_main_iget_state( enkf_main , iens ); + runpath_list_add( runpath_list , iens , enkf_state_get_run_path( state ) , enkf_state_get_eclbase( state )); + } + } + + qc_module_export_runpath_list( qc_module ); + } + for (iens = 0; iens < ens_size; iens++) { - if (iactive[iens]) { + if (bool_vector_iget(iactive , iens)) { stringlist_type * msg_list = arg_pack_iget_ptr( arg_list[iens] , 6 ); if (stringlist_get_size( msg_list )) enkf_tui_display_load_msg( iens , msg_list ); @@ -319,18 +343,24 @@ void enkf_tui_run_manual_load__( void * arg ) { arg_pack_free( arg_list[iens]); free( arg_list ); } - free( iactive ); + bool_vector_free( iactive ); } + +/*****************************************************************/ + void enkf_tui_run_menu(void * arg) { enkf_main_type * enkf_main = enkf_main_safe_cast( arg ); + model_config_type * model_config = enkf_main_get_model_config( enkf_main ); + path_fmt_type * runpath_fmt = model_config_get_runpath_fmt( model_config ); menu_type * menu; + { - char * title = util_alloc_sprintf("Run menu [case:%s]" , enkf_main_get_current_fs( enkf_main )); + char * title = util_alloc_sprintf("Run menu [case:%s Runpath:%s]" , enkf_main_get_current_fs( enkf_main ) , path_fmt_get_fmt ( runpath_fmt )); menu = menu_alloc(title , "Back" , "bB"); free(title); } @@ -344,7 +374,7 @@ void enkf_tui_run_menu(void * arg) { menu_item_type * restart_enkf_item = menu_add_item(menu , "Restart EnKF run from arbitrary state" , "rR" , enkf_tui_run_restart__ , enkf_main , NULL); menu_item_type * ES_item = menu_add_item(menu , "Integrated smoother update" , "iI" , enkf_tui_run_smoother , enkf_main , NULL); menu_item_type * it_ES_item = menu_add_item(menu , "Iterated smoother [RML-EnKF]" , "tT" , enkf_tui_run_iterated_ES , enkf_main , NULL); - + if (!ecl_config_has_schedule( ecl_config )) { menu_item_disable( enkf_item ); menu_item_disable( restart_enkf_item ); @@ -357,7 +387,7 @@ void enkf_tui_run_menu(void * arg) { } menu_add_separator(menu); menu_add_item(menu , "Create runpath directories - NO simulation" , "cC" , enkf_tui_run_create_runpath__ , enkf_main , NULL ); - menu_add_item(menu , "Load results manually" , "lL" , enkf_tui_run_manual_load__ , enkf_main , NULL); + menu_add_item(menu , "Load results manually" , "lL" , enkf_tui_run_manual_load__ , enkf_main , NULL); menu_add_separator(menu); { menu_item_type * analysis_item = menu_add_item(menu , "Analysis menu" , "aA" , enkf_tui_analysis_menu , enkf_main , NULL); diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_util.c b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_util.c index 1ab0aa3592..c529d3b580 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_util.c +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_util.c @@ -417,6 +417,23 @@ int enkf_tui_util_scanf_int_with_default_return_to_menu(const char * prompt , in return value; } +bool enkf_tui_util_sscanf_active_list( bool_vector_type * iactive , const char * select_string , int ens_size ) { + if (select_string == NULL) { + bool_vector_set_default( iactive , true ); + bool_vector_iset( iactive , ens_size - 1 , true ); + return true; + } else { + bool OK; + OK = string_util_init_active_mask( select_string , iactive ); + + if (bool_vector_size( iactive ) < ens_size) + bool_vector_iset( iactive , ens_size - 1 , false ); + + return OK; + } +} + + /*****************************************************************/ diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_util.h b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_util.h index e443467cb4..8ef31492a5 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_util.h +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_util.h @@ -19,6 +19,7 @@ #ifndef __ENKF_TUI_UTIL_H__ #define __ENKF_TUI_UTIL_H__ +#include #include #include @@ -41,4 +42,6 @@ char * enkf_tui_util_scanf_report_step_as_char(int , cons void enkf_tui_util_msg(const char * , ...); int enkf_tui_util_scanf_int_with_default(const char * prompt , int prompt_len , bool * default_used); int enkf_tui_util_scanf_int_with_default_return_to_menu(const char * prompt , int prompt_len , bool * default_used); + +bool enkf_tui_util_sscanf_active_list( bool_vector_type * iactive , const char * select_string , int ens_size ); #endif diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_workflow.c b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_workflow.c new file mode 100644 index 0000000000..f05870931b --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_workflow.c @@ -0,0 +1,115 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'enkf_tui_workflow.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + + +void enkf_tui_workflow_run( void * arg ) { + enkf_main_type * enkf_main = enkf_main_safe_cast( arg ); + { + ert_workflow_list_type * workflow_list = enkf_main_get_workflow_list( enkf_main ); + util_printf_prompt("Name of workflow" , PROMPT_LEN , '=' , "=> "); + { + char * workflow_name = util_alloc_stdin_line(); + if (workflow_name != NULL) { + if (ert_workflow_list_has_workflow( workflow_list , workflow_name )) { + if (!ert_workflow_list_run_workflow( workflow_list , workflow_name , enkf_main )) { + printf("Errors in workflow:%s \n", workflow_name ); + printf("-----------------------------------------------------------------\n"); + config_error_fprintf( ert_workflow_list_get_last_error( workflow_list ) , true , stdout); + printf("-----------------------------------------------------------------\n"); + } + } + } + util_safe_free( workflow_name ); + } + } +} + + +void enkf_tui_workflow_load( void * arg ) { + enkf_main_type * enkf_main = enkf_main_safe_cast( arg ); + { + + } +} + + +void enkf_tui_workflow_list( void * arg ) { + enkf_main_type * enkf_main = enkf_main_safe_cast( arg ); + { + ert_workflow_list_type * workflow_list = enkf_main_get_workflow_list( enkf_main ); + stringlist_type * name_list = ert_workflow_list_alloc_namelist( workflow_list ); + + printf("Available workflows: \n"); + { + int i; + for (i=0; i < stringlist_get_size( name_list ); i++) { + if ((i % 5) == 0) + printf("\n "); + else + printf(" "); + + printf( stringlist_iget( name_list , i )); + } + } + stringlist_free( name_list ); + printf("\n\n"); + } +} + + +void enkf_tui_workflow_menu(void * arg) { + enkf_main_type * enkf_main = enkf_main_safe_cast( arg ); + menu_type * menu = menu_alloc("Workflows" , "Back" , "bB"); + + menu_add_item(menu , "Run workflow" , "rR" , enkf_tui_workflow_run , enkf_main , NULL ); + menu_add_item(menu , "Load workflow" , "lL" , enkf_tui_workflow_load , enkf_main , NULL ); + menu_add_item(menu , "List available workflows" , "iI" , enkf_tui_workflow_list , enkf_main , NULL ); + + menu_add_item(menu , "Help" , "hH" , enkf_tui_help_menu_run , enkf_main , NULL); + menu_run(menu); + menu_free(menu); + +} + diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_workflow.h b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_workflow.h new file mode 100644 index 0000000000..d8d588bef1 --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/enkf_tui_workflow.h @@ -0,0 +1,24 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'enkf_tui_workflow.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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. +*/ + +#ifndef __ENKF_TUI_WORKFLOW_H__ +#define __ENKF_TUI_WORKFLOW_H__ + +void enkf_tui_workflow_menu(void *); + +#endif diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/ert_tui_jobs.c b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/ert_tui_jobs.c index 3fd94f190e..c23f679a1e 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/ert_tui_jobs.c +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/ert_tui_jobs.c @@ -19,6 +19,9 @@ #include #include +#include +#include +#include #include @@ -34,3 +37,26 @@ void enkf_tui_plot_all_summary_JOB(void * self , const stringlist_type * args ) enkf_tui_plot_all_summary__( enkf_main , iens1 , iens2 , step1 , step2 , prediction_mode ); } + + +void enkf_tui_plot_JOB(void * self , const stringlist_type * args ) { + enkf_main_type * enkf_main = enkf_main_safe_cast( self ); + enkf_fs_type * enkf_fs = enkf_main_get_fs( enkf_main ); + time_map_type * time_map = enkf_fs_get_time_map( enkf_fs ); + ensemble_config_type * ensemble_config = enkf_main_get_ensemble_config( enkf_main ); + const int step2 = time_map_get_last_step( time_map ); + const int step1 = 0; + int i; + + for (i=0; i < stringlist_get_size( args ); i++) { + const char * user_key = stringlist_iget( args , i ); + char * key_index; + enkf_config_node_type * config_node = ensemble_config_user_get_node( ensemble_config , user_key , &key_index); + if (config_node != NULL) + enkf_tui_plot_ensemble__(enkf_main , config_node , user_key , key_index , step1 , step2 , false , 0 , enkf_main_get_ensemble_size( enkf_main ) , BOTH ); + + util_safe_free( key_index ); + } +} + + diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/main.c b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/main.c index 81d0eb563e..692c19fb07 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/main.c +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/main.c @@ -32,6 +32,7 @@ #include #include +#define WORKFLOW_OPTION "-wf" void text_splash() { const int usleep_time = 1000; @@ -51,22 +52,6 @@ void text_splash() { } -void devel_warning() { -#ifdef DEVEL_VERSION - printf("\n"); - printf(" ***************************************************************\n"); - printf(" ** You have started a development version of ERT. If you are **\n"); - printf(" ** not an advanced user, it might be better to use a stable **\n"); - printf(" ** version which has been better tested. The stable version **\n"); - printf(" ** should be available with the command: **\n"); - printf(" ** **\n"); - printf(" ** bash%% ert config_file **\n"); - printf(" ** **\n"); - printf(" ***************************************************************\n"); -#endif -} - - /* GIT_COMMIT and COMPILE_TIME_STAMP are env variables set by the makefile. Will exit if the config file does not exist. @@ -108,7 +93,7 @@ void enkf_usage() { -static void init_debug( const char * executable ) { +static void init_debug( const char * argv0) { char * git_commit = util_alloc_sprintf("git commit...........: %s \n",GIT_COMMIT); char * compile_time = util_alloc_sprintf("Compile time.........: %s \n",COMPILE_TIME_STAMP); @@ -119,39 +104,68 @@ static void init_debug( const char * executable ) { free(git_commit); free(compile_time); - if (executable != NULL) - util_abort_set_executable( executable ); + util_abort_set_executable( argv0 ); } +void parse_workflows(int argc , char ** argv , stringlist_type * workflows) { + bool workflow_on = false; + for (int iarg = 2; iarg < argc; iarg++) { + stringlist_append_copy( workflows , argv[iarg]); + + /*if (strcmp( argv[iarg] , WORKFLOW_OPTION) == 0) + workflow_on = true; + else { + if (workflow_on) + stringlist_append_copy( workflows , argv[iarg]); + else + fprintf(stderr,"**Warning - option:\'%s\' ignored\n",argv[iarg]); + } + */ + } +} + + + int main (int argc , char ** argv) { - devel_warning(); text_splash(); - init_debug( NULL ); + init_debug( argv[0] ); printf("\n"); printf("Documentation : %s \n","http://ert.nr.no"); printf("git commit : %s \n",GIT_COMMIT); printf("compile time : %s \n",COMPILE_TIME_STAMP); - printf("site config : %s \n\n",SITE_CONFIG_FILE); + printf("site config : %s \n",SITE_CONFIG_FILE); + enkf_main_install_SIGNALS(); /* Signals common to both tui and gui. */ signal(SIGINT , util_abort_signal); /* Control C - tui only. */ - if (argc != 2) { + if (argc < 2) { enkf_usage(); exit(1); } else { const char * site_config_file = SITE_CONFIG_FILE; /* The variable SITE_CONFIG_FILE should be defined on compilation ... */ const char * model_config_file = argv[1]; + stringlist_type * workflow_list = stringlist_alloc_new(); + parse_workflows( argc , argv , workflow_list ); + if ( !(util_entry_readable(model_config_file) && util_is_file(model_config_file)) ) + util_exit("Can not read file %s - exiting \n", model_config_file); + + { + char * abs_config = util_alloc_realpath( model_config_file ); + printf("model config : %s \n\n", abs_config); + } enkf_welcome( model_config_file ); { enkf_main_type * enkf_main = enkf_main_bootstrap(site_config_file , model_config_file , true , true); + enkf_main_run_workflows( enkf_main , workflow_list ); enkf_tui_main_menu(enkf_main); enkf_main_free(enkf_main); } - + + stringlist_free( workflow_list ); util_abort_free_version_info(); /* No fucking leaks ... */ } - + exit(0); } diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/upgrade_fs104.c b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/upgrade_fs104.c index 08920c4627..0a96b2a825 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_tui/upgrade_fs104.c +++ b/ThirdParty/Ert/devel/libenkf/applications/ert_tui/upgrade_fs104.c @@ -268,7 +268,11 @@ int main (int argc , char ** argv) { ecl_sum_type * refcase; { config_type * config = create_config(); - config_parse( config , model_config_file , "--" , "INCLUDE" , "DEFINE" , false , true ); + if (!config_parse( config , model_config_file , "--" , "INCLUDE" , "DEFINE" , CONFIG_UNRECOGNIZED_IGNORE , true )) { + config_fprintf_erors( config , stderr ); + exit(1); + } + { char * path; util_alloc_file_components(model_config_file , &path , NULL , NULL); diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/analysis_config.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/analysis_config.h index 86ea068d98..1ece2b5665 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/analysis_config.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/analysis_config.h @@ -20,6 +20,10 @@ #ifndef __ANALYSIS_CONFIG_H__ #define __ANALYSIS_CONFIG_H__ +#ifdef __cplusplus +extern "C" { +#endif + #include #include @@ -30,12 +34,14 @@ #include #include - +#include typedef struct analysis_config_struct analysis_config_type; + +analysis_iter_config_type * analysis_config_get_iter_config( const analysis_config_type * config ); analysis_module_type * analysis_config_get_module( analysis_config_type * config , const char * module_name ); void analysis_config_load_internal_modules( analysis_config_type * analysis ); void analysis_config_reload_module( analysis_config_type * config , const char * module_name); @@ -91,6 +97,8 @@ const char * analysis_config_get_PC_filename( const analysis_config_ty void analysis_config_set_PC_path( analysis_config_type * config , const char * path ); const char * analysis_config_get_PC_path( const analysis_config_type * config ); - +#ifdef __cplusplus +} +#endif #endif diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/analysis_iter_config.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/analysis_iter_config.h new file mode 100644 index 0000000000..27541c6b01 --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/analysis_iter_config.h @@ -0,0 +1,41 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'analysis_iter_config.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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. +*/ + +#ifndef __ANALYSIS_ITER_CONFIG_H__ +#define __ANALYSIS_ITER_CONFIG_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + +typedef struct analysis_iter_config_struct analysis_iter_config_type; + + void analysis_iter_config_set_num_iterations( analysis_iter_config_type * config , int num_iterations); + int analysis_iter_config_get_num_iterations( const analysis_iter_config_type * config ); + analysis_iter_config_type * analysis_iter_config_alloc(); + void analysis_iter_config_free( analysis_iter_config_type * config ); + const char * analysis_iter_config_iget_case( analysis_iter_config_type * config , int iter); + const char * analysis_iter_config_iget_runpath_fmt( analysis_iter_config_type * config , int iter); + void analysis_iter_config_add_config_items( config_type * config ); + void analysis_iter_config_init(analysis_iter_config_type * iter_config , const config_type * config); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/config_keys.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/config_keys.h index 8d868b5688..c0f1cf57e5 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/config_keys.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/config_keys.h @@ -45,11 +45,13 @@ extern "C" { #define DEFINE_KEY "DEFINE" #define BASE_SURFACE_KEY "BASE_SURFACE" -#define STORE_SEED_KEY "STORE_SEED" -#define LOAD_SEED_KEY "LOAD_SEED" -#define ENKF_BOOTSTRAP_KEY "ENKF_BOOTSTRAP" -#define ENKF_PEN_PRESS_KEY "ENKF_PEN_PRESS" +#define ADD_FIXED_LENGTH_SCHEDULE_KW_KEY "ADD_FIXED_LENGTH_SCHEDULE_KW" +#define ANALYSIS_COPY_KEY "ANALYSIS_COPY" +#define ANALYSIS_LOAD_KEY "ANALYSIS_LOAD" +#define ANALYSIS_SET_VAR_KEY "ANALYSIS_SET_VAR" +#define ANALYSIS_SELECT_KEY "ANALYSIS_SELECT" #define CASE_TABLE_KEY "CASE_TABLE" +#define CONTAINER_KEY "CONTAINER" #define DATA_FILE_KEY "DATA_FILE" #define DATA_KW_KEY "DATA_KW" #define DBASE_TYPE_KEY "DBASE_TYPE" @@ -57,6 +59,8 @@ extern "C" { #define DELETE_RUNPATH_KEY "DELETE_RUNPATH" #define ECLBASE_KEY "ECLBASE" #define END_DATE_KEY "END_DATE" +#define ENKF_BOOTSTRAP_KEY "ENKF_BOOTSTRAP" +#define ENKF_PEN_PRESS_KEY "ENKF_PEN_PRESS" #define ENKF_ALPHA_KEY "ENKF_ALPHA" #define ENKF_CROSS_VALIDATION_KEY "ENKF_CROSS_VALIDATION" #define ENKF_CV_FOLDS_KEY "ENKF_CV_FOLDS" @@ -73,8 +77,9 @@ extern "C" { #define ENKF_SCHED_FILE_KEY "ENKF_SCHED_FILE" #define ENKF_TRUNCATION_KEY "ENKF_TRUNCATION" #define ENSPATH_KEY "ENSPATH" +#define ITER_CASE_KEY "ITER_CASE" +#define ITER_COUNT_KEY "ITER_COUNT" #define FIELD_KEY "FIELD" -#define SURFACE_KEY "SURFACE" #define FORWARD_MODEL_KEY "FORWARD_MODEL" #define GEN_DATA_KEY "GEN_DATA" #define GEN_KW_KEY "GEN_KW" @@ -83,6 +88,7 @@ extern "C" { #define GRID_KEY "GRID" #define HISTORY_SOURCE_KEY "HISTORY_SOURCE" #define HOSY_TYPE_KEY "HOST_TYPE" +#define IGNORE_SCHEDULE_KEY "IGNORE_SCHEDULE" #define IMAGE_TYPE_KEY "IMAGE_TYPE" #define IMAGE_VIEWER_KEY "IMAGE_VIEWER" #define INIT_SECTION_KEY "INIT_SECTION" @@ -91,8 +97,8 @@ extern "C" { #define JOBNAME_KEY "JOBNAME" #define KEEP_RUNPATH_KEY "KEEP_RUNPATH" #define LICENSE_PATH_KEY "LICENSE_PATH" +#define LOAD_SEED_KEY "LOAD_SEED" #define LOCAL_CONFIG_KEY "LOCAL_CONFIG" -#define ADD_FIXED_LENGTH_SCHEDULE_KW_KEY "ADD_FIXED_LENGTH_SCHEDULE_KW" #define LOG_FILE_KEY "LOG_FILE" #define LOG_LEVEL_KEY "LOG_LEVEL" #define LSF_QUEUE_KEY "LSF_QUEUE" @@ -112,27 +118,32 @@ extern "C" { #define PLOT_HEIGHT_KEY "PLOT_HEIGHT" #define PLOT_PATH_KEY "PLOT_PATH" #define PLOT_REFCASE_KEY "PLOT_REFCASE" +#define PLOT_REFCASE_LIST_KEY "PLOT_REFCASE_LIST" #define PLOT_WIDTH_KEY "PLOT_WIDTH" #define PRE_CLEAR_RUNPATH_KEY "PRE_CLEAR_RUNPATH" #define QUEUE_SYSTEM_KEY "QUEUE_SYSTEM" #define QUEUE_OPTION_KEY "QUEUE_OPTION" #define QC_PATH_KEY "QC_PATH" +#define QC_WORKFLOW_KEY "QC_WORKFLOW" #define REFCASE_KEY "REFCASE" +#define REFCASE_LIST_KEY "REFCASE_LIST" #define REPORT_CONTEXT_KEY "REPORT_CONTEXT" #define REPORT_SEARCH_PATH_KEY "REPORT_SEARCH_PATH" +#define REPORT_LARGE_KEY "REPORT_LARGE" #define REPORT_LIST_KEY "REPORT_LIST" #define REPORT_PATH_KEY "REPORT_PATH" #define REPORT_WELL_LIST_KEY "REPORT_WELL_LIST" #define REPORT_GROUP_LIST_KEY "REPORT_GROUP_LIST" +#define REPORT_TIMEOUT_KEY "REPORT_TIMEOUT" #define RERUN_START_KEY "RERUN_START" #define RSH_COMMAND_KEY "RSH_COMMAND" #define RSH_HOST_KEY "RSH_HOST" #define RUNPATH_KEY "RUNPATH" +#define ITER_RUNPATH_KEY "ITER_RUNPATH" #define RERUN_PATH_KEY "RERUN_PATH" #define RUN_TEMPLATE_KEY "RUN_TEMPLATE" #define RFT_CONFIG_KEY "RFT_CONFIG" #define RFTPATH_KEY "RFTPATH" -#define IGNORE_SCHEDULE_KEY "IGNORE_SCHEDULE" #define SCHEDULE_FILE_KEY "SCHEDULE_FILE" #define SCHEDULE_PREDICTION_FILE_KEY "SCHEDULE_PREDICTION_FILE" #define SCHEDULE_PREDICTION_FILE_KEY "SCHEDULE_PREDICTION_FILE" @@ -143,20 +154,16 @@ extern "C" { #define STATIC_KW_KEY "ADD_STATIC_KW" #define STD_CUTOFF_KEY "STD_CUTOFF" #define SUMMARY_KEY "SUMMARY" -#define CONTAINER_KEY "CONTAINER" -#define UMASK_KEY "UMASK" +#define SURFACE_KEY "SURFACE" #define UPDATE_LOG_PATH_KEY "UPDATE_LOG_PATH" #define UPDATE_PATH_KEY "UPDATE_PATH" #define UPDATE_RESULTS_KEY "UPDATE_RESULTS" #define SINGLE_NODE_UPDATE_KEY "SINGLE_NODE_UPDATE" - -#define ANALYSIS_COPY_KEY "ANALYSIS_COPY" -#define ANALYSIS_LOAD_KEY "ANALYSIS_LOAD" -#define ANALYSIS_SET_VAR_KEY "ANALYSIS_SET_VAR" -#define ANALYSIS_SELECT_KEY "ANALYSIS_SELECT" - - - +#define STORE_SEED_KEY "STORE_SEED" +#define UMASK_KEY "UMASK" +#define WORKFLOW_JOB_DIRECTORY_KEY "WORKFLOW_JOB_DIRECTORY" +#define LOAD_WORKFLOW_KEY "LOAD_WORKFLOW" +#define LOAD_WORKFLOW_JOB_KEY "LOAD_WORKFLOW_JOB" #define CONFIG_BOOL_STRING( var ) (var) ? "TRUE" : "FALSE" diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ecl_config.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ecl_config.h index 770f04fb48..de3c1d08bb 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ecl_config.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ecl_config.h @@ -33,8 +33,11 @@ extern "C" { #include +#include + typedef struct ecl_config_struct ecl_config_type; + void ecl_config_static_kw_init( ecl_config_type * ecl_config , const config_type * config ); bool ecl_config_active( const ecl_config_type * config ); time_t ecl_config_get_end_date( const ecl_config_type * ecl_config ); time_t ecl_config_get_start_date( const ecl_config_type * ecl_config ); @@ -60,6 +63,8 @@ extern "C" { const path_fmt_type * ecl_config_get_eclbase_fmt(const ecl_config_type * ); int ecl_config_get_num_restart_files(const ecl_config_type * ); const ecl_sum_type * ecl_config_get_refcase(const ecl_config_type * ecl_config); + bool ecl_config_has_refcase( const ecl_config_type * ecl_config ); + ecl_refcase_list_type * ecl_config_get_refcase_list( const ecl_config_type * ecl_config ); ecl_grid_type * ecl_config_get_grid(const ecl_config_type * ); void ecl_config_set_grid( ecl_config_type * ecl_config , const char * grid_file ); const char * ecl_config_get_gridfile( const ecl_config_type * ecl_config ); @@ -71,7 +76,7 @@ extern "C" { const char * ecl_config_get_eclbase( const ecl_config_type * ecl_config ); const char * ecl_config_get_schedule_file( const ecl_config_type * ecl_config ); void ecl_config_set_schedule_file( ecl_config_type * ecl_config , const char * schedule_file ); - void ecl_config_load_refcase( ecl_config_type * ecl_config , const char * refcase); + bool ecl_config_load_refcase( ecl_config_type * ecl_config , const char * refcase); const char * ecl_config_get_refcase_name( const ecl_config_type * ecl_config); void ecl_config_clear_static_kw( ecl_config_type * ecl_config ); stringlist_type * ecl_config_get_static_kw_list( const ecl_config_type * ecl_config ); diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ecl_refcase_list.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ecl_refcase_list.h new file mode 100644 index 0000000000..35904f0c0e --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ecl_refcase_list.h @@ -0,0 +1,49 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'ecl_refcase_list.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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. +*/ + + +#ifndef __ECL_REFCASE_LIST_H__ +#define __ECL_REFCASE_LIST_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + + + typedef struct ecl_refcase_list_struct ecl_refcase_list_type; + + ecl_refcase_list_type * ecl_refcase_list_alloc( ); + void ecl_refcase_list_free( ecl_refcase_list_type * refcase_list ); + + bool ecl_refcase_list_has_default( ecl_refcase_list_type * refcase_list ); + const ecl_sum_type * ecl_refcase_list_get_default( ecl_refcase_list_type * refcase_list ); + bool ecl_refcase_list_set_default( ecl_refcase_list_type * refcase_list , const char * default_case); + int ecl_refcase_list_get_size(ecl_refcase_list_type * refcase_list ); + int ecl_refcase_list_add_matching( ecl_refcase_list_type * refcase_list , const char * glob_string); + int ecl_refcase_list_add_case( ecl_refcase_list_type * refcase_list , const char * case_name); + const char * ecl_refcase_list_iget_pathcase( ecl_refcase_list_type * refcase_list , int index); + const ecl_sum_type * ecl_refcase_list_iget_case( ecl_refcase_list_type * refcase_list , int index); + const ecl_sum_type * ecl_refcase_list_get_case( ecl_refcase_list_type * refcase_list , const char * case_name); + bool ecl_refcase_list_has_case( ecl_refcase_list_type * refcase_list , const char * case_name); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_defaults.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_defaults.h index 57dac03ab9..3b758cbd09 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_defaults.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_defaults.h @@ -79,7 +79,7 @@ model_config_set_history_source() does currently not handle a default value different from SCHEDULE. */ -#define DEFAULT_HISTORY_SOURCE HISTORY_SOURCE_INVALID +#define DEFAULT_HISTORY_SOURCE REFCASE_HISTORY #define DEFAULT_MAX_SUBMIT 2 /* The number of times to resubmit - default value for config item: MAX_SUBMIT */ @@ -95,36 +95,39 @@ Defaults for the EnKF analysis. The analysis_config object is instantiated with these values. */ -#define DEFAULT_ENKF_MODE ENKF_STANDARD -#define DEFAULT_NCOMP 1 -#define DEFAULT_ENKF_TRUNCATION 0.99 -#define DEFAULT_ENKF_ALPHA 1.50 /* Should be raised ?? */ -#define DEFAULT_ENKF_STD_CUTOFF 1e-6 -#define DEFAULT_MERGE_OBSERVATIONS false -#define DEFAULT_RERUN false -#define DEFAULT_RERUN_START 0 -#define DEFAULT_UPDATE_LOG_PATH "update_log" -#define DEFAULT_CV_NFOLDS 10 -#define DEFAULT_ENKF_SCALING true -#define DEFAULT_ENKF_KERNEL_REG false -#define DEFAULT_ENKF_KERNEL_FUNC 1 /*Default is the Gaussian */ -#define DEFAULT_ENKF_KERNEL_PARAM 1 /*Scale by the maximum value in the distance matrix */ -#define DEFAULT_ENKF_CV false -#define DEFAULT_ENKF_BOOTSTRAP false -#define DEFAULT_ENKF_PEN_PRESS false -#define DEFAULT_ENKF_FORCE_NCOMP false -#define DEFAULT_UPDATE_RESULTS false -#define DEFAULT_SINGLE_NODE_UPDATE true -#define DEFAULT_ANALYSIS_MODULE "STD_ENKF" +#define DEFAULT_ENKF_MODE ENKF_STANDARD +#define DEFAULT_NCOMP 1 +#define DEFAULT_ENKF_TRUNCATION 0.99 +#define DEFAULT_ENKF_ALPHA 1.50 /* Should be raised ?? */ +#define DEFAULT_ENKF_STD_CUTOFF 1e-6 +#define DEFAULT_MERGE_OBSERVATIONS false +#define DEFAULT_RERUN false +#define DEFAULT_RERUN_START 0 +#define DEFAULT_UPDATE_LOG_PATH "update_log" +#define DEFAULT_CV_NFOLDS 10 +#define DEFAULT_ENKF_SCALING true +#define DEFAULT_ENKF_KERNEL_REG false +#define DEFAULT_ENKF_KERNEL_FUNC 1 /*Default is the Gaussian */ +#define DEFAULT_ENKF_KERNEL_PARAM 1 /*Scale by the maximum value in the distance matrix */ +#define DEFAULT_ENKF_CV false +#define DEFAULT_ENKF_BOOTSTRAP false +#define DEFAULT_ENKF_PEN_PRESS false +#define DEFAULT_ENKF_FORCE_NCOMP false +#define DEFAULT_UPDATE_RESULTS false +#define DEFAULT_SINGLE_NODE_UPDATE true +#define DEFAULT_ANALYSIS_MODULE "STD_ENKF" +#define DEFAULT_ANALYSIS_NUM_ITERATIONS 1 /* Default directories. */ -#define DEFAULT_QC_PATH "QC" -#define DEFAULT_REPORT_PATH "reports" -#define DEFAULT_PLOT_PATH "plots" -#define DEFAULT_RUNPATH "simulations/realization%d" -#define DEFAULT_ENSPATH "storage" -#define DEFAULT_RFTPATH "rft" -#define DEFAULT_PLOT_REFCASE "" +#define DEFAULT_QC_PATH "QC" +#define DEFAULT_REPORT_PATH "reports" +#define DEFAULT_PLOT_PATH "plots" +#define DEFAULT_RUNPATH "simulations/realization%d" +#define DEFAULT_ENSPATH "storage" +#define DEFAULT_RFTPATH "rft" +#define DEFAULT_PLOT_REFCASE true +#define DEFAULT_REPORT_LARGE false +#define DEFAULT_REPORT_TIMEOUT 120 #define DEFAULT_PRE_CLEAR_RUNPATH false @@ -144,7 +147,7 @@ #define SUMMARY_KEY_JOIN_STRING ":" #define USER_KEY_JOIN_STRING ":" - +#define DEFAULT_WORKFLOW_VERBOSE false /* Some #define symbols used when saving configuration files. diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_fs.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_fs.h index ef3ffc9932..690e15cce9 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_fs.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_fs.h @@ -37,6 +37,8 @@ extern "C" { #include const char * enkf_fs_get_mount_point( const enkf_fs_type * fs ); + const char * enkf_fs_get_root_path( const enkf_fs_type * fs ); + const char * enkf_fs_get_case_name( const enkf_fs_type * fs ); void enkf_fs_fsync( enkf_fs_type * fs ); enkf_fs_type * enkf_fs_mount(const char * , fs_driver_impl , const char * select_case, bool update_map, bool read_only); diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_main.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_main.h index cf6b5a7060..b82d61d3b7 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_main.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_main.h @@ -56,6 +56,8 @@ extern "C" { #include #include #include +#include +#include /*****************************************************************/ @@ -75,7 +77,7 @@ extern "C" { const char * enkf_main_get_rft_config_file( const enkf_main_type * enkf_main ); bool enkf_main_get_pre_clear_runpath( const enkf_main_type * enkf_main ); void enkf_main_set_pre_clear_runpath( enkf_main_type * enkf_main , bool pre_clear_runpath); - void enkf_main_set_refcase( enkf_main_type * enkf_main , const char * refcase_path); + bool enkf_main_set_refcase( enkf_main_type * enkf_main , const char * refcase_path); ert_report_list_type * enkf_main_get_report_list( const enkf_main_type * enkf_main ); ert_templates_type * enkf_main_get_templates( enkf_main_type * enkf_main ); @@ -98,6 +100,7 @@ extern "C" { void enkf_main_add_well(enkf_main_type * , const char * , int , const char ** ); void enkf_main_analysis(enkf_main_type * ); void enkf_main_free(enkf_main_type * ); + void enkf_main_exit(enkf_main_type * enkf_main); void enkf_main_init_eclipse(enkf_main_type * , int , int ); void enkf_main_init_run( enkf_main_type * enkf_main, run_mode_type run_mode); void enkf_main_load_ecl_init_mt(enkf_main_type * enkf_main , int ); @@ -109,6 +112,7 @@ extern "C" { void enkf_main_run_exp(enkf_main_type * enkf_main , const bool_vector_type * iactive , + bool simulate , int init_step_parameters , int start_report , state_enum start_state); @@ -163,7 +167,7 @@ extern "C" { const char * enkf_main_get_image_viewer(const enkf_main_type * ); const char * enkf_main_get_plot_driver(const enkf_main_type * enkf_main ); const char * enkf_main_get_image_type(const enkf_main_type * enkf_main); - void enkf_main_initialize_from_scratch(enkf_main_type * enkf_main , const stringlist_type * param_list , int iens1 , int iens2); + void enkf_main_initialize_from_scratch(enkf_main_type * enkf_main , const stringlist_type * param_list , int iens1 , int iens2, bool force_init); void enkf_main_initialize_from_existing(enkf_main_type * enkf_main , const char * source_case , @@ -215,7 +219,10 @@ extern "C" { void enkf_main_update_node( enkf_main_type * enkf_main , const char * key ); void enkf_main_fprintf_config( const enkf_main_type * enkf_main ); int_vector_type * enkf_main_update_alloc_step_list( const enkf_main_type * enkf_main , int load_start , int step2 , int stride); - + + const qc_module_type * enkf_main_get_qc_module( const enkf_main_type * enkf_main ); + bool enkf_main_has_QC_workflow( const enkf_main_type * enkf_main ); + void enkf_main_get_PC( const enkf_main_type * enkf_main , const matrix_type * S, const matrix_type * dObs, @@ -230,6 +237,14 @@ extern "C" { void enkf_main_set_verbose( enkf_main_type * enkf_main , bool verbose); bool enkf_main_get_verbose( const enkf_main_type * enkf_main ); + ert_workflow_list_type * enkf_main_get_workflow_list( enkf_main_type * enkf_main ); + void enkf_main_run_workflows( enkf_main_type * enkf_main , const stringlist_type * workflows); + bool enkf_main_run_workflow( enkf_main_type * enkf_main , const char * workflow); + + enkf_main_type * enkf_main_alloc_empty( ); + + rng_config_type * enkf_main_get_rng_config( const enkf_main_type * enkf_main ); + UTIL_SAFE_CAST_HEADER(enkf_main); #ifdef __cplusplus diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_obs.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_obs.h index 2b714fa247..02bbbb1ed9 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_obs.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_obs.h @@ -40,19 +40,22 @@ extern "C" { bool enkf_obs_have_obs( const enkf_obs_type * enkf_obs ); const char * enkf_obs_get_config_file( const enkf_obs_type * enkf_obs); - enkf_obs_type * enkf_obs_alloc( const history_type * hist, double std_cutoff ); + enkf_obs_type * enkf_obs_alloc( ); void enkf_obs_free( enkf_obs_type * enkf_obs); obs_vector_type * enkf_obs_get_vector(const enkf_obs_type * , const char * ); void enkf_obs_load(enkf_obs_type * enkf_obs, + const history_type * history , const char * config_file, const ecl_grid_type * grid , const ecl_sum_type * refcase , + double std_cutoff , ensemble_config_type * ensemble_config); - void enkf_obs_reload( enkf_obs_type * enkf_obs , const ecl_grid_type * grid , const ecl_sum_type * refcase , ensemble_config_type * ensemble_config ); + void enkf_obs_reload( enkf_obs_type * enkf_obs , const history_type * history , + const ecl_grid_type * grid , const ecl_sum_type * refcase , double std_cutoff , ensemble_config_type * ensemble_config ); void enkf_obs_get_obs_and_measure( const enkf_obs_type * enkf_obs, diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_state.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_state.h index 2bf0273c3c..db41476993 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_state.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_state.h @@ -67,13 +67,12 @@ typedef struct enkf_state_struct enkf_state_type; bool enkf_state_resubmit_simulation( enkf_state_type * enkf_state , enkf_fs_type * fs , bool resample); bool enkf_state_kill_simulation( const enkf_state_type * enkf_state ); void * enkf_state_internalize_results_mt( void * arg ); - void enkf_state_initialize(enkf_state_type * enkf_state , enkf_fs_type * fs, const stringlist_type * param_list); + void enkf_state_initialize(enkf_state_type * enkf_state , enkf_fs_type * fs, const stringlist_type * param_list , bool force_init); void enkf_state_fread(enkf_state_type * , enkf_fs_type * fs , int , int , state_enum ); bool enkf_state_get_analyzed(const enkf_state_type * ); void enkf_state_set_analyzed(enkf_state_type * , bool ); void enkf_state_swapout_node(const enkf_state_type * , const char *); void enkf_state_swapin_node(const enkf_state_type * , const char *); - enkf_state_type * enkf_state_copyc(const enkf_state_type * ); void enkf_state_iset_eclpath(enkf_state_type * , int , const char *); enkf_node_type * enkf_state_get_node(const enkf_state_type * , const char * ); void enkf_state_del_node(enkf_state_type * , const char * ); @@ -110,8 +109,10 @@ typedef struct enkf_state_struct enkf_state_type; int enkf_state_get_iens(const enkf_state_type * ); member_config_type *enkf_state_get_member_config(const enkf_state_type * enkf_state); const char * enkf_state_get_run_path(const enkf_state_type * ); + const char * enkf_state_get_eclbase( const enkf_state_type * enkf_state ); void enkf_state_printf_subst_list(enkf_state_type * enkf_state , int step1 , int step2); + unsigned int enkf_state_get_random( enkf_state_type * enkf_state ); /*****************************************************************/ void enkf_state_set_inactive(enkf_state_type * state); diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_types.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_types.h index 40500e70bb..28e3000d8d 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_types.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/enkf_types.h @@ -168,7 +168,8 @@ typedef enum { TRUNCATE_NONE = 0, typedef enum { ENKF_ASSIMILATION = 1, ENSEMBLE_EXPERIMENT = 2, - SMOOTHER_UPDATE = 4 } run_mode_type; + SMOOTHER_UPDATE = 4 , + INIT_ONLY = 8 } run_mode_type; #define ENKF_RUN_ENUM_DEFS {.value = 1 , .name = "ENKF_ASSIMILATION"}, \ diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ensemble_config.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ensemble_config.h index 0492450ec9..63b6425303 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ensemble_config.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ensemble_config.h @@ -69,6 +69,10 @@ typedef struct ensemble_config_struct ensemble_config_type; void ensemble_config_init_internalization( ensemble_config_type * ); void ensemble_config_del_node(ensemble_config_type * , const char * ); void ensemble_config_add_config_items(config_type * ); + + void ensemble_config_add_GEN_PARAM_config_item( config_type * config ); + void ensemble_config_init_GEN_PARAM( ensemble_config_type * ensemble_config , const config_type * config ); + enkf_config_node_type * ensemble_config_get_node(const ensemble_config_type * , const char * ); stringlist_type * ensemble_config_alloc_keylist(const ensemble_config_type *); stringlist_type * ensemble_config_alloc_keylist_from_var_type(const ensemble_config_type * , int var_mask); diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_report.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_report.h index 1c1eb114ff..8a93390fde 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_report.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_report.h @@ -30,9 +30,10 @@ extern "C" { ert_report_type * ert_report_alloc( const char * source_file , const char * target_file ); void ert_report_free( ert_report_type * ert_report ); void ert_report_free__(void * arg); - bool ert_report_create( ert_report_type * ert_report , const subst_list_type * context , const char * plot_path , const char * target_path ); + bool ert_report_create( ert_report_type * ert_report , int latex_timeout , const subst_list_type * context , const char * plot_path , const char * target_path ); const char * ert_report_get_basename( const ert_report_type * ert_report ); const char * ert_report_get_work_path( const ert_report_type * ert_report ); + void ert_report_set_latex_timeout( ert_report_type * ert_report , int timeout); #ifdef __cplusplus } diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_report_list.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_report_list.h index 2988abc73d..679f54263e 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_report_list.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_report_list.h @@ -43,7 +43,11 @@ extern "C" { void ert_report_list_add_global_context( ert_report_list_type * report_list , const char * key , const char * value); void ert_report_list_site_init( ert_report_list_type * report_list , config_type * config ); void ert_report_list_init( ert_report_list_type * report_list , config_type * config , const ecl_sum_type * refcase); - void ert_report_list_create( const ert_report_list_type * report_list , const char * current_case , bool verbose ); + void ert_report_list_create( ert_report_list_type * report_list , const char * current_case , bool verbose ); + void ert_report_list_add_config_items( config_type * config ); + int ert_report_list_get_latex_timeout( const ert_report_list_type * report_list ); + bool ert_report_list_get_init_large_report( const ert_report_list_type * report_list ); + void ert_report_list_set_init_large_report( ert_report_list_type * report_list , bool init_large_report); #ifdef __cplusplus } diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_template.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_template.h index 37788ee01e..d6c5c6be91 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_template.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_template.h @@ -26,6 +26,8 @@ extern "C" { #include #include +#include + typedef struct ert_template_struct ert_template_type; typedef struct ert_templates_struct ert_templates_type; @@ -50,6 +52,7 @@ const char * ert_template_get_template_file( const ert_template_type * e const char * ert_template_get_target_file( const ert_template_type * ert_template); const char * ert_template_get_args_as_string( const ert_template_type * ert_template ); void ert_templates_fprintf_config( const ert_templates_type * ert_templates , FILE * stream ); +void ert_templates_init( ert_templates_type * templates , const config_type * config ); #ifdef __cplusplus } diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_workflow_list.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_workflow_list.h new file mode 100644 index 0000000000..1f7d6875e8 --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/ert_workflow_list.h @@ -0,0 +1,58 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'ert_workflow_list.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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. +*/ + +#ifndef __ERT_WORKFLOW_LIST_H__ +#define __ERT_WORKFLOW_LIST_H__ + + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#include +#include + +#include + + + typedef struct ert_workflow_list_struct ert_workflow_list_type; + + workflow_type * ert_workflow_list_get_workflow(ert_workflow_list_type * workflow_list , const char * workflow_name ); + workflow_type * ert_workflow_list_add_workflow( ert_workflow_list_type * workflow_list , const char * workflow_file , const char * workflow_name); + void ert_workflow_list_free( ert_workflow_list_type * workflow_list ); + ert_workflow_list_type * ert_workflow_list_alloc( const subst_list_type * subst_list ); + void ert_workflow_list_add_jobs_in_directory( ert_workflow_list_type * workflow_list , const char * path , log_type * logh); + void ert_workflow_list_add_job( ert_workflow_list_type * workflow_list , const char * job_name , const char * config_file ); + void ert_workflow_list_add_alias( ert_workflow_list_type * workflow_list , const char * real_name , const char * alias); + void ert_workflow_list_add_config_items( config_type * config ); + void ert_workflow_list_init( ert_workflow_list_type * workflow_list , config_type * config , log_type * logh); + bool ert_workflow_list_run_workflow(ert_workflow_list_type * workflow_list , const char * workflow_name , void * self); + bool ert_workflow_list_run_workflow__(ert_workflow_list_type * workflow_list , workflow_type * workflow, bool verbose , void * self ); + bool ert_workflow_list_has_workflow(ert_workflow_list_type * workflow_list , const char * workflow_name ); + stringlist_type * ert_workflow_list_alloc_namelist( ert_workflow_list_type * workflow_list ); + const config_error_type * ert_workflow_list_get_last_error( const ert_workflow_list_type * workflow_list); + void ert_workflow_list_set_verbose( ert_workflow_list_type * workflow_list , bool verbose); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_config.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_config.h index 8b26c20d2b..0dc49fb512 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_config.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/local_config.h @@ -123,7 +123,7 @@ typedef enum { typedef struct local_config_struct local_config_type; -local_config_type * local_config_alloc( int history_length ); +local_config_type * local_config_alloc( ); void local_config_free( local_config_type * local_config ); local_updatestep_type * local_config_alloc_updatestep( local_config_type * local_config , const char * key ); local_ministep_type * local_config_alloc_ministep( local_config_type * local_config , const char * key , const char * obsset_name); diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/plot_config.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/plot_config.h index cad4fa918e..9e275d9e94 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/plot_config.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/plot_config.h @@ -19,13 +19,14 @@ #ifndef __PLOT_CONFIG_H__ #define __PLOT_CONFIG_H__ #include +#include typedef struct plot_config_struct plot_config_type; void plot_config_set_width(plot_config_type * plot_config , int width); void plot_config_set_height(plot_config_type * plot_config , int height); void plot_config_set_path(plot_config_type * plot_config , const char * plot_path); -void plot_config_set_plot_refcase(plot_config_type * plot_config , const char * plot_refcase); + void plot_config_set_image_type(plot_config_type * plot_config , const char * plot_device); void plot_config_set_viewer(plot_config_type * plot_config , const char * plot_viewer); void plot_config_set_driver(plot_config_type * plot_config , const char * plot_driver);; @@ -36,7 +37,8 @@ bool plot_config_get_plot_errorbar(const plot_config_type * plot_c int plot_config_get_width(const plot_config_type * plot_config ); int plot_config_get_height(const plot_config_type * plot_config ); const char * plot_config_get_path(const plot_config_type * plot_config ); -const char * plot_config_get_plot_refcase(const plot_config_type * plot_config); +bool plot_config_get_plot_refcase(const plot_config_type * plot_config); +void plot_config_set_plot_refcase(plot_config_type * plot_config, bool plot_refcase); const char * plot_config_get_image_type(const plot_config_type * plot_config ); const char * plot_config_get_viewer(const plot_config_type * plot_config ); const char * plot_config_get_driver(const plot_config_type * plot_config ); diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/qc_config.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/qc_config.h deleted file mode 100644 index 89fc077d50..0000000000 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/qc_config.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'qc_config.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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. -*/ -#ifndef __QC_CONFIG_H__ -#define __QC_CONFIG_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - - typedef struct qc_config_struct qc_config_type; - - qc_config_type * qc_config_alloc(const char * qc_path); - void qc_config_free(); - - void qc_config_set_path( qc_config_type * qc_config , const char * qc_path); - const char * qc_config_get_path( const qc_config_type * qc_config ); - void qc_config_init( qc_config_type * qc_config , const config_type * config); - - -#ifdef __cplusplus -} -#endif -#endif diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/qc_module.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/qc_module.h new file mode 100644 index 0000000000..d90b4de24f --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/qc_module.h @@ -0,0 +1,50 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'qc_module.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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. +*/ +#ifndef __QC_MODULE_H__ +#define __QC_MODULE_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include +#include + + typedef struct qc_module_struct qc_module_type; + + bool qc_module_has_workflow( const qc_module_type * qc_module ); + qc_module_type * qc_module_alloc(ert_workflow_list_type * workflow_list , const char * qc_path); + void qc_module_free(); + bool qc_module_run_workflow( qc_module_type * qc_module , void * self); + runpath_list_type * qc_module_get_runpath_list( qc_module_type * qc_module ); + void qc_module_set_path( qc_module_type * qc_module , const char * qc_path); + const char * qc_module_get_path( const qc_module_type * qc_module ); + void qc_module_init( qc_module_type * qc_module , const config_type * config); + void qc_module_export_runpath_list( const qc_module_type * qc_module ); + void qc_module_add_config_items( config_type * config ); + void qc_module_set_runpath_list_file( qc_module_type * qc_module , const char * filename); + const char * qc_module_get_runpath_list_file( qc_module_type * qc_module); + + + +#ifdef __cplusplus +} +#endif +#endif diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/rng_config.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/rng_config.h index 7b18f918d1..461e7fcdf6 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/rng_config.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/rng_config.h @@ -29,17 +29,18 @@ extern "C" { typedef struct rng_config_struct rng_config_type; -void rng_config_fprintf_config( rng_config_type * rng_config , FILE * stream ); -void rng_config_init( rng_config_type * rng_config , config_type * config ); -void rng_config_set_type( rng_config_type * rng_config , rng_alg_type type); -rng_alg_type rng_config_get_type(const rng_config_type * rng_config ); -const char * rng_config_get_seed_load_file( const rng_config_type * rng_config ); -void rng_config_set_seed_load_file( rng_config_type * rng_config , const char * seed_load_file); -const char * rng_config_get_seed_store_file( const rng_config_type * rng_config ); -void rng_config_set_seed_store_file( rng_config_type * rng_config , const char * seed_store_file); -rng_config_type * rng_config_alloc( ); -void rng_config_free( rng_config_type * rng); -void rng_config_add_config_items( config_type * config ); + void rng_config_fprintf_config( rng_config_type * rng_config , FILE * stream ); + void rng_config_init( rng_config_type * rng_config , config_type * config ); + void rng_config_set_type( rng_config_type * rng_config , rng_alg_type type); + rng_alg_type rng_config_get_type(const rng_config_type * rng_config ); + const char * rng_config_get_seed_load_file( const rng_config_type * rng_config ); + void rng_config_set_seed_load_file( rng_config_type * rng_config , const char * seed_load_file); + const char * rng_config_get_seed_store_file( const rng_config_type * rng_config ); + void rng_config_set_seed_store_file( rng_config_type * rng_config , const char * seed_store_file); + rng_config_type * rng_config_alloc( ); + void rng_config_free( rng_config_type * rng); + void rng_config_add_config_items( config_type * config ); + rng_type * rng_config_alloc_rng( rng_config_type * rng_config ); #ifdef __cplusplus } diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/runpath_list.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/runpath_list.h new file mode 100644 index 0000000000..b921985c96 --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/runpath_list.h @@ -0,0 +1,46 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + The file 'runpath_list.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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. +*/ + +#ifndef __RUNPATH_LIST_H__ +#define __RUNPATH_LIST_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#define RUNPATH_LIST_DEFAULT_LINE_FMT "%03d %s %s\n" + + + typedef struct runpath_list_struct runpath_list_type; + + void runpath_list_free( runpath_list_type * list ); + runpath_list_type * runpath_list_alloc(); + int runpath_list_size( const runpath_list_type * list ); + void runpath_list_add( runpath_list_type * list , int iens , const char * runpath , const char * basename); + void runpath_list_clear( runpath_list_type * list ); + void runpath_list_sort( runpath_list_type * list ); + int runpath_list_iget_iens( runpath_list_type * list , int index); + void runpath_list_set_line_fmt( runpath_list_type * list , const char * line_fmt ); + const char * runpath_list_get_line_fmt( const runpath_list_type * list ); + void runpath_list_fprintf( runpath_list_type * list , FILE * stream); + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/site_config.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/site_config.h index dd949bcf7a..16714d1535 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/site_config.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/site_config.h @@ -28,6 +28,7 @@ extern "C" { #include +#include #include #include @@ -45,7 +46,7 @@ typedef struct site_config_struct site_config_type; void site_config_set_num_cpu( site_config_type * site_config , int num_cpu ); void site_config_update_lsf_request(site_config_type * , const forward_model_type *); - void site_config_init(site_config_type * site_config , const config_type * config, bool user_config); + bool site_config_init(site_config_type * site_config , const config_type * config); void site_config_free(site_config_type *); ext_joblist_type * site_config_get_installed_jobs( const site_config_type * ); job_queue_type * site_config_get_job_queue( const site_config_type * ); @@ -95,7 +96,7 @@ typedef struct site_config_struct site_config_type; void site_config_fprintf_config( const site_config_type * site_config , FILE * stream ); site_config_type * site_config_alloc_empty(); - void site_config_add_config_items( config_type * config , bool site_only); + void site_config_add_config_items( config_type * config , bool site_mode); #ifdef __cplusplus } #endif diff --git a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/time_map.h b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/time_map.h index 1432aa4dfb..f501215935 100644 --- a/ThirdParty/Ert/devel/libenkf/include/ert/enkf/time_map.h +++ b/ThirdParty/Ert/devel/libenkf/include/ert/enkf/time_map.h @@ -23,20 +23,31 @@ extern "C" { #include +#include + #include typedef struct time_map_struct time_map_type; - + UTIL_SAFE_CAST_HEADER( time_map ); + void time_map_clear( time_map_type * map ); + bool time_map_equal( const time_map_type * map1 , const time_map_type * map2); time_map_type * time_map_alloc( ); void time_map_free( time_map_type * map ); - void time_map_update( time_map_type * map , int step , time_t time); - void time_map_summary_update( time_map_type * map , const ecl_sum_type * ecl_sum); + bool time_map_update( time_map_type * map , int step , time_t time); + bool time_map_summary_update( time_map_type * map , const ecl_sum_type * ecl_sum); time_t time_map_iget( time_map_type * map , int step ); void time_map_fwrite( time_map_type * map , const char * filename); void time_map_fread( time_map_type * map , const char * filename); double time_map_iget_sim_days( time_map_type * map , int step ); int time_map_get_last_step( time_map_type * map); + int time_map_get_size( time_map_type * map); + void time_map_update_strict( time_map_type * map , int step , time_t time); + void time_map_summary_update_strict( time_map_type * map , const ecl_sum_type * ecl_sum); + time_t time_map_get_start_time( time_map_type * map); + time_t time_map_get_end_time( time_map_type * map); + double time_map_get_end_days( time_map_type * map); + #ifdef __cplusplus } diff --git a/ThirdParty/Ert/devel/libenkf/src/CMakeLists.txt b/ThirdParty/Ert/devel/libenkf/src/CMakeLists.txt index 32d1963c4c..24dcedbcdf 100644 --- a/ThirdParty/Ert/devel/libenkf/src/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libenkf/src/CMakeLists.txt @@ -1,6 +1,7 @@ -set( source_files ert_report.c time_map.c rng_config.c trans_func.c enkf_types.c enkf_obs.c obs_data.c block_obs.c enkf_config_node.c field_config.c field.c ecl_static_kw.c enkf_state.c enkf_util.c enkf_node.c gen_kw_config.c gen_kw.c enkf_fs.c fs_driver.c meas_data.c summary_obs.c summary.c summary_config.c gen_data_config.c gen_data.c gen_common.c gen_obs.c enkf_sched.c enkf_serialize.c ecl_config.c enkf_defaults.c ensemble_config.c model_config.c site_config.c active_list.c obs_vector.c field_trans.c plain_driver.c local_ministep.c local_updatestep.c container_config.c container.c local_context.c local_config.c analysis_config.c misfit_ensemble.c misfit_member.c misfit_ts.c data_ranking.c misfit_ranking.c ranking_table.c fs_types.c block_fs_driver.c plot_config.c ert_template.c member_config.c enkf_analysis.c enkf_main.c local_dataset.c local_obsset.c surface.c surface_config.c enkf_plot_data.c enkf_plot_member.c qc_config.c ert_report_list.c enkf_plot_arg.c) +set( source_files ert_report.c time_map.c rng_config.c trans_func.c enkf_types.c enkf_obs.c obs_data.c block_obs.c enkf_config_node.c field_config.c field.c ecl_static_kw.c enkf_state.c enkf_util.c enkf_node.c gen_kw_config.c gen_kw.c enkf_fs.c fs_driver.c meas_data.c summary_obs.c summary.c summary_config.c gen_data_config.c gen_data.c gen_common.c gen_obs.c enkf_sched.c enkf_serialize.c ecl_config.c enkf_defaults.c ensemble_config.c model_config.c site_config.c active_list.c obs_vector.c field_trans.c plain_driver.c local_ministep.c local_updatestep.c container_config.c container.c local_context.c local_config.c analysis_config.c misfit_ensemble.c misfit_member.c misfit_ts.c data_ranking.c misfit_ranking.c ranking_table.c fs_types.c block_fs_driver.c plot_config.c ert_template.c member_config.c enkf_analysis.c enkf_main.c local_dataset.c local_obsset.c surface.c surface_config.c enkf_plot_data.c enkf_plot_member.c qc_module.c ert_report_list.c enkf_plot_arg.c runpath_list.c ert_workflow_list.c analysis_iter_config.c enkf_main_jobs.c ecl_refcase_list.c) + +set( header_files ert_report.h time_map.h rng_config.h enkf_analysis.h enkf_fs_type.h trans_func.h enkf_obs.h obs_data.h enkf_config_node.h block_obs.h field_config.h field.h enkf_macros.h ecl_static_kw.h enkf_state.h enkf_util.h enkf_main.h enkf_node.h enkf_fs.h gen_kw_config.h gen_kw.h enkf_types.h fs_driver.h meas_data.h summary_obs.h summary_config.h summary_config.h gen_data_config.h gen_data.h gen_common.h gen_obs.h enkf_sched.h fs_types.h enkf_serialize.h plain_driver.h ecl_config.h ensemble_config.h model_config.h site_config.h active_list.h obs_vector.h field_trans.h plain_driver.h local_ministep.h container.h local_updatestep.h local_config.h analysis_config.h misfit_ensemble.h misfit_ensemble_typedef.h misfit_ts.h misfit_member.h data_ranking.h ranking_table.h ranking_common.h misfit_ranking.h block_fs_driver.h field_common.h gen_kw_common.h gen_data_common.h plot_config.h ert_template.h member_config.h enkf_defaults.h container_config.h local_dataset.h local_obsset.h surface.h surface_config.h local_context.h enkf_plot_data.h enkf_plot_member.h qc_module.h ert_report_list.h enkf_plot_arg.h runpath_list.h ert_workflow_list.h analysis_iter_config.h ecl_refcase_list.h) -set( header_files ert_report.h time_map.h rng_config.h enkf_analysis.h enkf_fs_type.h trans_func.h enkf_obs.h obs_data.h enkf_config_node.h block_obs.h field_config.h field.h enkf_macros.h ecl_static_kw.h enkf_state.h enkf_util.h enkf_main.h enkf_node.h enkf_fs.h gen_kw_config.h gen_kw.h enkf_types.h fs_driver.h meas_data.h summary_obs.h summary_config.h summary_config.h gen_data_config.h gen_data.h gen_common.h gen_obs.h enkf_sched.h fs_types.h enkf_serialize.h plain_driver.h ecl_config.h ensemble_config.h model_config.h site_config.h active_list.h obs_vector.h field_trans.h plain_driver.h local_ministep.h container.h local_updatestep.h local_config.h analysis_config.h misfit_ensemble.h misfit_ensemble_typedef.h misfit_ts.h misfit_member.h data_ranking.h ranking_table.h ranking_common.h misfit_ranking.h block_fs_driver.h field_common.h gen_kw_common.h gen_data_common.h plot_config.h ert_template.h member_config.h enkf_defaults.h container_config.h local_dataset.h local_obsset.h surface.h surface_config.h local_context.h enkf_plot_data.h enkf_plot_member.h qc_config.h ert_report_list.h enkf_plot_arg.h) add_library( enkf ${LIBRARY_TYPE} ${source_files} ) set_target_properties( enkf PROPERTIES VERSION 1.0 SOVERSION 1.0 ) @@ -12,10 +13,11 @@ set_target_properties( enkf PROPERTIES VERSION 1.0 SOVERSION 1.0 ) target_link_libraries( enkf ecl sched analysis rms plot config job_queue ) #----------------------------------------------------------------- -install(TARGETS enkf DESTINATION ${CMAKE_INSTALL_LIBDIR}) -foreach(header ${header_files}) - install(FILES ../include/ert/enkf/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/enkf) -endforeach() - +if (INSTALL_ERT) + install(TARGETS enkf DESTINATION ${CMAKE_INSTALL_LIBDIR}) + foreach(header ${header_files}) + install(FILES ../include/ert/enkf/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/enkf) + endforeach() +endif() diff --git a/ThirdParty/Ert/devel/libenkf/src/analysis_config.c b/ThirdParty/Ert/devel/libenkf/src/analysis_config.c index 357b304ace..3e5fef6893 100644 --- a/ThirdParty/Ert/devel/libenkf/src/analysis_config.c +++ b/ThirdParty/Ert/devel/libenkf/src/analysis_config.c @@ -33,28 +33,34 @@ #include #include #include +#include struct analysis_config_struct { - hash_type * analysis_modules; - analysis_module_type * analysis_module; - char * log_path; /* Points to directory with update logs. */ - bool merge_observations; /* When observing from time1 to time2 - should ALL observations in between be used? */ - bool rerun; /* Should we rerun the simulator when the parameters have been updated? */ - int rerun_start; /* When rerunning - from where should we start? */ + hash_type * analysis_modules; + analysis_module_type * analysis_module; + char * log_path; /* Points to directory with update logs. */ + bool merge_observations; /* When observing from time1 to time2 - should ALL observations in between be used? */ + bool rerun; /* Should we rerun the simulator when the parameters have been updated? */ + int rerun_start; /* When rerunning - from where should we start? */ - double overlap_alpha; - double std_cutoff; + double overlap_alpha; + double std_cutoff; - char * PC_filename; - char * PC_path; - bool store_PC; - bool update_results; /* Should result values like e.g. WWCT be updated? */ - bool single_node_update; /* When creating the default ALL_ACTIVE local configuration. */ - rng_type * rng; + char * PC_filename; + char * PC_path; + bool store_PC; + bool update_results; /* Should result values like e.g. WWCT be updated? */ + bool single_node_update; /* When creating the default ALL_ACTIVE local configuration. */ + rng_type * rng; + analysis_iter_config_type * iter_config; }; + + + + /*****************************************************************/ /* @@ -107,8 +113,8 @@ ANALYSIS_SELECT ModuleName */ - - + +/*****************************************************************/ @@ -368,44 +374,67 @@ void analysis_config_init( analysis_config_type * analysis , const config_type * /* Loading external modules */ { - for (int i=0; i < config_get_occurences( config , ANALYSIS_LOAD_KEY ); i++) { - const stringlist_type * tokens = config_iget_stringlist_ref( config , ANALYSIS_LOAD_KEY , i); - const char * user_name = stringlist_iget( tokens , 0 ); - const char * lib_name = stringlist_iget( tokens , 1 ); - - analysis_config_load_external_module( analysis , user_name , lib_name); + const config_content_item_type * load_item = config_get_content_item( config , ANALYSIS_LOAD_KEY ); + if (load_item != NULL) { + for (int i=0; i < config_content_item_get_size( load_item ); i++) { + const config_content_node_type * load_node = config_content_item_iget_node( load_item , i ); + const char * user_name = config_content_node_iget( load_node , 0 ); + const char * lib_name = config_content_node_iget( load_node , 1 ); + + analysis_config_load_external_module( analysis , user_name , lib_name); + } } } /* Reload/copy modules. */ { - for (int i=0; i < config_get_occurences( config , ANALYSIS_COPY_KEY ); i++) { - const stringlist_type * tokens = config_iget_stringlist_ref( config , ANALYSIS_COPY_KEY , i); - const char * src_name = stringlist_iget( tokens , 0 ); - const char * target_name = stringlist_iget( tokens , 1 ); - - analysis_config_add_module_copy( analysis , src_name , target_name); + const config_content_item_type * copy_item = config_get_content_item( config , ANALYSIS_COPY_KEY ); + if (copy_item != NULL) { + for (int i=0; i < config_content_item_get_size( copy_item ); i++) { + const config_content_node_type * copy_node = config_content_item_iget_node( copy_item , i ); + const char * src_name = config_content_node_iget( copy_node , 0 ); + const char * target_name = config_content_node_iget( copy_node , 1 ); + + analysis_config_add_module_copy( analysis , src_name , target_name); + } } } /* Setting variables for analysis modules */ { - for (int i=0; i < config_get_occurences( config , ANALYSIS_SET_VAR_KEY ); i++) { - const stringlist_type * tokens = config_iget_stringlist_ref( config , ANALYSIS_SET_VAR_KEY , i); - const char * module_name = stringlist_iget( tokens , 0 ); - const char * var_name = stringlist_iget( tokens , 1 ); - char * value = stringlist_alloc_joined_substring( tokens , 2 , stringlist_get_size( tokens ) , " " ); - analysis_module_type * module = analysis_config_get_module( analysis , module_name ); - - analysis_module_set_var( module , var_name , value ); - free( value ); + const config_content_item_type * assign_item = config_get_content_item( config , ANALYSIS_SET_VAR_KEY ); + if (assign_item != NULL) { + for (int i=0; i < config_content_item_get_size( assign_item ); i++) { + const config_content_node_type * assign_node = config_content_item_iget_node( assign_item , i ); + + const char * module_name = config_content_node_iget( assign_node , 0 ); + const char * var_name = config_content_node_iget( assign_node , 1 ); + analysis_module_type * module = analysis_config_get_module( analysis , module_name ); + { + char * value = NULL; + + for (int j=2; j < config_content_node_get_size( assign_node ); j++) { + const char * config_value = config_content_node_iget( assign_node , j ); + if (value == NULL) + value = util_alloc_string_copy( config_value ); + else { + value = util_strcat_realloc( value , " " ); + value = util_strcat_realloc( value , config_value ); + } + } + + analysis_module_set_var( module , var_name , value ); + free( value ); + } + } } } if (config_item_set( config, ANALYSIS_SELECT_KEY )) analysis_config_select_module( analysis , config_get_value( config , ANALYSIS_SELECT_KEY )); - + + analysis_iter_config_init( analysis->iter_config , config ); } @@ -415,12 +444,13 @@ bool analysis_config_get_merge_observations(const analysis_config_type * config) } - - - +analysis_iter_config_type * analysis_config_get_iter_config( const analysis_config_type * config ) { + return config->iter_config; +} void analysis_config_free(analysis_config_type * config) { + analysis_iter_config_free( config->iter_config ); hash_free( config->analysis_modules ); free(config->log_path); free(config); @@ -451,6 +481,7 @@ analysis_config_type * analysis_config_alloc_default( rng_type * rng ) { config->analysis_module = NULL; config->analysis_modules = hash_alloc(); config->rng = rng; + config->iter_config = analysis_iter_config_alloc(); return config; } @@ -467,33 +498,35 @@ void analysis_config_add_config_items( config_type * config ) { config_add_key_value( config , ENKF_ALPHA_KEY , false , CONFIG_FLOAT); config_add_key_value( config , STD_CUTOFF_KEY , false , CONFIG_FLOAT); - config_add_key_value( config , ENKF_MERGE_OBSERVATIONS_KEY , false , CONFIG_BOOLEAN); - config_add_key_value( config , UPDATE_RESULTS_KEY , false , CONFIG_BOOLEAN); - config_add_key_value( config , SINGLE_NODE_UPDATE_KEY , false , CONFIG_BOOLEAN); - config_add_key_value( config , ENKF_CROSS_VALIDATION_KEY , false , CONFIG_BOOLEAN); - config_add_key_value( config , ENKF_LOCAL_CV_KEY , false , CONFIG_BOOLEAN); - config_add_key_value( config , ENKF_PEN_PRESS_KEY , false , CONFIG_BOOLEAN); - config_add_key_value( config , ENKF_SCALING_KEY , false , CONFIG_BOOLEAN); - config_add_key_value( config , ENKF_KERNEL_REG_KEY , false , CONFIG_BOOLEAN); + config_add_key_value( config , ENKF_MERGE_OBSERVATIONS_KEY , false , CONFIG_BOOL); + config_add_key_value( config , UPDATE_RESULTS_KEY , false , CONFIG_BOOL); + config_add_key_value( config , SINGLE_NODE_UPDATE_KEY , false , CONFIG_BOOL); + config_add_key_value( config , ENKF_CROSS_VALIDATION_KEY , false , CONFIG_BOOL); + config_add_key_value( config , ENKF_LOCAL_CV_KEY , false , CONFIG_BOOL); + config_add_key_value( config , ENKF_PEN_PRESS_KEY , false , CONFIG_BOOL); + config_add_key_value( config , ENKF_SCALING_KEY , false , CONFIG_BOOL); + config_add_key_value( config , ENKF_KERNEL_REG_KEY , false , CONFIG_BOOL); config_add_key_value( config , ENKF_KERNEL_FUNC_KEY , false , CONFIG_INT); config_add_key_value( config , ENKF_KERNEL_PARAM_KEY , false , CONFIG_INT); - config_add_key_value( config , ENKF_FORCE_NCOMP_KEY , false , CONFIG_BOOLEAN); + config_add_key_value( config , ENKF_FORCE_NCOMP_KEY , false , CONFIG_BOOL); config_add_key_value( config , ENKF_NCOMP_KEY , false , CONFIG_INT); config_add_key_value( config , ENKF_CV_FOLDS_KEY , false , CONFIG_INT); - config_add_key_value( config , ENKF_RERUN_KEY , false , CONFIG_BOOLEAN); + config_add_key_value( config , ENKF_RERUN_KEY , false , CONFIG_BOOL); config_add_key_value( config , RERUN_START_KEY , false , CONFIG_INT); config_add_key_value( config , UPDATE_LOG_PATH_KEY , false , CONFIG_STRING); config_add_key_value( config , ANALYSIS_SELECT_KEY , false , CONFIG_STRING); - item = config_add_schema_item( config , ANALYSIS_LOAD_KEY , false , true ); - config_schema_item_set_argc_minmax( item , 2 , 2 , 0 , NULL ); + item = config_add_schema_item( config , ANALYSIS_LOAD_KEY , false ); + config_schema_item_set_argc_minmax( item , 2 , 2); - item = config_add_schema_item( config , ANALYSIS_COPY_KEY , false , true ); - config_schema_item_set_argc_minmax( item , 2 , 2 , 0 , NULL ); + item = config_add_schema_item( config , ANALYSIS_COPY_KEY , false ); + config_schema_item_set_argc_minmax( item , 2 , 2); - item = config_add_schema_item( config , ANALYSIS_SET_VAR_KEY , false , true ); - config_schema_item_set_argc_minmax( item , 3 , -1 , 0 , NULL ); + + item = config_add_schema_item( config , ANALYSIS_SET_VAR_KEY , false ); + config_schema_item_set_argc_minmax( item , 3 , CONFIG_DEFAULT_ARG_MAX); + analysis_iter_config_add_config_items( config ); } diff --git a/ThirdParty/Ert/devel/libenkf/src/analysis_iter_config.c b/ThirdParty/Ert/devel/libenkf/src/analysis_iter_config.c new file mode 100644 index 0000000000..c0bd8debe7 --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/src/analysis_iter_config.c @@ -0,0 +1,130 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'analysis_iter_config.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include + +#include +#include + +#include + +#include +#include +#include + + +struct analysis_iter_config_struct { + char * runpath_fmt; + char * case_fmt; + stringlist_type * storage; + int num_iterations; +}; + + +void analysis_iter_config_set_num_iterations( analysis_iter_config_type * config , int num_iterations) { + config->num_iterations = num_iterations; +} + +int analysis_iter_config_get_num_iterations( const analysis_iter_config_type * config ) { + return config->num_iterations; +} + + + +analysis_iter_config_type * analysis_iter_config_alloc() { + analysis_iter_config_type * config = util_malloc( sizeof * config ); + config->runpath_fmt = NULL; + config->case_fmt = NULL; + config->storage = stringlist_alloc_new(); + analysis_iter_config_set_num_iterations( config , DEFAULT_ANALYSIS_NUM_ITERATIONS ); + return config; +} + +void analysis_iter_config_free( analysis_iter_config_type * config ) { + util_safe_free( config->runpath_fmt ); + util_safe_free( config->case_fmt ); + stringlist_free( config->storage ); +} + + +/** + This should contain a format string with two %d modifiers, the + first will be replaced with the iteration number, and the second + with the realization number. The actual instantiation will happen + in a two step process, hence the last '%d' must be protected with + an extra '%'. +*/ + +static void analysis_iter_config_set_runpath_fmt( analysis_iter_config_type * config , const char * runpath_fmt) { + util_safe_free( config->runpath_fmt ); + if (runpath_fmt != NULL) { + config->runpath_fmt = util_calloc( strlen(runpath_fmt ) + 2 , sizeof * config->runpath_fmt); + strcpy(config->runpath_fmt , runpath_fmt); + { + char * perc_ptr = strrchr( config->runpath_fmt , '%'); + memmove(&perc_ptr[1] , &perc_ptr[0] , strlen(perc_ptr) + 1); + perc_ptr[0] = '%'; + } + } +} + +static void analysis_iter_config_set_case_fmt( analysis_iter_config_type * config , const char * case_fmt) { + config->case_fmt = util_realloc_string_copy( config->case_fmt , case_fmt ); +} + +const char * analysis_iter_config_iget_runpath_fmt( analysis_iter_config_type * config , int iter) { + if (config->runpath_fmt != NULL) { + char * runpath_fmt = util_alloc_sprintf( config->runpath_fmt , iter ); + stringlist_append_owned_ref( config->storage , runpath_fmt ); + return runpath_fmt; + } else + return NULL; +} + +const char * analysis_iter_config_iget_case( analysis_iter_config_type * config , int iter) { + if (config->case_fmt != NULL) { + char * fs_case = util_alloc_sprintf( config->case_fmt , iter ); + stringlist_append_owned_ref( config->storage , fs_case); + return fs_case; + } else + return NULL; +} + + +void analysis_iter_config_add_config_items( config_type * config ) { + config_add_key_value( config , ITER_CASE_KEY , false , CONFIG_STRING); + config_add_key_value( config , ITER_RUNPATH_KEY , false , CONFIG_STRING); + config_add_key_value( config , ITER_COUNT_KEY , false , CONFIG_INT); +} + + +void analysis_iter_config_init(analysis_iter_config_type * iter_config , const config_type * config) { + if (config_item_set( config , ITER_CASE_KEY )) + analysis_iter_config_set_case_fmt( iter_config , config_get_value( config , ITER_CASE_KEY )); + + if (config_item_set( config , ITER_RUNPATH_KEY )) + analysis_iter_config_set_runpath_fmt( iter_config , config_get_value( config , ITER_RUNPATH_KEY )); + + if (config_item_set( config , ITER_COUNT_KEY )) + analysis_iter_config_set_num_iterations( iter_config , config_get_value_as_int( config , ITER_COUNT_KEY )); +} + + diff --git a/ThirdParty/Ert/devel/libenkf/src/ecl_config.c b/ThirdParty/Ert/devel/libenkf/src/ecl_config.c index 68f2ace152..258dbc9efe 100644 --- a/ThirdParty/Ert/devel/libenkf/src/ecl_config.c +++ b/ThirdParty/Ert/devel/libenkf/src/ecl_config.c @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -37,6 +38,7 @@ #include #include #include +#include #include /** @@ -64,7 +66,7 @@ struct ecl_config_struct { char * data_file; /* Eclipse data file. */ time_t start_date; /* The start date of the ECLIPSE simulation - parsed from the data_file. */ time_t end_date; /* An optional date value which can be used to check if the ECLIPSE simulation has been 'long enough'. */ - ecl_sum_type * refcase; /* Refcase - can be NULL. */ + ecl_refcase_list_type * refcase_list; ecl_grid_type * grid; /* The grid which is active for this model. */ char * schedule_prediction_file; /* Name of schedule prediction file - observe that this is internally handled as a gen_kw node. */ char * schedule_target_file; /* File name to write schedule info to */ @@ -264,20 +266,8 @@ const char * ecl_config_get_eclbase( const ecl_config_type * ecl_config ) { Can be called with @refcase == NULL - which amounts to clearing the current refcase. */ -void ecl_config_load_refcase( ecl_config_type * ecl_config , const char * refcase ){ - if (ecl_config->refcase != NULL) { - if (refcase == NULL) { /* Clear the refcase */ - ecl_sum_free( ecl_config->refcase ); - ecl_config->refcase = NULL; - } else { /* Check if the currently loaded case is the same as refcase */ - if (!ecl_sum_same_case( ecl_config->refcase , refcase )) { - ecl_sum_free( ecl_config->refcase ); - ecl_config->refcase = ecl_sum_fread_alloc_case( refcase , SUMMARY_KEY_JOIN_STRING ); - } - } - } else - if (refcase != NULL) - ecl_config->refcase = ecl_sum_fread_alloc_case( refcase , SUMMARY_KEY_JOIN_STRING ); +bool ecl_config_load_refcase( ecl_config_type * ecl_config , const char * refcase ){ + return ecl_refcase_list_set_default( ecl_config->refcase_list , refcase ); } @@ -285,11 +275,11 @@ void ecl_config_load_refcase( ecl_config_type * ecl_config , const char * refcas Will return NULL if no refcase is set. */ const char * ecl_config_get_refcase_name( const ecl_config_type * ecl_config) { - - if (ecl_config->refcase == NULL) + const ecl_sum_type * refcase = ecl_refcase_list_get_default( ecl_config->refcase_list ); + if (refcase == NULL) return NULL; else - return ecl_sum_get_case( ecl_config->refcase ); + return ecl_sum_get_case( refcase ); } @@ -405,7 +395,6 @@ ecl_config_type * ecl_config_alloc_empty( ) { ecl_config->data_file = NULL; ecl_config->input_init_section = NULL; ecl_config->init_section = NULL; - ecl_config->refcase = NULL; ecl_config->grid = NULL; ecl_config->can_restart = false; ecl_config->start_date = -1; @@ -413,6 +402,7 @@ ecl_config_type * ecl_config_alloc_empty( ) { ecl_config->sched_file = NULL; ecl_config->schedule_prediction_file = NULL; ecl_config->schedule_target_file = NULL; + ecl_config->refcase_list = ecl_refcase_list_alloc(); ecl_config_init_static_kw( ecl_config ); @@ -442,10 +432,43 @@ void ecl_config_init( ecl_config_type * ecl_config , const config_type * config config_iget_as_int(config , ADD_FIXED_LENGTH_SCHEDULE_KW_KEY , iocc , 1)); } + + if (config_item_set( config , REFCASE_KEY)) { + const char * refcase_path = config_get_value_as_path( config , REFCASE_KEY ); + if (!ecl_config_load_refcase( ecl_config , refcase_path)) + fprintf(stderr,"** Warning: loading refcase:%s failed \n", refcase_path); + } + - if (config_item_set( config , REFCASE_KEY)) - ecl_config_load_refcase( ecl_config , config_get_value( config , REFCASE_KEY )); - + if (config_item_set( config , REFCASE_LIST_KEY)) { + config_content_item_type * item = config_get_content_item( config , REFCASE_LIST_KEY); + int i; + for (i=0; i < config_content_item_get_size( item ); i++) { + config_content_node_type * node = config_content_item_iget_node( item , i ); + int j; + for (j=0; j < config_content_node_get_size( node ); j++) { + const char * case_glob = config_content_node_iget_as_path( node , j ); + ecl_refcase_list_add_matching( ecl_config->refcase_list , case_glob ); + } + } + } + + /* Deprecated */ + if (config_item_set( config , PLOT_REFCASE_LIST_KEY)) { + char * case_list_file = config_get_value( config , PLOT_REFCASE_LIST_KEY); + FILE * stream = util_fopen(case_list_file , "r"); + bool at_eof; + do { + char * case_name = util_fscanf_alloc_line(stream , &at_eof); + if (case_name) { + ecl_refcase_list_add_case( ecl_config->refcase_list , case_name); + free( case_name ); + } + } while (!at_eof); + + fclose( stream ); + } + if (config_item_set(config , INIT_SECTION_KEY)) ecl_config_set_init_section( ecl_config , config_get_value( config , INIT_SECTION_KEY )); else @@ -509,8 +532,7 @@ void ecl_config_free(ecl_config_type * ecl_config) { if (ecl_config->grid != NULL) ecl_grid_free( ecl_config->grid ); - if (ecl_config->refcase != NULL) - ecl_sum_free( ecl_config->refcase ); + ecl_refcase_list_free( ecl_config->refcase_list ); free(ecl_config); } @@ -592,8 +614,21 @@ void ecl_config_set_grid( ecl_config_type * ecl_config , const char * grid_file } +ecl_refcase_list_type * ecl_config_get_refcase_list( const ecl_config_type * ecl_config ) { + return ecl_config->refcase_list; +} + const ecl_sum_type * ecl_config_get_refcase(const ecl_config_type * ecl_config) { - return ecl_config->refcase; + return ecl_refcase_list_get_default( ecl_config->refcase_list ); +} + +bool ecl_config_has_refcase( const ecl_config_type * ecl_config ) { + const ecl_sum_type * refcase = ecl_config_get_refcase( ecl_config ); + printf("refcase:%p \n",refcase); + if (refcase) + return true; + else + return false; } @@ -640,44 +675,81 @@ bool ecl_config_get_unified_restart(const ecl_config_type * ecl_config) { retur bool ecl_config_get_unified_summary(const ecl_config_type * ecl_config) { return ecl_io_config_get_unified_summary( ecl_config->io_config ); } +void ecl_config_static_kw_init( ecl_config_type * ecl_config , const config_type * config ) { + const config_content_item_type * content_item = config_get_content_item( config , STATIC_KW_KEY ); + if (content_item != NULL) { + int j; + for (j=0; j < config_content_item_get_size( content_item ); j++) { + const config_content_node_type * content_node = config_content_item_iget_node( content_item , j); + int k; + for (k = 0; k < config_content_node_get_size( content_node ); k++) + ecl_config_add_static_kw(ecl_config , config_content_node_iget( content_node , k )); + } + } +} + void ecl_config_add_config_items( config_type * config ) { config_schema_item_type * item; - item = config_add_schema_item(config , SCHEDULE_FILE_KEY , false , false); - config_schema_item_set_argc_minmax(item , 1 , 1 , 1 , (const config_item_types [1]) {CONFIG_EXISTING_FILE}); + item = config_add_schema_item(config , SCHEDULE_FILE_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1 ); + config_schema_item_iset_type( item , 0 , CONFIG_EXISTING_PATH ); /* Observe that SCHEDULE_PREDICTION_FILE - which is implemented as a GEN_KW is added in ensemble_config.c */ - item = config_add_schema_item( config , IGNORE_SCHEDULE_KEY , false , false); - config_schema_item_set_argc_minmax(item , 1 , 1 , 1 , (const config_item_types [1]) { CONFIG_BOOLEAN }); + item = config_add_schema_item( config , IGNORE_SCHEDULE_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1 ); + config_schema_item_iset_type( item , 0 , CONFIG_BOOL); - item = config_add_schema_item(config , ECLBASE_KEY , false , false); - config_schema_item_set_argc_minmax(item , 1 , 1 , 0 , NULL); - - item = config_add_schema_item(config , DATA_FILE_KEY , false , false); - config_schema_item_set_argc_minmax(item , 1 , 1 , 1 , (const config_item_types [1]) {CONFIG_EXISTING_FILE}); - - item = config_add_schema_item(config , STATIC_KW_KEY , false , true); - config_schema_item_set_argc_minmax(item , 1 , -1 , 0 , NULL); - - item = config_add_schema_item(config , ADD_FIXED_LENGTH_SCHEDULE_KW_KEY , false , true); - config_schema_item_set_argc_minmax(item , 2 , 2 , 2 , (const config_item_types [2]) { CONFIG_STRING , CONFIG_INT}); - - item = config_add_schema_item(config , REFCASE_KEY , false , false); - config_schema_item_set_argc_minmax(item , 1 , 1 , 1 , NULL ); - item = config_add_schema_item(config , GRID_KEY , false , false); - config_schema_item_set_argc_minmax(item , 1 , 1 , 1 , (const config_item_types [1]) {CONFIG_EXISTING_FILE}); + item = config_add_schema_item(config , ECLBASE_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1); + + + item = config_add_schema_item(config , DATA_FILE_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1 ); + config_schema_item_iset_type( item , 0 , CONFIG_EXISTING_PATH ); + + + item = config_add_schema_item(config , STATIC_KW_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , CONFIG_DEFAULT_ARG_MAX ); - item = config_add_schema_item(config , INIT_SECTION_KEY , false , false); - config_schema_item_set_argc_minmax(item , 1 , 1 , 1 , (const config_item_types [1]) {CONFIG_FILE}); + + item = config_add_schema_item(config , ADD_FIXED_LENGTH_SCHEDULE_KW_KEY , false ); + config_schema_item_set_argc_minmax(item , 2 , 2 ); + config_schema_item_iset_type( item , 1 , CONFIG_INT ); + + + item = config_add_schema_item(config , REFCASE_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1 ); + config_schema_item_iset_type( item , 0 , CONFIG_PATH ); + + item = config_add_schema_item(config , REFCASE_LIST_KEY , false ); + config_schema_item_set_default_type( item , CONFIG_PATH ); + + item = config_add_key_value(config , PLOT_REFCASE_LIST_KEY , false , CONFIG_STRING); + { + char * message = util_alloc_sprintf("Warning: the key:%s is depreceated - use %s instead" , PLOT_REFCASE_LIST_KEY , REFCASE_LIST_KEY); + config_install_message( config , PLOT_REFCASE_LIST_KEY , message ); + free( message ); + } + + item = config_add_schema_item(config , GRID_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1 ); + config_schema_item_iset_type( item , 0 , CONFIG_EXISTING_PATH ); + + + item = config_add_schema_item(config , INIT_SECTION_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1 ); + config_schema_item_iset_type( item , 0 , CONFIG_PATH ); config_add_alias(config , INIT_SECTION_KEY , "EQUIL_INIT_FILE"); - item = config_add_schema_item(config , END_DATE_KEY , false , false); - config_schema_item_set_argc_minmax(item , 1 , 1 , 0 , NULL ); + + item = config_add_schema_item(config , END_DATE_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1 ); } @@ -713,10 +785,12 @@ void ecl_config_fprintf_config( const ecl_config_type * ecl_config , FILE * stre } } - if (ecl_config->refcase != NULL) { + /* + if (ecl_config->refcase != NULL) { fprintf( stream , CONFIG_KEY_FORMAT , REFCASE_KEY ); fprintf( stream , CONFIG_ENDVALUE_FORMAT , ecl_config_get_refcase_name( ecl_config )); - } + } + */ if (ecl_config->grid != NULL) { fprintf( stream , CONFIG_KEY_FORMAT , GRID_KEY ); @@ -752,5 +826,4 @@ void ecl_config_fprintf_config( const ecl_config_type * ecl_config , FILE * stre fprintf(stream , "\n\n"); - } diff --git a/ThirdParty/Ert/devel/libenkf/src/ecl_refcase_list.c b/ThirdParty/Ert/devel/libenkf/src/ecl_refcase_list.c new file mode 100644 index 0000000000..756ca37641 --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/src/ecl_refcase_list.c @@ -0,0 +1,397 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'ecl_refcase_list.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include + +#include +#include +#include +#include + +#include + +#include + + +/* + This file implements a quite simple collection of ecl_sum instances, + with the following twists: + + o The default case is special in several ways: + + - It is added with the ecl_refcase_list_set_default() function. + + - The default case is always the first case, i.e. iget(0) will + return the default case. + + - When setting the default we verify that it can be loaded, and + the thing fails if not. That is in contrast to the other cases + where the actual summary loading is lazy and on demand. + + o The collection has an internal dictionary which ensures that the + same case is not added twice. + + o When calling iget( ) the default case will come as index 0, and + the remaining cases will come in util_strcmp_int() ordering. + + o Observe that the functions in this module return NULL quite + liberally: + + - If you have added a case which does not exist you will get + NULL when you (at a later stage) try to access the ecl_sum + instance. + + - If you ask for the default case before one has been set you + will get NULL. + */ + + +#define SUM_PAIR_TYPE_ID 665109971 + +typedef struct sum_pair_struct { + UTIL_TYPE_ID_DECLARATION; + char * case_name; // This should be (path)/basename - no extension + ecl_sum_type * ecl_sum; +} sum_pair_type; + + + +struct ecl_refcase_list_struct { + sum_pair_type * default_case; + hash_type * case_dict; + vector_type * case_list; /* This is created, and sorted, on demand when we do indexed lookup of cases. */ + bool sorted; +}; + +/*****************************************************************/ + + + +static sum_pair_type * sum_pair_alloc( const char * case_name , bool strict_load) { + ecl_sum_type * ecl_sum = NULL; + char * path = NULL; + char * basename = NULL; + + util_alloc_file_components( case_name , &path , &basename , NULL); + if (basename != NULL) { + char * use_case = util_alloc_filename( path , basename , NULL); + if (strict_load) + ecl_sum = ecl_sum_fread_alloc_case( use_case , ":"); + + util_safe_free( path ); + free( basename ); + if (strict_load && (ecl_sum == NULL)) { + free( use_case ); + return NULL; + } + + + { + sum_pair_type * pair = util_malloc( sizeof * pair ); + UTIL_TYPE_ID_INIT( pair , SUM_PAIR_TYPE_ID ); + pair->case_name = use_case; + pair->ecl_sum = ecl_sum; + return pair; + } + } else { + util_safe_free( path ); + util_safe_free( basename ); + return NULL; + } +} + + +static UTIL_SAFE_CAST_FUNCTION( sum_pair , SUM_PAIR_TYPE_ID ); +static UTIL_SAFE_CAST_FUNCTION_CONST( sum_pair , SUM_PAIR_TYPE_ID ); +static UTIL_IS_INSTANCE_FUNCTION( sum_pair , SUM_PAIR_TYPE_ID); + +const ecl_sum_type * sum_pair_get_ecl_sum( sum_pair_type * sum_pair ) { + if (sum_pair->ecl_sum == NULL) + sum_pair->ecl_sum = ecl_sum_fread_alloc_case( sum_pair->case_name , ":"); + return sum_pair->ecl_sum; +} + + +static void sum_pair_free( sum_pair_type * sum_pair ) { + free( sum_pair->case_name ); + if (sum_pair->ecl_sum != NULL) + ecl_sum_free( sum_pair->ecl_sum ); + free( sum_pair ); +} + + +static void sum_pair_free__( void * arg ) { + sum_pair_type * pair = sum_pair_safe_cast( arg ); + sum_pair_free( pair ); +} + + + + +static int sum_pair_cmp( const void * arg1 , const void * arg2) { + const sum_pair_type * pair1 = sum_pair_safe_cast_const( arg1 ); + const sum_pair_type * pair2 = sum_pair_safe_cast_const( arg2 ); + + return util_strcmp_int( pair1->case_name , pair2->case_name ); +} + +/*****************************************************************/ + + +ecl_refcase_list_type * ecl_refcase_list_alloc( ) { + ecl_refcase_list_type * refcase_list = util_malloc( sizeof * refcase_list ); + refcase_list->default_case = NULL; + refcase_list->case_list = vector_alloc_new(); + refcase_list->case_dict = hash_alloc(); + refcase_list->sorted = false; + return refcase_list; +} + + + +void ecl_refcase_list_free( ecl_refcase_list_type * refcase_list ) { + vector_free( refcase_list->case_list ); + hash_free( refcase_list->case_dict ); + free( refcase_list ); +} + + + +const ecl_sum_type * ecl_refcase_list_get_default( ecl_refcase_list_type * refcase_list ) { + if (refcase_list->default_case) + return sum_pair_get_ecl_sum( refcase_list->default_case ); + else + return NULL; +} + + +bool ecl_refcase_list_has_default( ecl_refcase_list_type * refcase_list ) { + if (refcase_list->default_case) + return true; + else + return false; +} + + +static void ecl_refcase_list_del_default( ecl_refcase_list_type * refcase_list ) { + sum_pair_type * default_pair = refcase_list->default_case; + if (default_pair) { + hash_del( refcase_list->case_dict , default_pair->case_name ); + refcase_list->default_case = NULL; + } +} + + +/* + If a valid refcase has been set already, and this fails, nothing happens. +*/ + +bool ecl_refcase_list_set_default( ecl_refcase_list_type * refcase_list , const char * default_case) { + + if (default_case) { + sum_pair_type * default_pair = sum_pair_alloc( default_case , true ); + if (default_pair) { + ecl_refcase_list_del_default( refcase_list ); + refcase_list->default_case = default_pair; + + hash_insert_hash_owned_ref( refcase_list->case_dict , default_pair->case_name , default_pair , sum_pair_free__); + refcase_list->sorted = false; + return true; + } else + return false; + } else { + ecl_refcase_list_del_default( refcase_list ); + return true; + } +} + + + + +/** + Will sort the list and remove all elements which can not be loaded. +*/ + +static void ecl_refcase_list_assert_clean( ecl_refcase_list_type * refcase_list ) { + if (!refcase_list->sorted) { + vector_free( refcase_list->case_list ); + refcase_list->case_list = vector_alloc_new(); + + { + stringlist_type * tmp_list = hash_alloc_stringlist( refcase_list->case_dict ); + sum_pair_type * default_case = refcase_list->default_case; + int i; + + for (i =0; i < stringlist_get_size( tmp_list ); i++) { + const char * casename = stringlist_iget( tmp_list , i ); + bool normal_case = true; + + if (default_case && util_string_equal( casename , default_case->case_name)) + normal_case = false; + + if (normal_case) { + sum_pair_type * pair = hash_get( refcase_list->case_dict , casename); + const ecl_sum_type * ecl_sum = sum_pair_get_ecl_sum( pair ); + + if (ecl_sum) + vector_append_ref( refcase_list->case_list , pair); + else + hash_del( refcase_list->case_dict , casename ); + + } + } + stringlist_free( tmp_list ); + } + + vector_sort( refcase_list->case_list , sum_pair_cmp ); + refcase_list->sorted = true; + } +} + + +static sum_pair_type * ecl_refcase_list_get_pair( ecl_refcase_list_type * refcase_list , const char * case_name) { + ecl_refcase_list_assert_clean( refcase_list ); + { + if (hash_has_key( refcase_list->case_dict , case_name)) + return hash_get( refcase_list->case_dict , case_name ); + else + return NULL; + } +} + + +static sum_pair_type * ecl_refcase_list_iget_pair( ecl_refcase_list_type * refcase_list , int index) { + ecl_refcase_list_assert_clean( refcase_list ); + { + int index_offset = refcase_list->default_case ? 1 : 0; + index -= index_offset; + + if (index < 0) + return refcase_list->default_case; + else + return vector_safe_iget( refcase_list->case_list , index); + } +} + + +int ecl_refcase_list_get_size(ecl_refcase_list_type * refcase_list ) { + ecl_refcase_list_assert_clean( refcase_list ); + { + int size = hash_get_size( refcase_list->case_dict ); + return size; + } +} + + + +const ecl_sum_type * ecl_refcase_list_iget_case( ecl_refcase_list_type * refcase_list , int index) { + sum_pair_type * pair = ecl_refcase_list_iget_pair( refcase_list , index ); + if (pair) + return sum_pair_get_ecl_sum( pair ); + else + return NULL; +} + + +const ecl_sum_type * ecl_refcase_list_get_case( ecl_refcase_list_type * refcase_list , const char * case_name) { + sum_pair_type * pair = ecl_refcase_list_get_pair( refcase_list , case_name ); + if (pair) + return sum_pair_get_ecl_sum( pair ); + else + return NULL; +} + + +bool ecl_refcase_list_has_case( ecl_refcase_list_type * refcase_list , const char * case_name) { + const sum_pair_type * pair = ecl_refcase_list_get_pair( refcase_list , case_name ); + if (pair) + return true; + else + return false; +} + + + +const char * ecl_refcase_list_iget_pathcase( ecl_refcase_list_type * refcase_list , int index) { + const ecl_sum_type * ecl_sum = ecl_refcase_list_iget_case( refcase_list , index ); + if (ecl_sum) + return ecl_sum_get_case( ecl_sum ); + else + return NULL; +} + + + +int ecl_refcase_list_add_case( ecl_refcase_list_type * refcase_list , const char * case_name) { + sum_pair_type * pair = sum_pair_alloc( case_name , false ); + if (pair) { + if (hash_has_key( refcase_list->case_dict , pair->case_name)) { + sum_pair_free( pair ); + return 0; + } else { + hash_insert_hash_owned_ref( refcase_list->case_dict , pair->case_name , pair , sum_pair_free__); + refcase_list->sorted = false; + return 1; + } + } else + return 0; +} + +/* + The glob_string pattern must (for all practical purposes) end in an + explicit extension: + + - If it ends without an extension there will be zero mathces. It + - it ends with a '*' there will be a hell-of-a-lot of duplicate + matches. + + If the input glob string does not have an explicit extension we add + .*SMSPEC for the matching purpose. +*/ + + +int ecl_refcase_list_add_matching( ecl_refcase_list_type * refcase_list , const char * __glob_string) { + int count = 0; + char * glob_string; + + { + char * glob_ext; + util_alloc_file_components( __glob_string , NULL , NULL , &glob_ext); + if (glob_ext == NULL) + glob_string = util_alloc_filename(NULL , __glob_string , "*SMSPEC"); + else { + glob_string = util_alloc_string_copy( __glob_string ); + free( glob_ext ); + } + } + + { + stringlist_type * case_list = stringlist_alloc_new(); + int i; + stringlist_select_matching( case_list , glob_string ); + for (i=0; i < stringlist_get_size( case_list ); i++) { + count += ecl_refcase_list_add_case( refcase_list , stringlist_iget( case_list , i ) ); + } + stringlist_free( case_list ); + } + + free( glob_string ); + return count; +} + diff --git a/ThirdParty/Ert/devel/libenkf/src/enkf_fs.c b/ThirdParty/Ert/devel/libenkf/src/enkf_fs.c index 5a6d210ae9..4bdfecd968 100644 --- a/ThirdParty/Ert/devel/libenkf/src/enkf_fs.c +++ b/ThirdParty/Ert/devel/libenkf/src/enkf_fs.c @@ -208,8 +208,11 @@ struct enkf_fs_struct { UTIL_TYPE_ID_DECLARATION; - char * mount_point; - + char * case_name; + char * root_path; + char * mount_point; // mount_point = root_path / case_name; the mount_point is the fundamental INPUT. + + fs_driver_type * dynamic_forecast; fs_driver_type * dynamic_analyzed; fs_driver_type * parameter; @@ -249,6 +252,16 @@ static enkf_fs_type * enkf_fs_alloc_empty( const char * mount_point , bool read_ fs->mount_point = util_alloc_string_copy( mount_point ); if (mount_point == NULL) util_abort("%s: fatal internal error: mount_point == NULL \n",__func__); + { + char ** path_tmp; + int path_len; + + util_path_split( fs->mount_point , &path_len , &path_tmp); + fs->case_name = util_alloc_string_copy( path_tmp[path_len - 1]); + fs->root_path = util_alloc_joined_string( path_tmp , path_len , UTIL_PATH_SEP_STRING); + + util_free_stringlist( path_tmp , path_len ); + } return fs; } @@ -507,6 +520,8 @@ void enkf_fs_close( enkf_fs_type * fs ) { enkf_fs_free_driver( fs->eclipse_static ); enkf_fs_free_driver( fs->index ); + util_safe_free( fs->case_name ); + util_safe_free( fs->root_path ); util_safe_free( fs->mount_point ); path_fmt_free( fs->case_fmt ); path_fmt_free( fs->case_member_fmt ); @@ -696,6 +711,14 @@ const char * enkf_fs_get_mount_point( const enkf_fs_type * fs ) { return fs->mount_point; } +const char * enkf_fs_get_root_path( const enkf_fs_type * fs ) { + return fs->root_path; +} + +const char * enkf_fs_get_case_name( const enkf_fs_type * fs ) { + return fs->case_name; +} + void enkf_fs_debug_fprintf( const enkf_fs_type * fs) { printf("-----------------------------------------------------------------\n"); printf("fs...................: %p \n",fs ); diff --git a/ThirdParty/Ert/devel/libenkf/src/enkf_main.c b/ThirdParty/Ert/devel/libenkf/src/enkf_main.c index 2f374dbd38..6b6188d454 100644 --- a/ThirdParty/Ert/devel/libenkf/src/enkf_main.c +++ b/ThirdParty/Ert/devel/libenkf/src/enkf_main.c @@ -80,7 +80,7 @@ #include #include #include -#include +#include #include #include #include @@ -96,6 +96,7 @@ #include #include #include +#include /**/ @@ -135,7 +136,7 @@ struct enkf_main_struct { char * current_fs_case; enkf_fs_type * dbase; /* The internalized information. */ ensemble_config_type * ensemble_config; /* The config objects for the various enkf nodes.*/ - qc_config_type * qc_config; + qc_module_type * qc_module; model_config_type * model_config; ecl_config_type * ecl_config; site_config_type * site_config; @@ -147,6 +148,7 @@ struct enkf_main_struct { rng_config_type * rng_config; rng_type * rng; ert_report_list_type * report_list; + ert_workflow_list_type * workflow_list; ranking_table_type * ranking_table; /*---------------------------*/ /* Variables related to substitution. */ @@ -214,11 +216,12 @@ void enkf_main_set_jobname( enkf_main_type * enkf_main , const char * jobname_fm } - -void enkf_main_set_refcase( enkf_main_type * enkf_main , const char * refcase_path) { - ecl_config_load_refcase( enkf_main->ecl_config , refcase_path ); +bool enkf_main_set_refcase( enkf_main_type * enkf_main , const char * refcase_path) { + bool set_refcase = ecl_config_load_refcase( enkf_main->ecl_config , refcase_path ); model_config_set_refcase( enkf_main->model_config , ecl_config_get_refcase( enkf_main->ecl_config )); ensemble_config_set_refcase( enkf_main->ensemble_config , ecl_config_get_refcase( enkf_main->ecl_config )); + + return set_refcase; } @@ -298,11 +301,21 @@ enkf_obs_type * enkf_main_get_obs(const enkf_main_type * enkf_main) { return enkf_main->obs; } + bool enkf_main_have_obs( const enkf_main_type * enkf_main ) { return enkf_obs_have_obs( enkf_main->obs ); } +bool enkf_main_has_QC_workflow( const enkf_main_type * enkf_main ) { + return qc_module_has_workflow( enkf_main->qc_module ); +} + +const qc_module_type * enkf_main_get_qc_module( const enkf_main_type * enkf_main ) { + return enkf_main->qc_module; +} + + /** Will do a forced reload of the observtaions; if the user has edited the content of the observation file while the ERT instance is @@ -311,8 +324,10 @@ bool enkf_main_have_obs( const enkf_main_type * enkf_main ) { void enkf_main_reload_obs( enkf_main_type * enkf_main) { enkf_obs_reload(enkf_main->obs , + model_config_get_history(enkf_main->model_config), ecl_config_get_grid( enkf_main->ecl_config ), ecl_config_get_refcase( enkf_main->ecl_config ) , + analysis_config_get_std_cutoff(enkf_main->analysis_config), enkf_main->ensemble_config ); } @@ -327,9 +342,11 @@ void enkf_main_reload_obs( enkf_main_type * enkf_main) { void enkf_main_load_obs( enkf_main_type * enkf_main , const char * obs_config_file ) { if (!util_string_equal( obs_config_file , enkf_obs_get_config_file( enkf_main->obs ))) { enkf_obs_load(enkf_main->obs , + model_config_get_history(enkf_main->model_config), obs_config_file , ecl_config_get_grid( enkf_main->ecl_config ), ecl_config_get_refcase( enkf_main->ecl_config ) , + analysis_config_get_std_cutoff(enkf_main->analysis_config), enkf_main->ensemble_config ); } } @@ -375,27 +392,36 @@ static void enkf_main_free_ensemble( enkf_main_type * enkf_main ) { } -void enkf_main_free(enkf_main_type * enkf_main) { - rng_free( enkf_main->rng ); +void enkf_main_free(enkf_main_type * enkf_main){ + if (enkf_main->rng != NULL) + rng_free( enkf_main->rng ); rng_config_free( enkf_main->rng_config ); + enkf_obs_free(enkf_main->obs); ranking_table_free( enkf_main->ranking_table ); enkf_main_free_ensemble( enkf_main ); if (enkf_main->dbase != NULL) enkf_fs_close( enkf_main->dbase ); util_safe_free( enkf_main->current_fs_case ); - log_add_message( enkf_main->logh , false , NULL , "Exiting ert application normally - all is fine(?)" , false); + if (log_is_open( enkf_main->logh )) + log_add_message( enkf_main->logh , false , NULL , "Exiting ert application normally - all is fine(?)" , false); log_close( enkf_main->logh ); + analysis_config_free(enkf_main->analysis_config); ecl_config_free(enkf_main->ecl_config); model_config_free( enkf_main->model_config); - qc_config_free( enkf_main->qc_config ); + + + qc_module_free( enkf_main->qc_module ); site_config_free( enkf_main->site_config); ensemble_config_free( enkf_main->ensemble_config ); if (enkf_main->local_config != NULL) local_config_free( enkf_main->local_config ); + ert_report_list_free( enkf_main->report_list ); + ert_workflow_list_free( enkf_main->workflow_list ); + int_vector_free( enkf_main->keep_runpath ); plot_config_free( enkf_main->plot_config ); @@ -411,6 +437,12 @@ void enkf_main_free(enkf_main_type * enkf_main) { +void enkf_main_exit(enkf_main_type * enkf_main) { + enkf_main_free( enkf_main ); + exit(0); +} + + /*****************************************************************/ @@ -1278,7 +1310,7 @@ static bool enkf_main_run_step(enkf_main_type * enkf_main , if (step1 > 0) ecl_config_assert_restart( enkf_main_get_ecl_config( enkf_main ) ); - + { bool verbose_queue = enkf_main->verbose; int max_internal_submit = model_config_get_max_internal_submit(enkf_main->model_config); @@ -1290,36 +1322,42 @@ static bool enkf_main_run_step(enkf_main_type * enkf_main , if (run_mode == ENKF_ASSIMILATION) printf("Starting forward step: %d -> %d\n",step1 , step2); } - + log_add_message(enkf_main->logh , 1 , NULL , "===================================================================", false); if (run_mode == ENKF_ASSIMILATION) log_add_fmt_message(enkf_main->logh , 1 , NULL , "Forward model: %d -> %d ",step1,step2); else log_add_fmt_message(enkf_main->logh , 1 , NULL , "Forward model: %d -> ??? ",step1); - bool_vector_safe_cast( iactive ); job_size = bool_vector_count_equal( iactive , true ); { pthread_t queue_thread; job_queue_type * job_queue = site_config_get_job_queue(enkf_main->site_config); - arg_pack_type * queue_args = arg_pack_alloc(); /* This arg_pack will be freed() in the job_que_run_jobs__() */ - arg_pack_append_ptr(queue_args , job_queue); - arg_pack_append_int(queue_args , job_size); - arg_pack_append_bool(queue_args , verbose_queue); - pthread_create( &queue_thread , NULL , job_queue_run_jobs__ , queue_args); + /* Start the queue */ + if (run_mode != INIT_ONLY) { + arg_pack_type * queue_args = arg_pack_alloc(); /* This arg_pack will be freed() in the job_que_run_jobs__() */ + arg_pack_append_ptr(queue_args , job_queue); + arg_pack_append_int(queue_args , job_size); + arg_pack_append_bool(queue_args , verbose_queue); + pthread_create( &queue_thread , NULL , job_queue_run_jobs__ , queue_args); + } + { thread_pool_type * submit_threads = thread_pool_alloc( 4 , true ); enkf_fs_type * fs = enkf_main_get_fs( enkf_main ); + runpath_list_type * runpath_list = qc_module_get_runpath_list( enkf_main->qc_module ); + runpath_list_clear( runpath_list ); for (iens = 0; iens < ens_size; iens++) { - if (bool_vector_iget(iactive , iens)) { + enkf_state_type * enkf_state = enkf_main->ensemble[iens]; + if (bool_vector_safe_iget(iactive , iens)) { int load_start = step1; if (step1 > 0) load_start++; - enkf_state_init_run(enkf_main->ensemble[iens] , + enkf_state_init_run(enkf_state , run_mode , true , max_internal_submit , @@ -1329,34 +1367,42 @@ static bool enkf_main_run_step(enkf_main_type * enkf_main , load_start , step1 , step2 ); + + runpath_list_add( runpath_list , + iens , + enkf_state_get_run_path( enkf_state ) , + enkf_state_get_eclbase( enkf_state )); { arg_pack_type * arg_pack = arg_pack_alloc( ); // This is discarded by the enkf_state_start_forward_model__() function. */ - arg_pack_append_ptr( arg_pack , enkf_main->ensemble[iens] ); + arg_pack_append_ptr( arg_pack , enkf_state ); arg_pack_append_ptr( arg_pack , fs ); thread_pool_add_job(submit_threads , enkf_state_start_forward_model__ , arg_pack); } } else - enkf_state_set_inactive( enkf_main->ensemble[iens] ); + enkf_state_set_inactive( enkf_state ); } /* After this join all directories/files for the simulations have been set up correctly, and all the jobs have been added to the job_queue manager. */ + qc_module_export_runpath_list( enkf_main->qc_module ); thread_pool_join(submit_threads); thread_pool_free(submit_threads); } - job_queue_submit_complete( job_queue ); - log_add_message(enkf_main->logh , 1 , NULL , "All jobs submitted to internal queue - waiting for completion" , false); - pthread_join( queue_thread , NULL ); /* Wait for the job_queue_run_jobs() function to complete. */ + if (run_mode != INIT_ONLY) { + job_queue_submit_complete( job_queue ); + log_add_message(enkf_main->logh , 1 , NULL , "All jobs submitted to internal queue - waiting for completion" , false); + pthread_join( queue_thread , NULL ); /* Wait for the job_queue_run_jobs() function to complete. */ + } } - + /* This should be carefully checked for the situation where only a subset (with offset > 0) of realisations are simulated. */ - { + if (run_mode != INIT_ONLY) { bool totalOK = true; for (iens = 0; iens < ens_size; iens++) { if (bool_vector_iget(iactive , iens)) { @@ -1378,12 +1424,15 @@ static bool enkf_main_run_step(enkf_main_type * enkf_main , } } - if (totalOK) - log_add_fmt_message(enkf_main->logh , 1 , NULL , "All jobs complete and data loaded."); - enkf_fs_fsync( enkf_main->dbase ); + if (totalOK) { + log_add_fmt_message(enkf_main->logh , 1 , NULL , "All jobs complete and data loaded."); + if (run_mode != ENKF_ASSIMILATION) + qc_module_run_workflow( enkf_main->qc_module , enkf_main ); + } return totalOK; - } + } else + return true; } } @@ -1444,52 +1493,31 @@ void enkf_main_init_run( enkf_main_type * enkf_main, run_mode_type run_mode) { } -/* -This function checks if no parameters have been initialized. If as much as one parameter -has been initialized the function will return false. -*/ - - -bool enkf_main_is_not_initialized_at_all( const enkf_main_type * enkf_main ) { - stringlist_type * parameter_keys = ensemble_config_alloc_keylist_from_var_type( enkf_main->ensemble_config , PARAMETER ); - bool initialized; - bool not_initialized_at_all = true; - int ikey, iens; - for (ikey = 0 ; ikey < stringlist_get_size( parameter_keys ) ; ikey++){ - const enkf_config_node_type * config_node = ensemble_config_get_node( enkf_main->ensemble_config , stringlist_iget( parameter_keys , ikey) ); - for ( iens = 0 ; iens < enkf_main->ens_size ; iens++ ){ - node_id_type node_id = {.report_step = 0 , .iens = iens , .state = ANALYZED }; - initialized = enkf_config_node_has_node( config_node , enkf_main->dbase , node_id); - if (initialized) - not_initialized_at_all = false; - } - - } - return not_initialized_at_all; -} - void enkf_main_run_exp(enkf_main_type * enkf_main , const bool_vector_type * iactive , + bool simulate , int init_step_parameters , int start_report , state_enum start_state) { - bool initialize = enkf_main_is_not_initialized_at_all( enkf_main ); - int ens_size = enkf_main_get_ensemble_size( enkf_main ); - if (initialize) { + + bool force_init = false; + int ens_size = enkf_main_get_ensemble_size( enkf_main ); + run_mode_type run_mode = simulate ? ENSEMBLE_EXPERIMENT : INIT_ONLY; + { stringlist_type * param_list = ensemble_config_alloc_keylist_from_var_type( enkf_main->ensemble_config , PARAMETER ); - enkf_main_initialize_from_scratch( enkf_main , param_list , 0 , ens_size - 1); + enkf_main_initialize_from_scratch( enkf_main , param_list , 0 , ens_size - 1, force_init); stringlist_free( param_list ); } - enkf_main_init_run( enkf_main , ENSEMBLE_EXPERIMENT ); + enkf_main_init_run( enkf_main , run_mode ); { const enkf_sched_type * enkf_sched = model_config_get_enkf_sched(enkf_main->model_config); const int last_report = -1; // Should be fully ignored. int load_start = start_report; state_enum init_state_parameter = start_state; state_enum init_state_dynamic = start_state; - enkf_main_run_step(enkf_main , ENSEMBLE_EXPERIMENT , iactive , load_start , init_step_parameters , init_state_parameter , init_state_dynamic , start_report , -1); + enkf_main_run_step(enkf_main , run_mode , iactive , load_start , init_step_parameters , init_state_parameter , init_state_dynamic , start_report , -1); } } @@ -1500,11 +1528,11 @@ void enkf_main_run_assimilation(enkf_main_type * enkf_main , int init_step_parameters , int start_report , state_enum start_state) { - bool initialize = enkf_main_is_not_initialized_at_all( enkf_main ); + bool force_init = false; int ens_size = enkf_main_get_ensemble_size( enkf_main ); - if (initialize) { + { stringlist_type * param_list = ensemble_config_alloc_keylist_from_var_type( enkf_main->ensemble_config , PARAMETER ); - enkf_main_initialize_from_scratch( enkf_main , param_list , 0 , ens_size - 1); + enkf_main_initialize_from_scratch( enkf_main , param_list , 0 , ens_size - 1 , force_init ); stringlist_free( param_list ); } bool rerun = analysis_config_get_rerun( enkf_main->analysis_config ); @@ -1597,11 +1625,11 @@ void enkf_main_run_assimilation(enkf_main_type * enkf_main , void enkf_main_run_smoother(enkf_main_type * enkf_main , const char * target_fs_name , bool rerun) { - bool initialize = enkf_main_is_not_initialized_at_all( enkf_main ); + bool force_init = false; int ens_size = enkf_main_get_ensemble_size( enkf_main ); - if (initialize) { + { stringlist_type * param_list = ensemble_config_alloc_keylist_from_var_type( enkf_main->ensemble_config , PARAMETER ); - enkf_main_initialize_from_scratch( enkf_main , param_list , 0 , ens_size - 1); + enkf_main_initialize_from_scratch( enkf_main , param_list , 0 , ens_size - 1 , force_init); stringlist_free( param_list ); } @@ -1765,18 +1793,19 @@ static void * enkf_main_initialize_from_scratch_mt(void * void_arg) { stringlist_type * param_list = arg_pack_iget_ptr( arg_pack , 1 ); int iens1 = arg_pack_iget_int( arg_pack , 2 ); int iens2 = arg_pack_iget_int( arg_pack , 3 ); + bool force_init = arg_pack_iget_bool( arg_pack , 4 ); int iens; for (iens = iens1; iens < iens2; iens++) { enkf_state_type * state = enkf_main_iget_state( enkf_main , iens); - enkf_state_initialize( state , enkf_main_get_fs( enkf_main ) , param_list ); + enkf_state_initialize( state , enkf_main_get_fs( enkf_main ) , param_list , force_init); } return NULL; } -void enkf_main_initialize_from_scratch(enkf_main_type * enkf_main , const stringlist_type * param_list , int iens1 , int iens2) { +void enkf_main_initialize_from_scratch(enkf_main_type * enkf_main , const stringlist_type * param_list , int iens1 , int iens2, bool force_init) { int num_cpu = 4; thread_pool_type * tp = thread_pool_alloc( num_cpu , true ); int ens_sub_size = (iens2 - iens1 + 1) / num_cpu; @@ -1800,6 +1829,7 @@ void enkf_main_initialize_from_scratch(enkf_main_type * enkf_main , const string arg_pack_append_int( arg_list[i] , start_iens ); arg_pack_append_int( arg_list[i] , end_iens ); } + arg_pack_append_bool( arg_list[i] , force_init ); thread_pool_add_job( tp , enkf_main_initialize_from_scratch_mt , arg_list[i]); } thread_pool_join( tp ); @@ -1811,6 +1841,9 @@ void enkf_main_initialize_from_scratch(enkf_main_type * enkf_main , const string } + + + /** This function creates a local_config file corresponding to the default 'ALL_ACTIVE' configuration. We eat our own dogshit around @@ -1892,34 +1925,28 @@ void enkf_main_create_all_active_config( const enkf_main_type * enkf_main , -static config_type * enkf_main_alloc_config( bool site_only , bool strict ) { - config_type * config = config_alloc(); +static void enkf_main_init_user_config( const enkf_main_type * enkf_main , config_type * config ) { config_schema_item_type * item; /*****************************************************************/ - /* config_add_schema_item(): */ + /* config_add_schema_item(): */ /* */ /* 1. boolean - required? */ - /* 2. boolean - append? */ /*****************************************************************/ - site_config_add_config_items( config , site_only ); - if (site_only) - return config; /* <---------------- return statement here! */ - - - + ert_workflow_list_add_config_items( config ); plot_config_add_config_items( config ); analysis_config_add_config_items( config ); - ensemble_config_add_config_items(config); + ensemble_config_add_config_items( config ); ecl_config_add_config_items( config ); rng_config_add_config_items( config ); /*****************************************************************/ /* Required keywords from the ordinary model_config file */ - item = config_add_schema_item(config , CASE_TABLE_KEY , false , false); - config_schema_item_set_argc_minmax(item , 1 , 1 , 1, (const config_item_types [1]) {CONFIG_EXISTING_FILE}); + item = config_add_schema_item(config , CASE_TABLE_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1); + config_schema_item_iset_type( item , 0 , CONFIG_EXISTING_PATH ); config_add_key_value( config , LOG_LEVEL_KEY , false , CONFIG_INT); config_add_key_value( config , LOG_FILE_KEY , false , CONFIG_STRING); @@ -1927,8 +1954,9 @@ static config_type * enkf_main_alloc_config( bool site_only , bool strict ) { config_add_key_value(config , MAX_RESAMPLE_KEY , false , CONFIG_INT); - item = config_add_schema_item(config , NUM_REALIZATIONS_KEY , true , false); - config_schema_item_set_argc_minmax(item , 1 , 1 , 1, (const config_item_types [1]) {CONFIG_INT}); + item = config_add_schema_item(config , NUM_REALIZATIONS_KEY , true ); + config_schema_item_set_argc_minmax(item , 1 , 1); + config_schema_item_iset_type( item , 0 , CONFIG_INT ); config_add_alias(config , NUM_REALIZATIONS_KEY , "SIZE"); config_add_alias(config , NUM_REALIZATIONS_KEY , "NUM_REALISATIONS"); config_install_message(config , "SIZE" , "** Warning: \'SIZE\' is depreceated - use \'NUM_REALIZATIONS\' instead."); @@ -1937,56 +1965,61 @@ static config_type * enkf_main_alloc_config( bool site_only , bool strict ) { /*****************************************************************/ /* Optional keywords from the model config file */ - item = config_add_schema_item( config , RUN_TEMPLATE_KEY , false , true ); - config_schema_item_set_argc_minmax(item , 2 , -1 , 2 , (const config_item_types [2]) { CONFIG_EXISTING_FILE , CONFIG_STRING }); /* Force the template to exist at boot time. */ + item = config_add_schema_item( config , RUN_TEMPLATE_KEY , false ); + config_schema_item_set_argc_minmax(item , 2 , CONFIG_DEFAULT_ARG_MAX ); + config_schema_item_iset_type( item , 0 , CONFIG_EXISTING_PATH ); config_add_key_value(config , RUNPATH_KEY , false , CONFIG_STRING); config_add_key_value(config , RERUN_PATH_KEY , false , CONFIG_STRING); - item = config_add_schema_item(config , ENSPATH_KEY , false , false); - config_schema_item_set_argc_minmax(item , 1 , 1 , 0 , NULL); + item = config_add_schema_item(config , ENSPATH_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1 ); - item = config_add_schema_item( config , JOBNAME_KEY , false , false ); - config_schema_item_set_argc_minmax(item , 1 , 1 , 0 , NULL); + item = config_add_schema_item( config , JOBNAME_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1 ); - item = config_add_schema_item(config , SELECT_CASE_KEY , false , false); - config_schema_item_set_argc_minmax(item , 1 , 1 , 0 , NULL); + item = config_add_schema_item(config , SELECT_CASE_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1 ); - item = config_add_schema_item(config , DBASE_TYPE_KEY , false , false); - config_schema_item_set_argc_minmax(item , 1, 1 , 0 , NULL); - config_schema_item_set_common_selection_set(item , 3 , (const char *[3]) {"PLAIN" , "SQLITE" , "BLOCK_FS"}); + item = config_add_schema_item(config , DBASE_TYPE_KEY , false ); + config_schema_item_set_argc_minmax(item , 1, 1 ); + config_schema_item_set_common_selection_set(item , 2 , (const char *[2]) {"PLAIN" , "BLOCK_FS"}); - item = config_add_schema_item(config , FORWARD_MODEL_KEY , false , true); - config_schema_item_set_argc_minmax(item , 1 , -1 , 0 , NULL); + item = config_add_schema_item(config , FORWARD_MODEL_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , CONFIG_DEFAULT_ARG_MAX); - item = config_add_schema_item(config , DATA_KW_KEY , false , true); - config_schema_item_set_argc_minmax(item , 2 , 2 , 0 , NULL); + item = config_add_schema_item(config , DATA_KW_KEY , false ); + config_schema_item_set_argc_minmax(item , 2 , 2); - item = config_add_schema_item(config , KEEP_RUNPATH_KEY , false , false); - config_schema_item_set_argc_minmax(item , 1 , -1 , 0 , NULL); + item = config_add_schema_item(config , KEEP_RUNPATH_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , CONFIG_DEFAULT_ARG_MAX); - config_add_key_value(config , PRE_CLEAR_RUNPATH_KEY , false , CONFIG_BOOLEAN); + config_add_key_value(config , PRE_CLEAR_RUNPATH_KEY , false , CONFIG_BOOL); - item = config_add_schema_item(config , DELETE_RUNPATH_KEY , false , false); - config_schema_item_set_argc_minmax(item , 1 , -1 , 0 , NULL); + item = config_add_schema_item(config , DELETE_RUNPATH_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , CONFIG_DEFAULT_ARG_MAX); - item = config_add_schema_item(config , OBS_CONFIG_KEY , false , false); - config_schema_item_set_argc_minmax(item , 1 , 1 , 1 , (const config_item_types [1]) { CONFIG_EXISTING_FILE}); + item = config_add_schema_item(config , OBS_CONFIG_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1 ); + config_schema_item_iset_type( item , 0 , CONFIG_EXISTING_PATH ); - item = config_add_schema_item(config , RFT_CONFIG_KEY , false , false); - config_schema_item_set_argc_minmax(item , 1 , 1 , 1 , (const config_item_types [1]) { CONFIG_EXISTING_FILE}); + item = config_add_schema_item(config , RFT_CONFIG_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1 ); + config_schema_item_iset_type( item , 0 , CONFIG_EXISTING_PATH ); - item = config_add_schema_item(config , RFTPATH_KEY , false , false); - config_schema_item_set_argc_minmax(item , 1 , 1 , 0 , NULL); + item = config_add_schema_item(config , RFTPATH_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1 ); - item = config_add_schema_item(config , LOCAL_CONFIG_KEY , false , true); - config_schema_item_set_argc_minmax(item , 1 , 1 , 1 , (const config_item_types [1]) { CONFIG_EXISTING_FILE}); + item = config_add_schema_item(config , LOCAL_CONFIG_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1 ); + config_schema_item_iset_type( item , 0 , CONFIG_EXISTING_PATH ); - item = config_add_schema_item(config , ENKF_SCHED_FILE_KEY , false , false); - config_schema_item_set_argc_minmax(item , 1 , 1 , 1 , (const config_item_types [1]) { CONFIG_EXISTING_FILE}); + item = config_add_schema_item(config , ENKF_SCHED_FILE_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1 ); + config_schema_item_iset_type( item , 0 , CONFIG_EXISTING_PATH ); - item = config_add_schema_item(config , HISTORY_SOURCE_KEY , false , false); - config_schema_item_set_argc_minmax(item , 1 , 1 , 0 , NULL); + item = config_add_schema_item(config , HISTORY_SOURCE_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1); { stringlist_type * refcase_dep = stringlist_alloc_argv_ref( (const char *[1]) { REFCASE_KEY } , 1); @@ -1996,28 +2029,9 @@ static config_type * enkf_main_alloc_config( bool site_only , bool strict ) { stringlist_free(refcase_dep); } - /*****************************************************************/ - /* Report */ - item = config_add_schema_item(config , REPORT_LIST_KEY , false , true); - config_schema_item_set_argc_minmax(item , 1 , -1 , 0 , NULL); - - item = config_add_schema_item(config , REPORT_CONTEXT_KEY , false , true); - config_schema_item_set_argc_minmax(item , 2 , 2 , 0 , NULL); - item = config_add_schema_item(config , REPORT_PATH_KEY , false , false); - config_schema_item_set_argc_minmax(item , 1 , 1 , 0 , NULL); - - item = config_add_schema_item( config , REPORT_WELL_LIST_KEY , false , true ); - config_schema_item_set_argc_minmax(item , 1 , -1 , 0 , NULL); - - item = config_add_schema_item( config , REPORT_GROUP_LIST_KEY , false , true ); - config_schema_item_set_argc_minmax(item , 1 , -1 , 0 , NULL); - /*****************************************************************/ - /* QC */ - item = config_add_schema_item( config , QC_PATH_KEY , false , false ); - config_schema_item_set_argc_minmax(item , 1 , 1 , 0 , NULL); - - return config; + ert_report_list_add_config_items( config); + qc_module_add_config_items( config ); } @@ -2052,29 +2066,25 @@ void enkf_main_parse_keep_runpath(enkf_main_type * enkf_main , const char * keep int i; for (i = 0; i < ens_size; i++) int_vector_iset( enkf_main->keep_runpath , i , DEFAULT_KEEP); + { - int * active_list; - int num_items; + int_vector_type * active_list = string_util_alloc_active_list(keep_runpath_string); - active_list = util_sscanf_alloc_active_list(keep_runpath_string , &num_items); - for (i = 0; i < num_items; i++) - int_vector_iset( enkf_main->keep_runpath , i , EXPLICIT_KEEP); + for (i = 0; i < int_vector_size( active_list ); i++) + int_vector_iset( enkf_main->keep_runpath , int_vector_iget( active_list , i ) , EXPLICIT_KEEP); - - free( active_list ); + int_vector_free( active_list ); } { - int * active_list; - int num_items; + int_vector_type * active_list = string_util_alloc_active_list(delete_runpath_string); - active_list = util_sscanf_alloc_active_list(delete_runpath_string , &num_items); - for (i = 0; i < num_items; i++) - int_vector_iset( enkf_main->keep_runpath , i , EXPLICIT_DELETE); + for (i = 0; i < int_vector_size( active_list ); i++) + int_vector_iset( enkf_main->keep_runpath , int_vector_iget( active_list , i ) , EXPLICIT_DELETE); - free( active_list ); + int_vector_free( active_list ); } } @@ -2102,11 +2112,30 @@ void enkf_main_clear_data_kw( enkf_main_type * enkf_main ) { subst_list_clear( enkf_main->subst_list ); } +static void enkf_main_add_subst_kw( enkf_main_type * enkf_main , const char * key , const char * value, const char * help_text , bool insert_copy) { + char * tagged_key = util_alloc_sprintf( INTERNAL_DATA_KW_TAG_FORMAT , key ); + + if (insert_copy) + subst_list_append_owned_ref( enkf_main->subst_list , tagged_key , util_alloc_string_copy( value ), help_text); + else + subst_list_append_ref( enkf_main->subst_list , tagged_key , value , help_text); + + free(tagged_key); +} + +static void enkf_main_init_workflow_list( enkf_main_type * enkf_main , config_type * config ) { + ert_workflow_list_init( enkf_main->workflow_list , config , enkf_main->logh); +} + + +static void enkf_main_init_qc( enkf_main_type * enkf_main , config_type * config ) { + qc_module_init( enkf_main->qc_module , config ); + enkf_main_add_subst_kw( enkf_main , "QC_PATH" , qc_module_get_path( enkf_main->qc_module ) , "QC Root path" , true); +} static void enkf_main_init_subst_list( enkf_main_type * enkf_main ) { /* Here we add the functions which should be available for string substitution operations. */ - enkf_main->subst_func_pool = subst_func_pool_alloc( enkf_main->rng ); subst_func_pool_add_func( enkf_main->subst_func_pool , "EXP" , "exp" , subst_func_exp , false , 1 , 1 , NULL); subst_func_pool_add_func( enkf_main->subst_func_pool , "LOG" , "log" , subst_func_log , false , 1 , 1 , NULL); subst_func_pool_add_func( enkf_main->subst_func_pool , "POW10" , "Calculates 10^x" , subst_func_pow10 , false , 1 , 1 , NULL); @@ -2114,7 +2143,7 @@ static void enkf_main_init_subst_list( enkf_main_type * enkf_main ) { subst_func_pool_add_func( enkf_main->subst_func_pool , "MUL" , "Multiplies arguments" , subst_func_mul , true , 1 , 0 , NULL); subst_func_pool_add_func( enkf_main->subst_func_pool , "RANDINT" , "Returns a random integer - 32 bit" , subst_func_randint , false , 0 , 0 , enkf_main->rng); subst_func_pool_add_func( enkf_main->subst_func_pool , "RANDFLOAT" , "Returns a random float 0-1." , subst_func_randfloat , false , 0 , 0 , enkf_main->rng); - + /** Allocating the parent subst_list instance. This will (should ...) be the top level subst instance for all substitions in the ert @@ -2131,7 +2160,7 @@ static void enkf_main_init_subst_list( enkf_main_type * enkf_main ) { o Constant in time. */ - enkf_main->subst_list = subst_list_alloc( enkf_main->subst_func_pool ); + /* Installing the functions. */ subst_list_insert_func( enkf_main->subst_list , "EXP" , "__EXP__"); subst_list_insert_func( enkf_main->subst_list , "LOG" , "__LOG__"); @@ -2144,7 +2173,7 @@ static void enkf_main_init_subst_list( enkf_main_type * enkf_main ) { -static enkf_main_type * enkf_main_alloc_empty( ) { +enkf_main_type * enkf_main_alloc_empty( ) { enkf_main_type * enkf_main = util_malloc(sizeof * enkf_main); UTIL_TYPE_ID_INIT(enkf_main , ENKF_MAIN_ID); enkf_main->current_fs_case = NULL; @@ -2154,33 +2183,44 @@ static enkf_main_type * enkf_main_alloc_empty( ) { enkf_main->site_config_file = NULL; enkf_main->rft_config_file = NULL; enkf_main->local_config = NULL; + enkf_main->rng = NULL; enkf_main->ens_size = 0; enkf_main->keep_runpath = int_vector_alloc( 0 , DEFAULT_KEEP ); - enkf_main->logh = log_alloc_existing( NULL , DEFAULT_LOG_LEVEL ); + enkf_main->logh = log_open( NULL , DEFAULT_LOG_LEVEL ); enkf_main->rng_config = rng_config_alloc( ); + enkf_main->site_config = site_config_alloc_empty(); + enkf_main->ensemble_config = ensemble_config_alloc_empty(); + enkf_main->ecl_config = ecl_config_alloc_empty(); + enkf_main->plot_config = plot_config_alloc_default(); + enkf_main->ranking_table = ranking_table_alloc( 0 ); + enkf_main->obs = enkf_obs_alloc( ); + enkf_main->model_config = model_config_alloc_empty( ); + + enkf_main_rng_init( enkf_main ); + enkf_main->subst_func_pool = subst_func_pool_alloc( ); + enkf_main->subst_list = subst_list_alloc( enkf_main->subst_func_pool ); + enkf_main->templates = ert_templates_alloc( enkf_main->subst_list ); + enkf_main->workflow_list = ert_workflow_list_alloc( enkf_main->subst_list ); + enkf_main->qc_module = qc_module_alloc( enkf_main->workflow_list , DEFAULT_QC_PATH ); + enkf_main->analysis_config = analysis_config_alloc_default( enkf_main->rng ); + enkf_main->report_list = ert_report_list_alloc( DEFAULT_REPORT_PATH , plot_config_get_path( enkf_main->plot_config ) ); + enkf_main_init_subst_list( enkf_main ); enkf_main_set_verbose( enkf_main , true ); - enkf_main->site_config = site_config_alloc_empty(); - enkf_main->ensemble_config = ensemble_config_alloc_empty(); - enkf_main->ecl_config = ecl_config_alloc_empty(); - enkf_main->qc_config = qc_config_alloc( DEFAULT_QC_PATH ); - enkf_main->model_config = model_config_alloc_empty(); - enkf_main->analysis_config = analysis_config_alloc_default( enkf_main->rng ); /* This is ready for use. */ - enkf_main->plot_config = plot_config_alloc_default(); /* This is ready for use. */ - enkf_main->report_list = ert_report_list_alloc( DEFAULT_REPORT_PATH , plot_config_get_path( enkf_main->plot_config ) ); - enkf_main->ranking_table = ranking_table_alloc( 0 ); + printf("enkf_main->subst_list :%p \n",enkf_main->subst_list); return enkf_main; } + static void enkf_main_install_data_kw( enkf_main_type * enkf_main , hash_type * config_data_kw) { /* Installing the DATA_KW keywords supplied by the user - these are at the very top level, so they can reuse everything defined later. */ - { + if (config_data_kw) { hash_iter_type * iter = hash_iter_alloc(config_data_kw); const char * key = hash_iter_get_next_key(iter); while (key != NULL) { @@ -2197,26 +2237,18 @@ static void enkf_main_install_data_kw( enkf_main_type * enkf_main , hash_type * ensemble members, and independent of time. */ { - char * cwd = util_alloc_cwd(); - char * date_string = util_alloc_date_stamp(); - - char * cwd_key = util_alloc_sprintf( INTERNAL_DATA_KW_TAG_FORMAT , "CWD" ); - char * config_path_key = util_alloc_sprintf( INTERNAL_DATA_KW_TAG_FORMAT , "CONFIG_PATH" ); - char * date_key = util_alloc_sprintf( INTERNAL_DATA_KW_TAG_FORMAT , "DATE" ); - char * num_cpu_key = util_alloc_sprintf( INTERNAL_DATA_KW_TAG_FORMAT , "NUM_CPU" ); - char * num_cpu_string = "1"; + char * cwd = util_alloc_cwd(); + char * date_string = util_alloc_date_stamp(); + const char * num_cpu_string = "1"; + + enkf_main_add_subst_kw( enkf_main , "CWD" , cwd , "The current working directory we are running from - the location of the config file." , true); + enkf_main_add_subst_kw( enkf_main , "CONFIG_PATH" , cwd , "The current working directory we are running from - the location of the config file." , false); + enkf_main_add_subst_kw( enkf_main , "DATE" , date_string , "The current date." , true); + enkf_main_add_subst_kw( enkf_main , "NUM_CPU" , num_cpu_string , "The number of CPU used for one forward model." , true ); + enkf_main_add_subst_kw( enkf_main , "RUNPATH_FILE" , qc_module_get_runpath_list_file( enkf_main->qc_module ) , "The name of a file with a list of run directories." , true); - - subst_list_append_owned_ref( enkf_main->subst_list , cwd_key , cwd , "The current working directory we are running from - the location of the config file."); - subst_list_append_ref( enkf_main->subst_list , config_path_key , cwd , "The current working directory we are running from - the location of the config file."); - subst_list_append_owned_ref( enkf_main->subst_list , date_key , date_string , "The current date"); - subst_list_append_ref( enkf_main->subst_list , num_cpu_key , num_cpu_string , "The number of CPU used for one forward model."); - - - free( num_cpu_key ); - free( cwd_key ); - free( config_path_key ); - free( date_key ); + //free( cwd ); + //free( date_string ); } } @@ -2393,6 +2425,7 @@ char * enkf_main_alloc_mount_point( const enkf_main_type * enkf_main , const cha return mount_point; } + void enkf_main_set_fs( enkf_main_type * enkf_main , enkf_fs_type * fs , const char * case_path ) { if (enkf_main->dbase != fs) { if (enkf_main->dbase != NULL) @@ -2402,6 +2435,7 @@ void enkf_main_set_fs( enkf_main_type * enkf_main , enkf_fs_type * fs , const ch enkf_main_link_current_fs__( enkf_main , case_path); enkf_main->current_fs_case = util_realloc_string_copy( enkf_main->current_fs_case , case_path); enkf_main_gen_data_special( enkf_main ); + enkf_main_add_subst_kw( enkf_main , "CASE" , enkf_main->current_fs_case , "Current case" , true ); } } @@ -2609,7 +2643,7 @@ void enkf_main_update_obs_keys( enkf_main_type * enkf_main ) { void enkf_main_set_log_file( enkf_main_type * enkf_main , const char * log_file ) { - log_reset_filename( enkf_main->logh , log_file); + log_reopen( enkf_main->logh , log_file); } @@ -2646,9 +2680,15 @@ static void enkf_main_init_log( enkf_main_type * enkf_main , const config_type * } static void enkf_main_init_data_kw( enkf_main_type * enkf_main , config_type * config ) { - hash_type * data_kw = config_alloc_hash(config , DATA_KW_KEY); + config_content_item_type * data_item = config_get_content_item( config , DATA_KW_KEY ); + hash_type * data_kw = NULL; + if (data_item) + data_kw = config_content_item_alloc_hash(data_item , true); + enkf_main_install_data_kw( enkf_main , data_kw ); - hash_free( data_kw ); + + if (data_kw) + hash_free( data_kw ); } @@ -2658,24 +2698,54 @@ static void enkf_main_init_data_kw( enkf_main_type * enkf_main , config_type * c /*****************************************************************/ -void enkf_main_rng_init( enkf_main_type * enkf_main) { - const char * seed_load = rng_config_get_seed_load_file( enkf_main->rng_config ); - const char * seed_store = rng_config_get_seed_store_file( enkf_main->rng_config ); - enkf_main->rng = rng_alloc( rng_config_get_type(enkf_main->rng_config) , INIT_DEFAULT); - - if (seed_load != NULL) { - FILE * stream = util_fopen( seed_load , "r"); - rng_fscanf_state( enkf_main->rng , stream ); - fclose( stream ); - } else - rng_init( enkf_main->rng , INIT_DEV_RANDOM ); - +rng_config_type * enkf_main_get_rng_config( const enkf_main_type * enkf_main ) { + return enkf_main->rng_config; +} - if (seed_store != NULL) { - FILE * stream = util_mkdir_fopen( seed_store , "w"); - rng_fprintf_state( enkf_main->rng , stream ); - fclose( stream ); +void enkf_main_rng_init( enkf_main_type * enkf_main) { + if (enkf_main->rng != NULL) { + rng_free( enkf_main->rng ); + enkf_main->rng = NULL; } + enkf_main->rng = rng_config_alloc_rng( enkf_main->rng_config ); +} + + +void enkf_main_init_local_updates( enkf_main_type * enkf_main , const config_type * config ) { + if (model_config_has_history( enkf_main->model_config )) { + enkf_main->local_config = local_config_alloc( ); + + /* First create the default ALL_ACTIVE configuration. */ + { + char * all_active_config_file = util_alloc_tmp_file("/tmp" , "enkf_local_config" , true); + enkf_main_create_all_active_config( enkf_main , + all_active_config_file ); + + /* Install custom local_config - if present.*/ + { + int i; + for (i = 0; i < config_get_occurences( config , LOCAL_CONFIG_KEY); i++) { + const stringlist_type * files = config_iget_stringlist_ref(config , LOCAL_CONFIG_KEY , i); + for (int j=0; j < stringlist_get_size( files ); j++) + local_config_add_config_file( enkf_main->local_config , stringlist_iget( files , j) ); + } + } + + /** + This is where the local configuration files are actually parsed. + */ + local_config_reload( enkf_main->local_config , + ecl_config_get_grid( enkf_main->ecl_config ), + enkf_main->ensemble_config , + enkf_main->obs , + all_active_config_file ); + + unlink( all_active_config_file ); + free(all_active_config_file); + } + } else + if (config_get_occurences( config , LOCAL_CONFIG_KEY) > 0) + fprintf(stderr,"** Warning: Not possible to configure local analysis without SCHEDULE or REFCASE - %s keyword(s) ignored\n", LOCAL_CONFIG_KEY); } @@ -2688,31 +2758,24 @@ void enkf_main_rng_init( enkf_main_type * enkf_main) { */ -static void enkf_main_bootstrap_site(enkf_main_type * enkf_main , const char * site_config_file , bool strict) { - char * cwd = util_alloc_cwd(); - { - +static void enkf_main_bootstrap_site(enkf_main_type * enkf_main , const char * site_config_file) { + if (site_config_file != NULL) { + if (!util_file_exists(site_config_file)) util_exit("%s: can not locate site configuration file:%s \n",__func__ , site_config_file); + config_type * config = config_alloc(); { - char * site_config_path; - util_alloc_file_components( site_config_file , &site_config_path , NULL , NULL ); - if (site_config_path != NULL) { - if (chdir( site_config_path ) != 0) - util_abort("s: holy diver - could not chdir() to directory:%s containing the site configuration. \n",__func__ , site_config_path); + site_config_add_config_items( config , true ); + if (config_parse(config , site_config_file , "--" , INCLUDE_KEY , DEFINE_KEY , CONFIG_UNRECOGNIZED_WARN , false)) { + site_config_init( enkf_main->site_config , config ); + ert_report_list_site_init( enkf_main->report_list , config ); + ert_workflow_list_init( enkf_main->workflow_list , config , enkf_main->logh); + } else { + fprintf(stderr , "** ERROR: Parsing site configuration file:%s failed \n\n" , site_config_file); + config_fprintf_errors( config , true , stderr ); + exit(1); } - util_safe_free( site_config_path ); } - - { - config_type * config = enkf_main_alloc_config( true , strict ); - config_parse(config , site_config_file , "--" , INCLUDE_KEY , DEFINE_KEY , true , false); - site_config_init( enkf_main->site_config , config , false); /* <---- site_config : first pass. */ - ert_report_list_site_init( enkf_main->report_list , config ); - config_free( config ); - } - + config_free( config ); } - chdir( cwd ); - free( cwd ); } @@ -2760,9 +2823,9 @@ enkf_main_type * enkf_main_bootstrap(const char * _site_config, const char * _mo if (site_config == NULL) site_config = _site_config; - + if (site_config == NULL) - util_exit("%s: main enkf_config file is not set. Use environment variable \"ERT_SITE_CONFIG\" - or recompile - aborting.\n",__func__); + fprintf(stderr,"**WARNING** main enkf_config file is not set. Use environment variable \"ERT_SITE_CONFIG\" - or recompile.\n"); { char * path; @@ -2797,23 +2860,28 @@ enkf_main_type * enkf_main_bootstrap(const char * _site_config, const char * _mo } - if (!util_file_exists(site_config)) util_exit("%s: can not locate site configuration file:%s \n",__func__ , site_config); if (!util_file_exists(model_config)) util_exit("%s: can not locate user configuration file:%s \n",__func__ , model_config); { - enkf_main = enkf_main_alloc_empty( ); config_type * config; - /* Parsing the site_config file first */ + enkf_main = enkf_main_alloc_empty( ); enkf_main_set_verbose( enkf_main , verbose ); - enkf_main_bootstrap_site( enkf_main , site_config , strict ); + enkf_main_bootstrap_site( enkf_main , site_config); - - config = enkf_main_alloc_config( false , strict ); + config = config_alloc(); + enkf_main_init_user_config( enkf_main , config ); + site_config_add_config_items( config , false ); site_config_init_user_mode( enkf_main->site_config ); - config_parse(config , model_config , "--" , INCLUDE_KEY , DEFINE_KEY , true , true); - site_config_init( enkf_main->site_config , config , true ); /* <---- model_config : second pass. */ + + if (!config_parse(config , model_config , "--" , INCLUDE_KEY , DEFINE_KEY , CONFIG_UNRECOGNIZED_WARN , true)) { + config_fprintf_errors( config , true , stderr ); + exit(1); + } + + site_config_init( enkf_main->site_config , config ); /* <---- model_config : second pass. */ /*****************************************************************/ - /* OK - now we have parsed everything - and we are ready to start + /* + OK - now we have parsed everything - and we are ready to start populating the enkf_main object. */ @@ -2827,6 +2895,8 @@ enkf_main_type * enkf_main_bootstrap(const char * _site_config, const char * _mo rng_config_init( enkf_main->rng_config , config ); enkf_main_rng_init( enkf_main ); /* Must be called before the ensmeble is created. */ enkf_main_init_subst_list( enkf_main ); + ert_workflow_list_init( enkf_main->workflow_list , config , enkf_main->logh ); + enkf_main_init_qc( enkf_main , config ); enkf_main_init_data_kw( enkf_main , config ); analysis_config_load_internal_modules( enkf_main->analysis_config ); @@ -2834,7 +2904,7 @@ enkf_main_type * enkf_main_bootstrap(const char * _site_config, const char * _mo ecl_config_init( enkf_main->ecl_config , config ); plot_config_init( enkf_main->plot_config , config ); ensemble_config_init( enkf_main->ensemble_config , config , ecl_config_get_grid( enkf_main->ecl_config ) , ecl_config_get_refcase( enkf_main->ecl_config) ); - qc_config_init( enkf_main->qc_config , config ); + model_config_init( enkf_main->model_config , config , enkf_main_get_ensemble_size( enkf_main ), @@ -2844,11 +2914,13 @@ enkf_main_type * enkf_main_bootstrap(const char * _site_config, const char * _mo ecl_config_get_refcase( enkf_main->ecl_config )); enkf_main_update_num_cpu( enkf_main ); { - if (config_item_set( config , SCHEDULE_PREDICTION_FILE_KEY)) { - stringlist_type * tokens = config_iget_stringlist_ref(config , SCHEDULE_PREDICTION_FILE_KEY , 0); - const char * template_file = stringlist_iget(tokens , 0); + const config_content_item_type * pred_item = config_get_content_item( config , SCHEDULE_PREDICTION_FILE_KEY ); + if (pred_item != NULL) { + const config_content_node_type * pred_node = config_content_item_get_last_node( pred_item ); + const char * template_file = config_content_node_iget_as_path( pred_node , 0 ); { - hash_type * opt_hash = hash_alloc_from_options( tokens ); + hash_type * opt_hash = hash_alloc(); + config_content_node_init_opt_hash( pred_node , opt_hash , 1 ); const char * parameters = hash_safe_get( opt_hash , "PARAMETERS" ); const char * min_std = hash_safe_get( opt_hash , "MIN_STD" ); @@ -2884,10 +2956,10 @@ enkf_main_type * enkf_main_bootstrap(const char * _site_config, const char * _mo char * delete_runpath_string = NULL; int ens_size = config_get_value_as_int(config , NUM_REALIZATIONS_KEY); - if (config_has_set_item(config , KEEP_RUNPATH_KEY)) + if (config_item_set(config , KEEP_RUNPATH_KEY)) keep_runpath_string = config_alloc_joined_string(config , KEEP_RUNPATH_KEY , ""); - if (config_has_set_item(config , DELETE_RUNPATH_KEY)) + if (config_item_set(config , DELETE_RUNPATH_KEY)) delete_runpath_string = config_alloc_joined_string(config , DELETE_RUNPATH_KEY , ""); enkf_main_parse_keep_runpath( enkf_main , keep_runpath_string , delete_runpath_string , ens_size ); @@ -2899,43 +2971,16 @@ enkf_main_type * enkf_main_bootstrap(const char * _site_config, const char * _mo /* This is really in the wrong place ... */ { enkf_main->pre_clear_runpath = DEFAULT_PRE_CLEAR_RUNPATH; - if (config_has_set_item(config , PRE_CLEAR_RUNPATH_KEY)) + if (config_item_set(config , PRE_CLEAR_RUNPATH_KEY)) enkf_main->pre_clear_runpath = config_get_value_as_bool( config , PRE_CLEAR_RUNPATH_KEY); } - - - if (config_has_set_item(config , STATIC_KW_KEY)) { - for (int i=0; i < config_get_occurences(config , STATIC_KW_KEY); i++) { - const stringlist_type * static_kw_list = config_iget_stringlist_ref(config , STATIC_KW_KEY , i); - int k; - for (k = 0; k < stringlist_get_size(static_kw_list); k++) - ecl_config_add_static_kw(enkf_main->ecl_config , stringlist_iget( static_kw_list , k)); - } - } - + ecl_config_static_kw_init( enkf_main->ecl_config , config ); + /* Installing templates */ { - enkf_main->templates = ert_templates_alloc( enkf_main->subst_list ); - for (int i=0; i < config_get_occurences( config , RUN_TEMPLATE_KEY); i++) { - const char * template_file = config_iget( config , RUN_TEMPLATE_KEY , i , 0); - const char * target_file = config_iget( config , RUN_TEMPLATE_KEY , i , 1); - ert_template_type * template = ert_templates_add_template( enkf_main->templates , NULL , template_file , target_file , NULL); - - for (int iarg = 2; iarg < config_get_occurence_size( config , RUN_TEMPLATE_KEY , i); iarg++) { - char * key , *value; - util_binary_split_string( config_iget( config , RUN_TEMPLATE_KEY , i , iarg ), "=:" , true , &key , &value); - - if (value != NULL) - ert_template_add_arg( template ,key , value ); - else - fprintf(stderr,"** Warning - failed to parse argument:%s as key:value - ignored \n",config_iget( config , "RUN_TEMPLATE" , i , iarg )); - - free( key ); - util_safe_free( value ); - } - } + ert_templates_init( enkf_main->templates , config ); } /*****************************************************************/ @@ -2943,12 +2988,11 @@ enkf_main_type * enkf_main_bootstrap(const char * _site_config, const char * _mo { const char * obs_config_file; - if (config_has_set_item(config , OBS_CONFIG_KEY)) + if (config_item_set(config , OBS_CONFIG_KEY)) obs_config_file = config_iget(config , OBS_CONFIG_KEY , 0,0); else obs_config_file = NULL; - enkf_main->obs = enkf_obs_alloc( model_config_get_history(enkf_main->model_config), analysis_config_get_std_cutoff(enkf_main->analysis_config) ); enkf_main_load_obs( enkf_main , obs_config_file ); } @@ -2956,7 +3000,7 @@ enkf_main_type * enkf_main_bootstrap(const char * _site_config, const char * _mo { const char * rft_config_file = NULL; - if (config_has_set_item(config , RFT_CONFIG_KEY)) + if (config_item_set(config , RFT_CONFIG_KEY)) rft_config_file = config_iget(config , RFT_CONFIG_KEY , 0,0); enkf_main_set_rft_config_file( enkf_main , rft_config_file ); @@ -2974,7 +3018,7 @@ enkf_main_type * enkf_main_bootstrap(const char * _site_config, const char * _mo /* Adding ensemble members */ enkf_main_resize_ensemble( enkf_main , config_iget_as_int(config , NUM_REALIZATIONS_KEY , 0 , 0) ); - + /*****************************************************************/ /* Installing the local_config object. Observe that the @@ -2982,47 +3026,15 @@ enkf_main_type * enkf_main_bootstrap(const char * _site_config, const char * _mo if you have created a personal local config that will be loaded on top. */ - - if (model_config_has_history( enkf_main->model_config )) { - enkf_main->local_config = local_config_alloc( /*enkf_main->ensemble_config , enkf_main->enkf_obs , */ model_config_get_last_history_restart( enkf_main->model_config )); - - /* First create the default ALL_ACTIVE configuration. */ - { - char * all_active_config_file = util_alloc_tmp_file("/tmp" , "enkf_local_config" , true); - enkf_main_create_all_active_config( enkf_main , - all_active_config_file ); - - /* Install custom local_config - if present.*/ - { - int i; - for (i = 0; i < config_get_occurences( config , LOCAL_CONFIG_KEY); i++) { - const stringlist_type * files = config_iget_stringlist_ref(config , LOCAL_CONFIG_KEY , i); - for (int j=0; j < stringlist_get_size( files ); j++) - local_config_add_config_file( enkf_main->local_config , stringlist_iget( files , j) ); - } - } - - /** - This is where the local configuration files are actually parsed. - */ - local_config_reload( enkf_main->local_config , - ecl_config_get_grid( enkf_main->ecl_config ), - enkf_main->ensemble_config , - enkf_main->obs , - all_active_config_file ); - - unlink( all_active_config_file ); - free(all_active_config_file); - } - } else - if (config_get_occurences( config , LOCAL_CONFIG_KEY) > 0) - fprintf(stderr,"** Warning: Not possible to configure local analysis without SCHEDULE or REFCASE - %s keyword(s) ignored\n", LOCAL_CONFIG_KEY); + enkf_main_init_local_updates(enkf_main , config ); + } config_free(config); } enkf_main_init_jobname( enkf_main ); enkf_main_gen_data_special( enkf_main ); free( model_config ); + return enkf_main; } @@ -3469,8 +3481,31 @@ void enkf_main_fprintf_config( const enkf_main_type * enkf_main ) { enkf_main_log_fprintf_config( enkf_main , stream ); site_config_fprintf_config( enkf_main->site_config , stream ); rng_config_fprintf_config( enkf_main->rng_config , stream ); - ert_report_list_free( enkf_main->report_list ); fclose( stream ); } } + +/*****************************************************************/ + +ert_workflow_list_type * enkf_main_get_workflow_list( enkf_main_type * enkf_main ) { + return enkf_main->workflow_list; +} + + +bool enkf_main_run_workflow( enkf_main_type * enkf_main , const char * workflow) { + ert_workflow_list_type * workflow_list = enkf_main_get_workflow_list( enkf_main ); + if (ert_workflow_list_has_workflow( workflow_list , workflow)) + return ert_workflow_list_run_workflow( workflow_list , workflow , enkf_main ); + else + return false; +} + + +void enkf_main_run_workflows( enkf_main_type * enkf_main , const stringlist_type * workflows) { + int iw; + for (iw = 0; iw < stringlist_get_size( workflows ); iw++) + enkf_main_run_workflow( enkf_main , stringlist_iget( workflows , iw )); +} + + diff --git a/ThirdParty/Ert/devel/libenkf/src/enkf_main_jobs.c b/ThirdParty/Ert/devel/libenkf/src/enkf_main_jobs.c new file mode 100644 index 0000000000..608cef8583 --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/src/enkf_main_jobs.c @@ -0,0 +1,63 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'enkf_main_jobs.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + +#include + + +void enkf_main_exit_JOB(void * self , const stringlist_type * args ) { + enkf_main_type * enkf_main = enkf_main_safe_cast( self ); + enkf_main_exit( enkf_main ); +} + + + +void enkf_main_ensemble_run_JOB( void * self , const stringlist_type * args ) { + enkf_main_type * enkf_main = enkf_main_safe_cast( self ); + int ens_size = enkf_main_get_ensemble_size( enkf_main ); + bool_vector_type * iactive = bool_vector_alloc( 0 , true ); + + // Ignore args until string_utils is in place ..... + // if (stringlist_get_size( args ) + + bool_vector_iset( iactive , ens_size - 1 , true ); + enkf_main_run_exp( enkf_main , iactive , true , 0 , 0 , ANALYZED ); +} + + +void enkf_main_smoother_JOB( void * self , const stringlist_type * args ) { + enkf_main_type * enkf_main = enkf_main_safe_cast( self ); + int ens_size = enkf_main_get_ensemble_size( enkf_main ); + bool_vector_type * iactive = bool_vector_alloc( 0 , true ); + bool rerun = true; + const char * target_case = "AUTO-SMOOTHER"; + + bool_vector_iset( iactive , ens_size - 1 , true ); + enkf_main_run_smoother( enkf_main , target_case , rerun); +} + + + +void enkf_main_create_reports_JOB(void * self , const stringlist_type * args ) { + enkf_main_type * enkf_main = enkf_main_safe_cast( self ); + ert_report_list_type * report_list = enkf_main_get_report_list( enkf_main ); + + ert_report_list_create( report_list , enkf_main_get_current_fs( enkf_main ) , true ); +} + diff --git a/ThirdParty/Ert/devel/libenkf/src/enkf_obs.c b/ThirdParty/Ert/devel/libenkf/src/enkf_obs.c index 5f28267de3..f95cc2340a 100644 --- a/ThirdParty/Ert/devel/libenkf/src/enkf_obs.c +++ b/ThirdParty/Ert/devel/libenkf/src/enkf_obs.c @@ -185,7 +185,6 @@ struct enkf_obs_struct { bool have_obs; char * config_file; /* The name of the config file which has been loaded. */ hash_type * obs_hash; - double std_cutoff; /* (Dimensionfull) Std values below this limit are considered zero. */ time_t_vector_type * obs_time; /* For fast lookup of report_step -> obs_time */ const history_type * history; /* A shared (not owned by enkf_obs) reference to the history object - used when adding HISTORY observations. */ @@ -197,19 +196,20 @@ struct enkf_obs_struct { -enkf_obs_type * enkf_obs_alloc( const history_type * history , double std_cutoff ) +enkf_obs_type * enkf_obs_alloc( ) { enkf_obs_type * enkf_obs = util_malloc(sizeof * enkf_obs); enkf_obs->have_obs = false; enkf_obs->obs_hash = hash_alloc(); - enkf_obs->std_cutoff = std_cutoff; - enkf_obs->history = history; enkf_obs->obs_time = time_t_vector_alloc(0 , -1 ); + + enkf_obs->history = NULL; enkf_obs->config_file = NULL; return enkf_obs; } + bool enkf_obs_have_obs( const enkf_obs_type * enkf_obs ) { return enkf_obs->have_obs; } @@ -440,8 +440,13 @@ void enkf_obs_get_obs_and_measure(const enkf_obs_type * enkf_obs, -void enkf_obs_reload( enkf_obs_type * enkf_obs , const ecl_grid_type * grid , const ecl_sum_type * refcase , ensemble_config_type * ensemble_config ) { - enkf_obs_load( enkf_obs , enkf_obs->config_file , grid , refcase , ensemble_config ); +void enkf_obs_reload( enkf_obs_type * enkf_obs , + const history_type * history , + const ecl_grid_type * grid , + const ecl_sum_type * refcase , + double std_cutoff , + ensemble_config_type * ensemble_config ) { + enkf_obs_load( enkf_obs , history , enkf_obs->config_file , grid , refcase , std_cutoff , ensemble_config ); } @@ -456,11 +461,18 @@ void enkf_obs_reload( enkf_obs_type * enkf_obs , const ecl_grid_type * grid , co -void enkf_obs_load(enkf_obs_type * enkf_obs , const char * config_file, const ecl_grid_type * grid , const ecl_sum_type * refcase , ensemble_config_type * ensemble_config) { +void enkf_obs_load(enkf_obs_type * enkf_obs , + const history_type * history , + const char * config_file, + const ecl_grid_type * grid , + const ecl_sum_type * refcase , + double std_cutoff , ensemble_config_type * ensemble_config) { + if (config_file == NULL) { hash_clear( enkf_obs->obs_hash ); enkf_obs->have_obs = false; } else { + enkf_obs->history = history; if ( enkf_obs->history == NULL) { fprintf(stderr,"** ERROR: When loading obervations you must provide either REFCASE or a SCHEDULE file.\n"); fprintf(stderr,"** The observations in obs file:%s will be ignored \n",config_file); @@ -493,7 +505,7 @@ void enkf_obs_load(enkf_obs_type * enkf_obs , const char * config_file, const e if (config_node != NULL) { obs_vector = obs_vector_alloc( SUMMARY_OBS , obs_key , ensemble_config_get_node( ensemble_config , obs_key ) , enkf_obs->obs_time , last_report); if (obs_vector != NULL) { - if (obs_vector_load_from_HISTORY_OBSERVATION(obs_vector , hist_obs_conf , enkf_obs->history , ensemble_config , enkf_obs->std_cutoff )) + if (obs_vector_load_from_HISTORY_OBSERVATION(obs_vector , hist_obs_conf , enkf_obs->history , ensemble_config , std_cutoff )) enkf_obs_add_obs_vector(enkf_obs, obs_key, obs_vector); else { fprintf(stderr,"** Could not load historical data for observation:%s - ignored\n",obs_key); diff --git a/ThirdParty/Ert/devel/libenkf/src/enkf_state.c b/ThirdParty/Ert/devel/libenkf/src/enkf_state.c index 23cac00826..639524d057 100644 --- a/ThirdParty/Ert/devel/libenkf/src/enkf_state.c +++ b/ThirdParty/Ert/devel/libenkf/src/enkf_state.c @@ -279,14 +279,17 @@ static void shared_info_free(shared_info_type * shared_info) { /** Helper classes complete - starting on the enkf_state proper object. */ /*****************************************************************/ -void enkf_state_initialize(enkf_state_type * enkf_state , enkf_fs_type * fs , const stringlist_type * param_list) { +void enkf_state_initialize(enkf_state_type * enkf_state , enkf_fs_type * fs , const stringlist_type * param_list, bool force_init) { + state_enum init_state = ANALYZED; int ip; for (ip = 0; ip < stringlist_get_size(param_list); ip++) { int iens = enkf_state_get_iens( enkf_state ); enkf_node_type * param_node = enkf_state_get_node( enkf_state , stringlist_iget( param_list , ip)); - if (enkf_node_initialize( param_node , iens , enkf_state->rng)) { - node_id_type node_id = {.report_step = 0, .iens = iens , .state = ANALYZED }; - enkf_node_store( param_node , fs , true , node_id); + node_id_type node_id = {.report_step = 0, .iens = iens , .state = init_state }; + if (force_init || (enkf_node_has_data( param_node , fs , node_id) == false)) { + if (enkf_node_initialize( param_node , iens , enkf_state->rng)) + enkf_node_store( param_node , fs , true , node_id); + } } } @@ -359,7 +362,6 @@ void enkf_state_update_eclbase( enkf_state_type * enkf_state ) { enkf_state_add_subst_kw( enkf_state , "CASE" , eclbase , NULL); /* No CASE_TABLE loaded - using the eclbase as default. */ else enkf_state_add_subst_kw( enkf_state , "CASE" , casename , NULL); - } } @@ -498,7 +500,7 @@ enkf_state_type * enkf_state_alloc(int iens, done in a cascade like fashion). The user defined keywords are added first, so that these can refer to the built in keywords. */ - + enkf_state_add_subst_kw(enkf_state , "RUNPATH" , "---" , "The absolute path of the current forward model instance. "); enkf_state_add_subst_kw(enkf_state , "IENS" , "---" , "The realisation number for this realization."); enkf_state_add_subst_kw(enkf_state , "IENS4" , "---" , "The realization number for this realization - formated with %04d."); @@ -518,23 +520,16 @@ enkf_state_type * enkf_state_alloc(int iens, enkf_state_add_subst_kw(enkf_state , "CASE" , casename , "The casename for this realization - as loaded from the CASE_TABLE file."); else enkf_state_add_subst_kw(enkf_state , "CASE" , "---" , "The casename for this realization - similar to ECLBASE."); - + enkf_state->my_config = member_config_alloc( iens , casename , pre_clear_runpath , keep_runpath , ecl_config , ensemble_config , fs); enkf_state_set_static_subst_kw( enkf_state ); - enkf_state_add_nodes( enkf_state , ensemble_config ); - + return enkf_state; } -enkf_state_type * enkf_state_copyc(const enkf_state_type * src) { - util_abort("%s: not implemented \n",__func__); - return NULL; -} - - static bool enkf_state_has_node(const enkf_state_type * enkf_state , const char * node_key) { bool has_node = hash_has_key(enkf_state->node_hash , node_key); @@ -589,12 +584,17 @@ void enkf_state_update_node( enkf_state_type * enkf_state , const char * node_ke } +const char * enkf_state_get_eclbase( const enkf_state_type * enkf_state ) { + return member_config_get_eclbase( enkf_state->my_config ); +} + + static ecl_sum_type * enkf_state_load_ecl_sum(const enkf_state_type * enkf_state , stringlist_type * messages , bool * loadOK) { member_config_type * my_config = enkf_state->my_config; const run_info_type * run_info = enkf_state->run_info; const ecl_config_type * ecl_config = enkf_state->shared_info->ecl_config; const bool fmt_file = ecl_config_get_formatted(ecl_config); - const char * eclbase = member_config_get_eclbase( my_config ); + const char * eclbase = enkf_state_get_eclbase( enkf_state ); stringlist_type * data_files = stringlist_alloc_new(); @@ -739,7 +739,7 @@ static bool enkf_state_internalize_dynamic_eclipse_results(enkf_state_type * enk } { time_map_type * time_map = enkf_fs_get_time_map( fs ); - time_map_summary_update( time_map , summary ); + time_map_summary_update_strict( time_map , summary ); } ecl_sum_free( summary ); return true; @@ -1661,26 +1661,29 @@ static void enkf_state_start_forward_model(enkf_state_type * enkf_state , enkf_f const shared_info_type * shared_info = enkf_state->shared_info; const member_config_type * my_config = enkf_state->my_config; const site_config_type * site_config = shared_info->site_config; - arg_pack_type * load_arg = arg_pack_alloc(); - - /* - Prepare the job and submit it to the queue - */ enkf_state_init_eclipse( enkf_state , fs ); - arg_pack_append_ptr( load_arg , enkf_state ); - arg_pack_append_ptr( load_arg , fs ); - - run_info->queue_index = job_queue_add_job_mt( shared_info->job_queue , - site_config_get_job_script( site_config ), - enkf_state_complete_forward_modelOK__ , - enkf_state_complete_forward_modelEXIT__ , - load_arg , - ecl_config_get_num_cpu( shared_info->ecl_config ), - run_info->run_path , - member_config_get_jobname(my_config) , - 1, - (const char *[1]) { run_info->run_path } ); - run_info->num_internal_submit++; + + if (run_info->run_mode != INIT_ONLY) { + arg_pack_type * load_arg = arg_pack_alloc(); + + /* + Prepare the job and submit it to the queue + */ + arg_pack_append_ptr( load_arg , enkf_state ); + arg_pack_append_ptr( load_arg , fs ); + + run_info->queue_index = job_queue_add_job_mt( shared_info->job_queue , + site_config_get_job_script( site_config ), + enkf_state_complete_forward_modelOK__ , + enkf_state_complete_forward_modelEXIT__ , + load_arg , + ecl_config_get_num_cpu( shared_info->ecl_config ), + run_info->run_path , + member_config_get_jobname(my_config) , + 1, + (const char *[1]) { run_info->run_path } ); + run_info->num_internal_submit++; + } } } @@ -2034,15 +2037,11 @@ void enkf_state_init_run(enkf_state_type * state , -/*****************************************************************/ -/** - This function will return the true time (i.e. time_t instance) - cooresponding to the report_step 'report_step'. If no data has been - loaded for the input report_step -1 is returned, this must be - checked by the calling scope. -*/ +unsigned int enkf_state_get_random( enkf_state_type * enkf_state ) { + return rng_forward( enkf_state->rng ); +} diff --git a/ThirdParty/Ert/devel/libenkf/src/ensemble_config.c b/ThirdParty/Ert/devel/libenkf/src/ensemble_config.c index da935d4bec..d6567ba483 100644 --- a/ThirdParty/Ert/devel/libenkf/src/ensemble_config.c +++ b/ThirdParty/Ert/devel/libenkf/src/ensemble_config.c @@ -138,6 +138,7 @@ ensemble_config_type * ensemble_config_alloc_empty( ) { ensemble_config_type * ensemble_config = util_malloc(sizeof * ensemble_config ); ensemble_config->config_nodes = hash_alloc(); + ensemble_config->field_trans_table = field_trans_table_alloc(); ensemble_config->refcase = NULL; ensemble_config->gen_kw_format_string = util_alloc_string_copy( DEFAULT_GEN_KW_TAG_FORMAT ); pthread_mutex_init( &ensemble_config->mutex , NULL); @@ -147,6 +148,19 @@ ensemble_config_type * ensemble_config_alloc_empty( ) { +void ensemble_config_free(ensemble_config_type * ensemble_config) { + hash_free( ensemble_config->config_nodes ); + field_trans_table_free( ensemble_config->field_trans_table ); + free( ensemble_config->gen_kw_format_string ); + free( ensemble_config ); +} + + + + + + + ert_impl_type ensemble_config_impl_type(const ensemble_config_type *ensemble_config, const char * ecl_kw_name) { ert_impl_type impl_type = INVALID; @@ -176,16 +190,6 @@ enkf_var_type ensemble_config_var_type(const ensemble_config_type *ensemble_conf -void ensemble_config_free(ensemble_config_type * ensemble_config) { - hash_free( ensemble_config->config_nodes ); - field_trans_table_free( ensemble_config->field_trans_table ); - free( ensemble_config->gen_kw_format_string ); - free( ensemble_config ); -} - - - - bool ensemble_config_has_key(const ensemble_config_type * ensemble_config , const char * key) { @@ -284,6 +288,13 @@ void ensemble_config_clear_obs_keys(ensemble_config_type * ensemble_config) { +void ensemble_config_add_GEN_PARAM_config_item( config_type * config ) { + config_schema_item_type * item; + item = config_add_schema_item(config , GEN_PARAM_KEY , false ); + config_schema_item_set_argc_minmax(item , 5 , CONFIG_DEFAULT_ARG_MAX); +} + + void ensemble_config_add_config_items(config_type * config) { config_schema_item_type * item; @@ -292,174 +303,247 @@ void ensemble_config_add_config_items(config_type * config) { be able to print suitable messages before exiting. */ - item = config_add_schema_item(config , "HAVANA_FAULT" , false , true); - config_schema_item_set_argc_minmax(item , 2 , 2 , 0 , NULL ); + item = config_add_schema_item(config , "HAVANA_FAULT" , false ); + config_schema_item_set_argc_minmax(item , 2 , 2); - item = config_add_schema_item(config , "MULTFLT" , false , true); - config_schema_item_set_argc_minmax(item , 3 , 3 , 3 , (const config_item_types [3]) { CONFIG_STRING , CONFIG_STRING , CONFIG_EXISTING_FILE}); + item = config_add_schema_item(config , "MULTFLT" , false ); + config_schema_item_set_argc_minmax(item , 3 , 3 ); + config_schema_item_iset_type( item , 2 , CONFIG_EXISTING_PATH ); /*****************************************************************/ - item = config_add_schema_item(config , GEN_KW_KEY , false , true); - config_schema_item_set_argc_minmax(item , 4 , 6 , 6 , (const config_item_types [6]) { CONFIG_STRING , CONFIG_EXISTING_FILE , CONFIG_STRING , CONFIG_EXISTING_FILE , CONFIG_STRING , CONFIG_STRING}); + ensemble_config_add_GEN_PARAM_config_item( config ); + item = config_add_schema_item(config , GEN_KW_KEY , false ); + config_schema_item_set_argc_minmax(item , 4 , 6); + config_schema_item_iset_type( item , 1 , CONFIG_EXISTING_PATH ); + config_schema_item_iset_type( item , 3 , CONFIG_EXISTING_PATH ); + + + item = config_add_key_value( config , GEN_KW_TAG_FORMAT_KEY , false , CONFIG_STRING); - - item = config_add_schema_item(config , SCHEDULE_PREDICTION_FILE_KEY , false , false); + item = config_add_schema_item(config , SCHEDULE_PREDICTION_FILE_KEY , false ); /* scedhule_prediction_file filename */ - config_schema_item_set_argc_minmax(item , 1 , 3 , 3 , (const config_item_types [3]) { CONFIG_EXISTING_FILE , CONFIG_STRING , CONFIG_STRING}); - - item = config_add_schema_item(config , GEN_PARAM_KEY , false , true); - config_schema_item_set_argc_minmax(item , 5 , -1 , 0 , NULL); + config_schema_item_set_argc_minmax(item , 1 , 3 ); + config_schema_item_iset_type( item , 0 , CONFIG_EXISTING_PATH ); - item = config_add_schema_item(config , GEN_DATA_KEY , false , true); - config_schema_item_set_argc_minmax(item , 1 , -1 , 0 , NULL); - item = config_add_schema_item(config , SUMMARY_KEY , false , true); /* can have several summary keys on each line. */ - config_schema_item_set_argc_minmax(item , 1 , -1 , 0 , NULL); - item = config_add_schema_item(config , CONTAINER_KEY , false , true); /* can have several summary keys on each line. */ - config_schema_item_set_argc_minmax(item , 2 , -1 , 0 , NULL); - item = config_add_schema_item( config , SURFACE_KEY , false , true ); - config_schema_item_set_argc_minmax(item , 4 , 5 , 0 , NULL); + item = config_add_schema_item(config , GEN_DATA_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , CONFIG_DEFAULT_ARG_MAX); + + item = config_add_schema_item(config , SUMMARY_KEY , false ); /* can have several summary keys on each line. */ + config_schema_item_set_argc_minmax(item , 1 , CONFIG_DEFAULT_ARG_MAX); + + item = config_add_schema_item(config , CONTAINER_KEY , false ); /* can have several summary keys on each line. */ + config_schema_item_set_argc_minmax(item , 2 , CONFIG_DEFAULT_ARG_MAX); + + item = config_add_schema_item( config , SURFACE_KEY , false ); + config_schema_item_set_argc_minmax(item , 4 , 5 ); /* the way config info is entered for fields is unfortunate because it is difficult/impossible to let the config system handle run time validation of the input. */ - item = config_add_schema_item(config , FIELD_KEY , false , true); - config_schema_item_set_argc_minmax(item , 2 , -1 , 0 , NULL); + item = config_add_schema_item(config , FIELD_KEY , false ); + config_schema_item_set_argc_minmax(item , 2 , CONFIG_DEFAULT_ARG_MAX); config_schema_item_add_required_children(item , GRID_KEY); /* if you are using a field - you must have a grid. */ } -/** - observe that if the user has not given a refcase with the refcase - key the refcase pointer will be NULL. in that case it will be - impossible to use wildcards when expanding summary variables. -*/ - -void ensemble_config_init(ensemble_config_type * ensemble_config , const config_type * config , ecl_grid_type * grid, const ecl_sum_type * refcase) { - int i; - ensemble_config->field_trans_table = field_trans_table_alloc(); - ensemble_config_set_refcase( ensemble_config , refcase ); - - if (config_item_set( config , GEN_KW_TAG_FORMAT_KEY)) - ensemble_config_set_gen_kw_format( ensemble_config , config_iget( config , GEN_KW_TAG_FORMAT_KEY , 0 , 0 )); - - /* gen_param - should be unified with the gen_data*/ - for (i=0; i < config_get_occurences(config , GEN_PARAM_KEY); i++) { - stringlist_type * tokens = config_iget_stringlist_ref(config , GEN_PARAM_KEY , i); - const char * key = stringlist_iget(tokens , 0); - const char * ecl_file = stringlist_iget(tokens , 1); /* only difference from gen_data is that the ecl_file is not a ":" keyword. */ - enkf_config_node_type * config_node = ensemble_config_add_gen_data( ensemble_config , key ); - { - hash_type * options = hash_alloc_from_options( tokens ); - gen_data_file_format_type input_format = gen_data_config_check_format( hash_safe_get( options , INPUT_FORMAT_KEY)); - gen_data_file_format_type output_format = gen_data_config_check_format( hash_safe_get( options , OUTPUT_FORMAT_KEY)); - const char * init_file_fmt = hash_safe_get( options , INIT_FILES_KEY); - const char * template = hash_safe_get( options , TEMPLATE_KEY); - const char * key = hash_safe_get( options , KEY_KEY); - const char * result_file = hash_safe_get( options , RESULT_FILE_KEY); - const char * min_std_file = hash_safe_get( options , MIN_STD_KEY); - - enkf_config_node_update_gen_data( config_node , input_format , output_format , init_file_fmt , template , key , ecl_file , result_file , min_std_file); +void ensemble_config_init_GEN_DATA( ensemble_config_type * ensemble_config , const config_type * config ) { +/* gen_param - should be unified with the gen_data*/ + const config_content_item_type * item = config_get_content_item( config , GEN_DATA_KEY ); + if (item != NULL) { + int i; + for (i=0; i < config_content_item_get_size(item); i++) { + const config_content_node_type * node = config_content_item_iget_node( item , i ); + const char * key = config_content_node_iget( node , 0 ); + enkf_config_node_type * config_node = ensemble_config_add_gen_data( ensemble_config , key ); { - const gen_data_config_type * gen_data_config = enkf_config_node_get_ref( config_node ); - if (!gen_data_config_is_valid( gen_data_config )) - util_abort("%s: sorry the gen_param key:%s is not valid \n",__func__ , key); - } - hash_free( options ); - } - } - - /* gen_data */ - for (i=0; i < config_get_occurences(config , GEN_DATA_KEY); i++) { - stringlist_type * tokens = config_iget_stringlist_ref(config , GEN_DATA_KEY , i); - const char * key = stringlist_iget(tokens , 0); - enkf_config_node_type * config_node = ensemble_config_add_gen_data( ensemble_config , key ); - { - hash_type * options = hash_alloc_from_options( tokens ); - gen_data_file_format_type input_format = gen_data_config_check_format( hash_safe_get( options , INPUT_FORMAT_KEY)); - gen_data_file_format_type output_format = gen_data_config_check_format( hash_safe_get( options , OUTPUT_FORMAT_KEY)); - const char * init_file_fmt = hash_safe_get( options , INIT_FILES_KEY); - const char * template = hash_safe_get( options , TEMPLATE_KEY); - const char * key = hash_safe_get( options , KEY_KEY); - const char * ecl_file = hash_safe_get( options , ECL_FILE_KEY); - const char * result_file = hash_safe_get( options , RESULT_FILE_KEY); - const char * min_std_file = hash_safe_get( options , MIN_STD_KEY); - - enkf_config_node_update_gen_data( config_node , - input_format , - output_format , - init_file_fmt , - template , - key , - ecl_file , - result_file , - min_std_file); - { - const gen_data_config_type * gen_data_config = enkf_config_node_get_ref( config_node ); - if (!gen_data_config_is_valid( gen_data_config )) - util_abort("%s: sorry the gen_data key:%s is not valid \n",__func__ , key); - } - hash_free( options ); - } - } - - - /* surface */ - { - for (i=0; i < config_get_occurences( config , SURFACE_KEY ); i++) { - stringlist_type * tokens = config_iget_stringlist_ref(config , SURFACE_KEY , i); - const char * key = stringlist_iget(tokens , 0); - { - hash_type * options = hash_alloc_from_options( tokens ); /* INIT_FILE: OUTPUT_FILE: BASE_SURFACE: */ - - const char * init_file_fmt = hash_safe_get( options , INIT_FILES_KEY ); - const char * output_file = hash_safe_get( options , OUTPUT_FILE_KEY); - const char * base_surface = hash_safe_get( options , BASE_SURFACE_KEY); - const char * min_std_file = hash_safe_get( options , MIN_STD_KEY); - - if ((init_file_fmt == NULL) || (output_file == NULL) || (base_surface == NULL)) { - fprintf(stderr,"** error: when entering a surface you must provide arguments:\n"); - fprintf(stderr,"** %s:/path/to/input/files%%d \n",INIT_FILES_KEY); - fprintf(stderr,"** %s:name_of_output_file\n", OUTPUT_FILE_KEY); - fprintf(stderr,"** %s:base_surface_file\n",base_surface); - exit(1); - } - - { - enkf_config_node_type * config_node = ensemble_config_add_surface( ensemble_config , key ); - enkf_config_node_update_surface( config_node , base_surface , init_file_fmt , output_file , min_std_file ); - } + hash_type * options = hash_alloc(); + config_content_node_init_opt_hash( node , options , 1 ); + { + gen_data_file_format_type input_format = gen_data_config_check_format( hash_safe_get( options , INPUT_FORMAT_KEY)); + gen_data_file_format_type output_format = gen_data_config_check_format( hash_safe_get( options , OUTPUT_FORMAT_KEY)); + const char * init_file_fmt = hash_safe_get( options , INIT_FILES_KEY); + const char * ecl_file = hash_safe_get( options , ECL_FILE_KEY); + const char * template = hash_safe_get( options , TEMPLATE_KEY); + const char * key = hash_safe_get( options , KEY_KEY); + const char * result_file = hash_safe_get( options , RESULT_FILE_KEY); + const char * min_std_file = hash_safe_get( options , MIN_STD_KEY); + + enkf_config_node_update_gen_data( config_node , input_format , output_format , init_file_fmt , template , key , ecl_file , result_file , min_std_file); + { + const gen_data_config_type * gen_data_config = enkf_config_node_get_ref( config_node ); + if (!gen_data_config_is_valid( gen_data_config )) + util_abort("%s: sorry the gen_param key:%s is not valid \n",__func__ , key); + } + } hash_free( options ); } } } +} + + +void ensemble_config_init_GEN_PARAM( ensemble_config_type * ensemble_config , const config_type * config ) { + /* gen_param - should be unified with the gen_data*/ + const config_content_item_type * item = config_get_content_item( config , GEN_PARAM_KEY ); + if (item != NULL) { + int i; + for (i=0; i < config_content_item_get_size(item); i++) { + const config_content_node_type * node = config_content_item_iget_node( item , i ); + const char * key = config_content_node_iget( node , 0 ); + const char * ecl_file = config_content_node_iget( node , 1 ); + enkf_config_node_type * config_node = ensemble_config_add_gen_data( ensemble_config , key ); + { + hash_type * options = hash_alloc(); + + config_content_node_init_opt_hash( node , options , 2 ); + { + gen_data_file_format_type input_format = gen_data_config_check_format( hash_safe_get( options , INPUT_FORMAT_KEY)); + gen_data_file_format_type output_format = gen_data_config_check_format( hash_safe_get( options , OUTPUT_FORMAT_KEY)); + const char * init_file_fmt = hash_safe_get( options , INIT_FILES_KEY); + const char * template = hash_safe_get( options , TEMPLATE_KEY); + const char * key = hash_safe_get( options , KEY_KEY); + const char * result_file = hash_safe_get( options , RESULT_FILE_KEY); + const char * min_std_file = hash_safe_get( options , MIN_STD_KEY); + + enkf_config_node_update_gen_data( config_node , input_format , output_format , init_file_fmt , template , key , ecl_file , result_file , min_std_file); + { + const gen_data_config_type * gen_data_config = enkf_config_node_get_ref( config_node ); + if (!gen_data_config_is_valid( gen_data_config )) + util_abort("%s: sorry the gen_param key:%s is not valid \n",__func__ , key); + } + } + hash_free( options ); + } + } + } +} + + +void ensemble_config_init_GEN_KW( ensemble_config_type * ensemble_config , const config_type * config ) { + const config_content_item_type * gen_kw_item = config_get_content_item( config , GEN_KW_KEY ); + if (gen_kw_item != NULL) { + int i; + for (i=0; i < config_content_item_get_size( gen_kw_item ); i++) { + config_content_node_type * node = config_content_item_iget_node( gen_kw_item , i ); + + const char * key = config_content_node_iget( node , 0 ); + const char * template_file = config_content_node_iget_as_path( node , 1 ); + const char * enkf_outfile = config_content_node_iget( node , 2 ); + const char * parameter_file = config_content_node_iget_as_path( node , 3 ); + + { + hash_type * opt_hash = hash_alloc(); + enkf_config_node_type * config_node = ensemble_config_add_gen_kw( ensemble_config , key ); + config_content_node_init_opt_hash( node , opt_hash , 4 ); + enkf_config_node_update_gen_kw( config_node , + enkf_outfile , + template_file , + parameter_file , + hash_safe_get( opt_hash , MIN_STD_KEY ) , + hash_safe_get( opt_hash , INIT_FILES_KEY)); + hash_free( opt_hash ); + } + } + } +} +void ensemble_config_init_SURFACE( ensemble_config_type * ensemble_config , const config_type * config ) { + const config_content_item_type * item = config_get_content_item( config , SURFACE_KEY ); + if (item != NULL) { + int i; + for (i=0; i < config_content_item_get_size( item ); i++) { + const config_content_node_type * node = config_content_item_iget_node( item , i ); + const char * key = config_content_node_iget( node , 0 ); + { + hash_type * options = hash_alloc(); /* INIT_FILE: OUTPUT_FILE: BASE_SURFACE: */ + + config_content_node_init_opt_hash( node , options , 1 ); + { + const char * init_file_fmt = hash_safe_get( options , INIT_FILES_KEY ); + const char * output_file = hash_safe_get( options , OUTPUT_FILE_KEY); + const char * base_surface = hash_safe_get( options , BASE_SURFACE_KEY); + const char * min_std_file = hash_safe_get( options , MIN_STD_KEY); + + if ((init_file_fmt == NULL) || (output_file == NULL) || (base_surface == NULL)) { + fprintf(stderr,"** error: when entering a surface you must provide arguments:\n"); + fprintf(stderr,"** %s:/path/to/input/files%%d \n",INIT_FILES_KEY); + fprintf(stderr,"** %s:name_of_output_file\n", OUTPUT_FILE_KEY); + fprintf(stderr,"** %s:base_surface_file\n",base_surface); + exit(1); + } + + { + enkf_config_node_type * config_node = ensemble_config_add_surface( ensemble_config , key ); + enkf_config_node_update_surface( config_node , base_surface , init_file_fmt , output_file , min_std_file ); + } + } + hash_free( options ); + } + } + } +} - /* field */ - { - for (i=0; i < config_get_occurences(config , FIELD_KEY); i++) { - stringlist_type * tokens = config_iget_stringlist_ref(config , FIELD_KEY , i); - const char * key = stringlist_iget(tokens , 0); - const char * var_type_string = stringlist_iget(tokens , 1); - enkf_config_node_type * config_node = ensemble_config_add_field( ensemble_config , key , grid ); + +void ensemble_config_init_SUMMARY( ensemble_config_type * ensemble_config , const config_type * config , const ecl_sum_type * refcase) { + const config_content_item_type * item = config_get_content_item( config , SUMMARY_KEY ); + + if (item != NULL) { + int i; + for (i=0; i < config_content_item_get_size( item ); i++) { + const config_content_node_type * node = config_content_item_iget_node( item , i ); + int j; + for (j= 0; j < config_content_node_get_size( node ); j++) { + const char * key = config_content_node_iget( node , j ); + + if (util_string_has_wildcard( key )) { + if (ensemble_config->refcase != NULL) { + int k; + stringlist_type * keys = stringlist_alloc_new ( ); + + ecl_sum_select_matching_general_var_list( ensemble_config->refcase , key , keys ); /* expanding the wildcard notatition with help of the refcase. */ + for (k=0; k < stringlist_get_size( keys ); k++) + ensemble_config_add_summary(ensemble_config , stringlist_iget(keys , k) , LOAD_FAIL_SILENT ); + + stringlist_free( keys ); + } else + util_exit("error: when using summary wildcards like: \"%s\" you must supply a valid refcase.\n",key); + } else + ensemble_config_add_summary(ensemble_config , key , LOAD_FAIL_SILENT); + } + } + } +} + + +void ensemble_config_init_FIELD( ensemble_config_type * ensemble_config , const config_type * config , ecl_grid_type * grid) { + const config_content_item_type * item = config_get_content_item( config , FIELD_KEY ); + if (item != NULL) { + int i; + for (i=0; i < config_content_item_get_size( item ); i++) { + const config_content_node_type * node = config_content_item_iget_node( item , i ); + const char * key = config_content_node_iget( node , 0 ); + const char * var_type_string = config_content_node_iget( node , 1 ); + enkf_config_node_type * config_node = ensemble_config_add_field( ensemble_config , key , grid ); { - hash_type * options = hash_alloc_from_options( tokens ); + hash_type * options = hash_alloc(); int truncation = TRUNCATE_NONE; double value_min = -1; double value_max = -1; + config_content_node_init_opt_hash( node , options , 2 ); if (hash_has_key( options , MIN_KEY)) { truncation |= TRUNCATE_MIN; value_min = atof(hash_get( options , MIN_KEY)); @@ -474,12 +558,12 @@ void ensemble_config_init(ensemble_config_type * ensemble_config , const config_ if (strcmp(var_type_string , DYNAMIC_KEY) == 0) enkf_config_node_update_state_field( config_node , truncation , value_min , value_max ); else if (strcmp(var_type_string , PARAMETER_KEY) == 0) { - const char * ecl_file = stringlist_iget(tokens , 2); + const char * ecl_file = config_content_node_iget( node , 2 ); const char * init_file_fmt = hash_safe_get( options , INIT_FILES_KEY ); const char * init_transform = hash_safe_get( options , INIT_TRANSFORM_KEY ); const char * output_transform = hash_safe_get( options , OUTPUT_TRANSFORM_KEY ); const char * min_std_file = hash_safe_get( options , MIN_STD_KEY ); - + enkf_config_node_update_parameter_field( config_node, ecl_file , init_file_fmt , @@ -490,8 +574,8 @@ void ensemble_config_init(ensemble_config_type * ensemble_config , const config_ init_transform , output_transform ); } else if (strcmp(var_type_string , GENERAL_KEY) == 0) { - const char * ecl_file = stringlist_iget(tokens , 2); - const char * enkf_infile = stringlist_iget(tokens , 3); + const char * ecl_file = config_content_node_iget( node , 2 ); + const char * enkf_infile = config_content_node_iget( node , 3 ); const char * init_file_fmt = hash_safe_get( options , INIT_FILES_KEY ); const char * init_transform = hash_safe_get( options , INIT_TRANSFORM_KEY ); const char * output_transform = hash_safe_get( options , OUTPUT_TRANSFORM_KEY ); @@ -517,63 +601,31 @@ void ensemble_config_init(ensemble_config_type * ensemble_config , const config_ } } } +} - /* gen_kw */ - for (i=0; i < config_get_occurences(config , GEN_KW_KEY); i++) { - stringlist_type * tokens = config_iget_stringlist_ref(config , GEN_KW_KEY , i); - char * key = stringlist_iget_copy(tokens , 0); - char * template_file = stringlist_iget_copy(tokens , 1); - char * enkf_outfile = stringlist_iget_copy(tokens , 2); - char * parameter_file = stringlist_iget_copy(tokens , 3); - stringlist_idel( tokens , 0); - stringlist_idel( tokens , 0); - stringlist_idel( tokens , 0); - stringlist_idel( tokens , 0); - { - hash_type * opt_hash = hash_alloc_from_options( tokens ); - enkf_config_node_type * config_node = ensemble_config_add_gen_kw( ensemble_config , key ); - enkf_config_node_update_gen_kw( config_node , - enkf_outfile , - template_file , - parameter_file , - hash_safe_get( opt_hash , MIN_STD_KEY ) , - hash_safe_get( opt_hash , INIT_FILES_KEY)); - hash_free( opt_hash ); - } + +/** + observe that if the user has not given a refcase with the refcase + key the refcase pointer will be NULL. in that case it will be + impossible to use wildcards when expanding summary variables. +*/ + +void ensemble_config_init(ensemble_config_type * ensemble_config , const config_type * config , ecl_grid_type * grid, const ecl_sum_type * refcase) { + int i; + ensemble_config_set_refcase( ensemble_config , refcase ); + + if (config_item_set( config , GEN_KW_TAG_FORMAT_KEY)) + ensemble_config_set_gen_kw_format( ensemble_config , config_iget( config , GEN_KW_TAG_FORMAT_KEY , 0 , 0 )); + + ensemble_config_init_GEN_PARAM( ensemble_config , config ); + ensemble_config_init_GEN_DATA( ensemble_config , config ); + ensemble_config_init_GEN_KW(ensemble_config , config ); + ensemble_config_init_SURFACE( ensemble_config , config ); + ensemble_config_init_SUMMARY( ensemble_config , config , refcase ); + ensemble_config_init_FIELD( ensemble_config , config , grid ); + - free(key); - free(template_file); - free(enkf_outfile); - free(parameter_file); - } - - - /* summary */ - { - stringlist_type * keys = stringlist_alloc_new ( ); - - for (i=0; i < config_get_occurences(config , SUMMARY_KEY ); i++) { - int j,k; - const stringlist_type * summary_kw_list = config_iget_stringlist_ref(config , SUMMARY_KEY , i); - for (j= 0; j < stringlist_get_size( summary_kw_list ); j++) { - const char * key = stringlist_iget( summary_kw_list , j); - - if (util_string_has_wildcard( key )) { - if (ensemble_config->refcase != NULL) { - ecl_sum_select_matching_general_var_list( ensemble_config->refcase , key , keys ); /* expanding the wildcard notatition with help of the refcase. */ - for (k=0; k < stringlist_get_size( keys ); k++) - ensemble_config_add_summary(ensemble_config , stringlist_iget(keys , k) , LOAD_FAIL_SILENT ); - } else - util_exit("error: when using summary wildcards like: \"%s\" you must supply a valid refcase.\n",key); - } else - ensemble_config_add_summary(ensemble_config , key , LOAD_FAIL_SILENT); - } - } - - stringlist_free( keys ); - } - /* Containers - this must come last, to ensure that the other nodes have been added. */ { for (i=0; i < config_get_occurences(config , CONTAINER_KEY ); i++) { @@ -793,7 +845,7 @@ enkf_config_node_type * ensemble_config_add_surface( ensemble_config_type * ense If key == NULL the function will create a random key. */ enkf_config_node_type * ensemble_config_add_container( ensemble_config_type * ensemble_config , const char * key) { - char * local_key = key; + char * local_key = (char *) key; bool random_key = false; if (key == NULL) { local_key = util_calloc( 11 , sizeof * local_key ); diff --git a/ThirdParty/Ert/devel/libenkf/src/ert_report.c b/ThirdParty/Ert/devel/libenkf/src/ert_report.c index 211d8a7ce6..92dba7eee6 100644 --- a/ThirdParty/Ert/devel/libenkf/src/ert_report.c +++ b/ThirdParty/Ert/devel/libenkf/src/ert_report.c @@ -41,7 +41,6 @@ */ #define LATEX_PATH_FMT "/tmp/latex-XXXXXX" #define ERT_REPORT_TYPE_ID 919191653 -#define LATEX_TIMEOUT 20 /* @@ -75,7 +74,6 @@ struct ert_report_struct { UTIL_TYPE_ID_DECLARATION; template_type * template; - int latex_timeout; char * latex_basename; char * input_path; bool with_xref; @@ -96,6 +94,7 @@ static void ert_report_set_work_path( ert_report_type * report ) { ert_report_type * ert_report_alloc( const char * source_file , const char * target_file ) { ert_report_type * report = util_malloc( sizeof * report ); + UTIL_TYPE_ID_INIT(report , ERT_REPORT_TYPE_ID); report->template = template_alloc( source_file , false , NULL ); { @@ -118,7 +117,6 @@ ert_report_type * ert_report_alloc( const char * source_file , const char * targ report->ignore_errors = true; report->target_file = NULL; report->work_path = NULL; - report->latex_timeout = LATEX_TIMEOUT; ert_report_set_work_path( report ); return report; } @@ -135,7 +133,8 @@ static void ert_report_clear( ert_report_type * ert_report , bool mkdir_work_pat -bool ert_report_create( ert_report_type * ert_report , const subst_list_type * context , const char * plot_path , const char * target_path ) { + +bool ert_report_create( ert_report_type * ert_report , int latex_timeout , const subst_list_type * context , const char * plot_path , const char * target_path ) { bool success; { char * latex_file = util_alloc_filename( ert_report->work_path , ert_report->latex_basename , LATEX_EXTENSION ); @@ -144,11 +143,11 @@ bool ert_report_create( ert_report_type * ert_report , const subst_list_type * c latex_type * latex = latex_alloc( latex_file , true ); char * target_file = util_alloc_filename( target_path , ert_report->latex_basename , "pdf"); - latex_set_timeout( latex , ert_report->latex_timeout ); + latex_set_timeout( latex , latex_timeout ); latex_link_directory_content( latex , ert_report->input_path ); latex_link_directory_content( latex , plot_path ); latex_set_target_file( latex , target_file ); - success = latex_compile( latex , ert_report->ignore_errors , ert_report->with_xref); + success = latex_compile( latex , ert_report->ignore_errors , ert_report->with_xref , true); if (success) ert_report->target_file = util_realloc_string_copy( ert_report->target_file , latex_get_target_file( latex )); diff --git a/ThirdParty/Ert/devel/libenkf/src/ert_report_list.c b/ThirdParty/Ert/devel/libenkf/src/ert_report_list.c index 98aa060da4..cb38a1502b 100644 --- a/ThirdParty/Ert/devel/libenkf/src/ert_report_list.c +++ b/ThirdParty/Ert/devel/libenkf/src/ert_report_list.c @@ -33,6 +33,7 @@ #include #include #include +#include #define WELL_LIST_TAG "$WELL_LIST" #define GROUP_LIST_TAG "$GROUP_LIST" @@ -42,6 +43,7 @@ + struct ert_report_list_struct { stringlist_type * path_list; vector_type * report_list; @@ -50,10 +52,36 @@ struct ert_report_list_struct { stringlist_type * well_list; stringlist_type * group_list; subst_list_type * global_context; + int latex_timeout; + bool init_large_report; }; +void ert_report_list_set_latex_timeout( ert_report_list_type * report_list , int timeout) { + report_list->latex_timeout = timeout; +} +int ert_report_list_get_latex_timeout( const ert_report_list_type * report_list ) { + return report_list->latex_timeout; +} + +static void ert_report_list_init_large_report( ert_report_list_type * report_list ) { + if (report_list->init_large_report) { + printf("Running script \'fmtutil --all\' to regenerate pdflatex config information ..... "); + fflush(stdout); + util_fork_exec("fmtutil" , 1 , (const char *[1]) {"--all"} , true , NULL , NULL , NULL , "/dev/null" , "/dev/null"); + printf("\n"); + } + report_list->init_large_report = false; +} + +bool ert_report_list_get_init_large_report( const ert_report_list_type * report_list ) { + return report_list->init_large_report; +} + +void ert_report_list_set_large_report(ert_report_list_type * report_list , bool init_large_report) { + report_list->init_large_report = init_large_report; +} ert_report_list_type * ert_report_list_alloc(const char * target_path, const char * plot_path ) { @@ -62,12 +90,14 @@ ert_report_list_type * ert_report_list_alloc(const char * target_path, const cha report_list->report_list = vector_alloc_new( ); report_list->target_path = NULL; report_list->plot_path = NULL; + report_list->init_large_report = DEFAULT_REPORT_LARGE; report_list->well_list = stringlist_alloc_new(); report_list->group_list = stringlist_alloc_new(); report_list->global_context = subst_list_alloc( NULL ); ert_report_list_set_plot_path( report_list , plot_path ); ert_report_list_set_target_path( report_list , target_path ); + ert_report_list_set_latex_timeout( report_list , DEFAULT_REPORT_TIMEOUT); return report_list; } @@ -189,7 +219,7 @@ char * alloc_list(const stringlist_type * list) { /*****************************************************************/ -void ert_report_list_create( const ert_report_list_type * report_list , const char * current_case , bool verbose ) { +void ert_report_list_create( ert_report_list_type * report_list , const char * current_case , bool verbose ) { if (vector_get_size( report_list->report_list ) > 0) { subst_list_type * context = subst_list_alloc( report_list->global_context ); char * target_path = util_alloc_filename( report_list->target_path , current_case , NULL ); @@ -199,6 +229,7 @@ void ert_report_list_create( const ert_report_list_type * report_list , const ch subst_list_append_owned_ref( context , WELL_LIST_TAG , alloc_list( report_list->well_list ), "The list of wells for plotting"); subst_list_append_owned_ref( context , GROUP_LIST_TAG , alloc_list( report_list->group_list ), "The list of groups for plotting"); + ert_report_list_init_large_report( report_list ); for (int ir = 0; ir < vector_get_size( report_list->report_list ); ir++) { ert_report_type * ert_report = vector_iget( report_list->report_list , ir); @@ -207,7 +238,7 @@ void ert_report_list_create( const ert_report_list_type * report_list , const ch fflush( stdout ); } { - bool success = ert_report_create( vector_iget( report_list->report_list , ir ) , context , report_list->plot_path , target_path ); + bool success = ert_report_create( vector_iget( report_list->report_list , ir ) , report_list->latex_timeout , context , report_list->plot_path , target_path ); if (success) printf("OK??\n"); else @@ -227,11 +258,17 @@ void ert_report_list_site_init( ert_report_list_type * report_list , config_type for (int j=0; j < stringlist_get_size( path_list ); j++) ert_report_list_add_path( report_list , stringlist_iget( path_list , j )); } - } + void ert_report_list_init( ert_report_list_type * report_list , config_type * config , const ecl_sum_type * refcase) { ert_report_list_site_init( report_list , config ); + + if (config_item_set( config , REPORT_LARGE_KEY)) + ert_report_list_set_large_report(report_list , config_get_value_as_bool( config , REPORT_LARGE_KEY )); + + if (config_item_set( config , REPORT_TIMEOUT_KEY)) + ert_report_list_set_latex_timeout( report_list , config_get_value_as_int( config , REPORT_TIMEOUT_KEY )); /* Installing the list of reports. */ for (int i=0; i < config_get_occurences( config , REPORT_LIST_KEY ); i++) { @@ -264,10 +301,37 @@ void ert_report_list_init( ert_report_list_type * report_list , config_type * co } /* Installing the target path for reports*/ - if (config_has_set_item(config , REPORT_PATH_KEY)) + if (config_item_set(config , REPORT_PATH_KEY)) ert_report_list_set_target_path( report_list , config_iget( config , REPORT_PATH_KEY , 0 , 0)); ert_report_list_add_global_context( report_list , CONFIG_FILE_TAG , config_get_config_file( config , true )); ert_report_list_add_global_context( report_list , USER_TAG , getenv("USER")); - +} + + +void ert_report_list_add_config_items( config_type * config ) { + config_schema_item_type * item; + + item = config_add_schema_item(config , REPORT_LIST_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , CONFIG_DEFAULT_ARG_MAX); + + item = config_add_schema_item(config , REPORT_CONTEXT_KEY , false ); + config_schema_item_set_argc_minmax(item , 2 , 2); + + item = config_add_schema_item(config , REPORT_PATH_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1); + + item = config_add_schema_item( config , REPORT_WELL_LIST_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , CONFIG_DEFAULT_ARG_MAX); + + item = config_add_schema_item( config , REPORT_GROUP_LIST_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , CONFIG_DEFAULT_ARG_MAX); + + item = config_add_schema_item( config , REPORT_TIMEOUT_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1 ); + config_schema_item_iset_type( item , 0 , CONFIG_INT); + + item = config_add_schema_item( config , REPORT_LARGE_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1 ); + config_schema_item_iset_type( item , 0 , CONFIG_BOOL); } diff --git a/ThirdParty/Ert/devel/libenkf/src/ert_template.c b/ThirdParty/Ert/devel/libenkf/src/ert_template.c index 196ca905c2..db02b383c4 100644 --- a/ThirdParty/Ert/devel/libenkf/src/ert_template.c +++ b/ThirdParty/Ert/devel/libenkf/src/ert_template.c @@ -211,6 +211,33 @@ stringlist_type * ert_templates_alloc_list( ert_templates_type * ert_templates) } +void ert_templates_init( ert_templates_type * templates , const config_type * config ) { + const config_content_item_type * template_item = config_get_content_item( config , RUN_TEMPLATE_KEY ); + if (template_item != NULL) { + for (int i=0; i < config_content_item_get_size( template_item ); i++) { + config_content_node_type * template_node = config_content_item_iget_node( template_item , i ); + const char * template_file = config_content_node_iget_as_path(template_node , 0 ); + const char * target_file = config_content_node_iget( template_node , 1 ); + + ert_template_type * template = ert_templates_add_template( templates , NULL , template_file , target_file , NULL); + + for (int iarg = 2; iarg < config_content_node_get_size( template_node ); iarg++) { + char * key , *value; + const char * key_value = config_content_node_iget( template_node , iarg ); + util_binary_split_string( key_value , "=:" , true , &key , &value); + + if (value != NULL) + ert_template_add_arg( template ,key , value ); + else + fprintf(stderr,"** Warning - failed to parse argument:%s as key:value - ignored \n",config_iget( config , "RUN_TEMPLATE" , i , iarg )); + + free( key ); + util_safe_free( value ); + } + } + } +} + void ert_templates_fprintf_config( const ert_templates_type * ert_templates , FILE * stream ) { if (hash_get_size( ert_templates->templates ) > 0 ) { diff --git a/ThirdParty/Ert/devel/libenkf/src/ert_workflow_list.c b/ThirdParty/Ert/devel/libenkf/src/ert_workflow_list.c new file mode 100644 index 0000000000..5bebfbca43 --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/src/ert_workflow_list.c @@ -0,0 +1,239 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'ert_workflow_list.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + +#include +#include +#include + + +struct ert_workflow_list_struct { + stringlist_type * path_list; + hash_type * workflows; + workflow_joblist_type * joblist; + const subst_list_type * context; + const config_error_type * last_error; + bool verbose; +}; + + + +ert_workflow_list_type * ert_workflow_list_alloc(const subst_list_type * context) { + ert_workflow_list_type * workflow_list = util_malloc( sizeof * workflow_list ); + workflow_list->path_list = stringlist_alloc_new(); + workflow_list->workflows = hash_alloc(); + workflow_list->joblist = workflow_joblist_alloc(); + workflow_list->context = context; + workflow_list->last_error = NULL; + ert_workflow_list_set_verbose( workflow_list , DEFAULT_WORKFLOW_VERBOSE ); + return workflow_list; +} + + +void ert_workflow_list_set_verbose( ert_workflow_list_type * workflow_list , bool verbose) { + workflow_list->verbose = verbose; +} + + +void ert_workflow_list_free( ert_workflow_list_type * workflow_list ) { + hash_free( workflow_list->workflows ); + stringlist_free( workflow_list->path_list ); + workflow_joblist_free( workflow_list->joblist ); + free( workflow_list ); +} + + + +workflow_type * ert_workflow_list_add_workflow( ert_workflow_list_type * workflow_list , const char * workflow_file , const char * workflow_name) { + if (util_file_exists( workflow_file )) { + workflow_type * workflow = workflow_alloc( workflow_file , workflow_list->joblist ); + if (workflow_name != NULL) + hash_insert_hash_owned_ref( workflow_list->workflows , workflow_name , workflow , workflow_free__); + else { + char * name; + util_alloc_file_components( workflow_file , NULL , &name , NULL ); + hash_insert_hash_owned_ref( workflow_list->workflows , name , workflow , workflow_free__); + free( name ); + } + return workflow; + } else + return NULL; +} + + + +void ert_workflow_list_add_alias( ert_workflow_list_type * workflow_list , const char * real_name , const char * alias) { + workflow_type * workflow = ert_workflow_list_get_workflow( workflow_list , real_name ); + hash_insert_ref( workflow_list->workflows , alias , workflow ); +} + + +void ert_workflow_list_add_job( ert_workflow_list_type * workflow_list , const char * job_name , const char * config_file ) { + char * name = (char *) job_name; + + if (job_name == NULL) + util_alloc_file_components( config_file , NULL , &name , NULL ); + + if (!workflow_joblist_add_job_from_file( workflow_list->joblist , name , config_file )) + fprintf(stderr,"** Warning: failed to add workflow job:%s from:%s \n",job_name , config_file ); + + if (job_name == NULL) + free(name); +} + + + + +void ert_workflow_list_add_jobs_in_directory( ert_workflow_list_type * workflow_list , const char * path , log_type * logh) { + DIR * dirH = opendir( path ); + while (true) { + struct dirent * entry = readdir( dirH ); + if (entry != NULL) { + if ((strcmp(entry->d_name , ".") != 0) && (strcmp(entry->d_name , "..") != 0)) { + char * full_path = util_alloc_filename( path , entry->d_name , NULL ); + + if (util_is_file( full_path )) { + if (log_is_open( logh )) + log_add_message( logh , 1 , NULL , util_alloc_sprintf("Adding workflow job:%s " , full_path ), true); + ert_workflow_list_add_job( workflow_list , entry->d_name , full_path ); + } + + free( full_path ); + } + } else + break; + } + closedir( dirH ); +} + + +void ert_workflow_list_init( ert_workflow_list_type * workflow_list , config_type * config , log_type * logh) { + /* Adding jobs */ + { + const config_content_item_type * jobpath_item = config_get_content_item( config , WORKFLOW_JOB_DIRECTORY_KEY); + if (jobpath_item != NULL) { + for (int i=0; i < config_content_item_get_size( jobpath_item ); i++) { + config_content_node_type * path_node = config_content_item_iget_node( jobpath_item , i ); + + for (int j=0; j < config_content_node_get_size( path_node ); j++) + ert_workflow_list_add_jobs_in_directory( workflow_list , config_content_node_iget_as_abspath( path_node , j ) , logh); + } + } + } + + { + const config_content_item_type * job_item = config_get_content_item( config , LOAD_WORKFLOW_JOB_KEY); + if (job_item != NULL) { + for (int i=0; i < config_content_item_get_size( job_item ); i++) { + config_content_node_type * job_node = config_content_item_iget_node( job_item , i ); + const char * config_file = config_content_node_iget_as_path( job_node , 0 ); + const char * job_name = config_content_node_safe_iget( job_node , 1 ); + ert_workflow_list_add_job( workflow_list , job_name , config_file); + } + } + } + + + /* Adding workflows */ + { + const config_content_item_type * workflow_item = config_get_content_item( config , LOAD_WORKFLOW_KEY); + + if (workflow_item != NULL) { + for (int i=0; i < config_content_item_get_size( workflow_item ); i++) { + config_content_node_type * workflow_node = config_content_item_iget_node( workflow_item , i ); + const char * workflow_file = config_content_node_iget_as_path( workflow_node , 0 ); + const char * workflow_name = config_content_node_safe_iget( workflow_node , 1 ); + + ert_workflow_list_add_workflow( workflow_list , workflow_file , workflow_name ); + } + } + } +} + + +void ert_workflow_list_add_config_items( config_type * config ) { + config_schema_item_type * item = config_add_schema_item( config , WORKFLOW_JOB_DIRECTORY_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1 ); + config_schema_item_iset_type( item , 0 , CONFIG_EXISTING_PATH ); + + item = config_add_schema_item( config , LOAD_WORKFLOW_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 2 ); + config_schema_item_iset_type( item , 0 , CONFIG_EXISTING_PATH ); + + item = config_add_schema_item( config , LOAD_WORKFLOW_JOB_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 2 ); + config_schema_item_iset_type( item , 0 , CONFIG_EXISTING_PATH ); +} + + + +workflow_type * ert_workflow_list_get_workflow(ert_workflow_list_type * workflow_list , const char * workflow_name ) { + return hash_get( workflow_list->workflows , workflow_name ); +} + +bool ert_workflow_list_has_workflow(ert_workflow_list_type * workflow_list , const char * workflow_name ) { + return hash_has_key( workflow_list->workflows , workflow_name ); +} + + +bool ert_workflow_list_run_workflow__(ert_workflow_list_type * workflow_list , workflow_type * workflow, bool verbose , void * self ) { + bool runOK = workflow_run( workflow , self , verbose , workflow_list->context ); + + if (runOK) + workflow_list->last_error = NULL; + else + workflow_list->last_error = workflow_get_last_error( workflow ); + + return runOK; +} + +bool ert_workflow_list_run_workflow(ert_workflow_list_type * workflow_list , const char * workflow_name , void * self) { + workflow_type * workflow = ert_workflow_list_get_workflow( workflow_list , workflow_name ); + return ert_workflow_list_run_workflow__( workflow_list , workflow , workflow_list->verbose , self ); +} + + +/*****************************************************************/ + +stringlist_type * ert_workflow_list_alloc_namelist( ert_workflow_list_type * workflow_list ) { + return hash_alloc_stringlist( workflow_list->workflows ); +} + + +const config_error_type * ert_workflow_list_get_last_error( const ert_workflow_list_type * workflow_list) { + return workflow_list->last_error; +} diff --git a/ThirdParty/Ert/devel/libenkf/src/field_config.c b/ThirdParty/Ert/devel/libenkf/src/field_config.c index 6721de679c..b3822cd006 100644 --- a/ThirdParty/Ert/devel/libenkf/src/field_config.c +++ b/ThirdParty/Ert/devel/libenkf/src/field_config.c @@ -943,14 +943,18 @@ void field_config_assert_binary( const field_config_type * config1 , const field bool field_config_parse_user_key__( const char * index_key , int *i , int *j , int *k) { int length; - int * indices = util_sscanf_alloc_active_list(index_key, &length); - if (length == 3) { - *i = indices[0] - 1; - *j = indices[1] - 1; - *k = indices[2] - 1; - } + { + int_vector_type * indices = string_util_alloc_active_list( index_key ); + length = int_vector_size( indices ); - free( indices ); + if (length == 3) { + *i = int_vector_iget( indices , 0) - 1; + *j = int_vector_iget( indices , 1) - 1; + *k = int_vector_iget( indices , 2) - 1; + } + + int_vector_free( indices ); + } if (length == 3) return true; else @@ -958,6 +962,7 @@ bool field_config_parse_user_key__( const char * index_key , int *i , int *j , i } + int field_config_parse_user_key(const field_config_type * config, const char * index_key , int *i , int *j , int *k) { int return_value = 0; diff --git a/ThirdParty/Ert/devel/libenkf/src/gen_kw.c b/ThirdParty/Ert/devel/libenkf/src/gen_kw.c index 8d9261afaf..6920be35a5 100644 --- a/ThirdParty/Ert/devel/libenkf/src/gen_kw.c +++ b/ThirdParty/Ert/devel/libenkf/src/gen_kw.c @@ -164,7 +164,7 @@ void gen_kw_filter_file(const gen_kw_type * gen_kw , const char * target_file) { int ikw; for (ikw = 0; ikw < size; ikw++) { - const char * key = gen_kw_config_get_tagged_name(gen_kw->config , ikw); + const char * key = gen_kw_config_get_tagged_name(gen_kw->config , ikw); subst_list_append_owned_ref(gen_kw->subst_list , key , util_alloc_sprintf("%g" , gen_kw_config_transform( gen_kw->config , ikw , gen_kw->data[ikw] )) , NULL); } @@ -231,7 +231,7 @@ const char * gen_kw_get_name(const gen_kw_type * gen_kw, int kw_nr) { void gen_kw_fload(gen_kw_type * gen_kw , const char * filename) { const int size = gen_kw_config_get_data_size(gen_kw->config ); FILE * stream = util_fopen( filename , "r"); - bool readOK = true; + bool readOK = true; /* First try reading all the data as one long vector. */ { diff --git a/ThirdParty/Ert/devel/libenkf/src/gen_obs.c b/ThirdParty/Ert/devel/libenkf/src/gen_obs.c index a2446ab625..2430269349 100644 --- a/ThirdParty/Ert/devel/libenkf/src/gen_obs.c +++ b/ThirdParty/Ert/devel/libenkf/src/gen_obs.c @@ -23,6 +23,7 @@ #include #include +#include #include #include @@ -197,7 +198,13 @@ gen_obs_type * gen_obs_alloc(const gen_data_config_type * data_config , const ch obs->data_index_list = gen_common_fscanf_alloc( data_index_file , ECL_INT_TYPE , &obs->obs_size); else /* Parsing a string of the type "1,3,5,9-100,200,202,300-1000" */ - obs->data_index_list = util_sscanf_alloc_active_list(data_index_string , &obs->obs_size); + { + int_vector_type * index_list = string_util_alloc_active_list( data_index_string ); + int_vector_shrink( index_list ); + obs->data_index_list = int_vector_get_ptr( index_list ); + obs->obs_size = int_vector_size( index_list ); + int_vector_free_container( index_list ); + } } if (error_covar_file != NULL) { diff --git a/ThirdParty/Ert/devel/libenkf/src/local_config.c b/ThirdParty/Ert/devel/libenkf/src/local_config.c index 7f13693a5d..9bd4a995b9 100644 --- a/ThirdParty/Ert/devel/libenkf/src/local_config.c +++ b/ThirdParty/Ert/devel/libenkf/src/local_config.c @@ -528,7 +528,6 @@ struct local_config_struct { hash_type * dataset_storage; hash_type * obsset_storage; stringlist_type * config_files; - int history_length; }; @@ -539,20 +538,12 @@ static void local_config_clear( local_config_type * local_config ) { hash_clear( local_config->dataset_storage ); hash_clear( local_config->obsset_storage ); vector_clear( local_config->updatestep ); - { - int report; - for (report=0; report <= local_config->history_length; report++) - vector_append_ref( local_config->updatestep , NULL ); - } } -/** - Observe that history_length is *INCLUSIVE* -*/ -local_config_type * local_config_alloc( int history_length ) { +local_config_type * local_config_alloc( ) { local_config_type * local_config = util_malloc( sizeof * local_config ); local_config->default_updatestep = NULL; @@ -561,7 +552,6 @@ local_config_type * local_config_alloc( int history_length ) { local_config->dataset_storage = hash_alloc(); local_config->obsset_storage = hash_alloc(); local_config->updatestep = vector_alloc_new(); - local_config->history_length = history_length; local_config->config_files = stringlist_alloc_new(); local_config_clear( local_config ); @@ -672,14 +662,14 @@ local_ministep_type * local_config_alloc_ministep_copy( local_config_type * loca const local_updatestep_type * local_config_iget_updatestep( const local_config_type * local_config , int index) { - const local_updatestep_type * updatestep = vector_iget_const( local_config->updatestep , index ); + const local_updatestep_type * updatestep = vector_safe_iget_const( local_config->updatestep , index ); if (updatestep == NULL) /* - No particular report step has been installed for this - time-index, revert to the default. + No particular report step has been installed for this + time-index, revert to the default. */ updatestep = local_config->default_updatestep; - + if (updatestep == NULL) util_exit("%s: fatal error. No report step information for step:%d - and no default \n",__func__ , index); @@ -702,9 +692,9 @@ local_updatestep_type * local_config_get_updatestep( const local_config_type * l void local_config_set_updatestep(local_config_type * local_config, int step1 , int step2 , const char * key) { local_updatestep_type * updatestep = hash_get( local_config->updatestep_storage , key ); int step; - - for ( step = step1; step < util_int_min(step2 + 1 , vector_get_size( local_config->updatestep )); step++) - vector_iset_ref(local_config->updatestep , step , updatestep ); + + for ( step = step1; step < step2 + 1; step++) + vector_safe_iset_ref(local_config->updatestep , step , updatestep ); } diff --git a/ThirdParty/Ert/devel/libenkf/src/member_config.c b/ThirdParty/Ert/devel/libenkf/src/member_config.c index 1969b9ca06..29f299b360 100644 --- a/ThirdParty/Ert/devel/libenkf/src/member_config.c +++ b/ThirdParty/Ert/devel/libenkf/src/member_config.c @@ -147,8 +147,10 @@ const char * member_config_get_jobname( const member_config_type * member_config else { if (member_config->eclbase != NULL) return member_config->eclbase; - else + else { util_abort("%s: sorry can not submit JOB - must specify name with JOBNAME or ECLBASE config keys\n",__func__); + return NULL; + } } } diff --git a/ThirdParty/Ert/devel/libenkf/src/model_config.c b/ThirdParty/Ert/devel/libenkf/src/model_config.c index 0e2d3e08b7..95867b8d4a 100644 --- a/ThirdParty/Ert/devel/libenkf/src/model_config.c +++ b/ThirdParty/Ert/devel/libenkf/src/model_config.c @@ -281,6 +281,7 @@ void model_config_select_refcase_history( model_config_type * model_config , con util_abort("%s: internal error - trying to load history from REFCASE - but no REFCASE has been loaded.\n",__func__); } + int model_config_get_max_internal_submit( const model_config_type * config ) { return config->max_internal_submit; } @@ -312,11 +313,12 @@ model_config_type * model_config_alloc_empty() { model_config->select_case = NULL; model_config->history = NULL; model_config->jobname_fmt = NULL; + model_config->forward_model = NULL; model_config->internalize_state = bool_vector_alloc( 0 , false ); model_config->__load_state = bool_vector_alloc( 0 , false ); model_config->history_source = HISTORY_SOURCE_INVALID; model_config->runpath_map = hash_alloc(); - + model_config_set_enspath( model_config , DEFAULT_ENSPATH ); model_config_set_rftpath( model_config , DEFAULT_RFTPATH ); model_config_set_dbase_type( model_config , DEFAULT_DBASE_TYPE ); @@ -328,6 +330,42 @@ model_config_type * model_config_alloc_empty() { } +static bool model_config_select_history( model_config_type * model_config , history_source_type source_type, const sched_file_type * sched_file , const ecl_sum_type * refcase) { + bool selectOK = false; + + if (source_type == SCHEDULE && sched_file != NULL) { + model_config_select_schedule_history( model_config , sched_file ); + selectOK = true; + } + + if (((source_type == REFCASE_HISTORY) || (source_type == REFCASE_SIMULATED)) && refcase != NULL) { + if (source_type == REFCASE_HISTORY) + model_config_select_refcase_history( model_config , refcase , true); + else + model_config_select_refcase_history( model_config , refcase , false); + selectOK = true; + } + + return selectOK; +} + + +static bool model_config_select_any_history( model_config_type * model_config , const sched_file_type * sched_file , const ecl_sum_type * refcase) { + bool selectOK = false; + + if (sched_file != NULL) { + model_config_select_schedule_history( model_config , sched_file ); + selectOK = true; + } else if ( refcase != NULL ) { + model_config_select_refcase_history( model_config , refcase , true); + selectOK = true; + } + + return selectOK; +} + + + void model_config_init(model_config_type * model_config , const config_type * config , @@ -336,8 +374,8 @@ void model_config_init(model_config_type * model_config , int last_history_restart , const sched_file_type * sched_file , const ecl_sum_type * refcase) { - - model_config->forward_model = forward_model_alloc( joblist ); + + model_config->forward_model = forward_model_alloc( joblist ); model_config_set_refcase( model_config , refcase ); @@ -369,20 +407,12 @@ void model_config_init(model_config_type * model_config , const char * history_source = config_iget(config , HISTORY_SOURCE_KEY, 0,0); source_type = history_get_source_type( history_source ); } + + if (!model_config_select_history( model_config , source_type , sched_file , refcase )) + if (!model_config_select_history( model_config , DEFAULT_HISTORY_SOURCE , sched_file , refcase )) + if (!model_config_select_any_history( model_config , sched_file , refcase)) + fprintf(stderr,"** Warning:: Do not have enough information to select a history source \n"); - switch (source_type) { - case SCHEDULE: - model_config_select_schedule_history( model_config , sched_file ); - break; - case REFCASE_HISTORY: - model_config_select_refcase_history( model_config , refcase , true); - break; - case REFCASE_SIMULATED: - model_config_select_refcase_history( model_config , refcase , false); - break; - default: - break; - } } @@ -446,9 +476,13 @@ void model_config_free(model_config_type * model_config) { util_safe_free( model_config->enkf_sched_file ); util_safe_free( model_config->select_case ); util_safe_free( model_config->case_table_file ); + if (model_config->history != NULL) history_free(model_config->history); - forward_model_free(model_config->forward_model); + + if (model_config->forward_model != NULL) + forward_model_free(model_config->forward_model); + bool_vector_free(model_config->internalize_state); bool_vector_free(model_config->__load_state); if (model_config->case_names != NULL) stringlist_free( model_config->case_names ); @@ -478,6 +512,7 @@ history_type * model_config_get_history(const model_config_type * config) { } int model_config_get_last_history_restart(const model_config_type * config) { + printf("config->history:%p \n",config->history); return history_get_last_restart( config->history ); } diff --git a/ThirdParty/Ert/devel/libenkf/src/plot_config.c b/ThirdParty/Ert/devel/libenkf/src/plot_config.c index af3650482f..b4efa56192 100644 --- a/ThirdParty/Ert/devel/libenkf/src/plot_config.c +++ b/ThirdParty/Ert/devel/libenkf/src/plot_config.c @@ -31,11 +31,11 @@ struct plot_config_struct { char * plot_path; /* All the plots will be saved as xxxx files in this directory. */ char * image_type; /* Type of plot file - currently only 'png' is tested. */ - char * plot_refcase; /* Full path to DATA file for refcase plotting */ char * driver; /* The driver used by the libplot layer when actually 'rendering' the plots. */ char * viewer; /* The executable used when displaying the newly created image - can be NULL - in which case the plots are not displayed in any way. */ int errorbar_max; /* If the number of observations is less than this it is plotted with errorbars - otherwise with lines. */ bool plot_errorbar; /*Should the errorbars be plotted*/ + bool plot_refcase; int height; int width; bool logy; @@ -65,10 +65,6 @@ void plot_config_set_path(plot_config_type * plot_config , const char * plot_pat util_make_path( plot_path ); } -void plot_config_set_plot_refcase(plot_config_type * plot_config , const char * plot_refcase) { - plot_config->plot_refcase = util_realloc_string_copy(plot_config->plot_refcase , plot_refcase); -} - void plot_config_set_image_type(plot_config_type * plot_config , const char * image_type) { plot_config->image_type = util_realloc_string_copy(plot_config->image_type , image_type); } @@ -108,6 +104,16 @@ void plot_config_set_logy( plot_config_type * plot_config , bool logy) { } +void plot_config_set_plot_refcase( plot_config_type * plot_config , bool plot_refcase) { + plot_config->plot_refcase = plot_refcase; +} + + +bool plot_config_get_plot_refcase( const plot_config_type * plot_config ) { + return plot_config->plot_refcase; +} + + void plot_config_toggle_logy( plot_config_type * plot_config ) { if (plot_config->logy) plot_config->logy = false; @@ -125,10 +131,6 @@ const char * plot_config_get_path(const plot_config_type * plot_config ) { return plot_config->plot_path; } -const char * plot_config_get_plot_refcase(const plot_config_type * plot_config ) { - return plot_config->plot_refcase; -} - const char * plot_config_get_image_type(const plot_config_type * plot_config ) { return plot_config->image_type; } @@ -160,7 +162,6 @@ bool plot_config_get_plot_errorbar( const plot_config_type * plot_config) { void plot_config_free( plot_config_type * plot_config) { free(plot_config->plot_path); - free(plot_config->plot_refcase); util_safe_free(plot_config->viewer); free(plot_config->image_type); free(plot_config->driver ); @@ -174,33 +175,29 @@ void plot_config_free( plot_config_type * plot_config) { plot_config_type * plot_config_alloc_default() { plot_config_type * info = util_malloc( sizeof * info ); info->plot_path = NULL; - info->plot_refcase = NULL; info->image_type = NULL; info->viewer = NULL; info->driver = NULL; + - plot_config_set_path(info , DEFAULT_PLOT_PATH ); - plot_config_set_plot_refcase(info , DEFAULT_PLOT_REFCASE ); - plot_config_set_image_type(info , DEFAULT_IMAGE_TYPE ); - plot_config_set_viewer(info , DEFAULT_IMAGE_VIEWER ); - plot_config_set_driver(info , DEFAULT_PLOT_DRIVER ); - plot_config_set_width(info , DEFAULT_PLOT_WIDTH ); - plot_config_set_height(info , DEFAULT_PLOT_HEIGHT ); - plot_config_set_errorbar_max(info , DEFAULT_PLOT_ERRORBAR_MAX); - plot_config_set_plot_errorbar(info, DEFAULT_PLOT_ERRORBAR); - plot_config_set_logy( info , DEFAULT_PLOT_LOGY ); + plot_config_set_plot_refcase( info , DEFAULT_PLOT_REFCASE); + plot_config_set_path(info , DEFAULT_PLOT_PATH ); + plot_config_set_image_type(info , DEFAULT_IMAGE_TYPE ); + plot_config_set_viewer(info , DEFAULT_IMAGE_VIEWER ); + plot_config_set_driver(info , DEFAULT_PLOT_DRIVER ); + plot_config_set_width(info , DEFAULT_PLOT_WIDTH ); + plot_config_set_height(info , DEFAULT_PLOT_HEIGHT ); + plot_config_set_errorbar_max(info , DEFAULT_PLOT_ERRORBAR_MAX); + plot_config_set_plot_errorbar(info , DEFAULT_PLOT_ERRORBAR); + plot_config_set_logy( info , DEFAULT_PLOT_LOGY ); return info; } - void plot_config_init(plot_config_type * plot_config , const config_type * config ) { if (config_item_set( config , PLOT_PATH_KEY)) plot_config_set_path( plot_config , config_get_value( config , PLOT_PATH_KEY )); - if (config_item_set( config , PLOT_REFCASE_KEY)) - plot_config_set_plot_refcase( plot_config , config_get_value( config , PLOT_REFCASE_KEY )); - if (config_item_set( config , PLOT_DRIVER_KEY)) plot_config_set_driver( plot_config , config_get_value( config , PLOT_DRIVER_KEY )); @@ -209,7 +206,7 @@ void plot_config_init(plot_config_type * plot_config , const config_type * confi if (config_item_set( config , PLOT_DRIVER_KEY)) plot_config_set_driver( plot_config , config_get_value( config , PLOT_DRIVER_KEY )); - + if (config_item_set( config , PLOT_ERRORBAR_MAX_KEY)) plot_config_set_errorbar_max( plot_config , config_get_value_as_int( config , PLOT_ERRORBAR_MAX_KEY )); @@ -221,6 +218,19 @@ void plot_config_init(plot_config_type * plot_config , const config_type * confi if (config_item_set( config , PLOT_WIDTH_KEY)) plot_config_set_width( plot_config , config_get_value_as_int( config , PLOT_WIDTH_KEY )); + + if (config_item_set( config , PLOT_REFCASE_KEY)) { + const char * plot_refcase_string = config_get_value( config , PLOT_REFCASE_KEY ); + bool plot_refcase; + if (!util_sscanf_bool( plot_refcase_string , &plot_refcase)) { + fprintf(stderr , + "Warning: The PLOT_REFCASE option should have value True | False. The value:%s will be interpreted as True" , + plot_refcase_string); + + plot_refcase = true; + } + plot_config_set_plot_refcase( plot_config , plot_refcase ); + } } @@ -228,9 +238,8 @@ void plot_config_add_config_items( config_type * config ) { config_add_key_value(config , PLOT_HEIGHT_KEY , false , CONFIG_INT); config_add_key_value(config , PLOT_WIDTH_KEY , false , CONFIG_INT); config_add_key_value(config , PLOT_PATH_KEY , false , CONFIG_STRING); - config_add_key_value(config , PLOT_REFCASE_KEY , false , CONFIG_STRING); - config_add_key_value(config , IMAGE_VIEWER_KEY , false , CONFIG_FILE); - config_add_key_value(config , PLOT_ERRORBAR_KEY , false , CONFIG_BOOLEAN); + config_add_key_value(config , IMAGE_VIEWER_KEY , false , CONFIG_PATH); + config_add_key_value(config , PLOT_ERRORBAR_KEY , false , CONFIG_BOOL); config_add_key_value(config , PLOT_ERRORBAR_MAX_KEY , false , CONFIG_INT); { @@ -240,8 +249,11 @@ void plot_config_add_config_items( config_type * config ) { config_schema_item_set_common_selection_set( item , 3 , (const char *[3]) {"png" , "jpg" , "psc"}); item = config_add_key_value(config , PLOT_DRIVER_KEY , false , CONFIG_STRING); - config_schema_item_set_common_selection_set( item , 2 , (const char *[2]) {"PLPLOT" , "TEXT"}); + config_schema_item_set_common_selection_set( item , 2 , ( const char *[2]) {"PLPLOT" , "TEXT"}); } + + config_add_key_value(config , PLOT_REFCASE_KEY , false , CONFIG_STRING); + // Should be CONFIG_BOOL } @@ -263,11 +275,6 @@ void plot_config_fprintf_config( const plot_config_type * plot_config , FILE * s fprintf(stream , CONFIG_ENDVALUE_FORMAT , plot_config->plot_path ); } - if (!util_string_equal( plot_config->plot_refcase , DEFAULT_PLOT_REFCASE)) { - fprintf(stream , CONFIG_KEY_FORMAT , PLOT_REFCASE_KEY ); - fprintf(stream , CONFIG_ENDVALUE_FORMAT , plot_config->plot_refcase ); - } - if (!util_string_equal( plot_config->image_type , DEFAULT_IMAGE_TYPE)) { fprintf(stream , CONFIG_KEY_FORMAT , IMAGE_TYPE_KEY ); fprintf(stream , CONFIG_ENDVALUE_FORMAT , plot_config->image_type ); @@ -310,3 +317,16 @@ void plot_config_fprintf_config( const plot_config_type * plot_config , FILE * s fprintf(stream , "\n\n"); } +stringlist_type * plot_config_refcase_fscanf(const char * plot_refcase_file ) { + stringlist_type * list_of_refcases = stringlist_alloc_new(); + if (plot_refcase_file != NULL){ + FILE * stream = util_fopen(plot_refcase_file , "r"); + bool at_eof; + do { + stringlist_append_copy( list_of_refcases ,util_fscanf_alloc_line(stream , &at_eof)); + } while (!at_eof); + + fclose( stream ); + } + return list_of_refcases; +} diff --git a/ThirdParty/Ert/devel/libenkf/src/qc_config.c b/ThirdParty/Ert/devel/libenkf/src/qc_config.c deleted file mode 100644 index 1e00c0e8d7..0000000000 --- a/ThirdParty/Ert/devel/libenkf/src/qc_config.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ert_qc_config.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 -#include - -#include - -#include - -#include -#include - - -struct qc_config_struct { - char * qc_path; -}; - - - - -qc_config_type * qc_config_alloc( const char * qc_path ) { - qc_config_type * qc_config = util_malloc( sizeof * qc_config ); - qc_config->qc_path = NULL; - qc_config_set_path( qc_config , qc_path ); - return qc_config; -} - - -void qc_config_free( qc_config_type * qc_config ) { - util_safe_free( qc_config->qc_path ); - free( qc_config ); -} - - -void qc_config_set_path( qc_config_type * qc_config , const char * qc_path) { - qc_config->qc_path = util_realloc_string_copy( qc_config->qc_path , qc_path ); -} - - -const char * qc_config_get_path( const qc_config_type * qc_config ) { - return qc_config->qc_path; -} - - -void qc_config_init( qc_config_type * qc_config , const config_type * config) { - if (config_item_set( config , QC_PATH_KEY )) - qc_config_set_path( qc_config , config_get_value( config , QC_PATH_KEY )); -} diff --git a/ThirdParty/Ert/devel/libenkf/src/qc_module.c b/ThirdParty/Ert/devel/libenkf/src/qc_module.c new file mode 100644 index 0000000000..8b2c1f8b3d --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/src/qc_module.c @@ -0,0 +1,160 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'qc_module.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include + +#include +#include + +#include + +#include + +#include +#include +#include +#include + +#define QC_WORKFLOW_NAME "QC" +#define RUNPATH_LIST_FILE "/tmp/ert_runpath_list" + + +struct qc_module_struct { + char * qc_path; + workflow_type * qc_workflow; + ert_workflow_list_type * workflow_list; + runpath_list_type * runpath_list; + char * runpath_list_file; +}; + + + + +qc_module_type * qc_module_alloc( ert_workflow_list_type * workflow_list , const char * qc_path ) { + qc_module_type * qc_module = util_malloc( sizeof * qc_module ); + qc_module->qc_workflow = NULL; + qc_module->qc_path = NULL; + qc_module->workflow_list = workflow_list; + qc_module->runpath_list = runpath_list_alloc(); + qc_module->runpath_list_file = NULL; + qc_module_set_path( qc_module , qc_path ); + qc_module_set_runpath_list_file( qc_module , RUNPATH_LIST_FILE ); + return qc_module; +} + + +void qc_module_free( qc_module_type * qc_module ) { + util_safe_free( qc_module->qc_path ); + runpath_list_free( qc_module->runpath_list ); + free( qc_module ); +} + +runpath_list_type * qc_module_get_runpath_list( qc_module_type * qc_module ) { + return qc_module->runpath_list; +} + + +void qc_module_export_runpath_list( const qc_module_type * qc_module ) { + FILE * stream = util_fopen( qc_module->runpath_list_file , "w"); + runpath_list_fprintf( qc_module->runpath_list , stream ); + fclose( stream ); +} + +void qc_module_set_runpath_list_file( qc_module_type * qc_module , const char * filename) { + qc_module->runpath_list_file = util_realloc_string_copy( qc_module->runpath_list_file , filename ); +} + +const char * qc_module_get_runpath_list_file( qc_module_type * qc_module) { + return qc_module->runpath_list_file; +} + + +void qc_module_set_path( qc_module_type * qc_module , const char * qc_path) { + qc_module->qc_path = util_realloc_string_copy( qc_module->qc_path , qc_path ); +} + + +const char * qc_module_get_path( const qc_module_type * qc_module ) { + return qc_module->qc_path; +} + + +void qc_module_set_workflow( qc_module_type * qc_module , const char * qc_workflow ) { + char * workflow_name; + util_alloc_file_components( qc_workflow , NULL , &workflow_name , NULL ); + { + workflow_type * workflow = ert_workflow_list_add_workflow( qc_module->workflow_list , qc_workflow , workflow_name); + if (workflow != NULL) { + ert_workflow_list_add_alias( qc_module->workflow_list , workflow_name , QC_WORKFLOW_NAME ); + qc_module->qc_workflow = workflow; + } + } + free( workflow_name ); +} + + +bool qc_module_run_workflow( qc_module_type * qc_module , void * self) { + bool verbose = false; + if (qc_module->qc_workflow != NULL ) { + if (!util_file_exists( qc_module->runpath_list_file )) + fprintf(stderr,"** Warning: the file:%s with a list of runpath directories was not found - QC workflow wil probably fail.\n" , qc_module->runpath_list_file); + + return ert_workflow_list_run_workflow__( qc_module->workflow_list , qc_module->qc_workflow , verbose , self); + } else + return false; +} + + +bool qc_module_has_workflow( const qc_module_type * qc_module ) { + if (qc_module->qc_workflow == NULL) + return false; + else + return true; +} + + + +/*****************************************************************/ + + +void qc_module_init( qc_module_type * qc_module , const config_type * config) { + if (config_item_set( config , QC_PATH_KEY )) + qc_module_set_path( qc_module , config_get_value( config , QC_PATH_KEY )); + + if (config_item_set( config , QC_WORKFLOW_KEY)) { + const char * qc_workflow = config_get_value_as_path(config , QC_WORKFLOW_KEY); + qc_module_set_workflow( qc_module , qc_workflow ); + } +} + + + +void qc_module_add_config_items( config_type * config ) { + config_schema_item_type * item; + + item = config_add_schema_item( config , QC_PATH_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1 ); + + item = config_add_schema_item( config , QC_WORKFLOW_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1 ); + config_schema_item_iset_type( item , 0 , CONFIG_EXISTING_PATH ); +} + + + diff --git a/ThirdParty/Ert/devel/libenkf/src/rng_config.c b/ThirdParty/Ert/devel/libenkf/src/rng_config.c index 0441d979ac..bea6a62229 100644 --- a/ThirdParty/Ert/devel/libenkf/src/rng_config.c +++ b/ThirdParty/Ert/devel/libenkf/src/rng_config.c @@ -21,8 +21,10 @@ #include #include #include +#include #include +#include #include #include @@ -80,23 +82,59 @@ void rng_config_free( rng_config_type * rng) { free( rng ); } + +rng_type * rng_config_alloc_rng( rng_config_type * rng_config ) { + const char * seed_load = rng_config_get_seed_load_file( rng_config ); + const char * seed_store = rng_config_get_seed_store_file( rng_config ); + rng_type * rng = rng_alloc( rng_config_get_type(rng_config) , INIT_DEFAULT); + + if (seed_load != NULL) { + if (util_file_exists( seed_load)) { + FILE * stream = util_fopen( seed_load , "r"); + rng_fscanf_state( rng , stream ); + fclose( stream ); + } else { + /* + In the special case that seed_load == seed_store; we accept a + seed_load argument pointing to a non-existant file. + */ + if (test_string_equal( seed_load , seed_store)) + rng_init( rng , INIT_DEV_URANDOM ); + else + util_abort("%s: tried to load random seed from non-existing file:%s \n",__func__ , seed_load); + } + } else + rng_init( rng , INIT_DEV_URANDOM ); + + + if (seed_store != NULL) { + FILE * stream = util_mkdir_fopen( seed_store , "w"); + rng_fprintf_state( rng , stream ); + fclose( stream ); + } + + return rng; +} + /*****************************************************************/ void rng_config_add_config_items( config_type * config ) { config_schema_item_type * item; - item= config_add_schema_item( config , STORE_SEED_KEY , false , false ); - config_schema_item_set_argc_minmax(item , 1 , 1 , 1 , NULL ); + item= config_add_schema_item( config , STORE_SEED_KEY , false); + config_schema_item_set_argc_minmax(item , 1 , 1 ); + config_schema_item_iset_type( item , 0 , CONFIG_PATH ); - item = config_add_schema_item( config , LOAD_SEED_KEY , false , false ); - config_schema_item_set_argc_minmax(item , 1 , 1 , 1 , (const config_item_types [1]) { CONFIG_EXISTING_FILE}); + item = config_add_schema_item( config , LOAD_SEED_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1 ); + config_schema_item_iset_type( item , 0 , CONFIG_PATH ); } void rng_config_init( rng_config_type * rng_config , config_type * config ) { if (config_item_set( config , STORE_SEED_KEY )) rng_config_set_seed_store_file( rng_config , config_iget(config , STORE_SEED_KEY ,0,0)); - + if (config_item_set( config , LOAD_SEED_KEY )) rng_config_set_seed_load_file( rng_config , config_iget(config , LOAD_SEED_KEY ,0,0)); } diff --git a/ThirdParty/Ert/devel/libenkf/src/runpath_list.c b/ThirdParty/Ert/devel/libenkf/src/runpath_list.c new file mode 100644 index 0000000000..a6d8e6556d --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/src/runpath_list.c @@ -0,0 +1,199 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + The file 'runpath_list.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include +#include + +#include +#include +#include + +#include + +typedef struct runpath_node_struct runpath_node_type; + + +struct runpath_list_struct { + pthread_rwlock_t lock; + vector_type * list; + char * line_fmt; // Format string : Values are in the order: (iens , runpath , basename) +}; + + +#define RUNPATH_NODE_TYPE_ID 661400541 +struct runpath_node_struct { + UTIL_TYPE_ID_DECLARATION; + int iens; + char * runpath; + char * basename; +}; + + +/*****************************************************************/ + + UTIL_SAFE_CAST_FUNCTION( runpath_node , RUNPATH_NODE_TYPE_ID ) + UTIL_SAFE_CAST_FUNCTION_CONST( runpath_node , RUNPATH_NODE_TYPE_ID ) + + static runpath_node_type * runpath_node_alloc( int iens, const char * runpath , const char * basename) { + runpath_node_type * node = util_malloc( sizeof * node ); + UTIL_TYPE_ID_INIT( node , RUNPATH_NODE_TYPE_ID ); + + node->iens = iens; + node->runpath = util_alloc_string_copy( runpath ); + node->basename = util_alloc_string_copy( basename ); + + return node; + } + + +static void runpath_node_free( runpath_node_type * node ) { + free(node->basename); + free(node->runpath); + free(node); +} + + +static void runpath_node_free__( void * arg ) { + runpath_node_type * node = runpath_node_safe_cast( arg ); + runpath_node_free( node ); +} + +static int runpath_node_cmp( const void * arg1 , const void * arg2) { + const runpath_node_type * node1 = runpath_node_safe_cast_const( arg1 ); + const runpath_node_type * node2 = runpath_node_safe_cast_const( arg2 ); + { + if (node1->iens > node2->iens) + return 1; + else if (node1->iens < node2->iens) + return -1; + else + return 0; + } +} + + +static void runpath_node_fprintf( const runpath_node_type * node , const char * line_fmt , FILE * stream) { + fprintf(stream , line_fmt , node->iens, node->runpath , node->basename); +} + + +/*****************************************************************/ + + +runpath_list_type * runpath_list_alloc() { + runpath_list_type * list = util_malloc( sizeof * list ); + list->list = vector_alloc_new(); + list->line_fmt = NULL; + pthread_rwlock_init( &list->lock , NULL ); + return list; +} + + +void runpath_list_free( runpath_list_type * list ) { + vector_free( list->list ); + util_safe_free( list->line_fmt ); + free( list ); +} + + +int runpath_list_size( const runpath_list_type * list ) { + return vector_get_size( list->list ); +} + + +void runpath_list_sort( runpath_list_type * list ) { + pthread_rwlock_wrlock( &list->lock ); + { + vector_sort( list->list , runpath_node_cmp ); + } + pthread_rwlock_unlock( &list->lock ); +} + + +void runpath_list_add( runpath_list_type * list , int iens , const char * runpath , const char * basename) { + runpath_node_type * node = runpath_node_alloc( iens , runpath , basename ); + pthread_rwlock_wrlock( &list->lock ); + { + vector_append_owned_ref( list->list , node , runpath_node_free__ ); + } + pthread_rwlock_unlock( &list->lock ); +} + + +void runpath_list_clear( runpath_list_type * list ) { + pthread_rwlock_wrlock( &list->lock ); + { + vector_clear( list->list ); + } + pthread_rwlock_unlock( &list->lock ); +} + +/*****************************************************************/ + +void runpath_list_set_line_fmt( runpath_list_type * list , const char * line_fmt ) { + list->line_fmt = util_realloc_string_copy( list->line_fmt , line_fmt ); +} + + +const char * runpath_list_get_line_fmt( const runpath_list_type * list ) { + if (list->line_fmt == NULL) + return RUNPATH_LIST_DEFAULT_LINE_FMT; + else + return list->line_fmt; +} + +/*****************************************************************/ + + +static const runpath_node_type * runpath_list_iget_node__( const runpath_list_type * list , int index) { + return vector_iget_const( list->list , index ); +} + + + +static const runpath_node_type * runpath_list_iget_node( runpath_list_type * list , int index) { + const runpath_node_type * node; + { + pthread_rwlock_rdlock( &list->lock ); + node = runpath_list_iget_node__( list , index ); + pthread_rwlock_unlock( &list->lock ); + } + return node; +} + + +int runpath_list_iget_iens( runpath_list_type * list , int index) { + const runpath_node_type * node = runpath_list_iget_node( list , index ); + return node->iens; +} + + +void runpath_list_fprintf(runpath_list_type * list , FILE * stream) { + pthread_rwlock_rdlock( &list->lock ); + { + const char * line_fmt = runpath_list_get_line_fmt( list ); + int index; + for (index =0; index < vector_get_size( list->list ); index++) { + const runpath_node_type * node = runpath_list_iget_node__( list , index ); + runpath_node_fprintf( node , line_fmt , stream ); + } + } + pthread_rwlock_unlock( &list->lock ); +} diff --git a/ThirdParty/Ert/devel/libenkf/src/site_config.c b/ThirdParty/Ert/devel/libenkf/src/site_config.c index 59dccf66f7..444d01086f 100644 --- a/ThirdParty/Ert/devel/libenkf/src/site_config.c +++ b/ThirdParty/Ert/devel/libenkf/src/site_config.c @@ -35,10 +35,13 @@ #include #include +#include +#include #include #include #include +#include /** This struct contains information which is specific to the site @@ -180,9 +183,8 @@ site_config_type * site_config_alloc_empty() { site_config_type * site_config = util_malloc( sizeof * site_config); site_config->joblist = ext_joblist_alloc( ); - site_config->job_queue = NULL; site_config->queue_drivers = hash_alloc( ); - + site_config->lsf_queue_name_site = NULL; site_config->lsf_request_site = NULL; site_config->rsh_command_site = NULL; @@ -196,19 +198,19 @@ site_config_type * site_config_alloc_empty() { site_config->user_mode = false; site_config->driver_type = NULL_DRIVER; - /* Some hooops to get the current umask. */ - site_config->umask = umask( 0 ); - site_config_set_umask( site_config , site_config->umask ); - site_config_set_manual_url( site_config , DEFAULT_MANUAL_URL ); - site_config_set_default_browser( site_config , DEFAULT_BROWSER ); - + site_config->job_queue = job_queue_alloc(DEFAULT_MAX_SUBMIT , "OK" , "ERROR" ); site_config->env_variables_user = hash_alloc(); site_config->env_variables_site = hash_alloc(); site_config->path_variables_user = stringlist_alloc_new(); site_config->path_values_user = stringlist_alloc_new(); site_config->path_variables_site = hash_alloc(); - + + /* Some hooops to get the current umask. */ + site_config->umask = umask( 0 ); + site_config_set_umask( site_config , site_config->umask ); + site_config_set_manual_url( site_config , DEFAULT_MANUAL_URL ); + site_config_set_default_browser( site_config , DEFAULT_BROWSER ); site_config_set_max_submit( site_config , DEFAULT_MAX_SUBMIT ); return site_config; } @@ -281,14 +283,17 @@ bool site_config_del_job( site_config_type * site_config , const char * job_name static void site_config_add_jobs(site_config_type * site_config , const config_type * config) { - int i; - - stringlist_type *item_list = config_alloc_complete_stringlist(config , INSTALL_JOB_KEY); - - for (i=0; i < stringlist_get_size(item_list); i+=2) - site_config_install_job(site_config , stringlist_iget(item_list , i) , stringlist_iget(item_list , i + 1)); - - stringlist_free(item_list); + if (config_item_set( config , INSTALL_JOB_KEY)) { + const config_content_item_type * content_item = config_get_content_item( config , INSTALL_JOB_KEY ); + int num_jobs = config_content_item_get_size( content_item ); + for (int job_nr = 0; job_nr < num_jobs; job_nr++) { + config_content_node_type * node = config_content_item_iget_node( content_item , job_nr ); + const char * job_key = config_content_node_iget( node , 0 ); + const char * description_file = config_content_node_iget_as_abspath( node , 1 ); + + site_config_install_job(site_config , job_key , description_file ); + } + } } @@ -660,6 +665,7 @@ void site_config_set_max_submit( site_config_type * site_config , int max_submit site_config->max_submit = max_submit; if (!site_config->user_mode) site_config->max_submit_site = max_submit; + job_queue_set_max_submit( site_config->job_queue , max_submit ); } @@ -672,13 +678,43 @@ static void site_config_install_job_queue(site_config_type * site_config ) { if (site_config->job_script == NULL) util_exit("Must set the path to the job script with the %s key in the site_config / config file\n",JOB_SCRIPT_KEY); - site_config->job_queue = job_queue_alloc(site_config->max_submit , "OK" , "ERROR" ); - /* All the various driver options are set, unconditionally of which driver is actually selected in the end. */ - site_config_set_job_queue__( site_config , site_config->driver_type ); + if (site_config->driver_type != NULL_DRIVER) + site_config_set_job_queue__( site_config , site_config->driver_type ); +} + + +void site_config_init_env( site_config_type * site_config , const config_type * config ) { + { + config_content_item_type * setenv_item = config_get_content_item( config , SETENV_KEY ); + if (setenv_item != NULL) { + int i; + for (i = 0; i < config_content_item_get_size( setenv_item ); i++) { + const config_content_node_type * setenv_node = config_content_item_iget_node( setenv_item , i ); + const char * var = config_content_node_iget( setenv_node , 0 ); + const char * value = config_content_node_iget( setenv_node , 1 ); + + site_config_setenv( site_config , var , value ); + } + } + } + + { + config_content_item_type * path_item = config_get_content_item( config , UPDATE_PATH_KEY ); + if (path_item != NULL) { + int i; + for (i = 0; i < config_content_item_get_size( path_item ); i++) { + const config_content_node_type * path_node = config_content_item_iget_node( path_item , i ); + const char * path = config_content_node_iget( path_node , 0 ); + const char * value = config_content_node_iget( path_node , 1 ); + + site_config_update_pathvar( site_config , path , value ); + } + } + } } @@ -692,26 +728,10 @@ static void site_config_install_job_queue(site_config_type * site_config ) { */ -void site_config_init(site_config_type * site_config , const config_type * config, bool user_config) { +bool site_config_init(site_config_type * site_config , const config_type * config) { site_config_add_jobs(site_config , config); - { - int i; - for (i = 0; i < config_get_occurences( config , SETENV_KEY); i++) { - const stringlist_type * tokens = config_iget_stringlist_ref(config , SETENV_KEY , i); - const char * var = stringlist_iget( tokens , 0); - const char * value = stringlist_iget( tokens , 1); - - site_config_setenv( site_config , var , value ); - } - - for (i=0; i < config_get_occurences( config, UPDATE_PATH_KEY); i++) { - const stringlist_type * tokens = config_iget_stringlist_ref(config , UPDATE_PATH_KEY , i); - const char * path = stringlist_iget( tokens , 0); - const char * value = stringlist_iget( tokens , 1); - - site_config_update_pathvar( site_config , path , value ); - } - } + site_config_init_env(site_config , config); + /* When LSF is used several enviroment variables must be set (by the site wide file) - i.e. the calls to SETENV must come first. @@ -730,7 +750,7 @@ void site_config_init(site_config_type * site_config , const config_type * confi prefix characters). */ if (config_item_set(config , UMASK_KEY)) { - const char * string_mask = config_iget( config , UMASK_KEY , 0 , 0); + const char * string_mask = config_get_value( config , UMASK_KEY); mode_t umask_value; if (util_sscanf_octal_int( string_mask , &umask_value)) site_config_set_umask( site_config , umask_value); @@ -745,7 +765,7 @@ void site_config_init(site_config_type * site_config , const config_type * confi /* LSF options */ { if (config_item_set(config , LSF_QUEUE_KEY)) - site_config_set_lsf_queue( site_config , config_iget( config , LSF_QUEUE_KEY , 0 , 0)); + site_config_set_lsf_queue( site_config , config_get_value( config , LSF_QUEUE_KEY )); if (config_item_set(config , LSF_RESOURCES_KEY)) { char * lsf_resource_request = config_alloc_joined_string(config , LSF_RESOURCES_KEY , " "); @@ -754,24 +774,25 @@ void site_config_init(site_config_type * site_config , const config_type * confi } if (config_item_set(config , MAX_RUNNING_LSF_KEY)) - site_config_set_max_running_lsf( site_config , config_iget_as_int( config , MAX_RUNNING_LSF_KEY , 0 , 0)); + site_config_set_max_running_lsf( site_config , config_get_value_as_int( config , MAX_RUNNING_LSF_KEY)); if (config_item_set(config , LSF_SERVER_KEY)) - site_config_set_lsf_server( site_config , config_iget( config , LSF_SERVER_KEY , 0 , 0)); + site_config_set_lsf_server( site_config , config_get_value( config , LSF_SERVER_KEY)); } /* RSH options */ { if (config_item_set( config , RSH_COMMAND_KEY )) - site_config_set_rsh_command( site_config , config_iget(config , RSH_COMMAND_KEY , 0,0)); + site_config_set_rsh_command( site_config , config_get_value(config , RSH_COMMAND_KEY)); if (config_item_set( config , MAX_RUNNING_RSH_KEY)) - site_config_set_max_running_rsh( site_config , config_iget_as_int( config , MAX_RUNNING_RSH_KEY , 0,0)); - + site_config_set_max_running_rsh( site_config , config_get_value_as_int( config , MAX_RUNNING_RSH_KEY)); + /* Parsing the "host1:4" strings. */ - if (user_config) { - if (config_item_set( config , RSH_HOST_KEY)) { + { + const config_content_item_type * rsh_host_item = config_get_content_item( config , RSH_HOST_KEY ); + if (rsh_host_item != NULL) { stringlist_type * rsh_host_list = config_alloc_complete_stringlist(config , RSH_HOST_KEY); int i; for (i=0; i < stringlist_get_size( rsh_host_list ); i++) @@ -781,11 +802,12 @@ void site_config_init(site_config_type * site_config , const config_type * confi } } } + if (config_item_set( config , QUEUE_SYSTEM_KEY)) { job_driver_type driver_type; { - const char * queue_system = config_iget(config , QUEUE_SYSTEM_KEY , 0,0); + const char * queue_system = config_get_value(config , QUEUE_SYSTEM_KEY); if (strcmp(queue_system , LSF_DRIVER_NAME) == 0) { driver_type = LSF_DRIVER; } else if (strcmp(queue_system , RSH_DRIVER_NAME) == 0) @@ -805,19 +827,18 @@ void site_config_init(site_config_type * site_config , const config_type * confi site_config_set_max_running_local( site_config , config_iget_as_int( config , MAX_RUNNING_LOCAL_KEY , 0,0)); if (config_item_set(config , JOB_SCRIPT_KEY)) - site_config_set_job_script( site_config , config_iget( config , JOB_SCRIPT_KEY , 0 , 0)); + site_config_set_job_script( site_config , config_get_value_as_abspath( config , JOB_SCRIPT_KEY)); if (config_item_set(config , LICENSE_PATH_KEY)) - site_config_set_license_root_path( site_config , config_iget( config , LICENSE_PATH_KEY , 0 , 0)); + site_config_set_license_root_path( site_config , config_get_value_as_abspath( config , LICENSE_PATH_KEY)); - if (user_config) - site_config_install_job_queue( site_config ); + site_config_install_job_queue( site_config ); /* Setting QUEUE_OPTIONS */ { int i; for (i=0; i < config_get_occurences(config , QUEUE_OPTION_KEY); i++) { - stringlist_type * tokens = config_iget_stringlist_ref(config , QUEUE_OPTION_KEY , i); + const stringlist_type * tokens = config_iget_stringlist_ref(config , QUEUE_OPTION_KEY , i); const char * driver_name = stringlist_iget( tokens , 0 ); const char * option_key = stringlist_iget( tokens , 1 ); const char * option_value = stringlist_alloc_joined_substring( tokens , 2 , stringlist_get_size( tokens ), " "); @@ -829,6 +850,7 @@ void site_config_init(site_config_type * site_config , const config_type * confi site_config_set_queue_option( site_config , driver_name , option_key , option_value ); } } + return true; } @@ -989,7 +1011,7 @@ void site_config_fprintf_config( const site_config_type * site_config , FILE * s { queue_driver_type * rsh_driver = site_config_get_queue_driver( site_config , RSH_DRIVER_NAME ); - const hash_type * host_list = queue_driver_get_option( rsh_driver , RSH_HOSTLIST ); + hash_type * host_list = queue_driver_get_option( rsh_driver , RSH_HOSTLIST ); hash_iter_type * iter = hash_iter_alloc( host_list ); while (!hash_iter_is_complete( iter )) { const char * host_name = hash_iter_get_next_key( iter ); @@ -1006,18 +1028,15 @@ void site_config_fprintf_config( const site_config_type * site_config , FILE * s /*****************************************************************/ - -void site_config_add_config_items( config_type * config , bool site_only) { - config_schema_item_type * item; - - item = config_add_schema_item(config , QUEUE_SYSTEM_KEY , site_only , false); - config_schema_item_set_argc_minmax(item , 1 , 1 , 0 , NULL); +void site_config_add_queue_config_items( config_type * config , bool site_mode) { + config_schema_item_type * item = config_add_schema_item(config , QUEUE_SYSTEM_KEY , site_mode); + config_schema_item_set_argc_minmax(item , 1 , 1); { stringlist_type * lsf_dep = stringlist_alloc_argv_ref( (const char *[2]) {"LSF_QUEUE" , "MAX_RUNNING_LSF"} , 2); stringlist_type * rsh_dep = stringlist_alloc_argv_ref( (const char *[3]) {"RSH_HOST" , "RSH_COMMAND" , "MAX_RUNNING_RSH"} , 2); stringlist_type * local_dep = stringlist_alloc_argv_ref( (const char *[1]) {"MAX_RUNNING_LOCAL"} , 1); - if (site_only) { + if (site_mode) { config_schema_item_set_common_selection_set( item , 3 , (const char *[3]) {LSF_DRIVER_NAME , LOCAL_DRIVER_NAME , RSH_DRIVER_NAME}); config_schema_item_set_required_children_on_value( item , LSF_DRIVER_NAME , lsf_dep); config_schema_item_set_required_children_on_value( item , RSH_DRIVER_NAME , rsh_dep); @@ -1029,75 +1048,92 @@ void site_config_add_config_items( config_type * config , bool site_only) { stringlist_free(local_dep); } - item = config_add_schema_item(config , MAX_SUBMIT_KEY , false , false); - config_schema_item_set_argc_minmax(item , 1 , 1 , 1 , (const config_item_types [1]) {CONFIG_INT}); + item = config_add_schema_item(config , MAX_SUBMIT_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1); + config_schema_item_iset_type( item , 0 , CONFIG_INT ); +} + + +void site_config_add_config_items( config_type * config , bool site_mode) { + config_schema_item_type * item; + ert_workflow_list_add_config_items( config ); + site_config_add_queue_config_items( config , site_mode ); + + /* You can set environment variables which will be applied to the run-time environment. Can unfortunately not use constructions like PATH=$PATH:/some/new/path, use the UPDATE_PATH function instead. */ - item = config_add_schema_item(config , SETENV_KEY , false , true); - config_schema_item_set_argc_minmax(item , 2 , 2 , 0 , NULL); + item = config_add_schema_item(config , SETENV_KEY , false ); + config_schema_item_set_argc_minmax(item , 2 , 2 ); config_schema_item_set_envvar_expansion( item , false ); /* Do not expand $VAR expressions (that is done in util_interp_setenv()). */ - item = config_add_schema_item(config , UMASK_KEY , false , false); - config_schema_item_set_argc_minmax(item , 1 , 1 , 0 , NULL); + item = config_add_schema_item(config , UMASK_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1 ); /** UPDATE_PATH LD_LIBRARY_PATH /path/to/some/funky/lib Will prepend "/path/to/some/funky/lib" at the front of LD_LIBRARY_PATH. */ - item = config_add_schema_item(config , UPDATE_PATH_KEY , false , true); - config_schema_item_set_argc_minmax(item , 2 , 2 , 0 , NULL); + item = config_add_schema_item(config , UPDATE_PATH_KEY , false ); + config_schema_item_set_argc_minmax(item , 2 , 2 ); config_schema_item_set_envvar_expansion( item , false ); /* Do not expand $VAR expressions (that is done in util_interp_setenv()). */ - item = config_add_schema_item( config , LICENSE_PATH_KEY , site_only , false ); - config_schema_item_set_argc_minmax(item , 1 , 1, 0 , NULL ); + item = config_add_schema_item( config , LICENSE_PATH_KEY , site_mode ); + config_schema_item_set_argc_minmax(item , 1 , 1 ); + config_schema_item_iset_type( item , 0 , CONFIG_PATH ); /*****************************************************************/ /* Items related to running jobs with lsf/rsh/local ... */ /* These must be set IFF QUEUE_SYSTEM == LSF */ - item = config_add_schema_item(config , LSF_QUEUE_KEY , false , false); - config_schema_item_set_argc_minmax(item , 1 , 1 , 0 , NULL); + item = config_add_schema_item(config , LSF_QUEUE_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1); - item = config_add_schema_item(config , LSF_RESOURCES_KEY , false , false); - config_schema_item_set_argc_minmax(item , 1 , -1 , 0 , NULL); + item = config_add_schema_item(config , LSF_RESOURCES_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , CONFIG_DEFAULT_ARG_MAX); - item = config_add_schema_item(config , MAX_RUNNING_LSF_KEY , false , false); - config_schema_item_set_argc_minmax(item , 1 , 1 , 1 , (const config_item_types [1]) {CONFIG_INT}); + item = config_add_schema_item(config , MAX_RUNNING_LSF_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1 ); + config_schema_item_iset_type( item , 0 , CONFIG_INT ); - item = config_add_schema_item(config , LSF_SERVER_KEY , false , false); - config_schema_item_set_argc_minmax(item , 1 , 1 , 1 , (const config_item_types [1]) {CONFIG_STRING}); + item = config_add_schema_item(config , LSF_SERVER_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1 ); /* These must be set IFF QUEUE_SYSTEM == RSH */ - if (!site_only) - config_add_schema_item(config , RSH_HOST_KEY , false , false); /* Only added when user parse. */ - item = config_add_schema_item(config , RSH_COMMAND_KEY , false , false); - config_schema_item_set_argc_minmax(item , 1 , 1 , 1 , (const config_item_types [1]) {CONFIG_EXECUTABLE}); - item = config_add_schema_item(config , MAX_RUNNING_RSH_KEY , false , false); - config_schema_item_set_argc_minmax(item , 1 , 1 , 1 , (const config_item_types [1]) {CONFIG_INT}); + if (!site_mode) + config_add_schema_item(config , RSH_HOST_KEY , false ); /* Only added when user parse. */ + item = config_add_schema_item(config , RSH_COMMAND_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1 ); + config_schema_item_iset_type( item , 0 , CONFIG_EXECUTABLE); + item = config_add_schema_item(config , MAX_RUNNING_RSH_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1); + config_schema_item_iset_type( item , 0 , CONFIG_INT); /* These must be set IFF QUEUE_SYSTEM == LOCAL */ - item = config_add_schema_item(config , MAX_RUNNING_LOCAL_KEY , false , false); - config_schema_item_set_argc_minmax(item , 1 , 1 , 1 , (const config_item_types [1]) {CONFIG_INT}); + item = config_add_schema_item(config , MAX_RUNNING_LOCAL_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , 1 ); + config_schema_item_iset_type( item , 0 , CONFIG_INT); /*****************************************************************/ - item = config_add_schema_item(config , QUEUE_OPTION_KEY , false , true); - config_schema_item_set_argc_minmax(item , 3 , -1 , 0 , NULL); + item = config_add_schema_item(config , QUEUE_OPTION_KEY , false ); + config_schema_item_set_argc_minmax(item , 3 , CONFIG_DEFAULT_ARG_MAX); - item = config_add_schema_item(config , JOB_SCRIPT_KEY , site_only , false); - config_schema_item_set_argc_minmax(item , 1 , 1 , 1 , (const config_item_types [1]) {CONFIG_EXISTING_FILE}); + item = config_add_schema_item(config , JOB_SCRIPT_KEY , site_mode ); + config_schema_item_set_argc_minmax(item , 1 , 1); + config_schema_item_iset_type( item , 0 , CONFIG_EXISTING_PATH); + + item = config_add_schema_item(config , INSTALL_JOB_KEY , false ); + config_schema_item_set_argc_minmax(item , 2 , 2 ); + config_schema_item_iset_type( item , 1 , CONFIG_EXISTING_PATH); - item = config_add_schema_item(config , INSTALL_JOB_KEY , false , true); - config_schema_item_set_argc_minmax(item , 2 , 2 , 2 , (const config_item_types [2]) {CONFIG_STRING , CONFIG_EXISTING_FILE}); - /* Items related to the reports. */ - item = config_add_schema_item( config , REPORT_SEARCH_PATH_KEY , false , true ); - config_schema_item_set_argc_minmax(item , 1 , -1 , 0 , NULL); + item = config_add_schema_item( config , REPORT_SEARCH_PATH_KEY , false ); + config_schema_item_set_argc_minmax(item , 1 , CONFIG_DEFAULT_ARG_MAX); } diff --git a/ThirdParty/Ert/devel/libenkf/src/time_map.c b/ThirdParty/Ert/devel/libenkf/src/time_map.c index 9b5595d85a..7302484f19 100644 --- a/ThirdParty/Ert/devel/libenkf/src/time_map.c +++ b/ThirdParty/Ert/devel/libenkf/src/time_map.c @@ -23,6 +23,7 @@ #include #include +#include #include @@ -31,21 +32,31 @@ #define DEFAULT_TIME -1 +#define TIME_MAP_TYPE_ID 7751432 struct time_map_struct { + UTIL_TYPE_ID_DECLARATION; time_t_vector_type * map; - time_t start_time; pthread_rwlock_t rw_lock; + bool modified; }; +UTIL_SAFE_CAST_FUNCTION( time_map , TIME_MAP_TYPE_ID ) + time_map_type * time_map_alloc( ) { time_map_type * map = util_malloc( sizeof * map ); + UTIL_TYPE_ID_INIT( map , TIME_MAP_TYPE_ID ); + map->map = time_t_vector_alloc(0 , DEFAULT_TIME ); - map->start_time = DEFAULT_TIME; + map->modified = false; pthread_rwlock_init( &map->rw_lock , NULL); return map; } +bool time_map_equal( const time_map_type * map1 , const time_map_type * map2) { + return time_t_vector_equal( map1->map , map2->map ); +} + void time_map_free( time_map_type * map ) { time_t_vector_free( map->map ); @@ -57,32 +68,25 @@ void time_map_free( time_map_type * map ) { Must hold the write lock. */ -static void time_map_update__( time_map_type * map , int step , time_t time) { + +static bool time_map_update__( time_map_type * map , int step , time_t time) { + bool updateOK = true; time_t current_time = time_t_vector_safe_iget( map->map , step); if (current_time == DEFAULT_TIME) time_t_vector_iset( map->map , step , time ); - else { - if (current_time != time) { - int current[3]; - int new[3]; - - util_set_date_values( current_time , ¤t[0] , ¤t[1] , ¤t[2]); - util_set_date_values( time , &new[0] , &new[1] , &new[2]); - - util_abort("%s: time mismatch for step:%d New: %02d/%02d/%04d existing: %02d/%02d/%04d \n",__func__ , step , - new[0] , new[1] , new[2] , - current[0] , current[1] , current[2]); - - } - } + else if (current_time != time) + updateOK = false; - if (step == 0) - map->start_time = time; + if (updateOK) + map->modified = true; + + return updateOK; } -static void time_map_summary_update__( time_map_type * map , const ecl_sum_type * ecl_sum) { +static bool time_map_summary_update__( time_map_type * map , const ecl_sum_type * ecl_sum) { + bool updateOK = true; int first_step = ecl_sum_get_first_report_step( ecl_sum ); int last_step = ecl_sum_get_last_report_step( ecl_sum ); int step; @@ -90,10 +94,11 @@ static void time_map_summary_update__( time_map_type * map , const ecl_sum_type for (step = first_step; step <= last_step; step++) { if (ecl_sum_has_report_step(ecl_sum , step)) { time_t time = ecl_sum_get_report_time( ecl_sum , step ); - time_map_update__( map , step , time ); + updateOK = (updateOK && time_map_update__( map , step , time )); } } - time_map_update__(map , 0 , ecl_sum_get_start_time( ecl_sum )); + updateOK = (updateOK && time_map_update__(map , 0 , ecl_sum_get_start_time( ecl_sum ))); + return updateOK; } @@ -113,9 +118,9 @@ double time_map_iget_sim_days( time_map_type * map , int step ) { time_t sim_time = time_map_iget__( map , step ); if (sim_time >= start_time) - return 1.0 * (sim_time - start_time) / (3600 * 24); + days = 1.0 * (sim_time - start_time) / (3600 * 24); else - return -1; + days = -1; } pthread_rwlock_unlock( &map->rw_lock ); @@ -133,33 +138,32 @@ time_t time_map_iget( time_map_type * map , int step ) { return t; } -void time_map_update( time_map_type * map , int step , time_t time) { - pthread_rwlock_wrlock( &map->rw_lock ); - time_map_update__( map , step , time ); - pthread_rwlock_unlock( &map->rw_lock ); -} -void time_map_summary_update( time_map_type * map , const ecl_sum_type * ecl_sum) { - pthread_rwlock_wrlock( &map->rw_lock ); - time_map_summary_update__( map , ecl_sum ); - pthread_rwlock_unlock( &map->rw_lock ); -} +/** + Observe that the locking is opposite of the function name; i.e. + the time_map_fwrite() function reads the time_map and takes the + read lock, whereas the time_map_fread() function takes the write + lock. +*/ void time_map_fwrite( time_map_type * map , const char * filename ) { - pthread_rwlock_wrlock( &map->rw_lock ); + pthread_rwlock_rdlock( &map->rw_lock ); { - FILE * stream = util_fopen(filename , "w"); - time_t_vector_fwrite( map->map , stream ); - fclose( stream ); -} + if (map->modified) { + FILE * stream = util_mkdir_fopen(filename , "w"); + time_t_vector_fwrite( map->map , stream ); + fclose( stream ); + } + map->modified = false; + } pthread_rwlock_unlock( &map->rw_lock ); } void time_map_fread( time_map_type * map , const char * filename) { - pthread_rwlock_rdlock( &map->rw_lock ); + pthread_rwlock_wrlock( &map->rw_lock ); { if (util_file_exists( filename )) { FILE * stream = util_fopen( filename , "r"); @@ -173,6 +177,8 @@ void time_map_fread( time_map_type * map , const char * filename) { } } pthread_rwlock_unlock( &map->rw_lock ); + time_map_get_last_step( map ); + map->modified = false; } @@ -189,6 +195,102 @@ int time_map_get_last_step( time_map_type * map) { pthread_rwlock_rdlock( &map->rw_lock ); last_step = time_t_vector_size( map->map ) - 1; pthread_rwlock_unlock( &map->rw_lock ); - + return last_step; } + +int time_map_get_size( time_map_type * map) { + return time_map_get_last_step( map ); +} + + +time_t time_map_get_start_time( time_map_type * map) { + return time_map_iget( map , 0 ); +} + + +time_t time_map_get_end_time( time_map_type * map) { + int last_step = time_map_get_last_step( map ); + return time_map_iget( map , last_step ); +} + +double time_map_get_end_days( time_map_type * map) { + int last_step = time_map_get_last_step( map ); + return time_map_iget_sim_days( map , last_step ); +} + +/*****************************************************************/ + +bool time_map_update( time_map_type * map , int step , time_t time) { + bool updateOK; + pthread_rwlock_wrlock( &map->rw_lock ); + { + updateOK = time_map_update__( map , step , time ); + } + pthread_rwlock_unlock( &map->rw_lock ); + return updateOK; +} + + +bool time_map_summary_update( time_map_type * map , const ecl_sum_type * ecl_sum) { + bool updateOK; + pthread_rwlock_wrlock( &map->rw_lock ); + { + updateOK = time_map_summary_update__( map , ecl_sum ); + } + pthread_rwlock_unlock( &map->rw_lock ); + return updateOK; +} + + +void time_map_clear( time_map_type * map ) { + pthread_rwlock_wrlock( &map->rw_lock ); + { + time_t_vector_reset( map->map ); + map->modified = true; + } + pthread_rwlock_unlock( &map->rw_lock ); +} + +/*****************************************************************/ + +void time_map_update_strict( time_map_type * map , int step , time_t time) { + if (!time_map_update( map , step , time )) { + time_t current_time = time_map_iget__( map , step ); + int current[3]; + int new[3]; + + util_set_date_values( current_time , ¤t[0] , ¤t[1] , ¤t[2]); + util_set_date_values( time , &new[0] , &new[1] , &new[2]); + + util_abort("%s: time mismatch for step:%d New: %02d/%02d/%04d existing: %02d/%02d/%04d \n",__func__ , step , + new[0] , new[1] , new[2] , + current[0] , current[1] , current[2]); + + } +} + +void time_map_summary_update_strict( time_map_type * map , const ecl_sum_type * ecl_sum) { + if (!time_map_summary_update( map , ecl_sum)) { + /* + If the normal summary update fails we just play through all + time steps to pinpoint exactly the step where the update fails. + */ + int first_step = ecl_sum_get_first_report_step( ecl_sum ); + int last_step = ecl_sum_get_last_report_step( ecl_sum ); + int step; + + for (step = first_step; step <= last_step; step++) { + if (ecl_sum_has_report_step(ecl_sum , step)) { + time_t time = ecl_sum_get_report_time( ecl_sum , step ); + time_map_update_strict( map , step , time ); + } + } + } +} + + + + + +/*****************************************************************/ diff --git a/ThirdParty/Ert/devel/libenkf/src/trans_func.c b/ThirdParty/Ert/devel/libenkf/src/trans_func.c index c546741653..344441b068 100644 --- a/ThirdParty/Ert/devel/libenkf/src/trans_func.c +++ b/ThirdParty/Ert/devel/libenkf/src/trans_func.c @@ -77,7 +77,9 @@ static void trans_errf_check(const char * func_name , const arg_pack_type * arg) } - +static double trans_none(double x , const arg_pack_type * arg) { + return x; +} static double trans_const(double x , const arg_pack_type * arg) { @@ -363,6 +365,10 @@ trans_func_type * trans_func_alloc( const char * func_name ) { arg_pack_append_double( trans_func->params , 0 ); trans_func->func = trans_const; } + + if (util_string_equal( func_name , "NONE")) + trans_func->func = trans_const; + if (trans_func->func == NULL) util_exit("%s: Sorry: function name:%s not recognized \n",__func__ , func_name); diff --git a/ThirdParty/Ert/devel/libenkf/tests/CMakeLists.txt b/ThirdParty/Ert/devel/libenkf/tests/CMakeLists.txt new file mode 100644 index 0000000000..a5e5a966b0 --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/tests/CMakeLists.txt @@ -0,0 +1,65 @@ +add_executable( enkf_runpath_list enkf_runpath_list.c ) +target_link_libraries( enkf_runpath_list enkf ) + +add_executable( enkf_site_config enkf_site_config.c ) +target_link_libraries( enkf_site_config enkf ) + +add_executable( enkf_time_map enkf_time_map.c ) +target_link_libraries( enkf_time_map enkf ) + +add_executable( enkf_ensemble_GEN_PARAM enkf_ensemble_GEN_PARAM.c ) +target_link_libraries( enkf_ensemble_GEN_PARAM enkf ) + +add_executable( enkf_ensemble enkf_ensemble.c ) +target_link_libraries( enkf_ensemble enkf ) + +add_executable( enkf_main enkf_main.c ) +target_link_libraries( enkf_main enkf ) +add_test( enkf_main ${EXECUTABLE_OUTPUT_PATH}/enkf_main ) + +add_executable( enkf_iter_config enkf_iter_config.c ) +target_link_libraries( enkf_iter_config enkf ) +add_test( enkf_iter_config ${EXECUTABLE_OUTPUT_PATH}/enkf_iter_config ) + +add_executable( enkf_model_config enkf_model_config.c ) +target_link_libraries( enkf_model_config enkf ) +add_test( enkf_model_config ${EXECUTABLE_OUTPUT_PATH}/enkf_model_config ) + +add_executable( enkf_rng enkf_rng.c ) +target_link_libraries( enkf_rng enkf ) +add_test( enkf_rng ${EXECUTABLE_OUTPUT_PATH}/enkf_rng ${CMAKE_CURRENT_SOURCE_DIR}/data/config/rng) + +add_executable( enkf_report_list enkf_report_list.c ) +target_link_libraries( enkf_report_list enkf ) +add_test( enkf_report_list ${EXECUTABLE_OUTPUT_PATH}/enkf_report_list ${CMAKE_CURRENT_SOURCE_DIR}/data/config/ert_report_list) + +add_executable( enkf_refcase_list enkf_refcase_list.c ) +target_link_libraries( enkf_refcase_list enkf ) +add_test( enkf_refcase_list ${EXECUTABLE_OUTPUT_PATH}/enkf_refcase_list ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat*/ECLIPSE) +add_test( enkf_refcase_list2 ${EXECUTABLE_OUTPUT_PATH}/enkf_refcase_list ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat*/ECLIPSE.*) +set_property( TEST enkf_refcase_list PROPERTY LABELS Statoil ) +set_property( TEST enkf_refcase_list2 PROPERTY LABELS Statoil ) + + +add_executable( enkf_ecl_config enkf_ecl_config.c ) +target_link_libraries( enkf_ecl_config enkf ) +add_test( enkf_ecl_config1 ${EXECUTABLE_OUTPUT_PATH}/enkf_ecl_config ) +add_test( enkf_ecl_config2 ${EXECUTABLE_OUTPUT_PATH}/enkf_ecl_config ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE) +set_property( TEST enkf_ecl_config2 PROPERTY LABELS Statoil ) + +add_executable( enkf_ecl_config_config enkf_ecl_config_config.c ) +target_link_libraries( enkf_ecl_config_config enkf ) +add_test( enkf_ecl_config_config ${EXECUTABLE_OUTPUT_PATH}/enkf_ecl_config_config ${PROJECT_SOURCE_DIR}/test-data/Statoil/config/ecl_config ) +set_property( TEST enkf_ecl_config_config PROPERTY LABELS Statoil ) + +add_test( enkf_runpath_list ${EXECUTABLE_OUTPUT_PATH}/enkf_runpath_list ) +add_test( enkf_site_config ${EXECUTABLE_OUTPUT_PATH}/enkf_site_config /project/res/etc/ERT/site-config) +add_test( enkf_time_map1 ${EXECUTABLE_OUTPUT_PATH}/enkf_time_map ) +add_test( enkf_time_map2 ${EXECUTABLE_OUTPUT_PATH}/enkf_time_map ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST ) +add_test( enkf_ensemble_GEN_PARAM ${EXECUTABLE_OUTPUT_PATH}/enkf_ensemble_GEN_PARAM ${CMAKE_CURRENT_SOURCE_DIR}/data/ensemble/GEN_PARAM ) +add_test( enkf_ensemble ${EXECUTABLE_OUTPUT_PATH}/enkf_ensemble ) + + +set_property( TEST enkf_time_map2 PROPERTY LABELS Statoil ) +set_property( TEST enkf_site_config PROPERTY LABELS Statoil ) + diff --git a/ThirdParty/Ert/devel/libenkf/tests/data/config/ert_report_list b/ThirdParty/Ert/devel/libenkf/tests/data/config/ert_report_list new file mode 100644 index 0000000000..270780b1f1 --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/tests/data/config/ert_report_list @@ -0,0 +1,3 @@ +REPORT_TIMEOUT 167 + +REPORT_LARGE TRUE \ No newline at end of file diff --git a/ThirdParty/Ert/devel/libenkf/tests/data/config/rng b/ThirdParty/Ert/devel/libenkf/tests/data/config/rng new file mode 100644 index 0000000000..64f4d50888 --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/tests/data/config/rng @@ -0,0 +1,6 @@ +NUM_REALIZATIONS 25 +STORE_SEED /tmp/seed2 +LOAD_SEED /tmp/seed2 + +-- The settings below here are artifacts which should not be necessary ... +JOB_SCRIPT /private/joaho/ERT/Statoil/etc/ERT/Scripts/job_dispatch.py diff --git a/ThirdParty/Ert/devel/libenkf/tests/data/ensemble/GEN_PARAM b/ThirdParty/Ert/devel/libenkf/tests/data/ensemble/GEN_PARAM new file mode 100644 index 0000000000..8f2fdaa749 --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/tests/data/ensemble/GEN_PARAM @@ -0,0 +1 @@ +GEN_PARAM GP GP.txt INIT_FILES:GP/GP.txt INPUT_FORMAT:ASCII OUTPUT_FORMAT:ASCII \ No newline at end of file diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_ecl_config.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_ecl_config.c new file mode 100644 index 0000000000..0381e75059 --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_ecl_config.c @@ -0,0 +1,54 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'enkf_ecl_config.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include +#include + +#include + +#include +#include + +int main(int argc , char ** argv) { + ecl_config_type * ecl_config = ecl_config_alloc_empty(); + + if (argc == 2) { + test_assert_true(ecl_config_load_refcase( ecl_config , argv[1])); + + ecl_refcase_list_type * refcase_list = ecl_config_get_refcase_list( ecl_config ); + test_assert_int_equal( ecl_refcase_list_get_size( refcase_list ) , 1 ); + { + const ecl_sum_type * iget0 = ecl_refcase_list_iget_case( refcase_list , 0 ); + const ecl_sum_type * def = ecl_refcase_list_get_default( refcase_list ); + + test_assert_ptr_equal( iget0 , def ); + test_assert_string_equal( argv[1] , ecl_sum_get_case( def )); + test_assert_string_equal( ecl_refcase_list_iget_pathcase( refcase_list , 0) , ecl_sum_get_case( def )); + + } + } + test_assert_false(ecl_config_load_refcase( ecl_config , "DOES_NOT_EXIST" )); + test_assert_true(ecl_config_load_refcase( ecl_config , NULL )); + + + + ecl_config_free( ecl_config ); + exit(0); +} + diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_ecl_config_config.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_ecl_config_config.c new file mode 100644 index 0000000000..c5a052198d --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_ecl_config_config.c @@ -0,0 +1,55 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'enkf_ecl_config_config.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include +#include + +#include +#include +#include + +#include + +#include +#include + +int main(int argc , char ** argv) { + const char * config_file = argv[1]; + + ecl_config_type * ecl_config = ecl_config_alloc_empty(); + ecl_refcase_list_type * refcase_list = ecl_config_get_refcase_list( ecl_config ); + { + config_type * config = config_alloc(); + + ecl_config_add_config_items( config ); + test_assert_true( config_parse( config , config_file , "--" , NULL , NULL , CONFIG_UNRECOGNIZED_WARN , true)); + ecl_config_init( ecl_config , config ); + + config_free( config ); + } + + test_assert_true( ecl_config_has_refcase( ecl_config )); + test_assert_int_equal( ecl_refcase_list_get_size( refcase_list) , 17); + + ecl_config_free( ecl_config ); + + + exit(0); +} + diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_ensemble.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_ensemble.c new file mode 100644 index 0000000000..0c8298781a --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_ensemble.c @@ -0,0 +1,46 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'enkf_ensemble.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include + +#include +#include + + + + + + + +int main(int argc , char ** argv) { + ensemble_config_type * ensemble = ensemble_config_alloc_empty(); + ensemble_config_free( ensemble ); + exit(0); +} + diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_ensemble_GEN_PARAM.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_ensemble_GEN_PARAM.c new file mode 100644 index 0000000000..d515d6fa40 --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_ensemble_GEN_PARAM.c @@ -0,0 +1,55 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'enkf_ensemble_GEN_PARAM.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include + +#include +#include + + + + + + + +int main(int argc , char ** argv) { + const char * config_file = argv[1]; + config_type * config = config_alloc(); + ensemble_config_type * ensemble = ensemble_config_alloc_empty(); + + ensemble_config_add_GEN_PARAM_config_item( config ); + test_assert_true( config_parse( config , config_file , "--" , NULL , NULL , CONFIG_UNRECOGNIZED_WARN , true ) ); + + ensemble_config_init_GEN_PARAM( ensemble, config ); + + config_free( config ); + ensemble_config_free( ensemble ); + exit(0); +} + diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_iter_config.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_iter_config.c new file mode 100644 index 0000000000..8232c59bff --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_iter_config.c @@ -0,0 +1,79 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'enkf_iter_config.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include +#include + +#include + +#include +#include +#include +#include + +#include +#include + + +#define TMP_PATH "/tmp" +char * create_config_file( const char * enspath_fmt , const char * runpath_fmt , int iter_count) { + char * config_file = util_alloc_tmp_file(TMP_PATH , "iter-config" , false); + FILE * stream = util_fopen( config_file , "w"); + fprintf(stream , "%s %s\n" , ITER_CASE_KEY , enspath_fmt); + fprintf(stream , "%s %s\n" , ITER_RUNPATH_KEY , runpath_fmt); + fprintf(stream , "%s %d\n" , ITER_COUNT_KEY , iter_count); + fclose( stream ); + return config_file; +} + + +int main(int argc , char ** argv) { + const char * enspath_fmt = "iter%d"; + const char * runpath_fmt = "run/iter%d/real%d"; + const int iter_count = 10; + char * config_file = create_config_file( enspath_fmt , runpath_fmt , iter_count); + + + config_type * config = config_alloc(); + analysis_iter_config_add_config_items( config ); + + test_assert_true( config_parse( config , config_file , NULL , NULL , NULL , CONFIG_UNRECOGNIZED_ERROR , true)); + + test_assert_true( config_item_set( config , ITER_CASE_KEY )); + test_assert_true( config_item_set( config , ITER_RUNPATH_KEY )); + test_assert_true( config_item_set( config , ITER_COUNT_KEY )); + + { + analysis_iter_config_type * iter_config = analysis_iter_config_alloc(); + test_assert_string_equal( analysis_iter_config_iget_case( iter_config , 5) , NULL ); + test_assert_string_equal( analysis_iter_config_iget_runpath_fmt( iter_config , 5) , NULL ); + + analysis_iter_config_init( iter_config , config ); + + test_assert_int_equal( analysis_iter_config_get_num_iterations( iter_config ) , iter_count ); + test_assert_string_equal( analysis_iter_config_iget_case( iter_config , 5) , "iter5"); + test_assert_string_equal( analysis_iter_config_iget_runpath_fmt( iter_config , 5) , "run/iter5/real%d" ); + + analysis_iter_config_free( iter_config ); + } + remove( config_file ); + free( config_file ); + config_free( config ); + exit(0); +} diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_main.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_main.c new file mode 100644 index 0000000000..5c8ac55eb4 --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_main.c @@ -0,0 +1,33 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'enkf_main.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include +#include + +#include + + +int main(int argc , char ** argv) { + { + enkf_main_type * enkf_main = enkf_main_alloc_empty(); + enkf_main_free( enkf_main ); + } + exit(0); +} + diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_model_config.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_model_config.c new file mode 100644 index 0000000000..519b51917d --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_model_config.c @@ -0,0 +1,31 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'enkf_model_config.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include +#include + +#include + + +int main(int argc , char ** argv) { + model_config_type * model_config = model_config_alloc_empty(); + model_config_free( model_config ); + exit(0); +} + diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_refcase_list.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_refcase_list.c new file mode 100644 index 0000000000..c247f69bf1 --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_refcase_list.c @@ -0,0 +1,128 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'enkf_refcase_list.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include +#include + +#include +#include +#include +#include +#include + +#include + +#include + +#include +#include + +#include + + +int main(int argc , char ** argv) { + const char * case1 = argv[1]; + const char * case_glob = argv[2]; + + { + ecl_refcase_list_type * refcase_list = ecl_refcase_list_alloc( ); + + test_assert_false( ecl_refcase_list_has_case( refcase_list , "DoesNotExist" )); + test_assert_NULL( ecl_refcase_list_get_case( refcase_list , "DoesNotExist")); + + test_assert_int_equal( ecl_refcase_list_add_matching( refcase_list , "DoesNotExist") , 0); + ecl_refcase_list_add_case( refcase_list , "DoesNotExist" ); + test_assert_false( ecl_refcase_list_has_case( refcase_list , "DoesNotExist")); + + ecl_refcase_list_add_case( refcase_list , case1 ); + test_assert_true( ecl_refcase_list_has_case( refcase_list , case1)); + + + test_assert_not_NULL( refcase_list ); + test_assert_false( ecl_refcase_list_has_default( refcase_list )); + test_assert_NULL( ecl_refcase_list_get_default( refcase_list )); + + test_assert_false( ecl_refcase_list_set_default( refcase_list , "DoesNotExist")); + test_assert_false( ecl_refcase_list_has_default( refcase_list )); + test_assert_NULL( ecl_refcase_list_get_default( refcase_list )); + test_assert_int_equal( 1 , ecl_refcase_list_get_size( refcase_list )); + + test_assert_true( ecl_refcase_list_set_default( refcase_list , case1)); + test_assert_true( ecl_refcase_list_has_default( refcase_list )); + test_assert_not_NULL( ecl_refcase_list_get_default( refcase_list )); + test_assert_int_equal( 1 , ecl_refcase_list_get_size( refcase_list )); + + test_assert_false( ecl_refcase_list_set_default( refcase_list , "DoesNotExist")); + test_assert_true( ecl_refcase_list_has_default( refcase_list )); + test_assert_not_NULL( ecl_refcase_list_get_default( refcase_list )); + test_assert_int_equal( 1 , ecl_refcase_list_get_size( refcase_list )); + test_assert_NULL( ecl_refcase_list_iget_case( refcase_list , 100)); + + ecl_refcase_list_free( refcase_list ); + } + + { + ecl_refcase_list_type * refcase_list = ecl_refcase_list_alloc( ); + test_assert_int_equal( ecl_refcase_list_add_matching( refcase_list , case_glob ) , 11); + test_assert_int_equal( 11 , ecl_refcase_list_get_size( refcase_list )); + + test_assert_true( ecl_refcase_list_set_default( refcase_list , case1)); + test_assert_true( ecl_refcase_list_has_default( refcase_list )); + test_assert_not_NULL( ecl_refcase_list_get_default( refcase_list )); + test_assert_int_equal( 11 , ecl_refcase_list_get_size( refcase_list )); + + test_assert_int_equal( ecl_refcase_list_add_matching( refcase_list , case_glob ) , 0); + test_assert_int_equal( ecl_refcase_list_add_matching( refcase_list , case_glob ) , 0); + { + const ecl_sum_type * ecl_sum = ecl_refcase_list_iget_case( refcase_list , 0 ); + test_assert_not_NULL( ecl_sum ); + } + test_assert_int_equal( 11 , ecl_refcase_list_get_size( refcase_list )); + + { + stringlist_type * case_list = stringlist_alloc_new( ); + const int N = ecl_refcase_list_get_size( refcase_list ); + int i; + for (i=0; i < N; i++) + stringlist_append_ref( case_list , ecl_refcase_list_iget_pathcase( refcase_list , N - 1 - i )); + + { + bool equal = true; + for (i=0; i < N; i++) + equal = equal && util_string_equal( stringlist_iget( case_list , i ) , ecl_refcase_list_iget_pathcase( refcase_list , i)); + + test_assert_false( equal ); + stringlist_sort( case_list , util_strcmp_int); + + equal = true; + for (i=0; i < N; i++) + equal = equal && util_string_equal( stringlist_iget( case_list , i ) , ecl_refcase_list_iget_pathcase( refcase_list , i)); + test_assert_true( equal ); + } + + } + ecl_refcase_list_add_matching( refcase_list , "DoesNotExist*"); + test_assert_int_equal( 11 , ecl_refcase_list_get_size( refcase_list )); + ecl_refcase_list_free( refcase_list ); + } + + + exit(0); +} + diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_report_list.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_report_list.c new file mode 100644 index 0000000000..fa2fe1d285 --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_report_list.c @@ -0,0 +1,44 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'enkf_main.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include +#include + +#include + +#include + +#include + +int main(int argc , char ** argv) { + config_type * config = config_alloc(); + ert_report_list_type * report_list = ert_report_list_alloc( NULL , NULL ); + + test_assert_not_NULL( report_list ); + ert_report_list_add_config_items( config ); + test_assert_true( config_parse( config , argv[1] , "--" , NULL, NULL , CONFIG_UNRECOGNIZED_IGNORE , true )); + ert_report_list_init( report_list , config , NULL); + + test_assert_int_equal( 167 , ert_report_list_get_latex_timeout( report_list )); + test_assert_true( ert_report_list_get_init_large_report( report_list )); + + ert_report_list_free( report_list ); + exit(0); +} + diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_rng.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_rng.c new file mode 100644 index 0000000000..98e31631cc --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_rng.c @@ -0,0 +1,118 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'enkf_rng.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include +#include + +#include + +#include +#include +#include + +int main(int argc , char ** argv) { + unsigned int rand1,rand2; + { + { + enkf_main_type * enkf_main = enkf_main_alloc_empty(); + enkf_main_resize_ensemble( enkf_main , 10 ); + { + enkf_state_type * state = enkf_main_iget_state( enkf_main , 9 ); + rand1 = enkf_state_get_random( state ); + } + enkf_main_free( enkf_main ); + } + + { + enkf_main_type * enkf_main = enkf_main_alloc_empty(); + enkf_main_resize_ensemble( enkf_main , 10 ); + { + enkf_state_type * state = enkf_main_iget_state( enkf_main , 9 ); + rand2 = enkf_state_get_random( state ); + } + enkf_main_free( enkf_main ); + } + test_assert_uint_not_equal( rand1 , rand2 ); + } + + /*****************************************************************/ + + { + const char * seed_file = "/tmp/seed"; + { + enkf_main_type * enkf_main = enkf_main_alloc_empty(); + { + rng_config_type * rng_config = enkf_main_get_rng_config( enkf_main ); + rng_config_set_seed_store_file( rng_config , seed_file ); + } + enkf_main_rng_init( enkf_main ); + + enkf_main_resize_ensemble( enkf_main , 10 ); + { + enkf_state_type * state = enkf_main_iget_state( enkf_main , 9 ); + rand1 = enkf_state_get_random( state ); + } + enkf_main_free( enkf_main ); + } + + { + enkf_main_type * enkf_main = enkf_main_alloc_empty(); + { + rng_config_type * rng_config = enkf_main_get_rng_config( enkf_main ); + rng_config_set_seed_load_file( rng_config , seed_file ); + } + enkf_main_rng_init( enkf_main ); + + enkf_main_resize_ensemble( enkf_main , 10 ); + { + enkf_state_type * state = enkf_main_iget_state( enkf_main , 9 ); + rand2 = enkf_state_get_random( state ); + } + enkf_main_free( enkf_main ); + } + test_assert_uint_equal( rand1 , rand2 ); + } + /*****************************************************************/ + { + { + enkf_main_type * enkf_main = enkf_main_bootstrap( NULL , argv[1] , true , true ); + enkf_state_type * state = enkf_main_iget_state( enkf_main , 9 ); + rand1 = enkf_state_get_random( state ); + enkf_main_free( enkf_main ); + } + + { + enkf_main_type * enkf_main = enkf_main_bootstrap( NULL , argv[1] , true , true ); + enkf_state_type * state = enkf_main_iget_state( enkf_main , 9 ); + rand2 = enkf_state_get_random( state ); + enkf_main_free( enkf_main ); + } + test_assert_uint_equal( rand1 , rand2 ); + + { + enkf_main_type * enkf_main = enkf_main_bootstrap( NULL , argv[1] , true , true ); + enkf_state_type * state = enkf_main_iget_state( enkf_main , 9 ); + rand2 = enkf_state_get_random( state ); + enkf_main_free( enkf_main ); + } + test_assert_uint_equal( rand1 , rand2 ); + } + exit(0); +} + diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_runpath_list.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_runpath_list.c new file mode 100644 index 0000000000..4fe6d9676a --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_runpath_list.c @@ -0,0 +1,126 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'enkf_runpath_list.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include +#include + +#include +#include +#include +#include + +#include + +void * add_pathlist( void * arg ) { + arg_pack_type * arg_pack = arg_pack_safe_cast( arg ); + runpath_list_type * list = arg_pack_iget_ptr( arg_pack , 0 ); + int offset = arg_pack_iget_int( arg_pack , 1 ); + int bs = arg_pack_iget_int( arg_pack , 2 ); + + int i; + for (i=0; i < bs; i++) + runpath_list_add( list , i + offset , "Path" , "Basename"); + + return NULL; +} + + + + +int main(int argc , char ** argv) { + + runpath_list_type * list = runpath_list_alloc(); + + test_assert_int_equal( runpath_list_size( list ) , 0 ); + + runpath_list_add( list , 3 , "path" , "base"); + runpath_list_add( list , 2 , "path" , "base"); + runpath_list_add( list , 1 , "path" , "base"); + + test_assert_int_equal( runpath_list_size( list ) , 3 ); + test_assert_int_equal( runpath_list_iget_iens( list , 0 ) , 3 ); + test_assert_int_equal( runpath_list_iget_iens( list , 2 ) , 1 ); + runpath_list_sort( list ); + + test_assert_int_equal( runpath_list_iget_iens( list , 0 ) , 1 ); + test_assert_int_equal( runpath_list_iget_iens( list , 2 ) , 3 ); + runpath_list_clear( list ); + test_assert_int_equal( runpath_list_size( list ) , 0 ); + + test_assert_string_equal( runpath_list_get_line_fmt( list ) , RUNPATH_LIST_DEFAULT_LINE_FMT ); + { + const char * other_line = "%d %s %s"; + runpath_list_set_line_fmt( list , other_line ); + test_assert_string_equal( runpath_list_get_line_fmt( list ) , other_line ); + } + runpath_list_set_line_fmt( list , NULL ); + test_assert_string_equal( runpath_list_get_line_fmt( list ) , RUNPATH_LIST_DEFAULT_LINE_FMT ); + + { + const int block_size = 100; + const int threads = 100; + thread_pool_type * tp = thread_pool_alloc( threads , true ); + int it; + + for (it = 0; it < threads; it++) { + int iens_offset = it * block_size; + arg_pack_type * arg_pack = arg_pack_alloc(); + + arg_pack_append_ptr( arg_pack , list ); + arg_pack_append_int( arg_pack , iens_offset ); + arg_pack_append_int( arg_pack , block_size ); + + thread_pool_add_job( tp , add_pathlist , arg_pack ); + } + thread_pool_join( tp ); + test_assert_int_equal( runpath_list_size( list ) , block_size * threads ); + runpath_list_sort( list ); + { + int iens; + for (iens = 0; iens < block_size * threads; iens++) + test_assert_int_equal( runpath_list_iget_iens( list , iens ) , iens ); + } + + { + const char *filename = "/tmp/runpath_list.txt"; + { + FILE * stream = util_fopen( filename, "w"); + runpath_list_fprintf( list , stream ); + fclose( stream ); + } + + { + int file_iens; + char file_path[256]; + char file_base[256]; + int iens; + FILE * stream = util_fopen( filename, "r"); + for (iens = 0; iens < threads * block_size; iens++) { + int fscanf_return = fscanf( stream , "%d %s %s" , &file_iens , file_path , file_base); + test_assert_int_equal(fscanf_return, 3 ); + test_assert_int_equal( file_iens , iens ); + } + fclose( stream ); + } + } + } + runpath_list_free( list ); + exit(0); +} + diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_site_config.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_site_config.c new file mode 100644 index 0000000000..0f1f672d74 --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_site_config.c @@ -0,0 +1,73 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'enkf_site_config.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include + +#include + + +#include + + + + +#define INCLUDE_KEY "INCLUDE" +#define DEFINE_KEY "DEFINE" + + +void test_empty() { + site_config_type * site_config = site_config_alloc_empty(); + site_config_free( site_config ); +} + + +void test_init(const char * config_file) { + site_config_type * site_config = site_config_alloc_empty(); + config_type * config = config_alloc(); + + site_config_add_config_items( config , true ); + if (!config_parse(config , config_file , "--" , INCLUDE_KEY , DEFINE_KEY , CONFIG_UNRECOGNIZED_WARN , true)) + test_error_exit("Parsing site config file:%s failed \n",config_file ); + + if (!site_config_init( site_config , config )) + test_error_exit("Loading site_config from config failed\n"); + + config_free( config ); + site_config_free( site_config ); +} + + +int main(int argc , char ** argv) { + const char * site_config_file = argv[1]; + test_empty(); + test_init( site_config_file ); + + exit(0); +} + diff --git a/ThirdParty/Ert/devel/libenkf/tests/enkf_time_map.c b/ThirdParty/Ert/devel/libenkf/tests/enkf_time_map.c new file mode 100644 index 0000000000..21c6d50f9b --- /dev/null +++ b/ThirdParty/Ert/devel/libenkf/tests/enkf_time_map.c @@ -0,0 +1,133 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'enkf_time_map.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include +#include + +#include +#include +#include +#include + +#include + +#include + + + +void ecl_test( const char * ecl_case ) { + ecl_sum_type * ecl_sum = ecl_sum_fread_alloc_case( ecl_case , ":"); + time_t start_time = ecl_sum_get_start_time( ecl_sum ); + time_t end_time = ecl_sum_get_end_time( ecl_sum ); + time_map_type * ecl_map = time_map_alloc( ); + + test_assert_true( time_map_summary_update( ecl_map , ecl_sum ) ); + test_assert_true( time_map_summary_update( ecl_map , ecl_sum ) ); + + test_assert_time_t_equal( time_map_get_start_time( ecl_map ) , start_time ); + test_assert_time_t_equal( time_map_get_end_time( ecl_map ) , end_time ); + test_assert_double_equal( time_map_get_end_days( ecl_map ) , ecl_sum_get_sim_length( ecl_sum )); + + time_map_clear( ecl_map ); + time_map_update( ecl_map , 1 , 256 ); + test_assert_false( time_map_summary_update( ecl_map , ecl_sum )); + + time_map_free( ecl_map ); + ecl_sum_free( ecl_sum ); +} + + + +void simple_test() { +time_map_type * time_map = time_map_alloc( ); + const char * mapfile = "/tmp/map"; + + test_assert_true( time_map_update( time_map , 0 , 100 ) ); + test_assert_true( time_map_update( time_map , 1 , 200 ) ); + test_assert_true( time_map_update( time_map , 1 , 200 ) ); + test_assert_false( time_map_update( time_map , 1 , 250 ) ); + + test_assert_true( time_map_equal( time_map , time_map ) ); + time_map_fwrite( time_map , mapfile); + { + time_map_type * time_map2 = time_map_alloc( ); + + test_assert_false( time_map_equal( time_map , time_map2 ) ); + time_map_fread( time_map2 , mapfile ); + test_assert_true( time_map_equal( time_map , time_map2 ) ); + time_map_free( time_map2 ); + } + { + time_t mtime1 = util_file_mtime( mapfile ); + sleep(2); + time_map_fwrite( time_map , mapfile); + + test_assert_time_t_equal( mtime1 , util_file_mtime( mapfile ) ); + time_map_update( time_map , 2 , 300 ); + time_map_fwrite( time_map , mapfile); + test_assert_time_t_not_equal( mtime1 , util_file_mtime( mapfile ) ); + } +} + + +#define MAP_SIZE 10000 + +void * update_time_map( void * arg ) { + time_map_type * time_map = time_map_safe_cast( arg ); + int i; + for (i=0; i < MAP_SIZE; i++) + time_map_update( time_map , i , i ); + return NULL; +} + + +void thread_test() { + time_map_type * time_map = time_map_alloc( ); + + { + int pool_size = 1000; + thread_pool_type * tp = thread_pool_alloc( pool_size/2 , true ); + + thread_pool_add_job( tp , update_time_map , time_map ); + + thread_pool_join(tp); + thread_pool_free(tp); + } + { + int i; + for (i=0; i < MAP_SIZE; i++) + test_assert_true( time_map_iget( time_map , i ) == i ); + } + time_map_free( time_map ); +} + + +int main(int argc , char ** argv) { + + if (argc == 1) { + simple_test(); + thread_test(); + } else + ecl_test( argv[1] ); + + + + exit(0); +} + diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/CMakeLists.txt b/ThirdParty/Ert/devel/libert_util/include/ert/util/CMakeLists.txt index 4fe85bd641..57291c4b47 100644 --- a/ThirdParty/Ert/devel/libert_util/include/ert/util/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libert_util/include/ert/util/CMakeLists.txt @@ -13,10 +13,11 @@ if (MSVC) list( APPEND header_files ${CMAKE_CURRENT_BINARY_DIR}/stdbool.h) endif() -foreach(header ${header_files}) - install(FILES ${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/util) -endforeach() - +if (INSTALL_ERT) + foreach(header ${header_files}) + install(FILES ${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/util) + endforeach() +endif() diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/hash.h b/ThirdParty/Ert/devel/libert_util/include/ert/util/hash.h index 74f9212c1f..6e95b3ba9d 100644 --- a/ThirdParty/Ert/devel/libert_util/include/ert/util/hash.h +++ b/ThirdParty/Ert/devel/libert_util/include/ert/util/hash.h @@ -71,6 +71,7 @@ void * hash_iter_get_next_value(hash_iter_type *); void hash_iter_restart( hash_iter_type * iter ); hash_type * hash_alloc_from_options(const stringlist_type *); +bool hash_add_option( hash_type * hash, const char * key_value); int hash_inc_counter(hash_type * hash , const char * counter_key); int hash_get_counter(hash_type * hash , const char * key); diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/latex.h b/ThirdParty/Ert/devel/libert_util/include/ert/util/latex.h index e4753d3984..6a21b54f13 100644 --- a/ThirdParty/Ert/devel/libert_util/include/ert/util/latex.h +++ b/ThirdParty/Ert/devel/libert_util/include/ert/util/latex.h @@ -34,11 +34,13 @@ extern "C" { latex_type * latex_alloc( const char * input_file , bool in_place); void latex_free( latex_type * latex ); void latex_set_target_file( latex_type * latex , const char * target_file ); - bool latex_compile( latex_type * latex , bool ignore_errors , bool with_xref); + bool latex_compile( latex_type * latex , bool ignore_errors , bool with_xref , bool cleanup); + void latex_cleanup( latex_type * latex ); void latex_set_timeout( latex_type * latex , int timeout); int latex_get_timeout( const latex_type * latex ); const char * latex_get_runpath( const latex_type * latex ); const char * latex_get_target_file( const latex_type * latex ); + bool latex_compile_in_place( const latex_type * latex ); void latex_link_path( const latex_type * latex , const char * path); void latex_link_directory_content(const latex_type * latex , const char * path); diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/log.h b/ThirdParty/Ert/devel/libert_util/include/ert/util/log.h index f7a8c38ab5..01a243cfbe 100644 --- a/ThirdParty/Ert/devel/libert_util/include/ert/util/log.h +++ b/ThirdParty/Ert/devel/libert_util/include/ert/util/log.h @@ -29,10 +29,8 @@ extern "C" { typedef struct log_struct log_type; FILE * log_get_stream(log_type * logh ); - void log_reset_filename( log_type * logh , const char * filename ); - void log_set_file(log_type * , const char *); - log_type * log_alloc_new(const char *filename, int log_level); - log_type * log_alloc_existing(const char *filename, int log_level); + void log_reopen( log_type * logh , const char * filename ); + log_type * log_open(const char *filename, int log_level); void log_add_message(log_type *logh, int message_level , FILE * dup_stream , char* message, bool free_message); void log_add_fmt_message(log_type * logh , int message_level , FILE * dup_stream , const char * fmt , ...); int log_get_level( const log_type * logh); @@ -42,6 +40,7 @@ typedef struct log_struct log_type; const char * log_get_filename( const log_type * logh ); int log_get_level( const log_type * logh); void log_set_level( log_type * logh , int log_level); + bool log_is_open( const log_type * logh); #ifdef __cplusplus diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/mzran.h b/ThirdParty/Ert/devel/libert_util/include/ert/util/mzran.h index 23f1332d1b..564cc2116f 100644 --- a/ThirdParty/Ert/devel/libert_util/include/ert/util/mzran.h +++ b/ThirdParty/Ert/devel/libert_util/include/ert/util/mzran.h @@ -35,6 +35,7 @@ void mzran_fscanf_state( void * __rng , FILE * stream ); unsigned int mzran_forward(void * __rng); void * mzran_alloc( void ); void mzran_set_state(void * __rng , const char * seed_buffer); +void mzran_get_state(void * __rng , char * state_buffer); double mzran_get_double(mzran_type * rng); int mzran_get_int( mzran_type * rng, int max); void mzran_fprintf_state( const void * __rng , FILE * stream); diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/path_stack.h b/ThirdParty/Ert/devel/libert_util/include/ert/util/path_stack.h new file mode 100644 index 0000000000..76f91edde1 --- /dev/null +++ b/ThirdParty/Ert/devel/libert_util/include/ert/util/path_stack.h @@ -0,0 +1,42 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'path_stack.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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. +*/ + + +#ifndef __PATH_STACK_H__ +#define __PATH_STACK_H__ + +#ifdef __cplusplus +extern "C" { +#endif + + typedef struct path_stack_struct path_stack_type; + + path_stack_type * path_stack_alloc(); + const char * path_stack_pop( path_stack_type * path_stack ); + void path_stack_push_cwd( path_stack_type * path_stack ); + bool path_stack_push( path_stack_type * path_stack , const char * path ); + void path_stack_free( path_stack_type * path_stack ); + int path_stack_size( const path_stack_type * path_stack ); + const char * path_stack_peek( const path_stack_type * path_stack ); + +#ifdef __cplusplus +} +#endif + + +#endif diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/rng.h b/ThirdParty/Ert/devel/libert_util/include/ert/util/rng.h index aba2a3d0d5..bfe0f2db32 100644 --- a/ThirdParty/Ert/devel/libert_util/include/ert/util/rng.h +++ b/ThirdParty/Ert/devel/libert_util/include/ert/util/rng.h @@ -41,6 +41,7 @@ typedef enum { typedef unsigned int ( rng_forward_ftype ) ( void * ); typedef void ( rng_set_state_ftype ) ( void * , const char * ); + typedef void ( rng_get_state_ftype ) ( void * , char * ); typedef void * ( rng_alloc_ftype ) ( void ); typedef void ( rng_free_ftype ) ( void * ); typedef void ( rng_fscanf_ftype ) ( void * , FILE * ); @@ -58,6 +59,10 @@ typedef enum { rng_alg_type rng_get_type( const rng_type * rng ); void rng_fprintf_state( rng_type * rng , FILE * stream ); void rng_fscanf_state( rng_type * rng , FILE * stream ); + int rng_state_size( const rng_type * rng ); + + void rng_set_state( rng_type * rng , const char * state); + void rng_get_state( const rng_type * rng , char * state); unsigned int rng_forward( rng_type * rng ); double rng_get_double( rng_type * rng ); diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/string_util.h b/ThirdParty/Ert/devel/libert_util/include/ert/util/string_util.h new file mode 100644 index 0000000000..af73d98f62 --- /dev/null +++ b/ThirdParty/Ert/devel/libert_util/include/ert/util/string_util.h @@ -0,0 +1,38 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'string_util.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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. +*/ +#ifndef __STRING_UTIL_H__ +#define __STRING_UTIL_H__ + +#ifdef __cplusplus +extern "C" { +#endif +#include +#include + + bool string_util_init_active_list( const char * range_string , int_vector_type * active_list ); + bool string_util_update_active_list( const char * range_string , int_vector_type * active_list ); + int_vector_type * string_util_alloc_active_list( const char * range_string ); + + bool string_util_init_active_mask( const char * range_string , bool_vector_type * active_mask); + bool string_util_update_active_mask( const char * range_string , bool_vector_type * active_mask); + bool_vector_type * string_util_alloc_active_mask( const char * range_string ); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/stringlist.h b/ThirdParty/Ert/devel/libert_util/include/ert/util/stringlist.h index 7d1d98c8f4..450a875392 100644 --- a/ThirdParty/Ert/devel/libert_util/include/ert/util/stringlist.h +++ b/ThirdParty/Ert/devel/libert_util/include/ert/util/stringlist.h @@ -32,7 +32,8 @@ extern "C" { typedef struct stringlist_struct stringlist_type; typedef int ( string_cmp_ftype) (const void * , const void *); - + const char * stringlist_get_last( const stringlist_type * stringlist ); + char * stringlist_pop( stringlist_type * stringlist); void stringlist_deep_copy( stringlist_type * target , const stringlist_type * src); stringlist_type * stringlist_alloc_deep_copy_with_limits(const stringlist_type * src , int offset, int num_strings); stringlist_type * stringlist_alloc_deep_copy_with_offset(const stringlist_type * src , int offset); @@ -50,6 +51,7 @@ typedef int ( string_cmp_ftype) (const void * , const void *); const char * stringlist_safe_iget( const stringlist_type * stringlist , int index); bool stringlist_iequal( const stringlist_type * stringlist , int index, const char * s ); const char * stringlist_iget(const stringlist_type * , int); + int stringlist_iget_as_int( const stringlist_type * stringlist , int index , bool * valid); char * stringlist_iget_copy(const stringlist_type * stringlist , int ); char * stringlist_alloc_joined_string(const stringlist_type * , const char * ); char * stringlist_alloc_joined_substring( const stringlist_type * s , int start_index , int end_index , const char * sep ); @@ -94,7 +96,8 @@ typedef int ( string_cmp_ftype) (const void * , const void *); void stringlist_buffer_fread( stringlist_type * s , buffer_type * buffer ); void stringlist_buffer_fwrite( const stringlist_type * s , buffer_type * buffer ); void stringlist_sort(stringlist_type * , string_cmp_ftype * string_cmp); - void stringlist_python_sort( stringlist_type * s , int cmp_flag); + void stringlist_reverse( stringlist_type * s ); + void stringlist_python_sort( stringlist_type * s , int cmp_flag); #ifdef HAVE_GLOB int stringlist_select_matching(stringlist_type * names , const char * pattern); diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/subst_func.h b/ThirdParty/Ert/devel/libert_util/include/ert/util/subst_func.h index dc41aeccf2..d31a7ba508 100644 --- a/ThirdParty/Ert/devel/libert_util/include/ert/util/subst_func.h +++ b/ThirdParty/Ert/devel/libert_util/include/ert/util/subst_func.h @@ -33,8 +33,8 @@ typedef struct subst_func_pool_struct subst_func_pool_type; /*****************************************************************/ -subst_func_pool_type * subst_func_pool_alloc( ); -void subst_func_pool_free( subst_func_pool_type * pool ); + subst_func_pool_type * subst_func_pool_alloc( ); + void subst_func_pool_free( subst_func_pool_type * pool ); void subst_func_pool_add_func( subst_func_pool_type * pool , const char * func_name , const char * doc_string , subst_func_ftype * func , bool vararg, int argc_min , int argc_max , void * arg); subst_func_type * subst_func_pool_get_func( const subst_func_pool_type * pool , const char * func_name ); bool subst_func_pool_has_func( const subst_func_pool_type * pool , const char * func_name ); diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/subst_list.h b/ThirdParty/Ert/devel/libert_util/include/ert/util/subst_list.h index 909a2c7c24..548ba35518 100644 --- a/ThirdParty/Ert/devel/libert_util/include/ert/util/subst_list.h +++ b/ThirdParty/Ert/devel/libert_util/include/ert/util/subst_list.h @@ -23,11 +23,12 @@ extern "C" { #endif #include +#include #include typedef struct subst_list_struct subst_list_type; - void subst_list_update_buffer( const subst_list_type * subst_list , buffer_type * buffer ); + bool subst_list_update_buffer( const subst_list_type * subst_list , buffer_type * buffer ); void subst_list_insert_func(subst_list_type * subst_list , const char * func_name , const char * local_func_name); void subst_list_fprintf(const subst_list_type * , FILE * stream); void subst_list_set_parent( subst_list_type * subst_list , const subst_list_type * parent); @@ -43,9 +44,9 @@ extern "C" { void subst_list_prepend_ref(subst_list_type * , const char * , const char * , const char * doc_string); void subst_list_prepend_owned_ref(subst_list_type * , const char * , const char * , const char * doc_string); - void subst_list_filter_file(const subst_list_type * , const char * , const char * ); - void subst_list_update_file(const subst_list_type * , const char * ); - void subst_list_update_string(const subst_list_type * , char ** ); + bool subst_list_filter_file(const subst_list_type * , const char * , const char * ); + bool subst_list_update_file(const subst_list_type * , const char * ); + bool subst_list_update_string(const subst_list_type * , char ** ); char * subst_list_alloc_filtered_string(const subst_list_type * , const char * ); void subst_list_filtered_fprintf(const subst_list_type * , const char * , FILE * ); int subst_list_get_size( const subst_list_type *); diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/template.h b/ThirdParty/Ert/devel/libert_util/include/ert/util/template.h index bccbedc6b8..691bd9538b 100644 --- a/ThirdParty/Ert/devel/libert_util/include/ert/util/template.h +++ b/ThirdParty/Ert/devel/libert_util/include/ert/util/template.h @@ -32,7 +32,7 @@ typedef struct template_struct template_type; template_type * template_alloc( const char * template_file , bool internalize_template, subst_list_type * parent_subst); void template_free( template_type * template ); -void template_instansiate( const template_type * template , const char * __target_file , const subst_list_type * arg_list , bool override_symlink); +void template_instantiate( const template_type * template , const char * __target_file , const subst_list_type * arg_list , bool override_symlink); void template_add_arg( template_type * template , const char * key , const char * value ); void template_clear_args( template_type * template ); diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/test_util.h b/ThirdParty/Ert/devel/libert_util/include/ert/util/test_util.h index 4dc39eafab..70dad43e99 100644 --- a/ThirdParty/Ert/devel/libert_util/include/ert/util/test_util.h +++ b/ThirdParty/Ert/devel/libert_util/include/ert/util/test_util.h @@ -38,36 +38,57 @@ extern "C" { #define test_assert_int_not_equal( i1 , i2 ) test_assert_int_not_equal__( (i1) , (i2) , __FILE__ , __LINE__ ) void test_assert_int_not_equal__( int i1 , int i2 , const char * file , int line ); +#define test_assert_uint_equal( i1 , i2 ) test_assert_uint_equal__( (i1) , (i2) , __FILE__ , __LINE__ ) + void test_assert_uint_equal__( unsigned int i1 , unsigned int i2 , const char * file , int line ); + +#define test_assert_uint_not_equal( i1 , i2 ) test_assert_uint_not_equal__( (i1) , (i2) , __FILE__ , __LINE__ ) + void test_assert_uint_not_equal__( unsigned int i1 , unsigned int i2 , const char * file , int line ); + + +#define test_assert_double_equal( d1 , d2 ) test_assert_double_equal__( (d1) , (d2) , __FILE__ , __LINE__ ) + void test_assert_double_equal__( double d1 , double d2 , const char * file , int line ); + +#define test_assert_double_not_equal( d1 , d2 ) test_assert_double_not_equal__( (d1) , (d2) , __FILE__ , __LINE__ ) + void test_assert_double_not_equal__( double d1 , double d2 , const char * file , int line ); + #define test_assert_bool_equal( b1 , b2 ) test_assert_bool_equal__( (b1) , (b2) , __FILE__ , __LINE__ ) void test_assert_bool_equal__( bool b1 , bool b2 , const char * file , int line); -#define test_assert_true( value ) test_assert_true__( (value) , __FILE__ , __LINE__); +#define test_assert_true( value ) test_assert_true__( (value) , __FILE__ , __LINE__) void test_assert_true__( bool value, const char * file , int line); -#define test_assert_false( value ) test_assert_false__( (value) , __FILE__ , __LINE__); +#define test_assert_false( value ) test_assert_false__( (value) , __FILE__ , __LINE__) void test_assert_false__( bool value, const char * file , int line); - -#define test_assert_time_t_equal( t1 , t2) test_assert_time_t_equal__((t1) , (t2) , __FILE__ , __LINE__); + +#define test_assert_time_t_equal( t1 , t2) test_assert_time_t_equal__((t1) , (t2) , __FILE__ , __LINE__) void test_assert_time_t_equal__( time_t t1 , time_t t2 , const char * file , int line); -#define test_assert_time_t_not_equal( t1 , t2) test_assert_time_t_not_equal__((t1) , (t2) , __FILE__ , __LINE__); +#define test_assert_time_t_not_equal( t1 , t2) test_assert_time_t_not_equal__((t1) , (t2) , __FILE__ , __LINE__) void test_assert_time_t_not_equal__( time_t t1 , time_t t2 , const char * file , int line); -#define test_assert_ptr_equal( p1 , p2 ) test_assert_ptr_equal__( (p1) , (p2) , __FILE__ , __LINE__); +#define test_assert_ptr_equal( p1 , p2 ) test_assert_ptr_equal__( (p1) , (p2) , __FILE__ , __LINE__) void test_assert_ptr_equal__( const void * p1 , const void * p2 , const char * file , int line); -#define test_assert_NULL( p ) test_assert_NULL__( (p) , __FILE__ , __LINE__); +#define test_assert_ptr_not_equal(p1 , p2) test_assert_ptr_not_equal__( (p1) , (p2) , __FILE__ , __LINE__) + void test_assert_ptr_not_equal__( const void * p1 , const void * p2 , const char * file , int line); + +#define test_assert_NULL( p ) test_assert_NULL__( (p) , __FILE__ , __LINE__) void test_assert_NULL__( const void * p , const char * file , int line); -#define test_assert_not_NULL( p ) test_assert_not_NULL__( (p) , __FILE__ , __LINE__); +#define test_assert_not_NULL( p ) test_assert_not_NULL__( (p) , __FILE__ , __LINE__) void test_assert_not_NULL__( const void * p , const char * file , int line); -#define test_assert_mem_equal( p1 , p2 , byte_size ) test_assert_mem_equal__( (p1) , (p2) , (byte_size), __FILE__ , __LINE__); +#define test_assert_mem_equal( p1 , p2 , byte_size ) test_assert_mem_equal__( (p1) , (p2) , (byte_size), __FILE__ , __LINE__) void test_assert_mem_equal__( const void * p1 , const void * p2 , size_t byte_size , const char * file , int line); -#define test_assert_mem_not_equal( p1 , p2 , byte_size ) test_assert_mem_not_equal__( (p1) , (p2) , (byte_size), __FILE__ , __LINE__); +#define test_assert_mem_not_equal( p1 , p2 , byte_size ) test_assert_mem_not_equal__( (p1) , (p2) , (byte_size), __FILE__ , __LINE__) void test_assert_mem_not_equal__( const void * p1 , const void * p2 , size_t byte_size , const char * file , int line); + +#ifdef HAVE_UTIL_ABORT + void test_util_addr2line(); +#endif + #ifdef __cplusplus } #endif diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/time_interval.h b/ThirdParty/Ert/devel/libert_util/include/ert/util/time_interval.h new file mode 100644 index 0000000000..048d5f25f2 --- /dev/null +++ b/ThirdParty/Ert/devel/libert_util/include/ert/util/time_interval.h @@ -0,0 +1,53 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'time_interval.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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. +*/ + +#ifndef __TIME_INTERVAL_H__ +#define __TIME_INTERVAL_H__ +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + + typedef struct time_interval_struct time_interval_type; + + time_interval_type * time_interval_alloc( time_t start_time , time_t end_time ); + time_interval_type * time_interval_alloc_open( ); + time_interval_type * time_interval_alloc_copy( const time_interval_type * src); + void time_interval_reopen( time_interval_type * time_interval); + void time_interval_free( time_interval_type * ti ); + bool time_interval_is_empty( time_interval_type * ti ); + bool time_interval_update( time_interval_type * ti , time_t start_time , time_t end_time); + bool time_interval_contains( const time_interval_type * ti , time_t t); + bool time_interval_has_overlap( const time_interval_type * t1 , const time_interval_type * t2); + bool time_interval_is_adjacent( const time_interval_type * t1 , const time_interval_type * t2); + bool time_interval_update_start( time_interval_type * ti , time_t start_time ); + bool time_interval_update_end( time_interval_type * ti , time_t end_time ); + time_t time_interval_get_start( const time_interval_type * ti); + time_t time_interval_get_end( const time_interval_type * ti); + bool time_interval_extend( time_interval_type * t1 , const time_interval_type * t2); + bool time_interval_intersect( time_interval_type * t1 , const time_interval_type * t2); + bool time_interval_equal( const time_interval_type * t1 , const time_interval_type * t2); + bool time_interval_arg_before( const time_interval_type * ti , time_t arg); + bool time_interval_arg_after( const time_interval_type * ti , time_t arg); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/util.h b/ThirdParty/Ert/devel/libert_util/include/ert/util/util.h index b519fb9514..a4f09bf665 100644 --- a/ThirdParty/Ert/devel/libert_util/include/ert/util/util.h +++ b/ThirdParty/Ert/devel/libert_util/include/ert/util/util.h @@ -76,9 +76,14 @@ typedef enum {left_pad = 0, void util_fprintf_datetime(time_t , FILE * ); void util_fprintf_date(time_t , FILE * ); time_t util_make_date(int , int , int); + time_t util_make_pure_date(time_t t); void util_inplace_forward_days(time_t * , double); + time_t util_file_mtime(const char * file); double util_difftime(time_t , time_t , int * , int * , int * , int *); double util_difftime_days(time_t , time_t ); + double util_difftime_seconds( time_t start_time , time_t end_time); + bool util_after( time_t t , time_t limit); + bool util_before( time_t t , time_t limit); bool util_file_newer( const char * file , time_t t0); bool util_file_older( const char * file , time_t t0); char * util_alloc_date_string( time_t t ); @@ -87,6 +92,7 @@ typedef enum {left_pad = 0, bool util_char_in(char c, int , const char *); char * util_alloc_sprintf_va(const char * fmt , va_list ap); char * util_alloc_sprintf(const char * , ...); + char * util_alloc_sprintf_escape(const char * src , int max_escape); char * util_realloc_sprintf(char * , const char * , ...); void util_fprintf_int(int , int , FILE * ); void util_fprintf_string(const char * , int , string_alignement_type , FILE * ); @@ -100,6 +106,7 @@ typedef enum {left_pad = 0, bool util_file_exists(const char *); bool util_is_abs_path(const char * ); char * util_alloc_abs_path( const char * path ); + char * util_alloc_rel_path( const char * __root_path , const char * path); bool util_fmt_bit8 (const char *); bool util_fmt_bit8_stream(FILE * ); void util_make_path (const char *); @@ -118,9 +125,12 @@ typedef enum {left_pad = 0, void util_move_file4( const char * src_name , const char * target_name , const char *src_path , const char * target_path); bool util_copy_file(const char * , const char * ); char * util_alloc_cwd(void); + bool util_is_cwd( const char * path ); char * util_alloc_realpath(const char * ); + char * util_alloc_realpath__(const char * input_path); bool util_string_match(const char * string , const char * pattern); bool util_string_has_wildcard( const char * s); + bool util_file_readable( const char * file ); bool util_entry_readable( const char * entry ); bool util_entry_writable( const char * entry ); void util_ftruncate(FILE * stream , long size); @@ -220,11 +230,13 @@ typedef enum {left_pad = 0, char * util_alloc_dequoted_copy(const char *s); void util_safe_free(void *); void util_free_stringlist(char **, int ); + void util_free_NULL_terminated_stringlist(char ** string_list); char * util_alloc_substring_copy(const char *, int offset , int N); bool util_is_directory(const char * ); bool util_is_file(const char * ); void util_set_datetime_values(time_t , int * , int * , int * , int * , int * , int *); void util_set_date_values(time_t , int * , int * , int * ); + bool util_is_first_day_in_month( time_t t); void util_fread_from_buffer(void * , size_t , size_t , char ** ); @@ -239,7 +251,7 @@ typedef enum {left_pad = 0, void util_abort_signal(int ); void util_abort_append_version_info(const char * ); void util_abort_free_version_info(); - void util_abort_set_executable( const char * executable ); + void util_abort_set_executable( const char * argv0 ); void * util_realloc(void * , size_t ); void * util_malloc(size_t ); void * util_calloc( size_t elements , size_t element_size ); @@ -303,8 +315,6 @@ typedef enum {left_pad = 0, bool util_sscanf_bytesize(const char * , size_t *); - void util_sscanf_active_range(const char * , int , bool * ); - int * util_sscanf_alloc_active_list(const char * , int * ); int util_get_current_linenr(FILE * stream); const char * util_update_path_var(const char * , const char * , bool ); @@ -317,9 +327,11 @@ typedef enum {left_pad = 0, char * util_fscanf_alloc_upto(FILE * stream , const char * stop_string, bool include_stop_string); bool util_files_equal( const char * file1 , const char * file2 ); double util_kahan_sum(const double *data, size_t N); + bool util_double_approx_equal( double d1 , double d2); int util_fnmatch( const char * pattern , const char * string ); void util_localtime( time_t * t , struct tm * ts ); - + + char ** util_alloc_PATH_list(); char * util_alloc_PATH_executable(const char * executable ); char * util_isscanf_alloc_envvar( const char * string , int env_index ); void util_setenv( const char * variable , const char * value); @@ -422,13 +434,17 @@ const char * util_enum_iget( int index , int size , const util_enum_element_type #ifdef HAVE_SYMLINK void util_make_slink(const char *, const char * ); char * util_alloc_link_target(const char * link); - #ifdef HAVE_READLINKAT - char * util_alloc_atlink_target(const char * path , const char * link); - #endif +#ifdef HAVE_READLINKAT + char * util_alloc_atlink_target(const char * path , const char * link); +#endif #endif + #ifdef HAVE_FORK -#include "util_fork.h" + pid_t util_fork_exec(const char * , int , const char ** , bool , const char * , const char * , const char * , const char * , const char * ); + uid_t * util_alloc_file_users( const char * filename , int * __num_users); + char * util_alloc_filename_from_stream( FILE * input_stream ); + bool util_ping( const char * hostname); #endif @@ -437,6 +453,17 @@ const char * util_enum_iget( int index , int size , const util_enum_element_type bool util_try_lockf(const char * , mode_t , int * ); #endif +#ifdef HAVE_FORK +#ifdef WITH_PTHREAD +#ifdef HAVE_EXECINFO + + bool util_addr2line_lookup(const void * bt_addr , char ** func_name , char ** file_line, int * line_nr); + +#define HAVE_UTIL_ABORT +#endif +#endif +#endif + diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/util_fork.h b/ThirdParty/Ert/devel/libert_util/include/ert/util/util_fork.h deleted file mode 100644 index a64f9e1c13..0000000000 --- a/ThirdParty/Ert/devel/libert_util/include/ert/util/util_fork.h +++ /dev/null @@ -1,11 +0,0 @@ -/** - Headers for the functions in util_fork.c - i.e. the functions which - are based on the fork() system call. - - This file will be included directly from the util.h header file. -*/ - -pid_t util_fork_exec(const char * , int , const char ** , bool , const char * , const char * , const char * , const char * , const char * ); -uid_t * util_alloc_file_users( const char * filename , int * __num_users); -char * util_alloc_filename_from_stream( FILE * input_stream ); - diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/vector.h b/ThirdParty/Ert/devel/libert_util/include/ert/util/vector.h index ca24a17435..64552a831d 100644 --- a/ThirdParty/Ert/devel/libert_util/include/ert/util/vector.h +++ b/ThirdParty/Ert/devel/libert_util/include/ert/util/vector.h @@ -74,6 +74,7 @@ extern "C" { int vector_get_size( const vector_type * ); void * vector_pop(vector_type * ); void vector_sort(vector_type * vector , vector_cmp_ftype * cmp); + void vector_inplace_reverse(vector_type * vector); vector_type * vector_alloc_copy(const vector_type * src , bool deep_copy); void vector_iset_buffer(vector_type * vector , int index , const void * buffer, int buffer_size); diff --git a/ThirdParty/Ert/devel/libert_util/include/ert/util/vector_template.h b/ThirdParty/Ert/devel/libert_util/include/ert/util/vector_template.h index fa875cd7f1..f104253b1a 100644 --- a/ThirdParty/Ert/devel/libert_util/include/ert/util/vector_template.h +++ b/ThirdParty/Ert/devel/libert_util/include/ert/util/vector_template.h @@ -22,6 +22,7 @@ extern "C" { #endif #include +#include #include #include @@ -63,6 +64,7 @@ typedef @TYPE@ (@TYPE@_ftype) (@TYPE@); @TYPE@ @TYPE@_vector_idel( @TYPE@_vector_type * vector , int index); void @TYPE@_vector_insert( @TYPE@_vector_type * vector , int index , @TYPE@ value); void @TYPE@_vector_append(@TYPE@_vector_type * , @TYPE@); + void @TYPE@_vector_free_container(@TYPE@_vector_type * vector); void @TYPE@_vector_free(@TYPE@_vector_type *); void @TYPE@_vector_free__(void *); void @TYPE@_vector_free_data(@TYPE@_vector_type *); @@ -75,6 +77,7 @@ typedef @TYPE@ (@TYPE@_ftype) (@TYPE@); @TYPE@ * @TYPE@_vector_get_ptr(const @TYPE@_vector_type * ); @TYPE@ * @TYPE@_vector_alloc_data_copy( const @TYPE@_vector_type * vector ); const @TYPE@ * @TYPE@_vector_get_const_ptr(const @TYPE@_vector_type * ); + bool @TYPE@_vector_init_range(@TYPE@_vector_type * vector , @TYPE@ min_value , @TYPE@ max_value , @TYPE@ delta); void @TYPE@_vector_set_many(@TYPE@_vector_type * , int , const @TYPE@ * , int ); void @TYPE@_vector_set_all(@TYPE@_vector_type * vector , @TYPE@ value); void @TYPE@_vector_append_many(@TYPE@_vector_type * vector , const @TYPE@ * data , int length); diff --git a/ThirdParty/Ert/devel/libert_util/src/CMakeLists.txt b/ThirdParty/Ert/devel/libert_util/src/CMakeLists.txt index cc7766f7b8..a753d36d3b 100644 --- a/ThirdParty/Ert/devel/libert_util/src/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libert_util/src/CMakeLists.txt @@ -1,7 +1,7 @@ -set(source_files rng.c lookup_table.c statistics.c mzran.c set.c hash_node.c hash_sll.c hash.c node_data.c node_ctype.c util.c thread_pool.c msg.c arg_pack.c path_fmt.c menu.c subst_list.c subst_func.c vector.c parser.c stringlist.c matrix.c buffer.c log.c template.c timer.c test_util.c) +set(source_files rng.c lookup_table.c statistics.c mzran.c set.c hash_node.c hash_sll.c hash.c node_data.c node_ctype.c util.c thread_pool.c msg.c arg_pack.c path_fmt.c menu.c subst_list.c subst_func.c vector.c parser.c stringlist.c matrix.c buffer.c log.c template.c timer.c test_util.c time_interval.c string_util.c) +set(header_files ssize_t.h type_macros.h rng.h lookup_table.h statistics.h mzran.h set.h hash.h hash_node.h hash_sll.h node_data.h node_ctype.h util.h thread_pool.h msg.h arg_pack.h path_fmt.h stringlist.h menu.h subst_list.h subst_func.h vector.h parser.h matrix.h buffer.h log.h template.h timer.h test_util.h time_interval.h string_util.h) -set(header_files ssize_t.h type_macros.h rng.h lookup_table.h statistics.h mzran.h set.h hash.h hash_node.h hash_sll.h node_data.h node_ctype.h util.h thread_pool.h msg.h arg_pack.h path_fmt.h stringlist.h menu.h subst_list.h subst_func.h vector.h parser.h matrix.h buffer.h log.h template.h timer.h test_util.h) if (WITH_LATEX) add_definitions( -DWITH_LATEX ) @@ -16,6 +16,11 @@ if (WITH_LAPACK) list( APPEND header_files matrix_lapack.h matrix_blas.h regression.h lars.h stepwise.h) endif() +if (UNISTD_HEADER) + list( APPEND source_files path_stack.c ) + list( APPEND header_files path_stack.h ) +endif() + foreach (type int double bool long time_t size_t float) set(TYPE ${type} ) set(src_target ${CMAKE_CURRENT_BINARY_DIR}/${type}_vector.c) @@ -25,11 +30,9 @@ foreach (type int double bool long time_t size_t float) list( APPEND source_files ${src_target} ) endforeach( type ) - -#if (WITH_ZLIB) -# list( APPEND source_files util_zlib.c ) -# list( APPEND header_files util_zlib.h ) -#endif() +if (PING_PATH) + add_definitions( -DPING_CMD=\"${PING_PATH}\") +endif() # The block_fs filesystem is so heavily dependant on pthreads that it is not # built if de not have pthreads. @@ -67,13 +70,17 @@ endif() if (NEED_LIBM) target_link_libraries( ert_util m ) endif() +if (NEED_LIBDL) + target_link_libraries( ert_util dl ) +endif() #----------------------------------------------------------------- -install(TARGETS ert_util DESTINATION ${CMAKE_INSTALL_LIBDIR}) -foreach(header ${header_files}) - install(FILES ../include/ert/util/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/util) -endforeach() - +if (INSTALL_ERT) + install(TARGETS ert_util DESTINATION ${CMAKE_INSTALL_LIBDIR}) + foreach(header ${header_files}) + install(FILES ../include/ert/util/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/util) + endforeach() +endif() diff --git a/ThirdParty/Ert/devel/libert_util/src/hash.c b/ThirdParty/Ert/devel/libert_util/src/hash.c index 02f7beb5cc..7a25deb62a 100644 --- a/ThirdParty/Ert/devel/libert_util/src/hash.c +++ b/ThirdParty/Ert/devel/libert_util/src/hash.c @@ -836,6 +836,24 @@ hash_type * hash_alloc_from_options(const stringlist_type * options) { } + bool hash_add_option( hash_type * hash, const char * key_value) { + bool addOK = false; + { + char * value; + char * key; + + util_binary_split_string( key_value , ":" , true , &key , &value); + if (value != NULL) { + hash_insert_hash_owned_ref( hash , key , value , free ); + addOK = true; + } + + util_safe_free( key ); + } + return addOK; +} + + /*****************************************************************/ diff --git a/ThirdParty/Ert/devel/libert_util/src/latex.c b/ThirdParty/Ert/devel/libert_util/src/latex.c index 394e482a7f..d3688bebcc 100644 --- a/ThirdParty/Ert/devel/libert_util/src/latex.c +++ b/ThirdParty/Ert/devel/libert_util/src/latex.c @@ -99,9 +99,24 @@ latex_type * latex_alloc( const char * input_file , bool in_place ) { char * input_path; char * input_extension; latex_type * latex = util_malloc( sizeof * latex ); - + + latex->latex_cmd = NULL; + latex->target_file = NULL; + latex->target_extension = NULL; + latex->target_path = NULL; + latex->result_file = NULL; + latex->basename = NULL; + latex->run_path = NULL; + latex->in_place = in_place; - util_alloc_file_components( input_file , &input_path , &latex->basename , &input_extension ); + { + char * basename; + util_alloc_file_components( input_file , &input_path , &basename , &input_extension ); + if (basename == NULL) + util_abort("%s: must provide a basename \n",__func__); + latex->basename = basename; + } + if (input_path == NULL) input_path = util_alloc_cwd( ); else { @@ -141,12 +156,6 @@ latex_type * latex_alloc( const char * input_file , bool in_place ) { /* Setting various default values. */ - latex->target_file = NULL; - latex->latex_cmd = NULL; - latex->target_extension = NULL; - latex->target_path = NULL; - latex->result_file = NULL; - latex_set_target_extension( latex , TARGET_EXTENSION ); latex_set_target_path( latex , input_path ); latex_set_command( latex , __LATEX_CMD ); @@ -185,7 +194,7 @@ static void latex_copy_target( latex_type * latex ) { } -static void latex_cleanup( latex_type * latex ) { +void latex_cleanup( latex_type * latex ) { if (latex->in_place) { int num_extensions = sizeof( delete_extensions ) / sizeof( delete_extensions[0] ); for (int iext = 0; iext < num_extensions; iext++) { @@ -198,6 +207,10 @@ static void latex_cleanup( latex_type * latex ) { } +bool latex_compile_in_place( const latex_type * latex ) { + return latex->in_place; +} + static void latex_ensure_target_file( latex_type * latex) { if (latex->target_file == NULL) @@ -205,48 +218,52 @@ static void latex_ensure_target_file( latex_type * latex) { } static bool latex_compile__( latex_type * latex , bool ignore_errors) { - bool normal_exit = true; - char ** argv; - int argc; - char * stderr_file = util_alloc_filename( latex->run_path , "latex" , "stderr"); - char * stdout_file = util_alloc_filename( latex->run_path , "latex" , "stdout"); - int usleep_time = 500000; /* 1/2 second. */ + if (util_is_directory( latex->run_path)) { + bool normal_exit = true; + char ** argv; + int argc; + char * stderr_file = util_alloc_filename( latex->run_path , "latex" , "stderr"); + char * stdout_file = util_alloc_filename( latex->run_path , "latex" , "stdout"); + int usleep_time = 500000; /* 1/2 second. */ - argc = 2; - argv = util_malloc( argc * sizeof * argv ); - if (ignore_errors) - argv[0] = "-interaction=nonstopmode"; - else - argv[0] = "-halt-on-error"; - argv[0] = "-halt-on-error";//latex->src_file; - - argv[1] = latex->src_file; - { - pid_t child_pid = util_fork_exec( latex->latex_cmd , argc , (const char **) argv , false , NULL , latex->run_path , NULL , stdout_file , stderr_file ); - double total_wait = 0; - int status; - - while (true) { - if (waitpid(child_pid , &status , WNOHANG) == 0) { - util_usleep( usleep_time ); - total_wait += usleep_time / 1000000.0; - - if (total_wait > latex->timeout) { - // Exit due to excessive time usage. - normal_exit = false; - kill( child_pid , SIGKILL ); - } - } else - // The child has exited - succesfull or not? - break; + argc = 2; + argv = util_malloc( argc * sizeof * argv ); + if (ignore_errors) + argv[0] = "-interaction=nonstopmode"; + else + argv[0] = "-halt-on-error"; + argv[0] = "-halt-on-error";//latex->src_file; + + argv[1] = latex->src_file; + { + pid_t child_pid = util_fork_exec( latex->latex_cmd , argc , (const char **) argv , false , NULL , latex->run_path , NULL , stdout_file , stderr_file ); + double total_wait = 0; + int status; + + while (true) { + if (waitpid(child_pid , &status , WNOHANG) == 0) { + util_usleep( usleep_time ); + total_wait += usleep_time / 1000000.0; + + if (total_wait > latex->timeout) { + // Exit due to excessive time usage. + normal_exit = false; + kill( child_pid , SIGKILL ); + } + } else + // The child has exited - succesfull or not? + break; + } } - } - - free( stderr_file ); - free( stdout_file ); - free( argv ); - - return normal_exit; + + free( stderr_file ); + free( stdout_file ); + free( argv ); + + return normal_exit; + } else + return false; // The runpath directory does not exist; if we try to rerun the latex + // compile on the same instance, after a cleanup this might happen. } /** @@ -254,7 +271,7 @@ static bool latex_compile__( latex_type * latex , bool ignore_errors) { compilation has been successfull or not. */ -bool latex_compile( latex_type * latex , bool ignore_errors , bool with_xref) { +bool latex_compile( latex_type * latex , bool ignore_errors , bool with_xref , bool cleanup) { int num_compile = 1; time_t compile_start; @@ -290,7 +307,8 @@ bool latex_compile( latex_type * latex , bool ignore_errors , bool with_xref) { if (success) { latex_copy_target( latex ); - latex_cleanup( latex ); + if (cleanup) + latex_cleanup( latex ); } return success; @@ -309,13 +327,12 @@ void latex_set_timeout( latex_type * latex , int timeout) { void latex_free( latex_type * latex ) { - - free( latex->latex_cmd ); - free( latex->run_path ); - free( latex->src_file ); - free( latex->basename ); - free( latex->target_extension ); - free( latex->target_path ); + util_safe_free( latex->latex_cmd ); + util_safe_free( latex->run_path ); + util_safe_free( latex->src_file ); + util_safe_free( latex->basename ); + util_safe_free( latex->target_extension ); + util_safe_free( latex->target_path ); util_safe_free( latex->target_file ); util_safe_free( latex->result_file ); diff --git a/ThirdParty/Ert/devel/libert_util/src/log.c b/ThirdParty/Ert/devel/libert_util/src/log.c index b498eed00e..bea28caa3c 100644 --- a/ThirdParty/Ert/devel/libert_util/src/log.c +++ b/ThirdParty/Ert/devel/libert_util/src/log.c @@ -48,7 +48,7 @@ struct log_struct { -void log_reset_filename(log_type *logh , const char *filename) { +void log_reopen(log_type *logh , const char *filename) { if (logh->stream != NULL) { /* Close the existing file descriptor. */ size_t file_size; fclose( logh->stream ); @@ -66,7 +66,7 @@ void log_reset_filename(log_type *logh , const char *filename) { logh->stream = util_mkdir_fopen( filename , "a+"); logh->fd = fileno( logh->stream ); } else { /* It is ~OK to open a log with NULL filename, but then - log_reset_filename() with a VALID filename must be + log_reopen() with a VALID filename must be called before it is actually used. */ logh->stream = NULL; logh->fd = -1; @@ -93,8 +93,9 @@ void log_set_level( log_type * logh , int log_level) { -static log_type *log_alloc_internal(const char *filename , bool new, int log_level) { +log_type * log_open( const char * filename , int log_level) { log_type *logh; + logh = util_malloc(sizeof *logh ); logh->log_level = log_level; @@ -103,24 +104,13 @@ static log_type *log_alloc_internal(const char *filename , bool new, int log_lev #ifdef HAVE_PTHREAD pthread_mutex_init( &logh->mutex , NULL ); #endif - log_reset_filename( logh ,filename ); - + if (filename != NULL) + log_reopen( logh , filename); + return logh; } -log_type * log_alloc_new(const char *filename, int log_level) { - log_type *logh = log_alloc_internal(filename , true , log_level); - return logh; -} - - - -log_type *log_alloc_existing(const char *filename, int log_level) { - return log_alloc_internal(filename , false , log_level); -} - - static bool log_include_message(const log_type *logh , int message_level) { if (message_level <= logh->log_level) @@ -212,9 +202,17 @@ void log_sync(log_type * logh) { void log_close( log_type * logh ) { - if ((logh->stream != stdout) && (logh->stream != stderr)) + if ((logh->stream != stdout) && (logh->stream != stderr) && (logh->stream != NULL)) fclose( logh->stream ); /* This closes BOTH the FILE * stream and the integer file descriptor. */ - free( logh->filename ); + util_safe_free( logh->filename ); free( logh ); } + + +bool log_is_open( const log_type * logh) { + if (logh->stream != NULL) + return true; + else + return false; +} diff --git a/ThirdParty/Ert/devel/libert_util/src/menu.c b/ThirdParty/Ert/devel/libert_util/src/menu.c index 291164287f..70704efba5 100644 --- a/ThirdParty/Ert/devel/libert_util/src/menu.c +++ b/ThirdParty/Ert/devel/libert_util/src/menu.c @@ -141,7 +141,7 @@ static bool __string_contains(const char * string , const char * char_set) { menu_type * menu_alloc(const char * title , const char * quit_label , const char * quit_keys) { menu_type * menu = util_malloc(sizeof * menu ); - menu->title = util_alloc_string_copy( title ); + menu->title = util_alloc_sprintf_escape( title , 0 ); menu->quit_keys = util_alloc_string_copy( quit_keys ); menu->items = vector_alloc_new(); menu->complete_key_set = util_alloc_string_copy( quit_keys ); @@ -311,7 +311,7 @@ static void __print_helptext(char * label, int l){ while(!end_reached){ int i; if(strlen(label_copy) > l){ - util_binary_split_string_from_max_length(label_copy , " ", l , &first_part , &second_part); + util_binary_split_string_from_max_length(label_copy , " ", l , &first_part , &second_part); printf("| %s",first_part); for (i=strlen(first_part); i < l; i++) fputc(' ' , stdout); diff --git a/ThirdParty/Ert/devel/libert_util/src/mzran.c b/ThirdParty/Ert/devel/libert_util/src/mzran.c index bf128a027a..32d83c22ed 100644 --- a/ThirdParty/Ert/devel/libert_util/src/mzran.c +++ b/ThirdParty/Ert/devel/libert_util/src/mzran.c @@ -170,19 +170,38 @@ void mzran_fprintf_state( const void * __rng , FILE * stream) { +static void mzran_set_default_state( mzran_type * rng ) { + mzran_set_state4( rng , DEFAULT_S0 , DEFAULT_S1 , DEFAULT_S2 , DEFAULT_S3); +} + + /** This function will set the state of the rng, based on a buffer of length buffer size. 16 bytes will be read from the seed buffer. */ -void mzran_set_state(void * __rng , const char * seed_buffer) { +void mzran_set_state(void * __rng , const char * state_buffer) { mzran_type * rng = mzran_safe_cast( __rng ); - const unsigned int * seed = (const unsigned int *) seed_buffer; - mzran_set_state4( rng , seed[0] , seed[1] , seed[2] , seed[3]); + if (state_buffer == NULL) + mzran_set_default_state(rng); + else { + const unsigned int * state = (const unsigned int *) state_buffer; + mzran_set_state4( rng , state[0] , state[1] , state[2] , state[3]); + } } +void mzran_get_state(void * __rng , char * state_buffer) { + mzran_type * rng = mzran_safe_cast( __rng ); + unsigned int * state = (unsigned int *) state_buffer; + + state[0] = rng->x; + state[1] = rng->y; + state[2] = rng->z; + state[3] = rng->n; +} + /** @@ -199,7 +218,7 @@ void mzran_set_state(void * __rng , const char * seed_buffer) { void * mzran_alloc( void ) { mzran_type * rng = util_malloc( sizeof * rng ); UTIL_TYPE_ID_INIT( rng , MZRAN_TYPE_ID ); - mzran_set_state4( rng , DEFAULT_S0 , DEFAULT_S1 , DEFAULT_S2 , DEFAULT_S3); + mzran_set_default_state( rng ); return rng; } diff --git a/ThirdParty/Ert/devel/libert_util/src/path_stack.c b/ThirdParty/Ert/devel/libert_util/src/path_stack.c new file mode 100644 index 0000000000..3391c1089e --- /dev/null +++ b/ThirdParty/Ert/devel/libert_util/src/path_stack.c @@ -0,0 +1,119 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'path_stack.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include +#include + +#include +#include +#include + +/** + This file implements the structure path_stack which is vaguely + inspired by the emacs-lisp scecial form (save-excursion ...). The + intentiation with the 'class' is to push directories onto a stack, + and then each time you pop from the stack the the process will + chdir() back to directory which is popped. + + Observe that the constructor path_stack_alloc() and destructor + path_stack_free() do *not* alter the stack or the cwd of the + process. +*/ + + +struct path_stack_struct { + stringlist_type * stack; + stringlist_type * storage; +}; + + +/** + This will create a new path_stack instance; it will push anything + on the current stack of paths. +*/ + +path_stack_type * path_stack_alloc() { + path_stack_type * path_stack = util_malloc( sizeof * path_stack ); + path_stack->stack = stringlist_alloc_new(); + path_stack->storage = stringlist_alloc_new(); + return path_stack; +} + +/* + This will destroy the storage taken by the current path_stack + instance. This function will NOT pop any elements off the stack; so + if you have not manully clerad the stack with the right number of + path_stack_pop() calls, you will (probably) destroy the path stack + instance with an incorrect value of cwd. +*/ + +void path_stack_free( path_stack_type * path_stack ) { + stringlist_free( path_stack->stack ); + stringlist_free( path_stack->storage ); +} + + +/** + This will push a path on to the stack. The function will start by + chdir() to the input path. If the chdir() call fails the function + will return false, and the stack will be unmodified; if the chdir() + succeeds the input @path will be pushed onto the stack. + + If path is NULL that is interpreted as cwd. +*/ + +bool path_stack_push( path_stack_type * path_stack , const char * path ) { + if (path != NULL) + if (chdir( path ) != 0) + return false; + + path_stack_push_cwd( path_stack ); + return true; +} + + +void path_stack_push_cwd( path_stack_type * path_stack ) { + char * cwd = util_alloc_cwd(); + stringlist_append_owned_ref( path_stack->storage , cwd); + stringlist_append_ref( path_stack->stack , cwd ); +} + +const char * path_stack_pop( path_stack_type * path_stack ) { + char * path = stringlist_pop( path_stack->stack ); + if (chdir( path ) == 0) + return path; + else { + // The directory has become inaccesible ... + util_abort("%s: could not pop back to directory:%s Error:%s\n", __func__ , path , strerror( errno )); + return NULL; + } +} + + +int path_stack_size( const path_stack_type * path_stack ) { + return stringlist_get_size( path_stack->stack ); +} + + +const char * path_stack_peek( const path_stack_type * path_stack ) { + return stringlist_get_last( path_stack->stack ); +} + diff --git a/ThirdParty/Ert/devel/libert_util/src/rng.c b/ThirdParty/Ert/devel/libert_util/src/rng.c index 0a7a74b756..1c5e733e98 100644 --- a/ThirdParty/Ert/devel/libert_util/src/rng.c +++ b/ThirdParty/Ert/devel/libert_util/src/rng.c @@ -42,7 +42,8 @@ struct rng_struct { rng_forward_ftype * forward; /* Brings the rng forward - returning a random unsigned int value. This is the fundamental source of random numbers, and all other random numbers are derived from this through scaling/shifting/type conversion/... */ - rng_set_state_ftype * set_state; /* Takes a char * buffer as input and sets the state of the rng. */ + rng_set_state_ftype * set_state; /* Takes a char * buffer as input and sets the state of the rng; should set the rng into a default state if arg == NULL. */ + rng_get_state_ftype * get_state; rng_alloc_ftype * alloc_state; /* Creates a new instance of this rng. */ rng_free_ftype * free_state; rng_fscanf_ftype * fscanf_state; /* Loads the state from a formatted file with (integer representation of) bytes. */ @@ -64,6 +65,7 @@ rng_type * rng_alloc__(rng_alloc_ftype * alloc_state, rng_free_ftype * free_state , rng_forward_ftype * forward , rng_set_state_ftype * set_state , + rng_get_state_ftype * get_state , rng_fscanf_ftype * fscanf_state , rng_fprintf_ftype * fprintf_state , rng_alg_type type , @@ -76,14 +78,15 @@ rng_type * rng_alloc__(rng_alloc_ftype * alloc_state, rng->free_state = free_state; rng->forward = forward; rng->set_state = set_state; + rng->get_state = get_state; rng->fscanf_state = fscanf_state; rng->fprintf_state = fprintf_state; rng->state_size = state_size; - rng->max_value = max_value; - rng->inv_max = 1.0 / max_value; - rng->type = type; - rng->state = NULL; + rng->max_value = max_value; + rng->inv_max = 1.0 / max_value; + rng->type = type; + rng->state = NULL; rng->state = rng->alloc_state( ); @@ -102,28 +105,32 @@ rng_type * rng_alloc__(rng_alloc_ftype * alloc_state, void rng_init( rng_type * rng , rng_init_mode init_mode ) { - char * seed_buffer = (char *) util_calloc( rng->state_size , sizeof * seed_buffer ); - - switch (init_mode) { - case(INIT_CLOCK): - { - int i; - for (i=0; i < rng->state_size; i++) - seed_buffer[i] = ( char ) util_clock_seed(); + if (init_mode == INIT_DEFAULT) + rng_set_state( rng , NULL ); + else { + char * seed_buffer = (char *) util_calloc( rng->state_size , sizeof * seed_buffer ); + + switch (init_mode) { + case(INIT_CLOCK): + { + int i; + for (i=0; i < rng->state_size; i++) + seed_buffer[i] = ( char ) util_clock_seed(); + } + break; + case(INIT_DEV_RANDOM): + util_fread_dev_random( rng->state_size * sizeof * seed_buffer , seed_buffer ); + break; + case(INIT_DEV_URANDOM): + util_fread_dev_urandom( rng->state_size * sizeof * seed_buffer , seed_buffer ); + break; + default: + util_abort("%s: unrecognized init_code:%d \n",__func__ , init_mode); } - break; - case(INIT_DEV_RANDOM): - util_fread_dev_random( rng->state_size * sizeof * seed_buffer , seed_buffer ); - break; - case(INIT_DEV_URANDOM): - util_fread_dev_urandom( rng->state_size * sizeof * seed_buffer , seed_buffer ); - break; - default: - util_abort("%s: unrecognized init_code:%d \n",__func__ , init_mode); + + rng_set_state( rng , seed_buffer ); + free( seed_buffer ); } - - rng->set_state( rng->state , seed_buffer ); - free( seed_buffer ); } @@ -151,6 +158,8 @@ void rng_rng_init( rng_type * rng , rng_type * seed_src) { + + rng_type * rng_alloc( rng_alg_type type , rng_init_mode init_mode ) { rng_type * rng; switch (type) { @@ -159,6 +168,7 @@ rng_type * rng_alloc( rng_alg_type type , rng_init_mode init_mode ) { mzran_free , mzran_forward , mzran_set_state , + mzran_get_state , mzran_fscanf_state , mzran_fprintf_state , type , @@ -170,13 +180,23 @@ rng_type * rng_alloc( rng_alg_type type , rng_init_mode init_mode ) { rng = NULL; } - if (init_mode != INIT_DEFAULT) - rng_init( rng , init_mode ); - + rng_init( rng , init_mode ); return rng; } +int rng_state_size( const rng_type * rng ) { + return rng->state_size; +} + + +void rng_get_state(const rng_type * rng, char * state) { + rng->get_state( rng->state , state ); +} + +void rng_set_state( rng_type * rng , const char * state) { + rng->set_state( rng->state , state ); +} void rng_free( rng_type * rng) { rng->free_state( rng->state ); diff --git a/ThirdParty/Ert/devel/libert_util/src/string_util.c b/ThirdParty/Ert/devel/libert_util/src/string_util.c new file mode 100644 index 0000000000..28360c2ebc --- /dev/null +++ b/ThirdParty/Ert/devel/libert_util/src/string_util.c @@ -0,0 +1,208 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'string_util.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + +#include +#include +#include +#include +#include + + +/*****************************************************************/ + +/* + This functions parses an input string 'range_string' of the type: + + "0,1,8, 10 - 20 , 15,17-21" + + I.e. integers separated by "," and "-". The integer values are + parsed out. +*/ + +//#include +//#include +//static int * util_sscanf_active_range__NEW(const char * range_string , int max_value , bool * active , int * _list_length) { +// tokenizer_type * tokenizer = tokenizer_alloc( NULL , /* No ordinary split characters. */ +// NULL , /* No quoters. */ +// ",-" , /* Special split on ',' and '-' */ +// " \t" , /* Removing ' ' and '\t' */ +// NULL , /* No comment */ +// NULL ); +// stringlist_type * tokens; +// tokens = tokenize_buffer( tokenizer , range_string , true); +// +// stringlist_free( tokens ); +// tokenizer_free( tokenizer ); +//} + + + +static bool valid_characters( const char * range_string ) { + bool valid = false; + if (range_string) { + int offset = 0; + valid = true; + while (true) { + char c = range_string[offset]; + if (isspace(c) || isdigit(c) || c == ',' || c == '-') + offset++; + else + valid = false; + if (offset == strlen( range_string ) || !valid) + break; + } + } + return valid; +} + + + +static int_vector_type * string_util_sscanf_alloc_active_list(const char * range_string ) { + int_vector_type *active_list = NULL; + bool valid = valid_characters( range_string ); + + if (valid) + { + parser_type * parser = parser_alloc( "," , /* No ordinary split characters. */ + NULL , /* No quoters. */ + NULL , /* No special split */ + " \t" , /* Removing ' ' and '\t' */ + NULL , /* No comment */ + NULL ); + stringlist_type * tokens; + int item; + active_list = int_vector_alloc(0,0); + tokens = parser_tokenize_buffer( parser , range_string , true); + + for (item = 0; item < stringlist_get_size( tokens ); item++) { + const char * string_item = stringlist_iget( tokens , item ); + char * pos_ptr = string_item; + int value1 , value2; + + value1 = strtol( string_item , &pos_ptr , 10); + if (*pos_ptr == '\0') + // The pos_ptr points to the end of the string, i.e. this was a single digit. + value2 = value1; + else { + // OK - this is a range; skip spaces and the range dash '-' + while (isspace(*pos_ptr) || *pos_ptr == '-') + pos_ptr++; + util_sscanf_int( pos_ptr , &value2); + } + + { + int value; + for (value = value1; value <= value2; value++) + int_vector_append( active_list , value ); + } + } + + + stringlist_free( tokens ); + parser_free( parser ); + } + + return active_list; +} + + + + +/*****************************************************************/ + +static bool_vector_type * alloc_mask( const int_vector_type * active_list ) { + bool_vector_type * mask = bool_vector_alloc( 0 , false ); + int i; + for (i=0; i < int_vector_size( active_list ); i++) + bool_vector_iset( mask , int_vector_iget( active_list , i) , true ); + + return mask; +} + + + +bool string_util_update_active_list( const char * range_string , int_vector_type * active_list ) { + int_vector_sort( active_list ); + { + bool_vector_type * mask = alloc_mask( active_list ); + bool valid = false; + + if (string_util_update_active_mask( range_string , mask )) { + int_vector_reset( active_list ); + { + int i; + for (i=0; i < bool_vector_size(mask); i++) { + bool active = bool_vector_iget( mask , i ); + if (active) + int_vector_append( active_list , i ); + } + } + valid = true; + } + bool_vector_free( mask ); + return valid; + } +} + + +bool string_util_init_active_list( const char * range_string , int_vector_type * active_list ) { + int_vector_reset( active_list ); + return string_util_update_active_list( range_string , active_list ); +} + + +int_vector_type * string_util_alloc_active_list( const char * range_string ) { + int_vector_type * active_list = int_vector_alloc( 0 , 0 ); + string_util_init_active_list( range_string , active_list ); + return active_list; +} + +/*****************************************************************/ + +/* + This is the only function which actually invokes the low level + string parsing in util_sscanf_alloc_active_list(). +*/ + +bool string_util_update_active_mask( const char * range_string , bool_vector_type * active_mask) { + int i; + int_vector_type * sscanf_active = string_util_sscanf_alloc_active_list( range_string ); + if (sscanf_active) { + for (i=0; i < int_vector_size( sscanf_active ); i++) + bool_vector_iset( active_mask , int_vector_iget(sscanf_active , i) , true ); + + int_vector_free( sscanf_active ); + return true; + } else + return false; +} + + +bool string_util_init_active_mask( const char * range_string , bool_vector_type * active_mask ) { + bool_vector_reset( active_mask ); + return string_util_update_active_mask( range_string , active_mask ); +} + + +bool_vector_type * string_util_alloc_active_mask( const char * range_string ) { + bool_vector_type * mask = bool_vector_alloc(0 , false ); + string_util_init_active_mask( range_string , mask ); + return mask; +} diff --git a/ThirdParty/Ert/devel/libert_util/src/stringlist.c b/ThirdParty/Ert/devel/libert_util/src/stringlist.c index 83e1fedc5a..0ce5e15880 100644 --- a/ThirdParty/Ert/devel/libert_util/src/stringlist.c +++ b/ThirdParty/Ert/devel/libert_util/src/stringlist.c @@ -56,15 +56,16 @@ struct stringlist_struct { static void stringlist_fprintf__(const stringlist_type * stringlist, const char * sep , FILE * stream) { - int i; int length = vector_get_size( stringlist->strings ); - - for (i=0; i < length - 1; i++) { - const char * s = stringlist_iget(stringlist , i); - fprintf(stream , "%s%s", s , sep); + if (length > 0) { + int i; + for (i=0; i < length - 1; i++) { + const char * s = stringlist_iget(stringlist , i); + fprintf(stream , "%s%s", s , sep); + } + + fprintf(stream , "%s", stringlist_iget( stringlist , length - 1 )); } - - fprintf(stream , "%s", stringlist_iget( stringlist , length - 1 )); } @@ -330,10 +331,33 @@ void stringlist_idel(stringlist_type * stringlist , int index) { } +char * stringlist_pop( stringlist_type * stringlist) { + return vector_pop( stringlist->strings ); +} + + const char * stringlist_iget(const stringlist_type * stringlist , int index) { return vector_iget(stringlist->strings ,index); } +int stringlist_iget_as_int( const stringlist_type * stringlist , int index , bool * valid) { + const char * string_value = stringlist_iget( stringlist , index ); + int value = -1; + + if (valid != NULL) + *valid = false; + + if (util_sscanf_int(string_value , &value)) + if (valid != NULL) + *valid = true; + + return value; +} + +const char * stringlist_get_last( const stringlist_type * stringlist ) { + return vector_get_last( stringlist->strings ); +} + bool stringlist_iequal( const stringlist_type * stringlist , int index, const char * s ) { return util_string_equal( stringlist_iget( stringlist , index ) , s); @@ -646,6 +670,11 @@ void stringlist_python_sort( stringlist_type * s , int cmp_flag) { } +void stringlist_reverse( stringlist_type * s ) { + vector_inplace_reverse( s->strings ); +} + + /*****************************************************************/ /* diff --git a/ThirdParty/Ert/devel/libert_util/src/subst_func.c b/ThirdParty/Ert/devel/libert_util/src/subst_func.c index d90b3882e4..eebdc69836 100644 --- a/ThirdParty/Ert/devel/libert_util/src/subst_func.c +++ b/ThirdParty/Ert/devel/libert_util/src/subst_func.c @@ -61,7 +61,7 @@ char * subst_func_eval( const subst_func_type * subst_func , const stringlist_ty util_abort("%s: Fatal error - aborting \n",__func__); } } - + printf("Running:%s \n",subst_func->name); return subst_func->func( args , subst_func->arg ); } diff --git a/ThirdParty/Ert/devel/libert_util/src/subst_list.c b/ThirdParty/Ert/devel/libert_util/src/subst_list.c index be9c2bced5..577f772968 100644 --- a/ThirdParty/Ert/devel/libert_util/src/subst_list.c +++ b/ThirdParty/Ert/devel/libert_util/src/subst_list.c @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -82,6 +83,7 @@ struct subst_list_struct { vector_type * string_data; /* The string substitutions we should do. */ vector_type * func_data; /* The functions we support. */ const subst_func_pool_type * func_pool; /* NOT owned by the subst_list instance - can be NULL */ + hash_type * map; }; @@ -207,7 +209,7 @@ static subst_list_string_type * subst_list_get_string_node(const subst_list_type subst_list_string_type * node = NULL; int index = 0; - /* Linear search ... */ + /* Linear search ... */ /*Should use map*/ while ((index < vector_get_size(subst_list->string_data)) && (node == NULL)) { subst_list_string_type * inode = vector_iget( subst_list->string_data , index); @@ -224,10 +226,12 @@ static subst_list_string_type * subst_list_get_string_node(const subst_list_type static subst_list_string_type * subst_list_insert_new_node(subst_list_type * subst_list , const char * key , bool append) { subst_list_string_type * new_node = subst_list_string_alloc(key); + if (append) vector_append_owned_ref( subst_list->string_data , new_node , subst_list_string_free__ ); else vector_insert_owned_ref( subst_list->string_data , 0 , new_node , subst_list_string_free__ ); + return new_node; } @@ -274,6 +278,7 @@ subst_list_type * subst_list_alloc(const void * input_arg) { UTIL_TYPE_ID_INIT( subst_list , SUBST_LIST_TYPE_ID); subst_list->parent = NULL; subst_list->func_pool = NULL; + subst_list->map = hash_alloc(); subst_list->string_data = vector_alloc_new(); subst_list->func_data = vector_alloc_new(); @@ -387,6 +392,7 @@ void subst_list_clear( subst_list_type * subst_list ) { void subst_list_free(subst_list_type * subst_list) { vector_free( subst_list->string_data ); vector_free( subst_list->func_data ); + hash_free( subst_list->map ); free(subst_list); } @@ -417,18 +423,22 @@ void subst_list_free(subst_list_type * subst_list) { subst_list. This is the lowest level function, which does *NOT* consider the parent pointer. */ -static void subst_list_replace_strings__(const subst_list_type * subst_list , buffer_type * buffer) { +static bool subst_list_replace_strings__(const subst_list_type * subst_list , buffer_type * buffer) { int index; + bool global_match = false; for (index = 0; index < vector_get_size( subst_list->string_data ); index++) { const subst_list_string_type * node = vector_iget_const( subst_list->string_data , index ); if (node->value != NULL) { - bool match; + bool match; buffer_rewind( buffer ); do { match = buffer_search_replace( buffer , node->key , node->value); + if (match) + global_match = true; } while (match); } } + return global_match; } @@ -464,63 +474,63 @@ static void subst_list_replace_strings__(const subst_list_type * subst_list , bu */ -static void subst_list_eval_funcs____(const subst_list_type * subst_list , const parser_type * parser , buffer_type * buffer) { - { - int index; - for (index = 0; index < vector_get_size( subst_list->func_data); index++) { - const subst_list_func_type * subst_func = vector_iget_const( subst_list->func_data , index ); - const char * func_name = subst_func->name; +static bool subst_list_eval_funcs____(const subst_list_type * subst_list , const parser_type * parser , buffer_type * buffer) { + bool global_match = false; + int index; + for (index = 0; index < vector_get_size( subst_list->func_data); index++) { + const subst_list_func_type * subst_func = vector_iget_const( subst_list->func_data , index ); + const char * func_name = subst_func->name; + + bool match; + buffer_rewind( buffer ); + do { + size_t match_pos; + match = buffer_strstr( buffer , func_name ); + match_pos = buffer_get_offset( buffer ); - bool match; - buffer_rewind( buffer ); - do { - size_t match_pos; - match = buffer_strstr( buffer , func_name ); - match_pos = buffer_get_offset( buffer ); + if (match) { + bool update = false; + char * arg_start = buffer_get_data( buffer ); + arg_start += buffer_get_offset( buffer ) + strlen( func_name ); - if (match) { - bool update = false; - char * arg_start = buffer_get_data( buffer ); - arg_start += buffer_get_offset( buffer ) + strlen( func_name ); - - if (arg_start[0] == '(') { /* We require that an opening paren follows immediately behind the function name. */ - char * arg_end = strchr( arg_start , ')'); - if (arg_end != NULL) { - /* OK - we found an enclosing () pair. */ - char * arg_content = util_alloc_substring_copy( arg_start, 1 , arg_end - arg_start - 1); - stringlist_type * arg_list = parser_tokenize_buffer( parser , arg_content , true); - char * func_eval = subst_list_func_eval( subst_func , arg_list ); - int old_len = strlen(func_name) + strlen( arg_content) + 2; - - if (func_eval != NULL) { - buffer_memshift( buffer , match_pos + old_len , strlen( func_eval ) - old_len); - buffer_fwrite( buffer , func_eval , strlen( func_eval ) , sizeof * func_eval ); - free( func_eval ); - update = true; - } - - free( arg_content ); - stringlist_free( arg_list ); - } + if (arg_start[0] == '(') { /* We require that an opening paren follows immediately behind the function name. */ + char * arg_end = strchr( arg_start , ')'); + if (arg_end != NULL) { + /* OK - we found an enclosing () pair. */ + char * arg_content = util_alloc_substring_copy( arg_start, 1 , arg_end - arg_start - 1); + stringlist_type * arg_list = parser_tokenize_buffer( parser , arg_content , true); + char * func_eval = subst_list_func_eval( subst_func , arg_list ); + int old_len = strlen(func_name) + strlen( arg_content) + 2; + + if (func_eval != NULL) { + buffer_memshift( buffer , match_pos + old_len , strlen( func_eval ) - old_len); + buffer_fwrite( buffer , func_eval , strlen( func_eval ) , sizeof * func_eval ); + free( func_eval ); + update = true; + global_match = true; + } + + free( arg_content ); + stringlist_free( arg_list ); } - - if (!update) - buffer_fseek( buffer , match_pos + strlen( func_name ) , SEEK_SET); - } - } while (match); - } + } + if (!update) + buffer_fseek( buffer , match_pos + strlen( func_name ) , SEEK_SET); + } + } while (match); } if (subst_list->parent != NULL) - subst_list_eval_funcs____( subst_list->parent , parser , buffer ); + global_match = (subst_list_eval_funcs____( subst_list->parent , parser , buffer ) || global_match); + return global_match; } -static void subst_list_eval_funcs__(const subst_list_type * subst_list , buffer_type * buffer) { +static bool subst_list_eval_funcs__(const subst_list_type * subst_list , buffer_type * buffer) { parser_type * parser = parser_alloc( "," , "\"\'" , NULL , " \t" , NULL , NULL ); - - subst_list_eval_funcs____( subst_list , parser , buffer ); + bool match = subst_list_eval_funcs____( subst_list , parser , buffer ); parser_free( parser ); + return match; } @@ -578,12 +588,14 @@ static void subst_list_eval_funcs__(const subst_list_type * subst_list , buffer_ subst_list_replace_strings__() which is not recursive. */ -static void subst_list_replace_strings( const subst_list_type * subst_list , buffer_type * buffer ) { +static bool subst_list_replace_strings( const subst_list_type * subst_list , buffer_type * buffer ) { + bool match = false; if (subst_list->parent != NULL) - subst_list_replace_strings( subst_list->parent , buffer ); + match = subst_list_replace_strings( subst_list->parent , buffer ); /* The actual string replace */ - subst_list_replace_strings__( subst_list , buffer ); + match = (subst_list_replace_strings__( subst_list , buffer ) || match); + return match; } @@ -597,9 +609,10 @@ static void subst_list_replace_strings( const subst_list_type * subst_list , buf */ -void subst_list_update_buffer( const subst_list_type * subst_list , buffer_type * buffer ) { - subst_list_replace_strings( subst_list , buffer ); - subst_list_eval_funcs__( subst_list , buffer ); +bool subst_list_update_buffer( const subst_list_type * subst_list , buffer_type * buffer ) { + bool match1 = subst_list_replace_strings( subst_list , buffer ); + bool match2 = subst_list_eval_funcs__( subst_list , buffer ); + return (match1 || match2); // Funny construction to ensure to avoid fault short circuit. } @@ -616,7 +629,8 @@ void subst_list_update_buffer( const subst_list_type * subst_list , buffer_type */ -void subst_list_filter_file(const subst_list_type * subst_list , const char * src_file , const char * target_file) { +bool subst_list_filter_file(const subst_list_type * subst_list , const char * src_file , const char * target_file) { + bool match; char * backup_file = NULL; buffer_type * buffer = buffer_fread_alloc( src_file ); buffer_fseek( buffer , 0 , SEEK_END ); /* Ensure that the buffer is a \0 terminated string. */ @@ -630,6 +644,7 @@ void subst_list_filter_file(const subst_list_type * subst_list , const char * sr free(backup_prefix); } + /* Writing backup file */ if (backup_file != NULL) { FILE * stream = util_fopen(backup_file , "w"); @@ -639,7 +654,7 @@ void subst_list_filter_file(const subst_list_type * subst_list , const char * sr /* Doing the actual update */ - subst_list_update_buffer(subst_list , buffer); + match = subst_list_update_buffer(subst_list , buffer); /* Writing updated file */ @@ -655,13 +670,15 @@ void subst_list_filter_file(const subst_list_type * subst_list , const char * sr free( backup_file ); } free(buffer); + return match; } /** This function does search-replace on a file inplace. */ -void subst_list_update_file(const subst_list_type * subst_list , const char * file) { - subst_list_filter_file( subst_list , file , file ); + +bool subst_list_update_file(const subst_list_type * subst_list , const char * file) { + return subst_list_filter_file( subst_list , file , file ); } @@ -669,11 +686,13 @@ void subst_list_update_file(const subst_list_type * subst_list , const char * fi /** This function does search-replace on string instance inplace. */ -void subst_list_update_string(const subst_list_type * subst_list , char ** string) { +bool subst_list_update_string(const subst_list_type * subst_list , char ** string) { buffer_type * buffer = buffer_alloc_private_wrapper( *string , strlen( *string ) + 1); - subst_list_update_buffer(subst_list , buffer); + bool match = subst_list_update_buffer(subst_list , buffer); *string = buffer_get_data( buffer ); buffer_free_container( buffer ); + + return match; } @@ -806,6 +825,7 @@ const char * subst_list_iget_doc_string( const subst_list_type * subst_list , in } + void subst_list_fprintf(const subst_list_type * subst_list , FILE * stream) { int index; for (index=0; index < vector_get_size( subst_list->string_data ); index++) { diff --git a/ThirdParty/Ert/devel/libert_util/src/test_util.c b/ThirdParty/Ert/devel/libert_util/src/test_util.c index 89c442a8dd..ed8effe35a 100644 --- a/ThirdParty/Ert/devel/libert_util/src/test_util.c +++ b/ThirdParty/Ert/devel/libert_util/src/test_util.c @@ -76,6 +76,18 @@ void test_assert_int_not_equal__( int i1 , int i2 , const char * file , int line } +void test_assert_uint_equal__( unsigned int i1 , unsigned int i2 , const char * file , int line) { + if (i1 != i2) + test_error_exit( "%s:%d => Integers are different i1:[%d] i2:[%d]\n" , file , line , i1 , i2 ); +} + + +void test_assert_uint_not_equal__( unsigned int i1 , unsigned int i2 , const char * file , int line) { + if (i1 == i2) + test_error_exit( "%s:%d => Integers are equal i1:[%d] i2:[%d]\n" , file , line , i1 , i2 ); +} + + void test_assert_bool_equal__( bool b1 , bool b2 , const char * file , int line) { if (b1 != b2) test_error_exit( "%s:%d => Booleans are different b1:[%d] b2:[%d]\n" , file , line , b1 , b2 ); @@ -87,20 +99,22 @@ void test_assert_bool_equal__( bool b1 , bool b2 , const char * file , int line) void test_assert_time_t_equal__( time_t t1 , time_t t2 , const char * file , int line) { if (t1 != t2) - test_error_exit("%s:%d => time_t values are different t1:%d t2:[%d]" , file , line , t1 , t2); + test_error_exit("%s:%d => time_t values are different t1:%d t2:[%d]\n" , file , line , t1 , t2); } void test_assert_time_t_not_equal__( time_t t1 , time_t t2 , const char * file , int line) { if (t1 == t2) - test_error_exit("%s:%d => time_t values are different t1:%d t2:[%d]" , file , line , t1 , t2); + test_error_exit("%s:%d => time_t values are different t1:%d t2:[%d]\n" , file , line , t1 , t2); } + + /*****************************************************************/ void test_assert_true__( bool value, const char * file , int line) { if (!value) - test_error_exit("%s:%d => assert( true ) failed" , file , line); + test_error_exit("%s:%d => assert( true ) failed\n" , file , line); } @@ -119,6 +133,13 @@ void test_assert_ptr_equal__( const void * p1 , const void * p2 , const char * f } +void test_assert_ptr_not_equal__( const void * p1 , const void * p2 , const char * file , int line) { + bool equal = (p1 == p2); + if (equal) + test_error_exit( "%s:%d => Pointers are different p1:[%p] p2:[%p]\n" , file , line , p1 , p2 ); +} + + void test_assert_NULL__( const void * p , const char * file , int line) { if (p != NULL) test_error_exit( "%s:%d => Pointer is != NULL \n" , file , line , p); @@ -132,8 +153,16 @@ void test_assert_not_NULL__( const void * p , const char * file , int line) { void test_assert_mem_equal__( const void * p1 , const void * p2 , size_t byte_size , const char * file , int line) { - if (memcmp(p1 ,p2 , byte_size) != 0) - test_error_exit( "%s:%d => Memory regions have different content \n" , file , line); + if (memcmp(p1 ,p2 , byte_size) != 0) { + const char * char_ptr1 = (const char *) p1; + const char * char_ptr2 = (const char *) p2; + size_t offset = 0; + + while( char_ptr1[offset] == char_ptr2[offset]) + offset++; + + test_error_exit( "%s:%d => Memory regions have different content. First difference at offset:%ld\n" , file , line , offset); + } } @@ -141,3 +170,44 @@ void test_assert_mem_not_equal__( const void * p1 , const void * p2 , size_t byt if (memcmp(p1 ,p2 , byte_size) == 0) test_error_exit( "%s:%d => Memory regions have the same content \n" , file , line); } + + + +void test_assert_double_equal__( double d1 , double d2, const char * file , int line) { + if (!util_double_approx_equal(d1 , d2)) + test_error_exit( "%s:%d => double values:%g %g are not sufficiently similar\n" , file , line , d1 , d2); +} + + +void test_assert_double_not_equal__( double d1 , double d2, const char * file , int line) { + if (util_double_approx_equal(d1 , d2)) + test_error_exit( "%s:%d => double values:%15.12g %15.12g are equal.\n" , file , line , d1 , d2); +} + + + +/*****************************************************************/ + +#ifdef HAVE_UTIL_ABORT +#include + +void test_util_addr2line() { + const char * file = __FILE__; + const char * func = __func__; + int line; + const int max_bt = 50; + void *bt_addr[max_bt]; + int size; + char * func_name , * file_name; + int line_nr; + + line = __LINE__ + 2; + size = backtrace(bt_addr , max_bt); + test_assert_int_equal( size , 4 ); + test_assert_true( util_addr2line_lookup( bt_addr[0] , &func_name , &file_name , &line_nr)); + test_assert_string_equal( func_name , func ); + test_assert_int_equal( line , line_nr ); + test_assert_string_equal( file_name , file ); +} + +#endif diff --git a/ThirdParty/Ert/devel/libert_util/src/time_interval.c b/ThirdParty/Ert/devel/libert_util/src/time_interval.c new file mode 100644 index 0000000000..afd87fec6e --- /dev/null +++ b/ThirdParty/Ert/devel/libert_util/src/time_interval.c @@ -0,0 +1,174 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'time_interval.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include + +#include +#include + +#define TIME_INTERVAL_EMPTY (time_t) -1 +#define TIME_T_MAX (time_t) ((1UL << (( sizeof(time_t) << 3) -1 )) -1 ) +#define TIME_T_MIN -TIME_T_MAX + + +struct time_interval_struct { + bool valid; + time_t start_time; + time_t end_time; +}; + + +/* + If you set something invalid - the whole interval is destroyed. +*/ + +bool time_interval_update( time_interval_type * ti , time_t start_time , time_t end_time) { + ti->start_time = start_time; + ti->end_time = end_time; + + ti->valid = (start_time <= end_time) ? true : false; + return ti->valid; +} + + +bool time_interval_update_start( time_interval_type * ti , time_t start_time ) { + return time_interval_update( ti , start_time , ti->end_time ); +} + + +bool time_interval_update_end( time_interval_type * ti , time_t end_time ) { + return time_interval_update( ti , ti->start_time , end_time ); +} + + +void time_interval_reopen( time_interval_type * time_interval) { + time_interval_update( time_interval , TIME_T_MIN , TIME_T_MAX); +} + + +time_interval_type * time_interval_alloc( time_t start_time , time_t end_time ) { + time_interval_type * ti = util_malloc( sizeof * ti ); + time_interval_update( ti , start_time , end_time ); + return ti; +} + + +time_interval_type * time_interval_alloc_open( ) { + return time_interval_alloc( TIME_T_MIN , TIME_T_MAX ); +} + +time_interval_type * time_interval_alloc_copy( const time_interval_type * src) { + return time_interval_alloc( src->start_time , src->end_time ); +} + + +void time_interval_free( time_interval_type * ti ) { + free( ti ); +} + + +bool time_interval_is_empty( time_interval_type * ti ) { + return (ti->end_time <= ti->start_time); +} + + +bool time_interval_contains( const time_interval_type * ti , time_t t) { + if (!ti->valid) + return false; + else { + if (t < ti->start_time) + return false; + else if (t >= ti->end_time) + return false; + else + return true; + } +} + + + +bool time_interval_has_overlap( const time_interval_type * t1 , const time_interval_type * t2) { + if (t1->valid && t2->valid) { + if (time_interval_contains(t1 , t2->start_time)) + return true; + + if (time_interval_contains(t1 , t2->end_time)) + return true; + + return false; + } else + return false; +} + +bool time_interval_is_adjacent( const time_interval_type * t1 , const time_interval_type * t2) { + if ((t1->end_time == t2->start_time) || (t1->start_time == t2->end_time)) + return true; + else + return false; +} + + +time_t time_interval_get_start( const time_interval_type * ti) { + return ti->start_time; +} + + + +time_t time_interval_get_end( const time_interval_type * ti) { + return ti->end_time; +} + + +bool time_interval_extend( time_interval_type * t1 , const time_interval_type * t2) { + if (time_interval_has_overlap(t1,t2) || time_interval_is_adjacent( t1 , t2)) { + time_t start_time = util_time_t_min( t1->start_time , t2->start_time ); + time_t end_time = util_time_t_max( t1->end_time , t2->end_time ); + + return time_interval_update(t1 , start_time , end_time); + } else + return false; +} + + +bool time_interval_intersect( time_interval_type * t1 , const time_interval_type * t2) { + if (time_interval_has_overlap(t1,t2) || time_interval_is_adjacent( t1 , t2)) { + time_t start_time = util_time_t_max( t1->start_time , t2->start_time ); + time_t end_time = util_time_t_min( t1->end_time , t2->end_time ); + + return time_interval_update(t1 , start_time , end_time); + } else + return false; +} + + +bool time_interval_equal( const time_interval_type * t1 , const time_interval_type * t2) { + if ((t1->start_time == t2->start_time) && (t1->end_time == t2->end_time)) + return true; + else + return false; +} + + +bool time_interval_arg_after( const time_interval_type * ti , time_t arg) { + return util_after( arg , ti->end_time ); +} + + +bool time_interval_arg_before( const time_interval_type * ti , time_t arg) { + return util_before( arg , ti->start_time ); +} diff --git a/ThirdParty/Ert/devel/libert_util/src/util.c b/ThirdParty/Ert/devel/libert_util/src/util.c index 1469eeb957..304a656b2d 100644 --- a/ThirdParty/Ert/devel/libert_util/src/util.c +++ b/ThirdParty/Ert/devel/libert_util/src/util.c @@ -34,6 +34,20 @@ #include #include + +#ifdef HAVE_FORK +#ifdef WITH_PTHREAD +#ifdef HAVE_EXECINFO +#define HAVE_UTIL_ABORT +#endif +#endif +#endif + +#ifdef HAVE_UTIL_ABORT +#define __USE_GNU // Must be defined to get access to the dladdr() function; Man page says the symbol should be: _GNU_SOURCE but that does not seem to work? +#define _GNU_SOURCE // Must be defined _before_ #include to get the symbol 'program_invocation_name'. +#include +#endif #include #include @@ -78,6 +92,7 @@ #include #endif + #include #if UINTPTR_MAX == 0xFFFFFFFF #define ARCH32 @@ -254,6 +269,10 @@ void util_endian_flip_vector_old(void *data, int element_size , int elements) { } } +#ifndef S_ISDIR +#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) +#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) +#endif /*****************************************************************/ @@ -330,8 +349,20 @@ double util_kahan_sum(const double *data, size_t N) { } - - +bool util_double_approx_equal( double d1 , double d2) { + if (d1 == d2) + return true; + else { + double epsilon = 1e-6; + double diff = fabs(d1 - d2); + double sum = fabs(d1) + fabs(d2); + + if ((diff / sum) < epsilon) + return true; + else + return false; + } +} char * util_alloc_substring_copy(const char *src , int offset , int N) { @@ -720,6 +751,34 @@ char * util_alloc_cwd(void) { +bool util_is_cwd( const char * path ) { + bool is_cwd = false; + struct stat path_stat; + + if (stat(path , &path_stat) == 0) { + if (S_ISDIR( path_stat.st_mode )) { + char * cwd = util_alloc_cwd(); +#ifdef ERT_WINDOWS + /* + The windows stat structure has the inode element, but it is + not set. Actually - this is a property of the filesystem, and + not the operating system - the whole check is probably broken? + */ + util_abort("%s: Internal error - function not properly implmented on Windows \n",__func__); +#else + struct stat cwd_stat; + stat(cwd , &cwd_stat); + if (cwd_stat.st_ino == path_stat.st_ino) + is_cwd = true; +#endif + free( cwd ); + } + } + return is_cwd; +} + + + /* Homemade realpath() for not existing path or platforms without realpath(). @@ -739,6 +798,81 @@ static char * util_alloc_cwd_abs_path( const char * path ) { } + +/** + Manual realpath() implementation to be used on platforms without + realpath() support. Will remove /../, ./ and extra //. Will not + handle symlinks. +*/ + + +#define BACKREF ".." +#define CURRENT "." + +char * util_alloc_realpath__(const char * input_path) { + char * abs_path = util_alloc_cwd_abs_path( input_path ); + char * real_path = util_malloc( strlen(abs_path) + 1 ); + real_path[0] = '\0'; + + { + bool * mask; + char ** path_list; + int path_len; + + util_path_split( abs_path , &path_len , &path_list ); + mask = util_malloc( path_len * sizeof * mask ); + { + int i; + for (i=0; i < path_len; i++) + mask[i] = true; + } + + { + int path_index = 1; // Path can not start with .. + int prev_index = 0; + while (true) { + if (path_index == path_len) + break; + + if (strcmp(path_list[path_index] , BACKREF ) == 0) { + mask[path_index] = false; + mask[prev_index] = false; + prev_index--; + path_index++; + } else if (strcmp( path_list[path_index] , CURRENT) == 0) { + mask[path_index] = false; + path_index++; + } else { + path_index++; + prev_index++; + while (!mask[prev_index]) + prev_index++; + } + } + + /* Build up the new string. */ + { + int i; + for (i=0; i < path_len; i++) { + if (mask[i]) { + strcat( real_path , UTIL_PATH_SEP_STRING ); + strcat( real_path , path_list[i]); + } + } + } + } + free(mask); + util_free_stringlist( path_list , path_len ); + } + + return real_path; +} + +#undef BACKREF +#undef CURRENT + + + /** The util_alloc_realpath() will fail hard if the @input_path does not exist. If the path might-not-exist you should use @@ -762,10 +896,13 @@ char * util_alloc_realpath(const char * input_path) { /* We do not have the realpath() implementation. Must first check if the entry exists; and if not we abort. If the entry indeed exists we call the util_alloc_cwd_abs_path() function: */ +#ifdef HAVE_SYMLINK + ERROR - What the fuck; have symlinks and not realpath()?! +#endif if (!util_entry_exists( input_path )) - util_abort("%s: input_path:%s does not exist - realpath() failed.\n",__func__ , input_path); + util_abort("%s: input_path:%s does not exist - failed.\n",__func__ , input_path); - return util_alloc_cwd_abs_path( input_path ); + return util_alloc_realpath__( input_path ); #endif } @@ -782,17 +919,103 @@ char * util_alloc_realpath(const char * input_path) { 2. Else cwd is prepended to the path. - In the manual realpath() neither "/../" nor symlinks are resolved. + In the manual realpath() neither "/../" nor symlinks are resolved. If path == NULL the function will return cwd(). */ char * util_alloc_abs_path( const char * path ) { - if (util_entry_exists( path )) - return util_alloc_realpath( path ); - else - return util_alloc_cwd_abs_path( path ); + if (path == NULL) + return util_alloc_cwd(); + else { + if (util_entry_exists( path )) + return util_alloc_realpath( path ); + else + return util_alloc_cwd_abs_path( path ); + } } + +/** + Both path arguments must be absolute paths; if not a copy of the + input path will be returned. Neither of the input arguments can + have "/../" elements - that will just fuck things up. + + root_path can be NULL - in which case cwd is used. +*/ + +char * util_alloc_rel_path( const char * __root_path , const char * path) { + char * root_path; + if (__root_path == NULL) + root_path = util_alloc_cwd(); + else + root_path = util_alloc_string_copy( __root_path ); + + if (util_is_abs_path(root_path) && util_is_abs_path(path)) { + const char * back_path = ".."; + char * rel_path = util_alloc_string_copy(""); // In case strcmp(root_path , path) == 0 the empty string "" will be returned + char ** root_path_list; + char ** path_list; + int root_path_length , path_length , back_length; + + /* 1. Split both input paths into list of path elements. */ + util_path_split( root_path, &root_path_length , &root_path_list ); + util_path_split( path , &path_length , &path_list ); + + { + /* 2: Determine the number of common leading path elements. */ + int common_length = 0; + while (true) { + if (strcmp(root_path_list[common_length] , path_list[common_length]) == 0) + common_length++; + else + break; + + if (common_length == util_int_min( root_path_length , path_length)) + break; + } + + /* 3: Start building up the relative path with leading ../ elements. */ + back_length = root_path_length - common_length; + if (back_length > 0) { + int i; + for (i=0; i < back_length; i++) { + rel_path = util_strcat_realloc( rel_path , back_path ); + rel_path = util_strcat_realloc( rel_path , UTIL_PATH_SEP_STRING ); + } + } + + /* 4: Add the remaining elements from the input path. */ + { + int i; + for (i=common_length; i < path_length; i++) { + rel_path = util_strcat_realloc( rel_path , path_list[i] ); + if (i != (path_length - 1)) + rel_path = util_strcat_realloc( rel_path , UTIL_PATH_SEP_STRING ); + } + } + } + + util_free_stringlist( root_path_list , root_path_length ); + util_free_stringlist( path_list , path_length ); + free( root_path ); + + if (strlen(rel_path) == 0) { + free(rel_path); + rel_path = NULL; + } return rel_path; + } else { + /* + One or both the input arguments do not correspond to an + absolute path; just return a copy of the input back. + */ + free( root_path ); + return util_alloc_string_copy( path ); + } +} + + + + /** This function will allocate a string copy of the env_index'th occurence of an embedded environment variable from the input @@ -1794,6 +2017,11 @@ double util_scanf_double(const char * prompt , int prompt_len) { } + + + + + /** The limits are inclusive. */ @@ -2207,13 +2435,7 @@ bool util_entry_exists( const char * entry ) { */ -#ifdef HAVE_ISREG -#endif -#ifndef S_ISDIR -#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) -#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) -#endif @@ -2279,6 +2501,13 @@ bool util_entry_readable( const char * entry ) { } +bool util_file_readable( const char * file ) { + if (util_entry_readable( file ) && util_is_file( file )) + return true; + else + return false; +} + bool util_entry_writable( const char * entry ) { struct stat buffer; if (stat( entry , &buffer ) == 0) @@ -2510,6 +2739,17 @@ void util_ftruncate(FILE * stream , long size) { +/* + The windows stat structure has the inode element, but it is not + set. Actually - this is a property of the filesystem, and not the + operating system - this check is probably broken on two levels: + + 1. One should really check the filesystem involved - whether it + supports inodes. + + 2. The code below will compile on windows, but for a windows + filesystem it will yield rubbish. +*/ bool util_same_file(const char * file1 , const char * file2) { struct stat buffer1 , buffer2; @@ -2518,7 +2758,7 @@ bool util_same_file(const char * file1 , const char * file2) { stat1 = stat(file1, &buffer1); // In the case of symlinks the stat call will stat the target file and not the link. stat2 = stat(file2, &buffer2); - if ((stat1 == 1) && (stat1 == stat2)) { + if ((stat1 == 0) && (stat1 == stat2)) { if (buffer1.st_ino == buffer2.st_ino) return true; else @@ -2666,6 +2906,22 @@ bool util_file_older( const char * file , time_t t0) { } +bool util_before( time_t t , time_t limit) { + if (difftime(limit , t) > 0) + return true; + else + return false; +} + + +bool util_after( time_t t , time_t limit) { + if (difftime(limit , t) < 0) + return true; + else + return false; +} + + /** This function will return a pointer to the newest of the two @@ -2732,6 +2988,16 @@ void util_set_date_values(time_t t , int * mday , int * month , int * year) { } +bool util_is_first_day_in_month( time_t t) { + int mday; + __util_set_timevalues(t , NULL , NULL , NULL , &mday ,NULL, NULL); + if (mday == 1) + return true; + else + return false; +} + + /** If the parsing fails the time_t pointer is set to -1; */ @@ -2870,6 +3136,11 @@ double util_difftime_days(time_t start_time , time_t end_time) { } +double util_difftime_seconds( time_t start_time , time_t end_time) { + double dt = difftime(end_time , start_time); + return dt; +} + /* Observe that this routine does the following transform before calling mktime: @@ -2906,6 +3177,12 @@ time_t util_make_date(int mday , int month , int year) { } +time_t util_make_pure_date(time_t t) { + int day,month,year; + util_set_date_values( t , &day , &month , &year); + return util_make_date( day , month , year ); +} + @@ -3189,29 +3466,53 @@ void util_free_stringlist(char **list , int N) { int i; if (list != NULL) { for (i=0; i < N; i++) { - if (list[i] != NULL) - free(list[i]); + util_safe_free( list[i] ); } free(list); } } +/** + Will free a list of strings where the last element is NULL. Will + go completely canacas if the list is not NULL terminated. +*/ + +void util_free_NULL_terminated_stringlist(char ** string_list) { + if (string_list != NULL) { + int i = 0; + while (true) { + if (string_list[i] == NULL) + break; + else + free( string_list[i] ); + i++; + } + free( string_list ); + } +} + /** This function will reallocate the string s1 to become the sum of s1 - and s2. If s1 == NULL it will just return a copy of s2. + and s2. If s1 == NULL it will just return a copy of s2. + + Observe that due to the use realloc() the s1 input argument MUST BE + the return value from a malloc() call; this is not intuitive and + the function should be discontinued. */ char * util_strcat_realloc(char *s1 , const char * s2) { if (s1 == NULL) s1 = util_alloc_string_copy(s2); else { - int new_length = strlen(s1) + strlen(s2) + 1; - s1 = util_realloc( s1 , new_length ); - strcat(s1 , s2); + if (s2 != NULL) { + int new_length = strlen(s1) + strlen(s2) + 1; + s1 = util_realloc( s1 , new_length ); + strcat(s1 , s2); + } } return s1; } @@ -3352,47 +3653,46 @@ void util_split_string(const char *line , const char *sep_set, int *_tokens, cha util_binary_split_string("A:B:C:D , ":" , false , ) => "A:B:C" & "D" - o Characters in the split_set at the front (or back if - split_on_first == false) are discarded _before_ the actual - splitting process. + o Characters in the split_set at the front and back are discarded + _BEFORE_ the actual splitting process. - util_binary_split_string(":::A:B:C:D" , ":" , true , ) => "A" & "B:C:D" + util_binary_split_string(":A:B:C:D:" , ":" , true , ) => "A" & "B:C:D" + util_binary_split_string(":A:B:C:D:" , ":" , false , ) => "A:B:C" & "D" o If no split is found the whole content is in first_part, and second_part is NULL. If the input string == NULL, both return - strings will be NULL. + strings will be NULL. Observe that because leading split + characters are removed before the splitting starts: + util_binary_split_string(":ABCD" , ":" , true , ) => "ABCD" & NULL + */ void util_binary_split_string(const char * __src , const char * sep_set, bool split_on_first , char ** __first_part , char ** __second_part) { char * first_part = NULL; char * second_part = NULL; - if (__src != NULL) { - char * src; - int pos; - if (split_on_first) { - /* Removing leading separators. */ - pos = 0; - while ((pos < strlen(__src)) && (strchr(sep_set , __src[pos]) != NULL)) - pos += 1; - if (pos == strlen(__src)) /* The string consisted ONLY of separators. */ - src = NULL; - else - src = util_alloc_string_copy(&__src[pos]); - } else { - /*Remove trailing separators. */ - pos = strlen(__src) - 1; - while ((pos >= 0) && (strchr(sep_set , __src[pos]) != NULL)) - pos -= 1; - if (pos < 0) - src = NULL; - else - src = util_alloc_substring_copy(__src , 0 , pos + 1); - } + char * src; + + if (__src != NULL) { + int offset = 0; + int len; + /* 1: Remove leading split characters. */ + while ((offset < strlen(__src)) && (strchr(sep_set , __src[offset]) != NULL)) + offset++; + len = strlen( __src ) - offset; + if (len > 0) { + int tail_pos = strlen( __src ) - 1; + /* 2: Remove trailing split characters. */ + while (strchr(sep_set , __src[tail_pos]) != NULL) + tail_pos--; + len = 1 + tail_pos - offset; + + src = util_alloc_substring_copy(__src , offset , len); + } else + src = NULL; - /* OK - we have removed all leading (or trailing) separators, and we have a valid string which we can continue with. @@ -4326,6 +4626,41 @@ char * util_alloc_sprintf(const char * fmt , ...) { } +char * util_alloc_sprintf_escape(const char * src , int max_escape) { + if (src == NULL) + return NULL; + + if (max_escape == 0) + max_escape = strlen( src ); + + { + const int src_len = strlen( src ); + char * target = util_calloc( max_escape + strlen(src) + 1 , sizeof * target); + + int escape_count = 0; + int src_offset = 0; + int target_offset = 0; + + while (true) { + if (src[src_offset] == '%') { + if (escape_count < max_escape) { + target[target_offset] = '%'; + target_offset++; + escape_count++; + } + } + target[target_offset] = src[src_offset]; + target_offset++; + src_offset++; + if (src_offset == src_len) + break; + } + target[target_offset] = '\0'; + target = util_realloc( target , (target_offset + 1) * sizeof * target); + return target; + } +} + /* char * util_realloc_sprintf(char * s , const char * fmt , ...) { @@ -4419,22 +4754,6 @@ int util_get_type( void * data ) { -static void __add_item__(int **_active_list , int * _current_length , int *_list_length , int value) { - int *active_list = *_active_list; - int current_length = *_current_length; - int list_length = *_list_length; - - active_list[current_length] = value; - current_length++; - if (current_length == list_length) { - list_length *= 2; - active_list = util_realloc( active_list , list_length * sizeof * active_list ); - - *_active_list = active_list; - *_list_length = list_length; - } - *_current_length = current_length; -} /** @@ -4464,191 +4783,6 @@ int util_get_current_linenr(FILE * stream) { -/* - This functions parses an input string 'range_string' of the type: - - "0,1,8, 10 - 20 , 15,17-21" - - I.e. integers separated by "," and "-". The integer values are - parsed out. The result can be returned in two different ways: - - - o If active != NULL the entries in active (corresponding to the - values in the range) are marked as true. All other entries are - marked as false. The active array must be allocated by the - calling scope, with length (at least) "max_value + 1". - - o If active == NULL - an (int *) pointer is allocated, filled with - the active indices and returned. - -*/ - -//#include -//#include -//static int * util_sscanf_active_range__NEW(const char * range_string , int max_value , bool * active , int * _list_length) { -// tokenizer_type * tokenizer = tokenizer_alloc( NULL , /* No ordinary split characters. */ -// NULL , /* No quoters. */ -// ",-" , /* Special split on ',' and '-' */ -// " \t" , /* Removing ' ' and '\t' */ -// NULL , /* No comment */ -// NULL ); -// stringlist_type * tokens; -// tokens = tokenize_buffer( tokenizer , range_string , true); -// -// stringlist_free( tokens ); -// tokenizer_free( tokenizer ); -//} - - - - -static int * util_sscanf_active_range__(const char * range_string , int max_value , bool * active , int * _list_length) { - int *active_list = NULL; - int current_length = 0; - int list_length; - int value,value1,value2; - char * start_ptr = (char *) range_string; - char * end_ptr; - bool didnt_work = false; - - if (active != NULL) { - for (value = 0; value <= max_value; value++) - active[value] = false; - } else { - list_length = 10; - active_list = util_calloc( list_length , sizeof * active_list ); - } - - - while (start_ptr != NULL) { - value1 = strtol(start_ptr , &end_ptr , 10); - if (active != NULL && value1 > max_value) - fprintf(stderr , "** Warning - value:%d is larger than the maximum value: %d \n",value1 , max_value); - - if (end_ptr == start_ptr){ - printf("Returning to menu: %s \n" , start_ptr); - didnt_work = true; - break; - } - /* OK - we have found the first integer, now there are three possibilities: - - 1. The string contains nothing more (except) possibly whitespace. - 2. The next characters are " , " - with more or less whitespace. - 3. The next characters are " - " - with more or less whitespace. - - Otherwise it is a an invalid string. - */ - - - /* Storing the value. */ - if (active != NULL) { - if (value1 <= max_value) active[value1] = true; - } else - __add_item__(&active_list , ¤t_length , &list_length , value1); - - - - /* Skipping trailing whitespace. */ - start_ptr = end_ptr; - while (start_ptr[0] != '\0' && isspace(start_ptr[0])) - start_ptr++; - - - if (start_ptr[0] == '\0') /* We have found the end */ - start_ptr = NULL; - else { - /* OK - now we can point at "," or "-" - else malformed string. */ - if (start_ptr[0] == ',' || start_ptr[0] == '-') { - if (start_ptr[0] == '-') { /* This is a range */ - start_ptr++; /* Skipping the "-" */ - while (start_ptr[0] != '\0' && isspace(start_ptr[0])) - start_ptr++; - - if (start_ptr[0] == '\0') { - /* The range just ended - without second value. */ - printf("%s[0]: malformed string: %s \n",__func__ , start_ptr); - didnt_work = true; - break; - } - value2 = strtol(start_ptr , &end_ptr , 10); - if (end_ptr == start_ptr) { - printf("%s[1]: failed to parse integer from: %s \n",__func__ , start_ptr); - didnt_work = true; - break; - } - if (active != NULL && value2 > max_value) - fprintf(stderr , "** Warning - value:%d is larger than the maximum value: %d \n",value2 , max_value); - - if (value2 < value1){ - printf("%s[2]: invalid interval - must have increasing range \n",__func__); - didnt_work = true; - break; - } - start_ptr = end_ptr; - { - int value; - for (value = value1 + 1; value <= value2; value++) { - if (active != NULL) { - if (value <= max_value) active[value] = true; - } else - __add_item__(&active_list , ¤t_length , &list_length , value); - } - } - - /* Skipping trailing whitespace. */ - while (start_ptr[0] != '\0' && isspace(start_ptr[0])) - start_ptr++; - - - if (start_ptr[0] == '\0') - start_ptr = NULL; /* We are done */ - else { - if (start_ptr[0] == ',') - start_ptr++; - else{ - printf("%s[3]: malformed string: %s \n",__func__ , start_ptr); - didnt_work = true; - break; - } - } - } else - start_ptr++; /* Skipping "," */ - - /** - When this loop is finished the start_ptr should point at a - valid integer. I.e. for instance for the following input - string: "1-3 , 78" - ^ - - The start_ptr should point at "78". - */ - - } else{ - printf("%s[4]: malformed string: %s \n",__func__ , start_ptr); - didnt_work = true; - break; - } - } - } - if (_list_length != NULL) - *_list_length = current_length; - - if (didnt_work){ - for (value = 0; value <= max_value; value++) - active[value] = false; - } - - return active_list; -} - - -void util_sscanf_active_range(const char * range_string , int max_value , bool * active) { - util_sscanf_active_range__(range_string , max_value , active , NULL); -} - -int * util_sscanf_alloc_active_list(const char * range_string , int * list_length) { - return util_sscanf_active_range__(range_string , 0 , NULL , list_length); -} const char * util_enum_iget( int index , int size , const util_enum_element_type * enum_defs , int * value) { @@ -4682,11 +4816,23 @@ void util_abort_free_version_info() { } -void util_abort_set_executable( const char * executable ) { - __current_executable = util_realloc_string_copy( __current_executable , executable ); +void util_abort_set_executable( const char * argv0 ) { + if (util_is_abs_path(argv0)) + __current_executable = util_realloc_string_copy( __current_executable , argv0 ); + else { + char * executable; + if (util_is_executable( argv0 )) + executable = util_alloc_realpath(argv0); + else + executable = util_alloc_PATH_executable( argv0 ); + + util_abort_set_executable( executable ); + free( executable ); + } } + /*****************************************************************/ /* @@ -4734,6 +4880,8 @@ CONTAINS(size_t) /*****************************************************************/ + + int util_fnmatch( const char * pattern , const char * string ) { #ifdef HAVE_FNMATCH return fnmatch( pattern , string , 0 ); @@ -4797,17 +4945,11 @@ char * util_alloc_link_target(const char * link) { } #endif -#ifdef HAVE_FORK -#ifdef WITH_PTHREAD -#ifdef HAVE_EXECINFO + + +#ifdef HAVE_UTIL_ABORT #include "util_abort_gnu.c" -#define HAVE_UTIL_ABORT -#endif -#endif -#endif - - -#ifndef HAVE_UTIL_ABORT +#else #include "util_abort_simple.c" #endif diff --git a/ThirdParty/Ert/devel/libert_util/src/util_abort_gnu.c b/ThirdParty/Ert/devel/libert_util/src/util_abort_gnu.c index 1195234dbd..9daba050da 100644 --- a/ThirdParty/Ert/devel/libert_util/src/util_abort_gnu.c +++ b/ThirdParty/Ert/devel/libert_util/src/util_abort_gnu.c @@ -2,90 +2,15 @@ This file implements the fully fledged util abort() function which assumes that the current build has the following features: - fork() : To support calling external program addr2line(). - pthread : To serialize the use of util abort() - not very important. - execinfo.h : The backtrace functions backtrace() and backtrace symbols(). + fork() : To support calling external program addr2line(). + pthread : To serialize the use of util abort() - not very important. + execinfo.h : The backtrace functions backtrace() and backtrace symbols(). + _GNU_SOURCE : To get the dladdr() function. If not all these features are availbale the simpler version in util abort_simple.c is built instead. */ - - -/** - This function uses the external program addr2line to convert the - hexadecimal adress given by the libc function backtrace() into a - function name and file:line. - - Observe that the function is quite involved, so if util_abort() is - called because something is seriously broken, it might very well fail. - - The executable should be found from one line in the backtrace with - the function util_bt_alloc_current_executable(), the argument - bt_symbol is the lines generated by the bt_symbols() function. - - This function is purely a helper function for util_abort(). -*/ - -static void util_addr2line_lookup(const char * executable , const char * bt_symbol , char ** func_name , char ** file_line) { - char *tmp_file = util_alloc_tmp_file("/tmp" , "addr2line" , true); - char * adress; - { - int start_pos = 0; - int end_pos; - while ( bt_symbol[start_pos] != '[') - start_pos++; - - end_pos = start_pos; - while ( bt_symbol[end_pos] != ']') - end_pos++; - - adress = util_alloc_substring_copy( bt_symbol , start_pos + 1 , end_pos - start_pos - 1 ); - } - - { - char ** argv; - - argv = util_calloc(3 , sizeof * argv ); - argv[0] = util_alloc_string_copy("--functions"); - argv[1] = util_alloc_sprintf("--exe=%s" , executable); - argv[2] = util_alloc_string_copy(adress); - - util_fork_exec("addr2line" , 3 , (const char **) argv , true , NULL , NULL , NULL , tmp_file , NULL); - util_free_stringlist(argv , 3); - } - - { - bool at_eof; - FILE * stream = util_fopen(tmp_file , "r"); - *func_name = util_fscanf_alloc_line(stream , &at_eof); - *file_line = util_fscanf_alloc_line(stream , &at_eof); - fclose(stream); - } - util_unlink_existing(tmp_file); - free(adress); - free(tmp_file); -} - - - -/** - This function prints a message to stderr and aborts. The function is - implemented with the help of a variable length argument list - just - like printf(fmt , arg1, arg2 , arg3 ...); - - Observe that it is __VERY__ important that the arguments and the - format string match up, otherwise the util_abort() routine will hang - indefinetely; without printing anything to stderr. - - A backtrace is also included, with the help of the exernal utility - addr2line, this backtrace is converted into usable - function/file/line information (provided the required debugging - information is compiled in). -*/ - -static pthread_mutex_t __abort_mutex = PTHREAD_MUTEX_INITIALIZER; /* Used purely to serialize the util_abort() routine. */ - /** If the variable __current_executable has been set, that value is returned as the executable, otherwise an attempt (which generally @@ -124,14 +49,178 @@ static char * util_bt_alloc_current_executable(const char * bt_symbol) { } + + +/** + This function uses the external program addr2line to convert the + hexadecimal adress given by the libc function backtrace() into a + function name and file:line. + + Observe that the function is quite involved, so if util_abort() is + called because something is seriously broken, it might very well fail. + + The executable should be found from one line in the backtrace with + the function util_bt_alloc_current_executable(), the argument + bt_symbol is the lines generated by the bt_symbols() function. + + This function is purely a helper function for util_abort(). +*/ + + + +#define UNDEFINED_FUNCTION "??" + +static bool util_addr2line_lookup__(const void * bt_addr , char ** func_name , char ** file_name , int * line_nr, bool subtract_base_adress) { + *func_name = NULL; // If dladdr() succeeds, but addr2line fails the func_name pointer will be set, but the function will return false anyway. + *file_name = NULL; + *line_nr = 0; + { + bool address_found = false; + Dl_info dl_info; + + if (dladdr(bt_addr , &dl_info)) { + const char * executable = dl_info.dli_fname; + *func_name = util_alloc_string_copy( dl_info.dli_sname ); + if (util_file_exists( executable )) { + char *stdout_file = util_alloc_tmp_file("/tmp" , "addr2line" , true); + /* 1: Run addr2line application */ + { + char ** argv = util_calloc(3 , sizeof * argv ); + argv[0] = util_alloc_string_copy("--functions"); + argv[1] = util_alloc_sprintf("--exe=%s" , executable ); + { + char * rel_address = (char *) bt_addr; + if (subtract_base_adress) + rel_address -= (size_t) dl_info.dli_fbase; + argv[2] = util_alloc_sprintf("%p" , (void *) rel_address); + } + util_fork_exec("addr2line" , 3 , (const char **) argv , true , NULL , NULL , NULL , stdout_file , NULL); + util_free_stringlist(argv , 3); + } + + /* 2: Parse stdout output */ + { + bool at_eof; + FILE * stream = util_fopen(stdout_file , "r"); + char * tmp_fname = util_fscanf_alloc_line(stream , &at_eof); + + if (strcmp(tmp_fname , UNDEFINED_FUNCTION) != 0) { + char * stdout_file_name = util_fscanf_alloc_line(stream , &at_eof); + char * line_string = NULL; + util_binary_split_string( stdout_file_name , ":" , false , file_name , &line_string); + if (line_string && util_sscanf_int( line_string , line_nr)) + address_found = true; + + free( stdout_file_name ); + util_safe_free( line_string ); + } + free( tmp_fname ); + fclose(stream); + } + util_unlink_existing(stdout_file); + free( stdout_file ); + } + } + return address_found; + } +} + + + +bool util_addr2line_lookup(const void * bt_addr , char ** func_name , char ** file_name , int * line_nr) { + if (util_addr2line_lookup__(bt_addr , func_name , file_name , line_nr , false)) + return true; + else + return util_addr2line_lookup__(bt_addr , func_name , file_name , line_nr , true); +} + + +/** + This function prints a message to stream and aborts. The function is + implemented with the help of a variable length argument list - just + like printf(fmt , arg1, arg2 , arg3 ...); + + Observe that it is __VERY__ important that the arguments and the + format string match up, otherwise the util_abort() routine will hang + indefinetely; without printing anything to stream. + + A backtrace is also included, with the help of the exernal utility + addr2line, this backtrace is converted into usable + function/file/line information (provided the required debugging + information is compiled in). +*/ + +static pthread_mutex_t __abort_mutex = PTHREAD_MUTEX_INITIALIZER; /* Used purely to serialize the util_abort() routine. */ + + +static char * realloc_padding(char * pad_ptr , int pad_length) { + int i; + pad_ptr = util_realloc( pad_ptr , (pad_length + 1) * sizeof * pad_ptr ); + for (i=0; i < pad_length; i++) + pad_ptr[i] = ' '; + pad_ptr[pad_length] = '\0'; + return pad_ptr; +} + + + +static void util_fprintf_backtrace(FILE * stream) { + const char * with_linenr_format = " #%02d %s(..) %s in %s:%d\n"; + const char * func_format = " #%02d %s(..) %s in ???\n"; + const char * unknown_format = " #%02d ???? \n"; + + const int max_bt = 50; + const int max_func_length = 45; + void *bt_addr[max_bt]; + int size,i; + + size = backtrace(bt_addr , max_bt); + + fprintf(stream , "--------------------------------------------------------------------------------\n"); + for (i=0; i < size; i++) { + int line_nr; + char * func_name; + char * file_name; + char * padding = NULL; + + if (util_addr2line_lookup(bt_addr[i] , &func_name , &file_name , &line_nr)) { + int pad_length; + char * function; + // Seems it can return true - but with func_name == NULL?! Static/inlinded functions? + if (func_name) + function = func_name; + else + function = "???"; + + pad_length = 2 + max_func_length - strlen(function); + padding = realloc_padding( padding , pad_length); + fprintf(stream , with_linenr_format , i , function , padding , file_name , line_nr); + } else { + if (func_name != NULL) { + int pad_length = 2 + max_func_length - strlen(func_name); + padding = realloc_padding( padding , pad_length); + fprintf(stream , func_format , i , func_name , padding); + } else { + padding = realloc_padding( padding , 2 + max_func_length ); + fprintf(stream , unknown_format , i , padding); + } + } + + util_safe_free( func_name ); + util_safe_free( file_name ); + util_safe_free( padding ); + } + fprintf(stream , "--------------------------------------------------------------------------------\n"); +} + void util_abort(const char * fmt , ...) { pthread_mutex_lock( &__abort_mutex ); /* Abort before unlock() */ { va_list ap; va_start(ap , fmt); - printf("\n\n"); - fprintf(stderr,"\n\n"); + fprintf(stderr , "\n\n"); + fprintf(stderr , "\n\n"); vfprintf(stderr , fmt , ap); va_end(ap); @@ -143,18 +232,10 @@ void util_abort(const char * fmt , ...) { const bool include_backtrace = true; if (include_backtrace) { - const int max_bt = 50; - char *executable; - void *array[max_bt]; - char **strings; - char ** func_list; - char ** file_line_list; - int max_func_length = 0; - int size,i; - if (__abort_program_message != NULL) { fprintf(stderr,"--------------------------------------------------------------------------------\n"); fprintf(stderr,"%s",__abort_program_message); + fprintf(stderr, "Current executable ..: %s\n" , program_invocation_name); fprintf(stderr,"--------------------------------------------------------------------------------\n"); } @@ -171,52 +252,17 @@ void util_abort(const char * fmt , ...) { fprintf(stderr,"** broken as well. **\n"); fprintf(stderr,"** **\n"); fprintf(stderr,"****************************************************************************\n"); - size = backtrace(array , max_bt); - strings = backtrace_symbols(array , size); - executable = util_bt_alloc_current_executable(strings[0]); - if (executable != NULL) { - fprintf(stderr,"Current executable : %s \n",executable); - - func_list = util_calloc(size , sizeof * func_list ); - file_line_list = util_calloc(size , sizeof * file_line_list ); - - for (i=0; i < size; i++) { - util_addr2line_lookup(executable , strings[i] , &func_list[i] , &file_line_list[i]); - max_func_length = util_int_max(max_func_length , strlen(func_list[i])); - } - - { - char string_fmt[64]; - sprintf(string_fmt, " #%s02d %s-%ds(..) in %ss \n" , "%" , "%" , max_func_length , "%"); - fprintf(stderr , "--------------------------------------------------------------------------------\n"); - for (i=0; i < size; i++) { - - int line_nr; - if (util_sscanf_int(file_line_list[i] , &line_nr)) - fprintf(stderr, string_fmt , i , func_list[i], file_line_list[i]); - else - fprintf(stderr, string_fmt , i , func_list[i], file_line_list[i]); - } - fprintf(stderr , "--------------------------------------------------------------------------------\n"); - util_free_stringlist(func_list , size); - util_free_stringlist(file_line_list , size); - } - } else - fprintf(stderr,"Could not determine executable file for:%s - no backtrace. \n",strings[0]); - - free(strings); - util_safe_free(executable); - } - if (getenv("UTIL_ABORT") != NULL) { - fprintf(stderr , "Aborting ... \n"); - abort(); - } else { - fprintf(stderr , "Exiting ... \n"); - exit(1); + util_fprintf_backtrace( stderr ); } - // Would have preferred abort() here - but that comes in conflict with the SIGABRT signal. } pthread_mutex_unlock( &__abort_mutex ); + + signal(SIGABRT , SIG_DFL); + fprintf(stderr , "Aborting ... \n"); + abort(); } + +/*****************************************************************/ + diff --git a/ThirdParty/Ert/devel/libert_util/src/util_abort_simple.c b/ThirdParty/Ert/devel/libert_util/src/util_abort_simple.c index ba1b466496..ffe4203004 100644 --- a/ThirdParty/Ert/devel/libert_util/src/util_abort_simple.c +++ b/ThirdParty/Ert/devel/libert_util/src/util_abort_simple.c @@ -2,7 +2,7 @@ This file implements a simpler version of the util_abort() function which does not present a backtrace. */ - +#include @@ -24,13 +24,9 @@ void util_abort(const char * fmt , ...) { } fprintf(stderr,"-----------------------------------------------------------------\n"); - if (getenv("UTIL_ABORT") != NULL) { - fprintf(stderr , "Aborting ... \n"); - abort(); - } else { - fprintf(stderr , "Exiting ... \n"); - exit(1); - } - // Would have preferred abort() here - but that comes in conflict with the SIGABRT signal. + signal(SIGABRT , SIG_DFL); + fprintf(stderr , "Aborting ... \n"); + assert(0); + abort(); } diff --git a/ThirdParty/Ert/devel/libert_util/src/util_env.c b/ThirdParty/Ert/devel/libert_util/src/util_env.c index 303ed7043e..934e3e75ae 100644 --- a/ThirdParty/Ert/devel/libert_util/src/util_env.c +++ b/ThirdParty/Ert/devel/libert_util/src/util_env.c @@ -46,6 +46,26 @@ void util_unsetenv( const char * variable ) { } #endif +/** + Will return a NULL terminated list char ** of the paths in the PATH + variable. +*/ + +char ** util_alloc_PATH_list() { + char ** path_list = NULL; + char * path_env = getenv("PATH"); + if (path_env != NULL) { + int path_size; + + util_split_string(path_env , PATHVAR_SPLIT , &path_size , &path_list); + path_list = util_realloc( path_list , (path_size + 1) * sizeof * path_list); + path_list[path_size] = NULL; + } else { + path_list = util_malloc( sizeof * path_list); + path_list[0] = NULL; + } + return path_list; +} /** This function searches through the content of the (currently set) @@ -81,29 +101,26 @@ char * util_alloc_PATH_executable(const char * executable) { return path; } else { - char * full_path = NULL; - char * path_env = getenv("PATH"); - if (path_env != NULL) { - bool cont = true; - char ** path_list; - int path_size , ipath; - - ipath = 0; - util_split_string(path_env , PATHVAR_SPLIT , &path_size , &path_list); - while ( cont ) { + char * full_path = NULL; + char ** path_list = util_alloc_PATH_list(); + int ipath = 0; + + while (true) { + if (path_list[ipath] != NULL) { char * current_attempt = util_alloc_filename(path_list[ipath] , executable , NULL); + if ( util_is_file( current_attempt ) && util_is_executable( current_attempt )) { full_path = current_attempt; - cont = false; + break; } else { free(current_attempt); ipath++; - if (ipath == path_size) - cont = false; } - } - util_free_stringlist(path_list , path_size); + } else + break; } + + util_free_NULL_terminated_stringlist(path_list); return full_path; } } diff --git a/ThirdParty/Ert/devel/libert_util/src/util_fork.c b/ThirdParty/Ert/devel/libert_util/src/util_fork.c index 13f71ea822..2eda0d2806 100644 --- a/ThirdParty/Ert/devel/libert_util/src/util_fork.c +++ b/ThirdParty/Ert/devel/libert_util/src/util_fork.c @@ -79,21 +79,14 @@ pid_t util_fork_exec(const char * executable , int argc , const char ** argv , util_abort("%s: failed to change to directory:%s %s \n",__func__ , run_path , strerror(errno)); } - if (stdout_file != NULL) { - /** This is just to invoke the "block on full disk behaviour" before the external program starts. */ - FILE * stream = util_fopen( stdout_file , "w"); - fclose(stream); + if (stdout_file != NULL) __util_redirect(1 , stdout_file , O_WRONLY | O_TRUNC | O_CREAT); - } - - if (stderr_file != NULL) { - /** This is just to invoke the "block on full disk behaviour" before the external program starts. */ - FILE * stream = util_fopen( stderr_file , "w"); - fclose(stream); + + if (stderr_file != NULL) __util_redirect(2 , stderr_file , O_WRONLY | O_TRUNC | O_CREAT); - } - if (stdin_file != NULL) __util_redirect(0 , stdin_file , O_RDONLY); - + + if (stdin_file != NULL) + __util_redirect(0 , stdin_file , O_RDONLY); __argv = util_malloc((argc + 2) * sizeof * __argv ); __argv[0] = executable; @@ -115,6 +108,7 @@ pid_t util_fork_exec(const char * executable , int argc , const char ** argv , } else { /* Parent */ + if (blocking) { waitpid(child_pid , NULL , 0); @@ -236,7 +230,32 @@ char * util_alloc_filename_from_stream( FILE * input_stream ) { return filename; } - + +/** + The ping program must(?) be setuid root, so implementing a simple + version based on sockets() proved to be nontrivial. + + The PING_CMD is passed as -D from the build system. +*/ + +bool util_ping(const char *hostname) { + pid_t ping_pid = util_fork_exec(PING_CMD , 4 , (const char *[4]) {"-c" , "3" , "-q", hostname} , false , NULL , NULL , NULL , NULL , NULL); + int wait_status; + pid_t wait_pid = waitpid(ping_pid , &wait_status , 0); + + if (wait_pid == -1) + return false; + else { + if (WIFEXITED( wait_status )) { + int ping_status = WEXITSTATUS( wait_status ); + if (ping_status == 0) + return true; + else + return false; + } else + return false; + } +} diff --git a/ThirdParty/Ert/devel/libert_util/src/util_path.c b/ThirdParty/Ert/devel/libert_util/src/util_path.c index 17ac011d8d..40e512aaff 100644 --- a/ThirdParty/Ert/devel/libert_util/src/util_path.c +++ b/ThirdParty/Ert/devel/libert_util/src/util_path.c @@ -205,7 +205,6 @@ int util_proc_mem_free(void) { - void util_path_split(const char *line , int *_tokens, char ***_token_list) { util_split_string( line , UTIL_PATH_SEP_STRING , _tokens , _token_list); } diff --git a/ThirdParty/Ert/devel/libert_util/src/vector.c b/ThirdParty/Ert/devel/libert_util/src/vector.c index b4fe3181ef..d84b67d6f4 100644 --- a/ThirdParty/Ert/devel/libert_util/src/vector.c +++ b/ThirdParty/Ert/devel/libert_util/src/vector.c @@ -449,7 +449,8 @@ const void * vector_get_last_const(const vector_type * vector) { This function removes the last element from the vector and returns it to the calling scope. Irrespective of whether the element _was_ inserted with a destructor: when calling vector_pop() the calling - scope takes responsability for freeing data. + scope takes responsability for freeing data; i.e. vector_pop will + NEVER call a destructor. */ @@ -577,6 +578,21 @@ void vector_sort(vector_type * vector , vector_cmp_ftype * cmp) { } +void vector_inplace_reverse(vector_type * vector) { + if (vector->size > 0) { + node_data_type ** new_data = util_calloc( vector->size , sizeof * new_data ); + int index; + for (index = 0; index < vector->size; index++) { + int rev_index = vector->size - 1 - index; + new_data[index] = vector->data[ rev_index ]; + } + free(vector->data); + vector->data = new_data; + } +} + + + /*****************************************************************/ diff --git a/ThirdParty/Ert/devel/libert_util/src/vector_template.c b/ThirdParty/Ert/devel/libert_util/src/vector_template.c index dd6fc5d667..65d48ad0c7 100644 --- a/ThirdParty/Ert/devel/libert_util/src/vector_template.c +++ b/ThirdParty/Ert/devel/libert_util/src/vector_template.c @@ -672,6 +672,11 @@ void @TYPE@_vector_reset(@TYPE@_vector_type * vector) { } +void @TYPE@_vector_free_container(@TYPE@_vector_type * vector) { + free( vector ); +} + + void @TYPE@_vector_free_data(@TYPE@_vector_type * vector) { @TYPE@_vector_reset(vector); @TYPE@_vector_realloc_data__(vector , 0); @@ -681,7 +686,7 @@ void @TYPE@_vector_free_data(@TYPE@_vector_type * vector) { void @TYPE@_vector_free(@TYPE@_vector_type * vector) { if (vector->data_owner) util_safe_free( vector->data ); - free( vector ); + @TYPE@_vector_free_container( vector ); } @@ -777,6 +782,20 @@ void @TYPE@_vector_set_all(@TYPE@_vector_type * vector , @TYPE@ value) { } } +bool @TYPE@_vector_init_range(@TYPE@_vector_type * vector , @TYPE@ min_value , @TYPE@ max_value , @TYPE@ delta) { + if (max_value >= min_value) { + @TYPE@ current_value = min_value; + @TYPE@_vector_reset( vector ); + while (current_value < max_value) { + @TYPE@_vector_append( vector , current_value ); + current_value += delta; + } + @TYPE@_vector_append( vector , max_value ); + return true; + } else + return false; +} + void @TYPE@_vector_append_many(@TYPE@_vector_type * vector , const @TYPE@ * data , int length) { @TYPE@_vector_set_many( vector , @TYPE@_vector_size( vector ) , data , length); diff --git a/ThirdParty/Ert/devel/libert_util/tests/CMakeLists.txt b/ThirdParty/Ert/devel/libert_util/tests/CMakeLists.txt index a376f74818..a33369c27d 100644 --- a/ThirdParty/Ert/devel/libert_util/tests/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libert_util/tests/CMakeLists.txt @@ -1,17 +1,100 @@ +# This should be a space separated list of up to three servers which +# will be tried out when testing the util_ping() functionality. The +# list of servers should behave like this: +# +# 1. First server - this should be an existing server which should return true. +# 2. This should be an invalid hostname - should return false. +# 3. This should be an valid host which does not answer ping - i.e currently off? +set(PING_SERVERS "localhost" CACHE STRING "List of LSF servers for testing") + + link_directories( ${ERT_BINARY_DIR}/libert_util/src ) add_executable( ert_util_type_vector_test ert_util_type_vector_test.c ) target_link_libraries( ert_util_type_vector_test ert_util ) add_test( ert_util_type_vector_test ${EXECUTABLE_OUTPUT_PATH}/ert_util_type_vector_test ) +add_executable( ert_util_string_util ert_util_string_util.c ) +target_link_libraries( ert_util_string_util ert_util ) +add_test( ert_util_string_util ${EXECUTABLE_OUTPUT_PATH}/ert_util_string_util ) + add_executable( ert_util_vector_test ert_util_vector_test.c ) target_link_libraries( ert_util_vector_test ert_util ) add_test( ert_util_vector_test ${EXECUTABLE_OUTPUT_PATH}/ert_util_vector_test ) +add_executable( ert_util_cwd_test ert_util_cwd_test.c ) +target_link_libraries( ert_util_cwd_test ert_util ) +add_test( ert_util_cwd_test ${EXECUTABLE_OUTPUT_PATH}/ert_util_cwd_test ${CMAKE_CURRENT_BINARY_DIR}) + +add_executable( ert_util_relpath_test ert_util_relpath_test.c ) +target_link_libraries( ert_util_relpath_test ert_util ) +add_test( ert_util_relpath_test ${EXECUTABLE_OUTPUT_PATH}/ert_util_relpath_test ) + +add_executable( ert_util_path_stack_test ert_util_path_stack_test.c ) +target_link_libraries( ert_util_path_stack_test ert_util ) +add_test( ert_util_path_stack_test ${EXECUTABLE_OUTPUT_PATH}/ert_util_path_stack_test ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) + +add_executable( ert_util_PATH_test ert_util_PATH_test.c ) +target_link_libraries( ert_util_PATH_test ert_util ) +add_test( ert_util_PATH_test ${EXECUTABLE_OUTPUT_PATH}/ert_util_PATH_test ) + +add_executable( ert_util_strcat_test ert_util_strcat_test.c ) +target_link_libraries( ert_util_strcat_test ert_util ) +add_test( ert_util_strcat_test ${EXECUTABLE_OUTPUT_PATH}/ert_util_strcat_test ) + +add_executable( ert_util_sprintf_escape ert_util_sprintf_escape.c ) +target_link_libraries( ert_util_sprintf_escape ert_util ) +add_test( ert_util_sprintf_escape ${EXECUTABLE_OUTPUT_PATH}/ert_util_sprintf_escape ) + + add_executable( ert_util_stringlist_test ert_util_stringlist_test.c ) target_link_libraries( ert_util_stringlist_test ert_util ) add_test( ert_util_stringlist_test ${EXECUTABLE_OUTPUT_PATH}/ert_util_stringlist_test ) +add_executable( ert_util_realpath ert_util_realpath.c ) +target_link_libraries( ert_util_realpath ert_util ) +add_test( ert_util_realpath ${EXECUTABLE_OUTPUT_PATH}/ert_util_realpath ) + +add_executable( ert_util_hash_test ert_util_hash_test.c ) +target_link_libraries( ert_util_hash_test ert_util ) +add_test( ert_util_hash_test ${EXECUTABLE_OUTPUT_PATH}/ert_util_hash_test ) + +add_executable( ert_util_binary_split ert_util_binary_split.c ) +target_link_libraries( ert_util_binary_split ert_util ) +add_test( ert_util_binary_split ${EXECUTABLE_OUTPUT_PATH}/ert_util_binary_split ) + +add_executable( ert_util_logh ert_util_logh.c ) +target_link_libraries( ert_util_logh ert_util ) +add_test( ert_util_logh ${EXECUTABLE_OUTPUT_PATH}/ert_util_logh ) + +add_executable( ert_util_rng ert_util_rng.c ) +target_link_libraries( ert_util_rng ert_util ) +add_test( ert_util_rng ${EXECUTABLE_OUTPUT_PATH}/ert_util_rng ) + +add_executable( ert_util_time_interval ert_util_time_interval.c ) +target_link_libraries( ert_util_time_interval ert_util ) +add_test( ert_util_time_interval ${EXECUTABLE_OUTPUT_PATH}/ert_util_time_interval ) + +add_executable( ert_util_before_after ert_util_before_after.c ) +target_link_libraries( ert_util_before_after ert_util ) +add_test( ert_util_before_after ${EXECUTABLE_OUTPUT_PATH}/ert_util_before_after ) + +add_executable( ert_util_approx_equal ert_util_approx_equal.c ) +target_link_libraries( ert_util_approx_equal ert_util ) +add_test( ert_util_approx_equal ${EXECUTABLE_OUTPUT_PATH}/ert_util_approx_equal ) + +add_executable( ert_util_ping ert_util_ping.c ) +target_link_libraries( ert_util_ping ert_util ) +add_test( ert_util_ping ${EXECUTABLE_OUTPUT_PATH}/ert_util_ping ${PING_SERVERS}) + +add_executable( ert_util_file_readable ert_util_file_readable.c ) +target_link_libraries( ert_util_file_readable ert_util ) +add_test( ert_util_file_readable ${EXECUTABLE_OUTPUT_PATH}/ert_util_file_readable ${FILE_READABLE_SERVERS}) + +add_executable( ert_util_addr2line ert_util_addr2line.c ) +target_link_libraries( ert_util_addr2line ert_util ) +add_test( ert_util_addr2line ${EXECUTABLE_OUTPUT_PATH}/ert_util_addr2line) + if (WITH_LATEX) add_executable( ert_util_latex_test ert_util_latex_test.c ) target_link_libraries(ert_util_latex_test ert_util ) diff --git a/ThirdParty/Ert/devel/libert_util/tests/ert_util_PATH_test.c b/ThirdParty/Ert/devel/libert_util/tests/ert_util_PATH_test.c new file mode 100644 index 0000000000..4eada494ec --- /dev/null +++ b/ThirdParty/Ert/devel/libert_util/tests/ert_util_PATH_test.c @@ -0,0 +1,59 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'ert_util_PATH_test.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include + +#include +#include +#include + + + +int main(int argc , char ** argv) { + unsetenv("PATH"); + { + char ** path_list = util_alloc_PATH_list(); + if (path_list[0] != NULL) + test_error_exit("Failed on empty PATH\n"); + + util_free_NULL_terminated_stringlist( path_list ); + } + + + setenv("PATH" , "/usr/bin:/bin:/usr/local/bin" , 1); + { + char ** path_list = util_alloc_PATH_list(); + if (strcmp(path_list[0] , "/usr/bin") != 0) + test_error_exit("Failed on first path element\n"); + + if (strcmp(path_list[1] , "/bin") != 0) + test_error_exit("Failed on second path element\n"); + + if (strcmp(path_list[2] , "/usr/local/bin") != 0) + test_error_exit("Failed on third path element\n"); + + if (path_list[3] != NULL) + test_error_exit("Failed termination \n"); + + util_free_NULL_terminated_stringlist( path_list ); + } + + + exit(0); +} diff --git a/ThirdParty/Ert/devel/libert_util/tests/ert_util_addr2line.c b/ThirdParty/Ert/devel/libert_util/tests/ert_util_addr2line.c new file mode 100644 index 0000000000..754dda49b3 --- /dev/null +++ b/ThirdParty/Ert/devel/libert_util/tests/ert_util_addr2line.c @@ -0,0 +1,108 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'ert_util_addr2line.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include +#include + +#include +#include +#include + + +void test_lookup(bool valid_address, bool change_cwd) { + const char * file = __FILE__; + const char * func = __func__; + int line; + const int max_bt = 50; + void *bt_addr[max_bt]; + int size; + char * func_name , * file_name; + int line_nr; + + line = __LINE__ + 2; + size = backtrace(bt_addr , max_bt); + test_assert_int_equal( size , 4 ); + + if (change_cwd) { + char * cwd = util_alloc_cwd(); + chdir("/tmp"); + if (valid_address) { + test_assert_false( util_addr2line_lookup( bt_addr[0] , &func_name , &file_name , &line_nr)); + test_assert_string_equal( func_name , func ); + test_assert_string_equal( file_name , NULL ); + test_assert_int_equal( 0 , line_nr); + } else { + test_assert_false( util_addr2line_lookup( NULL , &func_name , &file_name , &line_nr)); + test_assert_string_equal( func_name , NULL); + test_assert_string_equal( file_name , NULL); + test_assert_int_equal( 0 , line_nr ); + } + chdir(cwd); + free( cwd ); + } else { + if (valid_address) { + test_assert_true( util_addr2line_lookup( bt_addr[0] , &func_name , &file_name , &line_nr)); + test_assert_string_equal( func_name , func ); + test_assert_string_equal( file_name , file ); + test_assert_int_equal( line , line_nr ); + } else { + test_assert_false( util_addr2line_lookup( NULL , &func_name , &file_name , &line_nr)); + test_assert_string_equal( func_name , NULL); + test_assert_string_equal( file_name , NULL); + test_assert_int_equal( 0 , line_nr ); + } + } + + +} + + +int main( int argc , char ** argv) { + char * path = argv[0]; + if (util_is_abs_path(argv[0])) { + char * path; + char * name; + char * dot_name; + pid_t child_pid; + /* + This bisaaarre hoopsing is to be able to emulate the situation + where addr2line can not find the executable; this behavour is + invoked when change_cwd is set to true in the test_lookup() + call. + */ + util_alloc_file_components( argv[0] , &path , &name, NULL); + + chdir(path); + dot_name = util_alloc_sprintf("./%s" , name); + child_pid = util_fork_exec( dot_name , 0 , NULL , true , NULL , NULL , NULL , NULL , NULL); + exit(0); + } else { + printf("Testing internal lookup ....\n"); + test_lookup(true, false); + test_lookup(false , false); + + test_lookup(true, true); + test_lookup(false , true); + + printf("Testing external lookup ....\n"); + test_util_addr2line(); + + exit(0); + } +} diff --git a/ThirdParty/Ert/devel/libert_util/tests/ert_util_approx_equal.c b/ThirdParty/Ert/devel/libert_util/tests/ert_util_approx_equal.c new file mode 100644 index 0000000000..1dcc801cd9 --- /dev/null +++ b/ThirdParty/Ert/devel/libert_util/tests/ert_util_approx_equal.c @@ -0,0 +1,41 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'ert_util_approx_equal.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include + +#include +#include + + + + +int main( int argc , char ** argv) { + + test_assert_double_not_equal( -1.0 , 1.0 ); + test_assert_double_not_equal( 0.00000000002 , 0.000000000001 ); + test_assert_double_not_equal( 0.00000000002 , 0.000000000001 ); + + test_assert_double_equal( 1.00000000002 , 1.000000000001 ); + test_assert_double_equal( 0.0 , 0.0 ); + test_assert_double_equal( 0.75 , asin( sin(0.75))); + test_assert_double_equal( 2.25 , exp( log(2.25))); + test_assert_double_equal( 2.25 , log( exp(2.25))); + + exit(0); +} diff --git a/ThirdParty/Ert/devel/libert_util/tests/ert_util_before_after.c b/ThirdParty/Ert/devel/libert_util/tests/ert_util_before_after.c new file mode 100644 index 0000000000..7185674ec4 --- /dev/null +++ b/ThirdParty/Ert/devel/libert_util/tests/ert_util_before_after.c @@ -0,0 +1,41 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'ert_util_before_after.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include + +#include +#include + + + +int main( int argc , char ** argv) { + time_t t1 = util_make_date(1,1,2000); + time_t t2 = util_make_date(1,1,2001); + + test_assert_true( util_before( t1 , t2 )); + test_assert_true( util_after( t2 , t1 )); + + test_assert_false( util_before( t2 , t1 )); + test_assert_false( util_after( t1 , t2 )); + + test_assert_false( util_before( t1 , t1 )); + test_assert_false( util_after( t1 , t1 )); + + exit(0); +} diff --git a/ThirdParty/Ert/devel/libert_util/tests/ert_util_binary_split.c b/ThirdParty/Ert/devel/libert_util/tests/ert_util_binary_split.c new file mode 100644 index 0000000000..c5c01f625a --- /dev/null +++ b/ThirdParty/Ert/devel/libert_util/tests/ert_util_binary_split.c @@ -0,0 +1,55 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'ert_util_binary_split.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include + +#include +#include + +void test_split(const char * test_string , bool split_on_first , const char * true1, const char * true2) { + char * part1; + char * part2; + + + util_binary_split_string( test_string , ":" , split_on_first , &part1 , &part2 ); + test_assert_string_equal( true1 , part1 ); + test_assert_string_equal( true2 , part2 ); + + util_binary_split_string( test_string , ":;" , split_on_first , &part1 , &part2 ); + test_assert_string_equal( true1 , part1 ); + test_assert_string_equal( true2 , part2 ); + + util_binary_split_string( test_string , ";" , split_on_first , &part1 , &part2 ); + test_assert_string_equal( test_string , part1 ); + test_assert_string_equal( NULL , part2 ); +} + +int main(int argc , char ** argv) { + + test_split( "Hello:Hello" , true , "Hello" , "Hello"); + test_split( "ABC:DEF:GEH" , true , "ABC" , "DEF:GEH"); + test_split( "ABC:DEF:GEH" , false , "ABC:DEF" , "GEH"); + test_split( "ABC:DEF:GEH:" , false , "ABC:DEF" , "GEH"); + test_split( "ABC:DEF:GEH:" , true , "ABC", "DEF:GEH"); + test_split( "ABCDEFGEH" , false , "ABCDEFGEH" , NULL); + test_split( "ABCDEFGEH:" , false , "ABCDEFGEH" , NULL); + test_split( ":ABCDEFGEH" , false , "ABCDEFGEH" , NULL); + test_split( NULL , false , NULL , NULL); + + exit(0); +} diff --git a/ThirdParty/Ert/devel/libert_util/tests/ert_util_cwd_test.c b/ThirdParty/Ert/devel/libert_util/tests/ert_util_cwd_test.c new file mode 100644 index 0000000000..d5c593fe5f --- /dev/null +++ b/ThirdParty/Ert/devel/libert_util/tests/ert_util_cwd_test.c @@ -0,0 +1,37 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'ert_util_cwd_test.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include + +#include +#include +#include + +int main(int argc , char ** argv) { + char * cwd = argv[1]; + printf("cwd :%s\n",util_alloc_cwd()); + printf("argv[1]:%s\n",argv[1]); + + if (!util_is_cwd(cwd)) + test_error_exit("Hmmm did not recognize:%s as cwd\n",cwd); + + if (util_is_cwd("/some/path")) + test_error_exit("Took /whatver/ as CWD\n"); + + exit(0); +} diff --git a/ThirdParty/Ert/devel/libert_util/tests/ert_util_file_readable.c b/ThirdParty/Ert/devel/libert_util/tests/ert_util_file_readable.c new file mode 100644 index 0000000000..35a5cdd250 --- /dev/null +++ b/ThirdParty/Ert/devel/libert_util/tests/ert_util_file_readable.c @@ -0,0 +1,55 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'ert_util_file_readable.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include +#include +#include + +#include +#include + + +void assert_equal( bool equal ) { + if (!equal) + exit(1); +} + + + + +int main(int argc , char ** argv) { + test_assert_true( util_file_readable( argv[0] )); + { + char * path; + util_alloc_file_components( argv[0] , &path , NULL , NULL); + test_assert_false( util_file_readable( path )); + util_safe_free( path ); + } + { + const char * file = "/tmp/test_file.txt"; + mode_t mode = 0; + FILE * stream = util_fopen(file , "w"); + fclose( stream ); + + chmod(file , mode); + test_assert_false( util_file_readable( file)); + unlink( file ); + } + exit(0); +} diff --git a/ThirdParty/Ert/devel/libert_util/tests/ert_util_hash_test.c b/ThirdParty/Ert/devel/libert_util/tests/ert_util_hash_test.c new file mode 100644 index 0000000000..b7a5779e2c --- /dev/null +++ b/ThirdParty/Ert/devel/libert_util/tests/ert_util_hash_test.c @@ -0,0 +1,43 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'ert_util_hash_test.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include + +#include +#include + +int main(int argc , char ** argv) { + + hash_type * h = hash_alloc(); + + test_assert_bool_equal( hash_add_option( h , "Key" ) , false ); + test_assert_false( hash_add_option( h , "Key" ) ); + + test_assert_true( hash_add_option( h , "Key1:Value" ) ); + test_assert_true( hash_add_option( h , "Key2:Value1:Value2" ) ); + test_assert_true( hash_add_option( h , "Key3:Value1:value2:Value3" ) ); + + test_assert_string_equal( hash_get( h , "Key1" ) , "Value" ); + test_assert_string_equal( hash_get( h , "Key2" ) , "Value1:Value2" ); + test_assert_string_equal( hash_get( h , "Key3" ) , "Value1:value2:Value3" ); + + test_assert_false( hash_has_key( h , "Key" )); + + hash_free( h ); + exit(0); +} diff --git a/ThirdParty/Ert/devel/libert_util/tests/ert_util_latex_test.c b/ThirdParty/Ert/devel/libert_util/tests/ert_util_latex_test.c index ae87d99bdf..a3e8f6114c 100644 --- a/ThirdParty/Ert/devel/libert_util/tests/ert_util_latex_test.c +++ b/ThirdParty/Ert/devel/libert_util/tests/ert_util_latex_test.c @@ -20,21 +20,77 @@ #include #include +#include +#include + +void make_file( const char * filename ) { + FILE * stream = util_fopen( filename , "w"); + + fclose(stream); +} + + +void test_link( const latex_type * latex , const char * link , const char * target) { + char * latex_link = util_alloc_filename( latex_get_runpath( latex ) , link , NULL); + char * latex_target = util_alloc_link_target( latex_link ); + + test_assert_true( util_same_file( target , latex_target)); + + free( latex_link ); + free( latex_target); +} + + + +void test_latex_link( latex_type * latex ) { + const char * path = "/tmp/linkFarm"; + const char * file1 = util_alloc_filename( path , "File1" , NULL ); + const char * file2 = util_alloc_filename( path , "File2" , NULL ); + const char * file3 = util_alloc_filename( path , "File3" , NULL ); + + + util_make_path( path ); + make_file( file1 ); + make_file( file2 ); + make_file( file3 ); + + latex_link_path( latex , path ); + latex_link_directory_content( latex , path ); + + test_link( latex , "File1" , file1); + test_link( latex , "File2" , file2); + test_link( latex , "File3" , file3); + test_link( latex , "linkFarm" , path); + + util_clear_directory( path , true , true ); +} + int main(int argc , char ** argv) { bool ok; + { + bool in_place = false; + latex_type * latex = latex_alloc( argv[1] , in_place); + ok = latex_compile( latex , true , true , true); + test_assert_true( in_place == latex_compile_in_place( latex )); + latex_free( latex ); + test_assert_true( ok ); + } + + { latex_type * latex = latex_alloc( argv[1] , false ); - printf("input:%s \n",argv[1]); - ok = latex_compile( latex , true , true ); - printf("OK: %d \n",ok); + test_latex_link( latex ); latex_free( latex ); } - if (ok) - exit(0); - else - exit(1); + { + bool in_place = true; + latex_type * latex = latex_alloc( argv[1] , in_place); + test_assert_true( in_place == latex_compile_in_place( latex )); + test_latex_link( latex ); + latex_free( latex ); + } } diff --git a/ThirdParty/Ert/devel/libert_util/tests/ert_util_logh.c b/ThirdParty/Ert/devel/libert_util/tests/ert_util_logh.c new file mode 100644 index 0000000000..3c8347b33e --- /dev/null +++ b/ThirdParty/Ert/devel/libert_util/tests/ert_util_logh.c @@ -0,0 +1,46 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'ert_util_logh.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include + +#include +#include +#include + +#define LOG_FILE "/tmp/log.txt" + +int main(int argc , char ** argv) { + int log_level = 3; + + { + log_type * logh = log_open( NULL , 0 ); + + test_assert_false( log_is_open( logh )); + log_reopen( logh , LOG_FILE ); + test_assert_true( log_is_open( logh )); + + log_close( logh ); + } + + { + log_type * logh = log_open( LOG_FILE , 0 ); + test_assert_true( log_is_open( logh )); + log_close( logh ); + } + exit(0); +} diff --git a/ThirdParty/Ert/devel/libert_util/tests/ert_util_path_stack_test.c b/ThirdParty/Ert/devel/libert_util/tests/ert_util_path_stack_test.c new file mode 100644 index 0000000000..eecadb5a0c --- /dev/null +++ b/ThirdParty/Ert/devel/libert_util/tests/ert_util_path_stack_test.c @@ -0,0 +1,81 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'ert_util_path_stack_test.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include +#include + + +#include +#include +#include +#include + + + + +int main(int argc , char ** argv) { + char * cwd = util_alloc_cwd( ); + char * path1 = argv[1]; + char * path2 = argv[2]; + { + path_stack_type * path_stack = path_stack_alloc(); + + path_stack_push_cwd( path_stack ); + + if (path_stack_push( path_stack , "NotExist-1111")) + test_error_exit("Pushed unexisting path\n"); + + if (!path_stack_push( path_stack, path1 )) + test_error_exit("Failed to push:%s \n",path1 ); + + chdir( path2 ); + if (util_is_cwd( path1 )) + test_error_exit("Failed to chdir(%s) \n",path2 ); + + { + if (path_stack_size( path_stack ) != 2) + test_error_exit("Wrong stack size"); + + if (strcmp( path1 , path_stack_peek( path_stack )) != 0) + test_error_exit("peek error"); + } + + path_stack_pop( path_stack ); + printf("After pop: cwd:%s path1:%s \n",util_alloc_cwd() , path1); + if (!util_is_cwd( path1 )) + test_error_exit("path_stack_pop failed \n"); + + path_stack_pop( path_stack ); + if (!util_is_cwd( cwd )) + test_error_exit("path_stack_pop failed \n"); + + if (path_stack_size( path_stack ) != 0) + test_error_exit("Wrong stack size"); + + if (!path_stack_push(path_stack , NULL)) + test_error_exit("Hmmm - push(NULL) failed \n"); + + if (path_stack_size( path_stack ) != 1) + test_error_exit("Wrong stack size"); + + path_stack_pop( path_stack ); + path_stack_free( path_stack); + } + exit(0); +} diff --git a/ThirdParty/Ert/devel/libert_util/tests/ert_util_ping.c b/ThirdParty/Ert/devel/libert_util/tests/ert_util_ping.c new file mode 100644 index 0000000000..5b0a31876b --- /dev/null +++ b/ThirdParty/Ert/devel/libert_util/tests/ert_util_ping.c @@ -0,0 +1,41 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'ert_util_ping.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include + +#include +#include +#include + + + +int main( int argc , char ** argv) { + stringlist_type * server_list = stringlist_alloc_from_split( argv[1] , " "); + argc = stringlist_get_size( server_list ); + + if (argc >= 1) + test_assert_true( util_ping( stringlist_iget( server_list , 0 ))); + + if (argc >= 2) + test_assert_false( util_ping( stringlist_iget( server_list , 1 ))); + + if (argc >= 3) + test_assert_false( util_ping( stringlist_iget( server_list , 2 ))); + + exit(0); +} diff --git a/ThirdParty/Ert/devel/libert_util/tests/ert_util_realpath.c b/ThirdParty/Ert/devel/libert_util/tests/ert_util_realpath.c new file mode 100644 index 0000000000..c42adf6108 --- /dev/null +++ b/ThirdParty/Ert/devel/libert_util/tests/ert_util_realpath.c @@ -0,0 +1,52 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'ert_util_realpath.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include + +#include +#include +#include + +void test_path(const char * input , const char * expected) { + char * rpath = util_alloc_realpath__( input ); + if (!test_string_equal( rpath , expected )) + test_error_exit("util_alloc_realpath__(%s) => %s expected:%s \n",input , rpath , expected); + else + printf("OK: %s -> %s \n",input , rpath); + + free( rpath ); +} + + + +int main( int argc , char ** argv) { +#ifdef ERT_LINUX + + test_path("/tmp/" , "/tmp" ); + test_path("/tmp/test/normal" , "/tmp/test/normal" ); + test_path("/tmp/test/../test/normal" , "/tmp/test/normal"); + test_path("/tmp/test/../../tmp/test/normal" , "/tmp/test/normal"); + test_path("/tmp/test/../../tmp//test/normal" , "/tmp/test/normal"); + test_path("/tmp/test/../../tmp/./test/normal" , "/tmp/test/normal"); + test_path("/tmp/test/../../tmp/./test/normal/" , "/tmp/test/normal"); + test_path("/tmp/test/../../tmp/other/XX/" , "/tmp/other/XX"); + +#endif + + exit(0); +} diff --git a/ThirdParty/Ert/devel/libert_util/tests/ert_util_relpath_test.c b/ThirdParty/Ert/devel/libert_util/tests/ert_util_relpath_test.c new file mode 100644 index 0000000000..0eac93bf9a --- /dev/null +++ b/ThirdParty/Ert/devel/libert_util/tests/ert_util_relpath_test.c @@ -0,0 +1,88 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'ert_util_relpath_test.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include +#include + +#include +#include +#include + + +void test_path(int nr , const char * root , const char * path , const char * true_path) { + char * rel_path = util_alloc_rel_path( root , path); + + if (!test_string_equal( rel_path , true_path)) + test_error_exit("Case:%d rel_path(%s,%s) -> %s failed - expected: %s\n" , nr , root , path , rel_path , true_path); + else + printf("Case:%d OK \n",nr); + + util_safe_free( rel_path ); +} + +int main(int argc , char ** argv) { +#ifdef ERT_LINUX + const char * root1 = "/tmp/root/path"; + const char * path1 = "/tmp/root/path/relative"; + const char * true1 = "relative"; + + const char * root2 = "/tmp/root/path/"; + const char * path2 = "/tmp/root/path/relative"; + const char * true2 = "relative"; + + const char * root3 = "/tmp/root/path"; + const char * path3 = "/tmp/root/"; + const char * true3 = "../"; + + const char * root4 = "/tmp/root/path"; + const char * path4 = "relative"; + const char * true4 = "relative"; + + const char * root5 = "/tmp/root/path"; + const char * path5 = "/tmp/root/pathX/relative"; + const char * true5 = "../pathX/relative"; + + const char * root6 = "/tmp/root/path"; + const char * path6 = "/tmpX/root/pathX/relative"; + const char * true6 = "../../../tmpX/root/pathX/relative"; + + const char * root7 = "/tmp/root/path"; + const char * path7 = "/tmp/root/path"; + const char * true7 = NULL; + + const char * root8 = "/tmp"; + const char * path8 = "root/path"; + const char * true8 = "root/path"; + +#endif + + test_path( 1 , root1 , path1 , true1 ); + test_path( 2 , root2 , path2 , true2 ); + test_path( 3 , root3 , path3 , true3 ); + test_path( 4 , root4 , path4 , true4 ); + test_path( 5 , root5 , path5 , true5 ); + test_path( 6 , root6 , path6 , true6 ); + test_path( 7 , root7 , path7 , true7 ); + { + chdir(root8); + test_path( 8 , NULL , path8 , true8 ); + } + + exit(0); +} diff --git a/ThirdParty/Ert/devel/libert_util/tests/ert_util_rng.c b/ThirdParty/Ert/devel/libert_util/tests/ert_util_rng.c new file mode 100644 index 0000000000..8096c031e6 --- /dev/null +++ b/ThirdParty/Ert/devel/libert_util/tests/ert_util_rng.c @@ -0,0 +1,71 @@ +/* + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'ert_util_rng.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include + +#include +#include +#include +#include + + +#define MAX_INT 666661 + +int main(int argc , char ** argv) { + rng_type * rng = rng_alloc( MZRAN , INIT_DEFAULT ); + { + int val1 = rng_get_int( rng , MAX_INT); + int val2 = rng_get_int( rng , MAX_INT); + + test_assert_int_not_equal( val1 , val2 ); + + rng_init( rng , INIT_DEFAULT ); + val2 = rng_get_int( rng , MAX_INT ); + test_assert_int_equal( val1 , val2 ); + } + { + int val2 , val1; + int state_size = rng_state_size( rng ); + char * buffer1 = util_calloc( state_size , sizeof * buffer1 ); + char * buffer2 = util_calloc( state_size , sizeof * buffer2 ); + test_assert_int_not_equal( state_size , 0 ); + test_assert_int_equal( state_size , MZRAN_STATE_SIZE ); + + rng_init( rng , INIT_DEFAULT ); + rng_get_state( rng , buffer1 ); + val1 = rng_get_int( rng , MAX_INT); + val2 = rng_get_int( rng , MAX_INT); + + test_assert_int_not_equal( val1 , val2 ); + rng_set_state( rng , buffer1 ); + val2 = rng_get_int( rng , MAX_INT); + test_assert_int_equal( val1 , val2 ); + + rng_init( rng , INIT_DEFAULT ); + rng_get_state( rng , buffer2 ); + test_assert_mem_equal( buffer1 , buffer2 , state_size ); + val2 = rng_get_int( rng , MAX_INT); + rng_get_state( rng , buffer2 ); + test_assert_mem_not_equal( buffer1 , buffer2 , state_size ); + + free( buffer1 ); + free( buffer2 ); + } + rng_free( rng ); + exit(0); +} diff --git a/ThirdParty/Ert/devel/libert_util/tests/ert_util_sprintf_escape.c b/ThirdParty/Ert/devel/libert_util/tests/ert_util_sprintf_escape.c new file mode 100644 index 0000000000..0496ea72d3 --- /dev/null +++ b/ThirdParty/Ert/devel/libert_util/tests/ert_util_sprintf_escape.c @@ -0,0 +1,39 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'ert_util_sprintf_escape.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include + +#include +#include + + + +int main(int argc , char ** argv) { + test_assert_string_equal( NULL , util_alloc_sprintf_escape( NULL , 0)); + test_assert_string_equal( "String", util_alloc_sprintf_escape( "String" , 0)); + test_assert_string_equal( "String", util_alloc_sprintf_escape( "String" , 10)); + + test_assert_string_equal( "S%%tring%%", util_alloc_sprintf_escape( "S%tring%" , 0)); + test_assert_string_equal( "S%%tring%%", util_alloc_sprintf_escape( "S%tring%" , 2)); + test_assert_string_equal( "S%%tring%%", util_alloc_sprintf_escape( "S%tring%" , 10)); + test_assert_string_equal( "S%%tring%" , util_alloc_sprintf_escape( "S%tring%" , 1)); + test_assert_string_equal( "%%%%" , util_alloc_sprintf_escape( "%%" , 0)); + test_assert_string_equal( "%%%%" , util_alloc_sprintf_escape( "%%%" , 1)); + + exit(0); +} diff --git a/ThirdParty/Ert/devel/libert_util/tests/ert_util_strcat_test.c b/ThirdParty/Ert/devel/libert_util/tests/ert_util_strcat_test.c new file mode 100644 index 0000000000..e022fc51d1 --- /dev/null +++ b/ThirdParty/Ert/devel/libert_util/tests/ert_util_strcat_test.c @@ -0,0 +1,55 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'ert_util_strcat_test.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include + +#include +#include +#include + + +void test_strcat(char * s1 , const char *s2 , const char * expected) { + char * cat = util_strcat_realloc(s1 , s2 ); + if (test_string_equal( cat , expected )) + util_safe_free( cat ); + else + test_error_exit("util_strcat_realloc(%s,%s) Got:%s expected:%s \n",s1,s2,cat , expected); +} + + +int main(int argc , char ** argv) { + test_strcat(NULL , NULL , NULL); + + { + const char * s = "Hei"; + test_strcat(NULL, util_alloc_string_copy(s) , s); + } + { + const char * s = "Hei"; + test_strcat(util_alloc_string_copy(s) , NULL , s); + } + { + char * s1 = util_alloc_string_copy("hei"); + char * s2 = util_alloc_string_copy("-Hei"); + test_strcat(s1,s2 , "hei-Hei"); + } + + printf("Test OK\n"); + exit(0); +} diff --git a/ThirdParty/Ert/devel/libert_util/tests/ert_util_string_util.c b/ThirdParty/Ert/devel/libert_util/tests/ert_util_string_util.c new file mode 100644 index 0000000000..6700549b2e --- /dev/null +++ b/ThirdParty/Ert/devel/libert_util/tests/ert_util_string_util.c @@ -0,0 +1,106 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'ert_util_string_util.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include + +#include +#include +#include +#include + + +static void test1( const int_vector_type * active_list ) { + test_assert_int_equal( int_vector_size( active_list ), 10 ); + test_assert_int_equal( int_vector_iget( active_list , 0 ) , 1 ); + test_assert_int_equal( int_vector_iget( active_list , 1 ) , 3); + test_assert_int_equal( int_vector_iget( active_list , 8 ) ,10 ); + test_assert_int_equal( int_vector_iget( active_list , 9 ) ,15 ); +} + + +void test_active_list() { + int_vector_type * active_list = string_util_alloc_active_list("1,3- 10,15"); + test_assert_true( string_util_init_active_list("1,3- 10,15" , active_list) ); + test1( active_list ); + + test_assert_true( string_util_update_active_list("1,3- 10,15,8" , active_list) ); + test1( active_list ); + test_assert_false( string_util_update_active_list("1,X" , active_list) ); + test1( active_list ); + + test_assert_true( string_util_update_active_list("14-16" , active_list) ); + test_assert_int_equal( int_vector_size( active_list ) , 12); + test_assert_int_equal( int_vector_iget( active_list , 9 ) ,14 ); + test_assert_int_equal( int_vector_iget( active_list , 11 ) ,16 ); + + test_assert_true( string_util_update_active_list("0" , active_list) ); + test_assert_int_equal( int_vector_size( active_list ) , 13); + test_assert_int_equal( int_vector_iget( active_list , 0 ) ,0 ); + test_assert_int_equal( int_vector_iget( active_list , 10 ) ,14 ); + test_assert_int_equal( int_vector_iget( active_list , 12 ) ,16 ); + + test_assert_true( string_util_update_active_list("4-6" , active_list) ); + test_assert_int_equal( int_vector_size( active_list ) , 13); + test_assert_int_equal( int_vector_iget( active_list , 0 ) ,0 ); + test_assert_int_equal( int_vector_iget( active_list , 10 ) ,14 ); + test_assert_int_equal( int_vector_iget( active_list , 12 ) ,16 ); +} + + +static void test2( const bool_vector_type * active_mask ) { + test_assert_int_equal( bool_vector_size( active_mask ), 16 ); + + test_assert_true( bool_vector_iget( active_mask , 1 )); + test_assert_true( bool_vector_iget( active_mask , 3 )); + test_assert_true( bool_vector_iget( active_mask , 4 ) ); + test_assert_true( bool_vector_iget( active_mask , 9 )); + test_assert_true( bool_vector_iget( active_mask , 10 )); + test_assert_true( bool_vector_iget( active_mask , 15 )); + + test_assert_false( bool_vector_iget( active_mask , 0 )); + test_assert_false( bool_vector_iget( active_mask , 2 )); + test_assert_false( bool_vector_iget( active_mask , 11 )); + test_assert_false( bool_vector_iget( active_mask , 14 )); +} + + + +void test_active_mask() { + bool_vector_type * active_mask = string_util_alloc_active_mask("1,3 -6,6- 10, 15"); + + test2( active_mask ); + test_assert_true( string_util_init_active_mask("1,3- 10,15" , active_mask)); + test2( active_mask ); + + test_assert_false( string_util_update_active_mask("11,X" , active_mask)); + test2( active_mask ); + + bool_vector_free( active_mask ); + + + +} + + + + +int main(int argc , char ** argv) { + test_active_list(); + test_active_mask(); + exit(0); +} diff --git a/ThirdParty/Ert/devel/libert_util/tests/ert_util_stringlist_test.c b/ThirdParty/Ert/devel/libert_util/tests/ert_util_stringlist_test.c index a7b4624100..c56706e9f7 100644 --- a/ThirdParty/Ert/devel/libert_util/tests/ert_util_stringlist_test.c +++ b/ThirdParty/Ert/devel/libert_util/tests/ert_util_stringlist_test.c @@ -18,7 +18,7 @@ #include #include -//#include +#include #include void test_char() { @@ -48,7 +48,57 @@ void test_char() { +void test_reverse() { + const char *s0 = "AAA"; + const char *s1 = "BBB"; + const char *s2 = "CCC"; + + stringlist_type * s = stringlist_alloc_new(); + stringlist_append_ref( s , s0 ); + stringlist_append_ref( s , s1 ); + stringlist_append_ref( s , s2 ); + + stringlist_reverse(s); + + test_assert_string_equal( s2 , stringlist_iget(s , 0 )); + test_assert_string_equal( s1 , stringlist_iget(s , 1 )); + test_assert_string_equal( s0 , stringlist_iget(s , 2 )); +} + + +void test_iget_as_int() { + stringlist_type * s = stringlist_alloc_new(); + stringlist_append_ref(s , "1000" ); + stringlist_append_ref(s , "1000X" ); + stringlist_append_ref(s , "XXXX" ); + + { + int value; + bool valid; + + value = stringlist_iget_as_int( s , 0 , &valid); + test_assert_int_equal( value , 1000); + test_assert_true( valid ); + + value = stringlist_iget_as_int( s , 1 , &valid); + test_assert_int_equal( value , -1); + test_assert_false( valid ); + + value = stringlist_iget_as_int( s , 2 , NULL); + test_assert_int_equal( value , -1); + } +} + +void test_empty() { + stringlist_type * s = stringlist_alloc_new(); + stringlist_fprintf( s , "\n" , stdout ); +} + + int main( int argc , char ** argv) { + test_empty(); test_char(); + test_reverse(); + test_iget_as_int(); exit(0); } diff --git a/ThirdParty/Ert/devel/libert_util/tests/ert_util_time_interval.c b/ThirdParty/Ert/devel/libert_util/tests/ert_util_time_interval.c new file mode 100644 index 0000000000..0a733466f0 --- /dev/null +++ b/ThirdParty/Ert/devel/libert_util/tests/ert_util_time_interval.c @@ -0,0 +1,245 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'ert_util_time_interval.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include + +#include +#include +#include + + + +int main( int argc , char ** argv) { + time_t start_time = util_make_date(1,1,2000); + time_t end_time = util_make_date(1,1,2010); + time_t in = util_make_date( 1,1,2005); + time_t before = util_make_date( 1,1,1995); + time_t after = util_make_date( 1,1,2015); + + { + time_interval_type * ti = time_interval_alloc( start_time , end_time ); + test_assert_not_NULL( ti ); + test_assert_false( time_interval_is_empty( ti )); + + test_assert_true( time_interval_contains( ti , start_time )); + test_assert_true( time_interval_contains( ti , in )); + test_assert_false( time_interval_contains( ti , before )); + test_assert_false( time_interval_contains( ti , end_time )); + test_assert_false( time_interval_contains( ti , after )); + + test_assert_false( time_interval_update( ti , end_time , start_time )); + test_assert_true( time_interval_is_empty( ti )); + + test_assert_false( time_interval_contains( ti , start_time )); + test_assert_false( time_interval_contains( ti , in )); + test_assert_false( time_interval_contains( ti , before )); + test_assert_false( time_interval_contains( ti , end_time )); + test_assert_false( time_interval_contains( ti , after )); + + test_assert_true( time_interval_update( ti , start_time , end_time )); + test_assert_false( time_interval_is_empty( ti )); + + time_interval_free( ti ); + } + + { + time_interval_type * ti = time_interval_alloc( end_time , start_time ); + test_assert_not_NULL( ti ); + test_assert_true( time_interval_is_empty( ti )); + test_assert_true( time_interval_update( ti , start_time , end_time )); + test_assert_false( time_interval_is_empty( ti )); + time_interval_free( ti ); + } + + { + time_interval_type * t1 = time_interval_alloc( start_time , end_time ); + time_interval_type * t2 = time_interval_alloc( in , after ); + time_interval_type * t3 = time_interval_alloc( end_time , start_time ); + time_interval_type * t4 = time_interval_alloc( before , start_time ); + time_interval_type * t5 = time_interval_alloc( end_time , after ); + + test_assert_true( time_interval_has_overlap( t1 , t2 )); + + test_assert_true( time_interval_is_empty( t3 )); + test_assert_false( time_interval_has_overlap( t1 , t3 )); + test_assert_false( time_interval_has_overlap( t3 , t1 )); + test_assert_false( time_interval_has_overlap( t3 , t3 )); + test_assert_false( time_interval_has_overlap( t4 , t5 )); + test_assert_false( time_interval_has_overlap( t1 , t5 )); + + + time_interval_free( t1 ); + time_interval_free( t2 ); + } + + { + time_interval_type * ti = time_interval_alloc_open(); + + test_assert_false( time_interval_is_empty( ti )); + + test_assert_true( time_interval_contains( ti , start_time )); + test_assert_true( time_interval_contains( ti , in )); + test_assert_true( time_interval_contains( ti , before )); + test_assert_true( time_interval_contains( ti , end_time )); + test_assert_true( time_interval_contains( ti , after )); + + test_assert_true( time_interval_update_start( ti , start_time )); + test_assert_true( time_interval_contains( ti , start_time )); + test_assert_true( time_interval_update_start( ti , in )); + test_assert_false( time_interval_contains( ti , start_time )); + test_assert_false( time_interval_is_empty( ti )); + + test_assert_false( time_interval_update_end( ti , start_time )); + test_assert_true( time_interval_is_empty( ti )); + test_assert_true( time_interval_update_end( ti , end_time )); + test_assert_false( time_interval_is_empty( ti )); + test_assert_false( time_interval_contains( ti , start_time )); + + time_interval_free( ti ); + } + + { + time_interval_type * t1 = time_interval_alloc( start_time , end_time ); + + test_assert_time_t_equal( start_time , time_interval_get_start( t1 )); + test_assert_time_t_equal( end_time , time_interval_get_end( t1 )); + test_assert_false( time_interval_is_empty( t1 )); + + test_assert_false( time_interval_update_end( t1 , before )); + test_assert_true( time_interval_is_empty( t1 )); + test_assert_time_t_equal( start_time , time_interval_get_start( t1 )); + test_assert_time_t_equal( before , time_interval_get_end( t1 )); + + test_assert_true( time_interval_update_end( t1 , in )); + test_assert_false( time_interval_is_empty( t1 )); + test_assert_time_t_equal( start_time , time_interval_get_start( t1 )); + test_assert_time_t_equal( in , time_interval_get_end( t1 )); + + time_interval_free( t1 ); + } + + { + time_interval_type * t1 = time_interval_alloc( start_time , in ); + time_interval_type * t2 = time_interval_alloc( in , end_time ); + time_interval_type * t3 = time_interval_alloc( start_time , end_time); + + test_assert_true( time_interval_is_adjacent( t1 , t2 )); + test_assert_true( time_interval_is_adjacent( t2 , t1 )); + + test_assert_false( time_interval_is_adjacent( t1 , t3 )); + test_assert_false( time_interval_is_adjacent( t3 , t1 )); + test_assert_false( time_interval_is_adjacent( t2 , t3 )); + test_assert_false( time_interval_is_adjacent( t3 , t2 )); + + time_interval_free( t1 ); + time_interval_free( t2 ); + time_interval_free( t3 ); + } + + + + { + time_interval_type * t1 = time_interval_alloc( start_time , end_time ); + time_interval_type * t2 = time_interval_alloc( in , end_time ); + time_interval_type * t3 = time_interval_alloc( end_time , after ); + time_interval_type * t4 = time_interval_alloc( before , start_time ); + + test_assert_true( time_interval_extend(t1 , t2 )); + test_assert_time_t_equal( start_time , time_interval_get_start( t1 )); + test_assert_time_t_equal( end_time , time_interval_get_end( t1 )); + + test_assert_true( time_interval_extend(t1 , t3 )); + test_assert_time_t_equal( start_time , time_interval_get_start( t1 )); + test_assert_time_t_equal( after , time_interval_get_end( t1 )); + + test_assert_true( time_interval_update_start(t1 , in )); + test_assert_time_t_equal( in , time_interval_get_start( t1 )); + + + test_assert_false( time_interval_extend(t1 , t4 )); + test_assert_time_t_equal( in , time_interval_get_start( t1 )); + test_assert_time_t_equal( after , time_interval_get_end( t1 )); + + + test_assert_true( time_interval_update_end(t4 , in )); + test_assert_true( time_interval_extend(t1 , t4 )); + test_assert_time_t_equal( before , time_interval_get_start( t1 )); + test_assert_time_t_equal( after , time_interval_get_end( t1 )); + + + time_interval_free( t1 ); + time_interval_free( t2 ); + time_interval_free( t3 ); + time_interval_free( t4 ); + } + + { + time_interval_type * t1 = time_interval_alloc( start_time , end_time ); + time_interval_type * t2 = time_interval_alloc( in , end_time ); + time_interval_type * t3 = time_interval_alloc( end_time , after ); + time_interval_type * t4 = time_interval_alloc( before , start_time ); + + test_assert_true( time_interval_intersect(t1 , t2 )); + test_assert_time_t_equal( in , time_interval_get_start( t1 )); + test_assert_time_t_equal( end_time , time_interval_get_end( t1 )); + + time_interval_free( t1 ); + time_interval_free( t2 ); + time_interval_free( t3 ); + time_interval_free( t4 ); + } + + { + time_interval_type * t1 = time_interval_alloc( start_time , end_time ); + time_interval_type * t2 = time_interval_alloc( start_time , end_time ); + time_interval_type * t3 = time_interval_alloc( end_time , after ); + time_interval_type * t4 = time_interval_alloc_copy( t1 ); + + test_assert_true( time_interval_equal( t1 , t2 )); + test_assert_false( time_interval_equal( t1 , t3 )); + + test_assert_true( time_interval_equal( t4 , t2 )); + test_assert_false( time_interval_equal( t4 , t3 )); + + test_assert_ptr_not_equal( t4 , t1 ); + time_interval_free( t1 ); + time_interval_free( t2 ); + time_interval_free( t3 ); + time_interval_free( t4 ); + } + + { + time_interval_type * t1 = time_interval_alloc( start_time , end_time ); + + test_assert_true( time_interval_arg_before( t1 , before )); + test_assert_true( time_interval_arg_after( t1 , after)); + + test_assert_false( time_interval_arg_before( t1 , start_time )); + test_assert_false( time_interval_arg_before( t1 , in )); + test_assert_false( time_interval_arg_before( t1 , after )); + + test_assert_false( time_interval_arg_after( t1 , start_time)); + test_assert_false( time_interval_arg_after( t1 , in)); + test_assert_true( time_interval_arg_after( t1 , after)); + + time_interval_free( t1 ); + } + + exit(0); +} diff --git a/ThirdParty/Ert/devel/libert_util/tests/ert_util_type_vector_test.c b/ThirdParty/Ert/devel/libert_util/tests/ert_util_type_vector_test.c index e9e2447909..a231320461 100644 --- a/ThirdParty/Ert/devel/libert_util/tests/ert_util_type_vector_test.c +++ b/ThirdParty/Ert/devel/libert_util/tests/ert_util_type_vector_test.c @@ -19,6 +19,7 @@ #include #include +#include void assert_equal( bool equal ) { if (!equal) @@ -42,6 +43,37 @@ int main(int argc , char ** argv) { assert_equal( int_vector_iget(int_vector , 4 ) == 99 ); assert_equal( int_vector_iget(int_vector , 5 ) == -10 ); + { + int N1 = 100000; + int N2 = 10*N1; + int_vector_type * v1 = int_vector_alloc( N1 , 0 ); + int_vector_type * v2; + int * data1 = int_vector_get_ptr( v1 ); + int_vector_iset( v1 , N1 - 1, 99); + + int_vector_free_container( v1 ); + v2 = int_vector_alloc( N2 , 0 ); + int_vector_iset(v2 , N2 - 1, 77 ); + + test_assert_int_equal( data1[N1-1] , 99); + int_vector_free( v2 ); + free( data1 ); + } + + + test_assert_true( int_vector_init_range( int_vector , 100 , 1000 , 115 ) ); + test_assert_int_equal( int_vector_iget( int_vector , 0 ) , 100); + test_assert_int_equal( int_vector_iget( int_vector , 1 ) , 215); + test_assert_int_equal( int_vector_iget( int_vector , 2 ) , 330); + test_assert_int_equal( int_vector_iget( int_vector , 3 ) , 445); + test_assert_int_equal( int_vector_get_last( int_vector ) , 1000); + + test_assert_false( int_vector_init_range( int_vector , 100 , -1000 , 115 ) ); + test_assert_int_equal( int_vector_iget( int_vector , 0 ) , 100); + test_assert_int_equal( int_vector_iget( int_vector , 1 ) , 215); + test_assert_int_equal( int_vector_iget( int_vector , 2 ) , 330); + test_assert_int_equal( int_vector_iget( int_vector , 3 ) , 445); + test_assert_int_equal( int_vector_get_last( int_vector ) , 1000); exit(0); } diff --git a/ThirdParty/Ert/devel/libert_util/tests/ert_util_vector_test.c b/ThirdParty/Ert/devel/libert_util/tests/ert_util_vector_test.c index c68d64c911..29a22eeffb 100644 --- a/ThirdParty/Ert/devel/libert_util/tests/ert_util_vector_test.c +++ b/ThirdParty/Ert/devel/libert_util/tests/ert_util_vector_test.c @@ -19,29 +19,61 @@ #include #include +#include -void assert_equal( bool equal ) { - if (!equal) - exit(1); -} int test_iset( ) { - vector_type * vector = vector_alloc_new( 0 ); + vector_type * vector = vector_alloc_new( ); vector_iset_ref( vector , 2 , vector ); + - assert_equal( vector_get_size( vector ) == 3 ); - assert_equal( vector_iget( vector , 0 ) == NULL ); - assert_equal( vector_iget( vector , 1 ) == NULL ); - assert_equal( vector_iget( vector , 2 ) == vector ); + test_assert_true( vector_get_size( vector ) == 3 ); + test_assert_true( vector_iget( vector , 0 ) == NULL ); + test_assert_true( vector_iget( vector , 1 ) == NULL ); + test_assert_true( vector_iget( vector , 2 ) == vector ); vector_free( vector ); return 0; } +void test_reverse() { + const char * val1 = "value1"; + const char * val2 = "value2"; + const char * val3 = "value3"; + const char * val4 = "value4"; + + vector_type * vector1 = vector_alloc_new( ); + vector_type * vector2 = vector_alloc_new( ); + + vector_append_ref( vector1 , val1 ); + vector_append_ref( vector1 , val2 ); + vector_append_ref( vector1 , val3 ); + vector_append_ref( vector1 , val4 ); + + vector_append_ref( vector2 , val1 ); + vector_append_ref( vector2 , val2 ); + vector_append_ref( vector2 , val3 ); + vector_append_ref( vector2 , val4 ); + + vector_inplace_reverse( vector1 ); + + { + int i; + int size = vector_get_size( vector1 ); + for (i=0; i < vector_get_size( vector1 ); i++) + test_assert_ptr_equal( vector_iget_const( vector2 , i ) , vector_iget_const( vector1 , size - 1 - i )); + } + vector_free( vector1 ); + vector_free( vector2 ); +} + + + + int main(int argc , char ** argv) { test_iset( ); - + test_reverse( ); exit(0); } diff --git a/ThirdParty/Ert/devel/libgeometry/src/CMakeLists.txt b/ThirdParty/Ert/devel/libgeometry/src/CMakeLists.txt index 223ca9976b..cc1391ab09 100644 --- a/ThirdParty/Ert/devel/libgeometry/src/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libgeometry/src/CMakeLists.txt @@ -7,9 +7,11 @@ target_link_libraries( ert_geometry ert_util ) #----------------------------------------------------------------- -install(TARGETS ert_geometry DESTINATION ${CMAKE_INSTALL_LIBDIR}) -foreach(header ${header_files}) - install(FILES ../include/ert/geometry/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/geometry) -endforeach() +if (INSTALL_ERT) + install(TARGETS ert_geometry DESTINATION ${CMAKE_INSTALL_LIBDIR}) + foreach(header ${header_files}) + install(FILES ../include/ert/geometry/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/geometry) + endforeach() +endif() diff --git a/ThirdParty/Ert/devel/libjob_queue/CMakeLists.txt b/ThirdParty/Ert/devel/libjob_queue/CMakeLists.txt index 22c9ef1cec..159c0c64e8 100644 --- a/ThirdParty/Ert/devel/libjob_queue/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libjob_queue/CMakeLists.txt @@ -1,4 +1,5 @@ if (USE_LSF) + set( HAVE_LSF_LIBRARY ON ) set( LSF_INCLUDE_PATH $ENV{LSF_INCLUDE_PATH} CACHE FILEPATH "Path to LSF header files") set( LSF_LIB_PATH $ENV{LSF_HOME}/lib CACHE FILEPATH "Path to LSF library files") @@ -7,20 +8,19 @@ if (USE_LSF) find_library( LSF_LIBRARY NAMES lsf PATHS ${LSF_LIB_PATH}) if (NOT DEFINED LSF_HEADER) - set( USE_LSF OFF) + set( HAVE_LSF_LIBRARY OFF) endif() if (NOT DEFINED LSF_LIBRARY) - set( USE_LSF OFF ) + set( HAVE_LSF_LIBRARY OFF ) + endif() + + if (HAVE_LSF_LIBRARY) + include_directories( ${LSF_INCLUDE_PATH} ) + add_definitions( -DHAVE_LSF_LIBRARY ) endif() endif() -if (USE_LSF) - set( HAVE_LSF ON ) - add_definitions( -DHAVE_LSF ) -endif() - -include_directories( ${LSF_INCLUDE_PATH} ) add_subdirectory( src ) if (BUILD_APPLICATONS) diff --git a/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/ext_cmd.h b/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/ext_cmd.h deleted file mode 100644 index 0414011e1e..0000000000 --- a/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/ext_cmd.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'ext_cmd.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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. -*/ - -#ifndef __EXT_CMD_H__ -#define __EXT_CMD_H__ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - - - typedef struct ext_cmd_struct ext_cmd_type; - - bool ext_cmd_internal( const ext_cmd_type * ext_cmd ); - config_type * ext_cmd_alloc_config(); - ext_cmd_type * ext_cmd_alloc(bool internal); - void ext_cmd_free( ext_cmd_type * ext_cmd ); - void ext_cmd_free__( void * arg); - void ext_cmd_set_executable( ext_cmd_type * ext_cmd , const char * executable ); - ext_cmd_type * ext_cmd_config_alloc( config_type * config , const char * config_file); - - void ext_cmd_set_executable( ext_cmd_type * ext_cmd , const char * executable); - void ext_cmd_set_function( ext_cmd_type * ext_cmd , const char * function); - void ext_cmd_set_module( ext_cmd_type * ext_cmd , const char * module); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/lsb.h b/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/lsb.h new file mode 100644 index 0000000000..0b42edf899 --- /dev/null +++ b/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/lsb.h @@ -0,0 +1,56 @@ +/* + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'lsb.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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. +*/ + + +#ifndef __LSB_H__ +#define __LSB_H__ + + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include + +#include + + typedef struct lsb_struct lsb_type; + + + lsb_type * lsb_alloc(); + void lsb_free( lsb_type * lsb); + bool lsb_ready( const lsb_type * lsb); + + int lsb_initialize( const lsb_type * lsb); + int lsb_submitjob( const lsb_type * lsb , struct submit * , struct submitReply *); + int lsb_killjob( const lsb_type * lsb , int lsf_jobnr); + int lsb_openjob( const lsb_type * lsb , int lsf_jobnr); + struct jobInfoEnt * lsb_readjob( const lsb_type * lsb ); + int lsb_closejob( const lsb_type * lsb ); + char * lsb_sys_msg( const lsb_type * lsb ); + stringlist_type * lsb_get_error_list( const lsb_type * lsb ); + + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/lsf_driver.h b/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/lsf_driver.h index 6362f6aa6c..5adf0c2b06 100644 --- a/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/lsf_driver.h +++ b/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/lsf_driver.h @@ -39,6 +39,8 @@ extern "C" { #define LSF_BKILL_CMD "BKILL_CMD" #define LOCAL_LSF_SERVER "LOCAL" +#define NULL_LSF_SERVER "NULL" + typedef enum { LSF_SUBMIT_INVALID = 0, diff --git a/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/workflow.h b/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/workflow.h new file mode 100644 index 0000000000..eb10d65bac --- /dev/null +++ b/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/workflow.h @@ -0,0 +1,45 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'workflow.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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. +*/ + +#ifndef __WORKFLOW_H__ +#define __WORKFLOW_H__ + + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include + +#include + + typedef struct workflow_struct workflow_type; + + const config_error_type * workflow_get_last_error( const workflow_type * workflow); + workflow_type * workflow_alloc( const char * src_file , workflow_joblist_type * joblist); + bool workflow_run( workflow_type * workflow , void * self , bool verbose , const subst_list_type * context); + void workflow_free( workflow_type * workflow ); + void workflow_free__( void * arg ); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/workflow_job.h b/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/workflow_job.h new file mode 100644 index 0000000000..f6b7442864 --- /dev/null +++ b/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/workflow_job.h @@ -0,0 +1,51 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'workflow_job.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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. +*/ + +#ifndef __WORKFLOW_JOB_H__ +#define __WORKFLOW_JOB_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + + + typedef void (workflow_job_ftype) (void * self , const stringlist_type * arg ); + typedef struct workflow_job_struct workflow_job_type; + + const char * workflow_job_get_name( const workflow_job_type * workflow_job ); + bool workflow_job_internal( const workflow_job_type * workflow_job ); + config_type * workflow_job_alloc_config(); + workflow_job_type * workflow_job_alloc(const char * name , bool internal); + void workflow_job_free( workflow_job_type * workflow_job ); + void workflow_job_free__( void * arg); + void workflow_job_set_executable( workflow_job_type * workflow_job , const char * executable ); + workflow_job_type * workflow_job_config_alloc( const char * name , config_type * config , const char * config_file); + + void workflow_job_update_config_compiler( const workflow_job_type * workflow_job , config_type * config_compiler ); + void workflow_job_set_executable( workflow_job_type * workflow_job , const char * executable); + void workflow_job_set_function( workflow_job_type * workflow_job , const char * function); + void workflow_job_set_module( workflow_job_type * workflow_job , const char * module); + void workflow_job_run( const workflow_job_type * job , void * self , bool verbose , const stringlist_type * arg); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/workflow_joblist.h b/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/workflow_joblist.h new file mode 100644 index 0000000000..3102d72c63 --- /dev/null +++ b/ThirdParty/Ert/devel/libjob_queue/include/ert/job_queue/workflow_joblist.h @@ -0,0 +1,43 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'workflow_joblist.h' is part of ERT - Ensemble based + Reservoir Tool. + + ERT 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. + + ERT 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. +*/ + + + +#ifndef __WORKFLOW_JOBLIST_H__ +#define __WORKFLOW_JOBLIST_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +typedef struct workflow_joblist_struct workflow_joblist_type; + + workflow_joblist_type * workflow_joblist_alloc(); + void workflow_joblist_free( workflow_joblist_type * joblist); + const workflow_job_type * workflow_joblist_get_job( const workflow_joblist_type * joblist , const char * job_name); + void workflow_joblist_add_job( workflow_joblist_type * joblist , const workflow_job_type * job); + bool workflow_joblist_add_job_from_file( workflow_joblist_type * joblist , const char * job_name , const char * config_file ); + config_type * workflow_joblist_get_compiler( const workflow_joblist_type * joblist ); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/ThirdParty/Ert/devel/libjob_queue/src/CMakeLists.txt b/ThirdParty/Ert/devel/libjob_queue/src/CMakeLists.txt index 171a098633..76e70e7845 100644 --- a/ThirdParty/Ert/devel/libjob_queue/src/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libjob_queue/src/CMakeLists.txt @@ -1,22 +1,29 @@ #configure_file (${CMAKE_CURRENT_SOURCE_DIR}/CMake/include/libjob_queue_build_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/libjob_queue_build_config.h) -set(source_files forward_model.c queue_driver.c job_queue.c lsf_driver.c local_driver.c rsh_driver.c ext_job.c ext_joblist.c ext_cmd.c) -set(header_files job_queue.h queue_driver.h lsf_driver.h local_driver.h rsh_driver.h ext_job.h ext_joblist.h forward_model.h ext_cmd.h) +set(source_files forward_model.c queue_driver.c job_queue.c local_driver.c rsh_driver.c ext_job.c ext_joblist.c workflow_job.c workflow.c workflow_joblist.c) +set(header_files job_queue.h queue_driver.h local_driver.h rsh_driver.h ext_job.h ext_joblist.h forward_model.h workflow_job.h workflow.h workflow_joblist.h) -add_library( job_queue ${LIBRARY_TYPE} ${source_files} ) +if (USE_LSF) + list( APPEND source_files lsf_driver.c) + list( APPEND header_files lsf_driver.h) + + if (HAVE_LSF_LIBRARY) + list( APPEND source_files lsb.c) + list( APPEND header_files lsb.h) + endif() +endif() + +add_library( job_queue SHARED ${source_files} ) set_target_properties( job_queue PROPERTIES VERSION 1.0 SOVERSION 1.0 ) - target_link_libraries( job_queue config ert_util ) -if (HAVE_LSF) - target_link_libraries( job_queue bat ${LSF_LIBRARY} nsl) -endif() if (NEED_LIBDL) target_link_libraries( job_queue dl ) endif() - -install(TARGETS job_queue DESTINATION ${CMAKE_INSTALL_LIBDIR}) -foreach(header ${header_files}) - install(FILES ../include/ert/job_queue/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/job_queue) -endforeach() +if (INSTALL_ERT) + install(TARGETS job_queue DESTINATION ${CMAKE_INSTALL_LIBDIR}) + foreach(header ${header_files}) + install(FILES ../include/ert/job_queue/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/job_queue) + endforeach() +endif() diff --git a/ThirdParty/Ert/devel/libjob_queue/src/ext_cmd.c b/ThirdParty/Ert/devel/libjob_queue/src/ext_cmd.c deleted file mode 100644 index cec99560bb..0000000000 --- a/ThirdParty/Ert/devel/libjob_queue/src/ext_cmd.c +++ /dev/null @@ -1,267 +0,0 @@ -/* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'ext_cmd.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 -#include -#include - -#include -#include -#include - -#include - -#include - - -/* The default values are interepreted as no limit. */ -#define ARG_MIN_DEFAULT -1 -#define ARG_MAX_DEFAULT -1 -#define DEFAULT_INTERNAL false - - -#define MIN_ARG_KEY "MIN_ARG" -#define MAX_ARG_KEY "MAX_ARG" -#define ARG_TYPE_KEY "ARG_TYPE" -#define INTERNAL_KEY "INTERNAL" -#define MODULE_KEY "MODULE" -#define FUNCTION_KEY "FUNCTION" -#define EXECUTABLE_KEY "EXECUTABLE" - -#define NULL_STRING "NULL" -#define EXT_CMD_STRING_TYPE "STRING" -#define EXT_CMD_INT_TYPE "INT" -#define EXT_CMD_FLOAT_TYPE "FLOAT" - -#define EXT_CMD_TYPE_ID 614441 - -struct ext_cmd_struct { - UTIL_TYPE_ID_DECLARATION; - bool internal; - int min_arg; - int max_arg; - int_vector_type * arg_types; // Should contain values from the config_item_types enum in config.h. - char * executable; - char * module; - char * function; - void * lib_handle; - void * dl_func; - bool valid; -}; - - -bool ext_cmd_internal( const ext_cmd_type * ext_cmd ) { - return ext_cmd->internal; -} - - -config_type * ext_cmd_alloc_config() { - config_type * config = config_alloc(); - { - config_schema_item_type * item; - - item = config_add_schema_item( config , MIN_ARG_KEY , false , false); - config_schema_item_set_argc_minmax( item , 1 , 1 , 1 , (const config_item_types[1]) {CONFIG_INT}); - - item = config_add_schema_item( config , MAX_ARG_KEY , false , false); - config_schema_item_set_argc_minmax( item , 1 , 1 , 1 , (const config_item_types[1]) {CONFIG_INT}); - - item = config_add_schema_item( config , ARG_TYPE_KEY , false , true ); - config_schema_item_set_argc_minmax( item , 2 , 2 , 2 , (const config_item_types[2]) {CONFIG_INT , CONFIG_STRING}); - config_schema_item_set_indexed_selection_set( item , 1 , 3 , (const char *[3]) {EXT_CMD_STRING_TYPE , EXT_CMD_INT_TYPE , EXT_CMD_FLOAT_TYPE}); - - /*****************************************************************/ - item = config_add_schema_item( config , EXECUTABLE_KEY , false , false ); - config_schema_item_set_argc_minmax( item , 1 , 1 , 1 , (const config_item_types[1]) {CONFIG_EXECUTABLE}); - - /*---------------------------------------------------------------*/ - - item = config_add_schema_item( config , FUNCTION_KEY , false , false ); - config_schema_item_set_argc_minmax( item , 1 , 1 , 1 , (const config_item_types[1]) {CONFIG_STRING}); - - item = config_add_schema_item( config , MODULE_KEY , false , false ); - config_schema_item_set_argc_minmax( item , 1 , 1 , 1 , (const config_item_types[1]) {CONFIG_STRING}); - /*****************************************************************/ - - item = config_add_schema_item( config , INTERNAL_KEY , false , false); - config_schema_item_set_argc_minmax( item , 1 , 1 , 1 , (const config_item_types[1]) {CONFIG_BOOLEAN}); - - } - return config; -} - - - -static UTIL_SAFE_CAST_FUNCTION(ext_cmd , EXT_CMD_TYPE_ID ) - -ext_cmd_type * ext_cmd_alloc( bool internal ) { - ext_cmd_type * ext_cmd = util_malloc( sizeof * ext_cmd ); - UTIL_TYPE_ID_INIT( ext_cmd , EXT_CMD_TYPE_ID ); - ext_cmd->internal = internal; // This can NOT be changed run-time. - ext_cmd->min_arg = ARG_MIN_DEFAULT; - ext_cmd->max_arg = ARG_MAX_DEFAULT; - ext_cmd->arg_types = int_vector_alloc( 0 , CONFIG_STRING ); - - ext_cmd->executable = NULL; - ext_cmd->module = NULL; - ext_cmd->function = NULL; - ext_cmd->valid = false; - - return ext_cmd; -} - - -void ext_cmd_set_executable( ext_cmd_type * ext_cmd , const char * executable ) { - ext_cmd->executable = util_realloc_string_copy( ext_cmd->executable , executable ); -} - - -void ext_cmd_set_module( ext_cmd_type * ext_cmd , const char * module) { - if (strcmp(module ,NULL_STRING) == 0) - module = NULL; - - ext_cmd->module = util_realloc_string_copy( ext_cmd->module , module ); -} - - -void ext_cmd_set_function( ext_cmd_type * ext_cmd , const char * function) { - ext_cmd->function = util_realloc_string_copy( ext_cmd->function , function ); -} - - -void ext_cmd_iset_argtype( ext_cmd_type * ext_cmd , int iarg , config_item_types type) { - if (type == CONFIG_STRING || type == CONFIG_INT || type == CONFIG_FLOAT) - int_vector_iset( ext_cmd->arg_types , iarg , type ); -} - -void ext_cmd_set_min_arg( ext_cmd_type * ext_cmd , int min_arg) { - ext_cmd->min_arg = min_arg; -} - -void ext_cmd_set_max_arg( ext_cmd_type * ext_cmd , int max_arg) { - ext_cmd->max_arg = max_arg; -} - - -static void ext_cmd_iset_argtype_string( ext_cmd_type * ext_cmd , int iarg , const char * arg_type) { - config_item_types type = CONFIG_INVALID; - - if (strcmp( arg_type , EXT_CMD_STRING_TYPE) == 0) - type = CONFIG_STRING; - else if (strcmp( arg_type , EXT_CMD_INT_TYPE) == 0) - type = CONFIG_INT; - else if (strcmp( arg_type , EXT_CMD_FLOAT_TYPE) == 0) - type = CONFIG_FLOAT; - - if (type != CONFIG_INVALID) - ext_cmd_iset_argtype( ext_cmd , iarg , type ); - -} - - -static void ext_cmd_validate( ext_cmd_type * ext_cmd ) { - if (!ext_cmd->internal) { - if (ext_cmd->executable != NULL) { - if (util_is_executable( ext_cmd->executable ) && - (ext_cmd->module == ext_cmd->function) && - (ext_cmd == NULL)) - ext_cmd->valid = true; - } - } else { - if ((ext_cmd->executable == NULL) && (ext_cmd->function != NULL)) { - ext_cmd->lib_handle = dlopen( ext_cmd->module , RTLD_NOW ); - if (ext_cmd->lib_handle != NULL) { - ext_cmd->dl_func = dlsym( ext_cmd->lib_handle , ext_cmd->function ); - if (ext_cmd->dl_func != NULL) - ext_cmd->valid = true; - else - fprintf(stderr,"Failed to load symbol:%s Error:%s \n",ext_cmd->function , dlerror()); - } else { - if (ext_cmd->module != NULL) - fprintf(stderr,"Failed to load module:%s Error:%s \n",ext_cmd->module , dlerror()); - } - } - } -} - - - -ext_cmd_type * ext_cmd_config_alloc( config_type * config , const char * config_file) { - config_clear( config ); - config_parse( config , config_file , "--", NULL , NULL , true , true); - { - - bool internal = DEFAULT_INTERNAL; - if (config_item_set( config , INTERNAL_KEY)) - internal = config_iget_as_bool( config , INTERNAL_KEY , 0 , 0 ); - - { - ext_cmd_type * ext_cmd = ext_cmd_alloc( internal ); - - if (config_item_set( config , MIN_ARG_KEY)) - ext_cmd_set_min_arg( ext_cmd , config_iget_as_int( config , MIN_ARG_KEY , 0 , 0 )); - - if (config_item_set( config , MAX_ARG_KEY)) - ext_cmd_set_max_arg( ext_cmd , config_iget_as_int( config , MAX_ARG_KEY , 0 , 0 )); - - { - int i; - for (i=0; i < config_get_occurences( config , ARG_TYPE_KEY); i++) { - int iarg = config_iget_as_int( config , ARG_TYPE_KEY , i , 0 ); - const char * arg_type = config_iget( config , ARG_TYPE_KEY , i , 1 ); - - ext_cmd_iset_argtype_string( ext_cmd , iarg , arg_type ); - } - } - - if (config_item_set( config , MODULE_KEY)) - ext_cmd_set_module( ext_cmd , config_iget( config , MODULE_KEY , 0 , 0 )); - - if (config_item_set( config , FUNCTION_KEY)) - ext_cmd_set_function( ext_cmd , config_iget( config , FUNCTION_KEY , 0 , 0 )); - - if (config_item_set( config , EXECUTABLE_KEY)) - ext_cmd_set_executable( ext_cmd , config_iget( config , EXECUTABLE_KEY , 0 , 0 )); - - ext_cmd_validate( ext_cmd ); - - if (!ext_cmd->valid) { - ext_cmd_free( ext_cmd ); - ext_cmd = NULL; - } - - return ext_cmd; - } - } -} - - - -void ext_cmd_free( ext_cmd_type * ext_cmd ) { - util_safe_free( ext_cmd->module ); - util_safe_free( ext_cmd->function ); - util_safe_free( ext_cmd->executable ); - int_vector_free( ext_cmd->arg_types ); - free( ext_cmd ); -} - - -void ext_cmd_free__( void * arg) { - ext_cmd_type * ext_cmd = ext_cmd_safe_cast( arg ); - ext_cmd_free( ext_cmd ); -} diff --git a/ThirdParty/Ert/devel/libjob_queue/src/ext_job.c b/ThirdParty/Ert/devel/libjob_queue/src/ext_job.c index c4fa5e9971..c8db735d36 100644 --- a/ThirdParty/Ert/devel/libjob_queue/src/ext_job.c +++ b/ThirdParty/Ert/devel/libjob_queue/src/ext_job.c @@ -629,15 +629,26 @@ static void ext_job_fprintf_python_argList( const ext_job_type * ext_job , FILE } - -void ext_job_python_fprintf(const ext_job_type * ext_job, FILE * stream, const subst_list_type * global_args) { +static bool ext_job_check_executable( const ext_job_type * ext_job , const subst_list_type * global_args) { + bool OK = true; char * executable; executable = subst_list_alloc_filtered_string( ext_job->private_args , ext_job->executable ); if (global_args != NULL) subst_list_update_string( global_args , &executable ); - if (util_is_executable( executable )) { - fprintf(stream," {"); + if (!util_is_executable( executable )) + OK = false; + free( executable ); + return OK; +} + + +void ext_job_python_fprintf(const ext_job_type * ext_job, FILE * stream, const subst_list_type * global_args) { + if (!ext_job_check_executable( ext_job , global_args )) + fprintf(stderr," ** WARNING: The executable:%s could not be located on host computer - job will most probably fail.\n", ext_job->executable); + + fprintf(stream," {"); + { __indent(stream, 0); __fprintf_python_string(stream , "name" , ext_job->name , ext_job->private_args , NULL); __end_line(stream); __indent(stream, 2); __fprintf_python_string(stream , "executable" , ext_job->executable , ext_job->private_args, global_args); __end_line(stream); __indent(stream, 2); __fprintf_python_string(stream , "target_file" , ext_job->target_file , ext_job->private_args, global_args); __end_line(stream); @@ -651,11 +662,8 @@ void ext_job_python_fprintf(const ext_job_type * ext_job, FILE * stream, const s __indent(stream, 2); __fprintf_python_string(stream , "license_path" , ext_job->license_path , ext_job->private_args, global_args); __end_line(stream); __indent(stream, 2); __fprintf_python_int( stream , "max_running_minutes" , ext_job->max_running_minutes ); __end_line(stream); __indent(stream, 2); __fprintf_python_int( stream , "max_running" , ext_job->max_running ); __end_line(stream); - fprintf(stream,"}"); - } else - fprintf(stderr," ** WARNING: The executable:%s could not be located on host computer - job will most probably fail.\n", executable); - - free( executable ); + } + fprintf(stream,"}"); } @@ -753,22 +761,22 @@ ext_job_type * ext_job_fscanf_alloc(const char * name , const char * license_roo ext_job_set_config_file( ext_job , config_file ); { config_schema_item_type * item; - item = config_add_schema_item(config , "MAX_RUNNING" , false , false); config_schema_item_set_argc_minmax(item , 1 , 1 , 1 , (const config_item_types [1]) {CONFIG_INT}); - item = config_add_schema_item(config , "STDIN" , false , false); config_schema_item_set_argc_minmax(item , 1 , 1 , 0 , NULL); - item = config_add_schema_item(config , "STDOUT" , false , false); config_schema_item_set_argc_minmax(item , 1 , 1 , 0 , NULL); - item = config_add_schema_item(config , "STDERR" , false , false); config_schema_item_set_argc_minmax(item , 1 , 1 , 0 , NULL); - item = config_add_schema_item(config , "EXECUTABLE" , false , false); config_schema_item_set_argc_minmax(item , 1 , 1 , 0 , NULL); - item = config_add_schema_item(config , "TARGET_FILE" , false , false); config_schema_item_set_argc_minmax(item , 1 , 1 , 0 , NULL); - item = config_add_schema_item(config , "ERROR_FILE" , false , false); config_schema_item_set_argc_minmax(item , 1 , 1 , 0 , NULL); - item = config_add_schema_item(config , "START_FILE" , false , false); config_schema_item_set_argc_minmax(item , 1 , 1 , 0 , NULL); - item = config_add_schema_item(config , "ENV" , false , true ); config_schema_item_set_argc_minmax(item , 2 , 2 , 0 , NULL); - item = config_add_schema_item(config , "DEFAULT" , false , true ); config_schema_item_set_argc_minmax(item , 2 , 2 , 0 , NULL); - item = config_add_schema_item(config , "ARGLIST" , false , true ); config_schema_item_set_argc_minmax(item , 1 ,-1 , 0 , NULL); - item = config_add_schema_item(config , "MAX_RUNNING_MINUTES" , false , false); config_schema_item_set_argc_minmax(item , 1 , 1 , 1 , (const config_item_types [1]) {CONFIG_INT}); + item = config_add_schema_item(config , "MAX_RUNNING" , false ); config_schema_item_set_argc_minmax(item , 1 , 1 ); config_schema_item_iset_type( item , 0 , CONFIG_INT ); + item = config_add_schema_item(config , "STDIN" , false ); config_schema_item_set_argc_minmax(item , 1 , 1 ); + item = config_add_schema_item(config , "STDOUT" , false ); config_schema_item_set_argc_minmax(item , 1 , 1 ); + item = config_add_schema_item(config , "STDERR" , false ); config_schema_item_set_argc_minmax(item , 1 , 1 ); + item = config_add_schema_item(config , "EXECUTABLE" , false ); config_schema_item_set_argc_minmax(item , 1 , 1 ); + item = config_add_schema_item(config , "TARGET_FILE" , false ); config_schema_item_set_argc_minmax(item , 1 , 1 ); + item = config_add_schema_item(config , "ERROR_FILE" , false ); config_schema_item_set_argc_minmax(item , 1 , 1 ); + item = config_add_schema_item(config , "START_FILE" , false ); config_schema_item_set_argc_minmax(item , 1 , 1 ); + item = config_add_schema_item(config , "ENV" , false ); config_schema_item_set_argc_minmax(item , 2 , 2 ); + item = config_add_schema_item(config , "DEFAULT" , false ); config_schema_item_set_argc_minmax(item , 2 , 2 ); + item = config_add_schema_item(config , "ARGLIST" , false ); config_schema_item_set_argc_minmax(item , 1 , CONFIG_DEFAULT_ARG_MAX ); + item = config_add_schema_item(config , "MAX_RUNNING_MINUTES" , false ); config_schema_item_set_argc_minmax(item , 1 , 1 ); config_schema_item_iset_type( item , 0 , CONFIG_INT ); } config_add_alias(config , "EXECUTABLE" , "PORTABLE_EXE"); - config_parse(config , config_file , "--" , NULL , NULL , true , true); - { + + if (config_parse(config , config_file , "--" , NULL , NULL , CONFIG_UNRECOGNIZED_WARN , true)) { if (config_item_set(config , "STDIN")) ext_job_set_stdin_file(ext_job , config_iget(config , "STDIN" , 0,0)); if (config_item_set(config , "STDOUT")) ext_job_set_stdout_file(ext_job , config_iget(config , "STDOUT" , 0,0)); if (config_item_set(config , "STDERR")) ext_job_set_stderr_file(ext_job , config_iget(config , "STDERR" , 0,0)); @@ -781,36 +789,51 @@ ext_job_type * ext_job_fscanf_alloc(const char * name , const char * license_roo - if (config_item_set(config , "ARGLIST")) { - stringlist_type *argv = config_iget_stringlist_ref( config , "ARGLIST" , 0); - stringlist_deep_copy( ext_job->argv , argv ); + { + config_content_node_type * arg_node = config_get_value_node( config , "ARGLIST"); + if (arg_node != NULL) { + int i; + for (i=0; i < config_content_node_get_size( arg_node ); i++) + stringlist_append_copy( ext_job->argv , config_content_node_iget( arg_node , i )); + } } /** The code assumes that the hash tables are valid, can not be NULL: */ - if (config_item_set(config , "ENV")) { - for (int occ_nr = 0; occ_nr < config_get_occurences( config , "ENV"); occ_nr++) { - const stringlist_type *key_value = config_iget_stringlist_ref( config , "ENV" , occ_nr); - for (int i=0; i < stringlist_get_size( key_value ); i+= 2) - hash_insert_hash_owned_ref( ext_job->environment, - stringlist_iget( key_value , i ) , - util_alloc_string_copy( stringlist_iget( key_value , i + 1)) , free); + { + const config_content_item_type * env_item = config_get_content_item( config , "ENV" ); + if (env_item != NULL) { + for (int ivar = 0; ivar < config_content_item_get_size( env_item ); ivar++) { + const config_content_node_type * env_node = config_content_item_iget_node( env_item , ivar ); + for (int i=0; i < config_content_node_get_size( env_node ); i+= 2) { + const char * key = config_content_node_iget( env_node , i ); + const char * value = config_content_node_iget( env_node , i + 1); + hash_insert_hash_owned_ref( ext_job->environment, key , util_alloc_string_copy( value ) , free); + } + } } } /* Default mappings; these are used to set values in the argList which have not been supplied by the calling context. */ - if (config_item_set(config , "DEFAULT")) { - for (int occ_nr = 0; occ_nr < config_get_occurences( config , "DEFAULT"); occ_nr++) { - const stringlist_type *key_value = config_iget_stringlist_ref( config , "DEFAULT" , occ_nr); - for (int i=0; i < stringlist_get_size( key_value ); i+= 2) - hash_insert_hash_owned_ref( ext_job->default_mapping, - stringlist_iget( key_value , i ) , - util_alloc_string_copy( stringlist_iget( key_value , i + 1)) , free); + { + const config_content_item_type * default_item = config_get_content_item( config , "DEFAULT"); + if (default_item != NULL) { + for (int ivar = 0; ivar < config_content_item_get_size( default_item ); ivar++) { + const config_content_node_type * default_node = config_content_item_iget_node( default_item , ivar ); + for (int i=0; i < config_content_node_get_size( default_node ); i+= 2) { + const char * key = config_content_node_iget( default_node , i ); + const char * value = config_content_node_iget( default_node , i + 1); + hash_insert_hash_owned_ref( ext_job->default_mapping, key , util_alloc_string_copy( value ) , free); + } + } } } + } else { + config_fprintf_errors( config , true , stderr ); + exit(1); } config_free(config); diff --git a/ThirdParty/Ert/devel/libjob_queue/src/job_queue.c b/ThirdParty/Ert/devel/libjob_queue/src/job_queue.c index 4756dc3625..e9f4052104 100644 --- a/ThirdParty/Ert/devel/libjob_queue/src/job_queue.c +++ b/ThirdParty/Ert/devel/libjob_queue/src/job_queue.c @@ -1511,6 +1511,13 @@ void job_queue_set_driver(job_queue_type * queue , queue_driver_type * driver) { } +bool job_queue_has_driver(const job_queue_type * queue ) { + if (queue->driver == NULL) + return false; + else + return true; +} + /** Observe that if the max number of running jobs is decreased, diff --git a/ThirdParty/Ert/devel/libjob_queue/src/lsb.c b/ThirdParty/Ert/devel/libjob_queue/src/lsb.c new file mode 100644 index 0000000000..13dadd89bc --- /dev/null +++ b/ThirdParty/Ert/devel/libjob_queue/src/lsb.c @@ -0,0 +1,197 @@ +/* + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'lsb.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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. +*/ + +/* + This file implements a very small wrapper structure around the + lsb_xxxx() functions from the libbat.so shared library which are + used to submit, monitor and control simulations with LSF. + + Loading and initializing the lsf libraries is quite painful, in an + attempt to reduce unecessary dependencies the lsf libraries are + loaded with dlopen() in the lsb_alloc() function below. This means + that the libjob_queue.so shared library can be loaded without access + to the lsf libraries. +*/ + +#include +#include + +#include + +#include +#include + +#include + + + +typedef int (lsb_submit_ftype) ( struct submit * , struct submitReply *); +typedef int (lsb_openjobinfo_ftype) (int , char * , char * , char * , char * , int); +typedef struct jobInfoEnt * (lsb_readjobinfo_ftype) (int * ); +typedef int (lsb_closejobinfo_ftype) ( ); +typedef int (lsb_forcekilljob_ftype) ( int ); +typedef int (lsb_init_ftype) ( char * ); +typedef char * (lsb_sysmsg_ftype) ( ); + + + +struct lsb_struct { + lsb_submit_ftype * submit; + lsb_openjobinfo_ftype * open_job; + lsb_readjobinfo_ftype * read_job; + lsb_closejobinfo_ftype * close_job; + lsb_forcekilljob_ftype * kill_job; + lsb_init_ftype * lsb_init; + lsb_sysmsg_ftype * sys_msg; + + stringlist_type * error_list; + void * lib_handle; + bool ready; +}; + + + +static void * lsb_dlsym( lsb_type * lsb , const char * function_name ) { + void * function = dlsym( lsb->lib_handle , function_name ); + if (!function) { + lsb->ready = false; + stringlist_append_owned_ref( lsb->error_list , util_alloc_sprintf( "Failed to locate symbol:%s dlerror:%s" , function_name , dlerror())); + } + + return function; +} + + +void * lsb_dlopen( lsb_type * lsb , const char * lib_name) { + void * lib_handle = dlopen( lib_name , RTLD_NOW | RTLD_GLOBAL); + if (!lib_handle) { + lsb->ready = false; + stringlist_append_owned_ref( lsb->error_list , util_alloc_sprintf("dlopen(%s) - failed:%s \n" , lib_name , dlerror())); + } + return lib_handle; +} + +/* + The following environment variables must be set (at some stage) before + LSF will work properly: + + LSF_BINDIR $LSF_HOME/bin + LSF_LIBDIR $LSF_HOME/lib + XLSF_UIDDIR $LSF_HOME/lib/uid + LSF_SERVERDIR $LSF_HOME/etc + LSF_ENVDIR /prog/LSF/conf + + The runtime linker must locate the libnsl, libbat and liblsf + libraries using whatever method it usually does. If the loading + fails the lsb object will get the ->ready flag set to false, and the + lsf_driver will discard the lsb instance (and hopefully use shell + commands to perform job management). +*/ + +lsb_type * lsb_alloc() { + lsb_type * lsb = util_malloc( sizeof * lsb ); + lsb->ready = true; + lsb->error_list = stringlist_alloc_new(); + + lsb_dlopen(lsb , "libnsl.so" ); + lsb_dlopen(lsb , "liblsf.so" ); + lsb->lib_handle = lsb_dlopen(lsb , "libbat.so"); + + if (lsb->lib_handle) { + lsb->submit = (lsb_submit_ftype *) lsb_dlsym( lsb , "lsb_submit"); + lsb->open_job = (lsb_openjobinfo_ftype *) lsb_dlsym( lsb , "lsb_openjobinfo"); + lsb->read_job = (lsb_readjobinfo_ftype *) lsb_dlsym( lsb , "lsb_readjobinfo"); + lsb->close_job = (lsb_closejobinfo_ftype *) lsb_dlsym( lsb , "lsb_closejobinfo"); + lsb->kill_job = (lsb_forcekilljob_ftype *) lsb_dlsym( lsb , "lsb_forcekilljob"); + lsb->lsb_init = (lsb_init_ftype *) lsb_dlsym( lsb , "lsb_init"); + lsb->sys_msg = (lsb_sysmsg_ftype *) lsb_dlsym( lsb , "lsb_sysmsg"); + } + + return lsb; +} + + + +void lsb_free( lsb_type * lsb) { + stringlist_free( lsb->error_list ); + if (lsb->lib_handle) + dlclose( lsb->lib_handle ); + free( lsb ); +} + + + +bool lsb_ready( const lsb_type * lsb) { + return lsb->ready; +} + +stringlist_type * lsb_get_error_list( const lsb_type * lsb ) { + return lsb->error_list; +} + + +/*****************************************************************/ + +int lsb_initialize( const lsb_type * lsb) { + /* + The environment variable LSF_ENVDIR must be set to point the + directory containing LSF configuration information, the whole + thing will crash and burn if this is not properly set. + */ + printf("Calling initialize ... \n"); + if ( lsb->lsb_init(NULL) != 0 ) { + fprintf(stderr,"LSF_ENVDIR: "); + if (getenv("LSF_ENVDIR") != NULL) + fprintf(stderr,"%s\n", getenv("LSF_ENVDIR")); + else + fprintf(stderr, "not set\n"); + + util_abort("%s failed to initialize LSF environment : %s \n",__func__ , lsb->sys_msg() ); + } + return 0; +} + + +int lsb_submitjob( const lsb_type * lsb , struct submit * submit_data, struct submitReply * reply_data) { + return lsb->submit( submit_data , reply_data ); +} + + +int lsb_killjob( const lsb_type * lsb , int lsf_jobnr) { + return lsb->kill_job(lsf_jobnr); +} + + +int lsb_openjob( const lsb_type * lsb , int lsf_jobnr) { + return lsb->open_job(lsf_jobnr , NULL , NULL , NULL , NULL , ALL_JOB); +} + + +int lsb_closejob( const lsb_type * lsb) { + return lsb->close_job(); +} + +char * lsb_sys_msg( const lsb_type * lsb) { + return lsb->sys_msg(); +} + + +struct jobInfoEnt * lsb_readjob( const lsb_type * lsb ) { + struct jobInfoEnt * job_info = lsb->read_job( NULL ); + return job_info; +} diff --git a/ThirdParty/Ert/devel/libjob_queue/src/lsf_driver.c b/ThirdParty/Ert/devel/libjob_queue/src/lsf_driver.c index 2f9d7d4377..e5a26cdc5c 100644 --- a/ThirdParty/Ert/devel/libjob_queue/src/lsf_driver.c +++ b/ThirdParty/Ert/devel/libjob_queue/src/lsf_driver.c @@ -1,7 +1,7 @@ /* Copyright (C) 2011 Statoil ASA, Norway. - The file 'lsf_driver.c' is part of ERT - Ensemble based Reservoir Tool. + The file 'lsf_driver_impl.c' is part of ERT - Ensemble based Reservoir Tool. ERT is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16,26 +16,937 @@ for more details. */ -/** - If the symbol INCLUDE_LSF is not defined a dummy LSF driver will be - compiled. This driver has stubs for all the driver related - functions, and a dummy driver can be created with the - queue_driver_alloc_LSF() function. +#include +#include +#include +#include +#include - If one of the queue_driver function pointers pointing down to one - of the lsf_driver_xxx() functions is actually invoked (e.g. through - the queue layer) the program will exit with an error message. This - is only a utility to avoid changing the source when the library is - built and used on a platform without LSF inst1alled. - - When compiling with proper LSF support the preprocessor symbol - INCLUDE_LSF must be set (to an arbitrary value), in addition the - libraries liblsf, libbat and libnsl must be linked in when creating - the final executable. +#include +#include +#include + +#include +#include + +#include +#ifdef HAVE_LSF_LIBRARY +#include +#endif + + + + + +/** + Documentation/examples of programming towards the lsf libraries can + be found in /prog/LSF/7.0/misc/examples */ -#ifdef HAVE_LSF -#include "lsf_driver_impl.c" -#else -#include "lsf_driver_dummy.c" + +/* + How to call the lsf commands bsub/bjobs/bkill: + ---------------------------------------------- + + The commands to submit, monitor and modify LSF jobs are available + through library calls through the lsf library. This is a good + solution which works well. + + Unfortunately only quite few of the workstations in Statoil are + "designated LSF machines", meaning that they are allowed to talk to + the LIM servers, to be able to use the low-level lsb_xxx() function + calls the host making the calls must configured (by an LSF + administrator) to be a LSF client. + + The lsf_driver can either make use of the proper lsf library calls + (lsb_submit(), lsb_openjobinfo(), ...) or alternatively it can issue + ssh calls to an external LSF_SERVER and call up the bsub/bkill/bjob + executables on the remote server. + + All the functions with 'library' in the name are based on library + calls, and the functions with 'shell' in the name are based on + external functions (the actual calls are through the + util_fork_exec() function). + + By default the driver will use the library, but if a value is + provided with the LSF_SERVER option, the shell based functions will + be used. Internally this is goverened by the boolean flag + 'use_library_calls'. + + Even though you only intend to submit through the shell commands + bsub / bjobs / bkill the build process still requires access to the + lsf headers and the lsf library; that is probably not optimal. + + + Remote login shell + ------------------ + + When submitting with LSF the job will inherit the current + environment on the submitting host, and not read the users login + files on the remote host where the job is actually executed. E.g. in + situations where submitting host and executing host are + e.g. different operating system versions this might be + unfortunate. The '-L @shell' switch can used with bsub to force lsf + to source schell specific input files prior to executing your + job. This can be achieved with the LSF_LOGIN_SHELL option: + + lsf_driver_set_option( driver , LSF_LOGIN_SHELL , "/bin/csh" ); + +*/ + + + + + +#define LSF_DRIVER_TYPE_ID 10078365 +#define LSF_JOB_TYPE_ID 9963900 +#define BJOBS_REFRESH_TIME 10 +#define DEFAULT_RSH_CMD "/usr/bin/ssh" +#define DEFAULT_BSUB_CMD "bsub" +#define DEFAULT_BJOBS_CMD "bjobs" +#define DEFAULT_BKILL_CMD "bkill" + + + +struct lsf_job_struct { + UTIL_TYPE_ID_DECLARATION; + long int lsf_jobnr; + int num_exec_host; + char **exec_host; + char * lsf_jobnr_char; /* Used to look up the job status in the bjobs_cache hash table */ +}; + + + +struct lsf_driver_struct { + UTIL_TYPE_ID_DECLARATION; + char * queue_name; + char * resource_request; + char * login_shell; + pthread_mutex_t submit_lock; + + lsf_submit_method_enum submit_method; + + /*-----------------------------------------------------------------*/ + /* Fields used by the lsf library functions */ +#ifdef HAVE_LSF_LIBRARY + struct submit lsf_request; + struct submitReply lsf_reply; + lsb_type * lsb; #endif + + /*-----------------------------------------------------------------*/ + /* Fields used by the shell based functions */ + + int bjobs_refresh_interval; + time_t last_bjobs_update; + hash_type * my_jobs; /* A hash table of all jobs submitted by this ERT instance - + to ensure that we do not check status of old jobs in e.g. ZOMBIE status. */ + hash_type * status_map; + hash_type * bjobs_cache; /* The output of calling bjobs is cached in this table. */ + pthread_mutex_t bjobs_mutex; /* Only one thread should update the bjobs_chache table. */ + char * remote_lsf_server; + char * rsh_cmd; + char * bsub_cmd; + char * bjobs_cmd; + char * bkill_cmd; +}; + + + + +/*****************************************************************/ + +UTIL_SAFE_CAST_FUNCTION( lsf_driver , LSF_DRIVER_TYPE_ID) +static UTIL_SAFE_CAST_FUNCTION_CONST( lsf_driver , LSF_DRIVER_TYPE_ID) +static UTIL_SAFE_CAST_FUNCTION( lsf_job , LSF_JOB_TYPE_ID) + +lsf_job_type * lsf_job_alloc() { + lsf_job_type * job; + job = util_malloc(sizeof * job); + job->num_exec_host = 0; + job->exec_host = NULL; + + job->lsf_jobnr_char = NULL; + UTIL_TYPE_ID_INIT( job , LSF_JOB_TYPE_ID); + return job; +} + + + +void lsf_job_free(lsf_job_type * job) { + util_safe_free(job->lsf_jobnr_char); + util_free_stringlist(job->exec_host , job->num_exec_host); + free(job); +} + + +static int lsf_job_parse_bsub_stdout(const lsf_driver_type * driver , const char * stdout_file) { + int jobid = -1; + FILE * stream = util_fopen(stdout_file , "r"); + if (util_fseek_string(stream , "<" , true , true)) { + char * jobid_string = util_fscanf_alloc_upto(stream , ">" , false); + if (jobid_string != NULL) { + jobid = atoi( jobid_string ); + free( jobid_string ); + } + } + fclose( stream ); + + if (jobid == -1) { + char * file_content = util_fread_alloc_file_content( stdout_file , NULL ); + fprintf(stderr,"Failed to get lsf job id from file: %s \n",stdout_file ); + fprintf(stderr,"bsub command : %s \n",driver->bsub_cmd ); + fprintf(stderr,"%s\n", file_content); + free( file_content ); + util_exit("%s: \n",__func__); + } + return jobid; +} + + + +static void lsf_driver_internal_error( const lsf_driver_type * driver ) { + fprintf(stderr , "\n\n"); + fprintf(stderr , "*****************************************************************\n"); + fprintf(stderr , "** The LSF driver can be configured and used in many different **\n"); + fprintf(stderr , "** ways. The important point is how we choose to submit: **\n"); + fprintf(stderr , "** **\n"); + fprintf(stderr , "** 1. Using the lsf library calls **\n"); + fprintf(stderr , "** 2. Using the bsub/bjobs/bkill commands locally **\n"); + fprintf(stderr , "** 3. Using the bsub/bjobs/bkill commands through ssh **\n"); + fprintf(stderr , "** **\n"); + fprintf(stderr , "** To chose between these three alternatives you set the remote**\n"); + fprintf(stderr , "** server with the lsf_driver_set_option() function. Passing **\n"); + fprintf(stderr , "** the value NULL will give alternative 1, passing the special **\n"); + fprintf(stderr , "** string \'%s\' will give alternative 2, and any other **\n",LOCAL_LSF_SERVER); + fprintf(stderr , "** value will submit through that host using ssh. **\n"); + fprintf(stderr , "** **\n"); + fprintf(stderr , "** The ability to submit thorugh lsf library calls must be **\n"); + fprintf(stderr , "** compiled in by defining the symbol \'HAVE_LSF_LIBRARY\' when **\n"); + fprintf(stderr , "** compiling. **\n"); + fprintf(stderr , "** **\n"); +#ifdef HAVE_LSF_LIBRARY + fprintf(stderr , "** This lsf driver has support for using lsf library calls. **\n"); +#else + fprintf(stderr , "** This lsf driver does NOT have support for using lsf **\n"); + fprintf(stderr , "** library calls; but you have tried to submit without setting **\n"); + fprintf(stderr , "** a value for LSF_SERVER. Set this and try again. **\n"); +#endif + fprintf(stderr , "*****************************************************************\n\n"); + exit(1); +} + + + +static void lsf_driver_assert_submit_method( const lsf_driver_type * driver ) { + if (driver->submit_method == LSF_SUBMIT_INVALID) { + lsf_driver_internal_error(driver); + } +} + + + + + +stringlist_type * lsf_driver_alloc_cmd(lsf_driver_type * driver , + const char * lsf_stdout , + const char * job_name , + const char * submit_cmd , + int num_cpu , + int job_argc, + const char ** job_argv) { + + stringlist_type * argv = stringlist_alloc_new(); + char * num_cpu_string = util_alloc_sprintf("%d" , num_cpu); + char * quoted_resource_request = NULL; + + /* + The resource request string contains spaces, and when passed + through the shell it must be protected with \"..\"; this applies + when submitting to a remote lsf server with ssh. However when + submitting to the local workstation using a bsub command the + command will be invoked with the util_fork_exec() command - and no + shell is involved. In this latter case we must avoid the \"...\" + quoting. + */ + + if (driver->resource_request != NULL) { + if (driver->submit_method == LSF_SUBMIT_REMOTE_SHELL) + quoted_resource_request =util_alloc_sprintf("\"%s\"" , driver->resource_request); + else + quoted_resource_request = util_alloc_string_copy( driver->resource_request ); + } + + if (driver->submit_method == LSF_SUBMIT_REMOTE_SHELL) + stringlist_append_ref( argv , driver->bsub_cmd); + + stringlist_append_ref( argv , "-o" ); + stringlist_append_copy( argv , lsf_stdout ); + if (driver->queue_name != NULL) { + stringlist_append_ref( argv , "-q" ); + stringlist_append_ref( argv , driver->queue_name ); + } + stringlist_append_ref( argv , "-J" ); + stringlist_append_ref( argv , job_name ); + stringlist_append_ref( argv , "-n" ); + stringlist_append_copy( argv , num_cpu_string ); + + if (quoted_resource_request != NULL) { + stringlist_append_ref( argv , "-R"); + stringlist_append_copy( argv , quoted_resource_request ); + } + + if (driver->login_shell != NULL) { + stringlist_append_ref( argv , "-L"); + stringlist_append_ref( argv , driver->login_shell ); + } + + stringlist_append_ref( argv , submit_cmd); + { + int iarg; + for (iarg = 0; iarg < job_argc; iarg++) + stringlist_append_ref( argv , job_argv[ iarg ]); + } + free( num_cpu_string ); + util_safe_free( quoted_resource_request ); + return argv; +} + + +static int lsf_driver_submit_internal_job( lsf_driver_type * driver , + const char * lsf_stdout , + const char * job_name , + const char * submit_cmd , + int num_cpu , + int argc, + const char ** argv) { + +#ifdef HAVE_LSF_LIBRARY + char * command; + { + buffer_type * command_buffer = buffer_alloc( 256 ); + buffer_fwrite_char_ptr( command_buffer , submit_cmd ); + for (int iarg = 0; iarg < argc; iarg++) { + buffer_fwrite_char( command_buffer , ' '); + buffer_fwrite_char_ptr( command_buffer , argv[ iarg ]); + } + buffer_terminate_char_ptr( command_buffer ); + command = buffer_get_data( command_buffer ); + buffer_free_container( command_buffer ); + } + + { + int options = SUB_JOB_NAME + SUB_OUT_FILE; + + if (driver->queue_name != NULL) + options += SUB_QUEUE; + + if (driver->resource_request != NULL) + options += SUB_RES_REQ; + + if (driver->login_shell != NULL) + options += SUB_LOGIN_SHELL; + + driver->lsf_request.options = options; + } + + driver->lsf_request.resReq = driver->resource_request; + driver->lsf_request.loginShell = driver->login_shell; + driver->lsf_request.queue = driver->queue_name; + driver->lsf_request.jobName = (char *) job_name; + driver->lsf_request.outFile = (char *) lsf_stdout; + driver->lsf_request.command = command; + driver->lsf_request.numProcessors = num_cpu; + + { + int lsf_jobnr = lsb_submitjob( driver->lsb , &driver->lsf_request , &driver->lsf_reply ); + free( command ); /* I trust the lsf layer is finished with the command? */ + if (lsf_jobnr <= 0) + fprintf(stderr,"%s: ** Warning: lsb_submit() failed: %s \n",__func__ , lsb_sys_msg( driver->lsb )); + + return lsf_jobnr; + } +#else + lsf_driver_internal_error( driver ); +#endif +} + + + +static int lsf_driver_submit_shell_job(lsf_driver_type * driver , + const char * lsf_stdout , + const char * job_name , + const char * submit_cmd , + int num_cpu , + int job_argc, + const char ** job_argv) { + int job_id; + char * tmp_file = util_alloc_tmp_file("/tmp" , "enkf-submit" , true); + + if (driver->remote_lsf_server != NULL) { + stringlist_type * remote_argv = lsf_driver_alloc_cmd( driver , lsf_stdout , job_name , submit_cmd , num_cpu , job_argc , job_argv); + + if (driver->submit_method == LSF_SUBMIT_REMOTE_SHELL) { + char ** argv = util_calloc( 2 , sizeof * argv ); + argv[0] = driver->remote_lsf_server; + argv[1] = stringlist_alloc_joined_string( remote_argv , " "); + util_fork_exec(driver->rsh_cmd , 2 , (const char **) argv , true , NULL , NULL , NULL , tmp_file , NULL); + free( argv[1] ); + free( argv ); + } else if (driver->submit_method == LSF_SUBMIT_LOCAL_SHELL) { + char ** argv = stringlist_alloc_char_ref( remote_argv ); + util_fork_exec(driver->bsub_cmd , stringlist_get_size( remote_argv) , (const char **) argv , true , NULL , NULL , NULL , tmp_file , tmp_file); + free( argv ); + } + + stringlist_free( remote_argv ); + } + + job_id = lsf_job_parse_bsub_stdout(driver , tmp_file); + util_unlink_existing( tmp_file ); + free(tmp_file); + return job_id; +} + + + +static int lsf_driver_get_status__(lsf_driver_type * driver , const char * status, const char * job_id) { + if (hash_has_key( driver->status_map , status)) + return hash_get_int( driver->status_map , status); + else { + util_exit("The lsf_status:%s for job:%s is not recognized; call your LSF administrator - sorry :-( \n", status , job_id); + return -1; + } +} + + + +static void lsf_driver_update_bjobs_table(lsf_driver_type * driver) { + char * tmp_file = util_alloc_tmp_file("/tmp" , "enkf-bjobs" , true); + + if (driver->submit_method == LSF_SUBMIT_REMOTE_SHELL) { + char ** argv = util_calloc( 2 , sizeof * argv); + argv[0] = driver->remote_lsf_server; + argv[1] = util_alloc_sprintf("%s -a" , driver->bjobs_cmd); + util_fork_exec(driver->rsh_cmd , 2 , (const char **) argv , true , NULL , NULL , NULL , tmp_file , NULL); + free( argv[1] ); + free( argv ); + } else if (driver->submit_method == LSF_SUBMIT_LOCAL_SHELL) { + char ** argv = util_calloc( 1 , sizeof * argv); + argv[0] = "-a"; + util_fork_exec(driver->bjobs_cmd , 1 , (const char **) argv , true , NULL , NULL , NULL , tmp_file , NULL); + free( argv ); + } + + { + char user[32]; + char status[16]; + FILE *stream = util_fopen(tmp_file , "r");; + bool at_eof = false; + hash_clear(driver->bjobs_cache); + util_fskip_lines(stream , 1); + while (!at_eof) { + char * line = util_fscanf_alloc_line(stream , &at_eof); + if (line != NULL) { + int job_id_int; + + if (sscanf(line , "%d %s %s", &job_id_int , user , status) == 3) { + char * job_id = util_alloc_sprintf("%d" , job_id_int); + + if (hash_has_key( driver->my_jobs , job_id )) /* Consider only jobs submitted by this ERT instance - not old jobs lying around from the same user. */ + hash_insert_int(driver->bjobs_cache , job_id , lsf_driver_get_status__( driver , status , job_id)); + + free(job_id); + } + free(line); + } + } + fclose(stream); + } + util_unlink_existing(tmp_file); + free(tmp_file); +} + + + +static int lsf_driver_get_job_status_libary(void * __driver , void * __job) { + if (__job == NULL) + /* the job has not been registered at all ... */ + return JOB_QUEUE_NOT_ACTIVE; + else { + int status; + lsf_driver_type * driver = lsf_driver_safe_cast( __driver ); +#ifdef HAVE_LSF_LIBRARY + lsf_job_type * job = lsf_job_safe_cast( __job ); + if (lsb_openjob( driver->lsb , job->lsf_jobnr) != 1) { + /* + Failed to get information about the job - we boldly assume + the following situation has occured: + + 1. The job is running happily along. + 2. The lsf deamon is not responding for a long time. + 3. The job finishes, and is eventually expired from the LSF job database. + 4. The lsf deamon answers again - but can not find the job... + + */ + fprintf(stderr,"Warning: failed to get status information for job:%ld - assuming it is finished. \n", job->lsf_jobnr); + status = JOB_QUEUE_DONE; + } else { + struct jobInfoEnt *job_info = lsb_readjob( driver->lsb ); + if (job->num_exec_host == 0) { + job->num_exec_host = job_info->numExHosts; + job->exec_host = util_alloc_stringlist_copy( (const char **) job_info->exHosts , job->num_exec_host); + } + status = job_info->status; + lsb_closejob(driver->lsb); + } +#else + lsf_driver_internal_error( driver ); +#endif + + return status; + } +} + + + + +static int lsf_driver_get_job_status_shell(void * __driver , void * __job) { + int status = JOB_STAT_NULL; + + if (__job != NULL) { + lsf_job_type * job = lsf_job_safe_cast( __job ); + lsf_driver_type * driver = lsf_driver_safe_cast( __driver ); + + { + /** + Updating the bjobs_table of the driver involves a significant change in + the internal state of the driver; that is semantically a bit + unfortunate because this is clearly a get() function; to protect + against concurrent updates of this table we use a mutex. + */ + pthread_mutex_lock( &driver->bjobs_mutex ); + { + if (difftime(time(NULL) , driver->last_bjobs_update) > driver->bjobs_refresh_interval) { + lsf_driver_update_bjobs_table(driver); + driver->last_bjobs_update = time( NULL ); + } + } + pthread_mutex_unlock( &driver->bjobs_mutex ); + + + if (hash_has_key( driver->bjobs_cache , job->lsf_jobnr_char) ) + status = hash_get_int(driver->bjobs_cache , job->lsf_jobnr_char); + else + /* + It might be running - but since job != NULL it is at least in the queue system. + */ + status = JOB_STAT_PEND; + + } + } + + return status; +} + + +job_status_type lsf_driver_convert_status( int lsf_status ) { + job_status_type job_status; + switch (lsf_status) { + case JOB_STAT_NULL: + job_status = JOB_QUEUE_NOT_ACTIVE; + break; + case JOB_STAT_PEND: + job_status = JOB_QUEUE_PENDING; + break; + case JOB_STAT_SSUSP: + job_status = JOB_QUEUE_RUNNING; + break; + case JOB_STAT_USUSP: + job_status = JOB_QUEUE_RUNNING; + break; + case JOB_STAT_PSUSP: + job_status = JOB_QUEUE_RUNNING; + break; + case JOB_STAT_RUN: + job_status = JOB_QUEUE_RUNNING; + break; + case JOB_STAT_DONE: + job_status = JOB_QUEUE_DONE; + break; + case JOB_STAT_EXIT: + job_status = JOB_QUEUE_EXIT; + break; + case JOB_STAT_UNKWN: // Have lost contact with one of the daemons. + job_status = JOB_QUEUE_EXIT; + break; + case 192: /* this 192 seems to pop up - where the fuck does it come frome ?? _pdone + _ususp ??? */ + job_status = JOB_QUEUE_DONE; + break; + default: + job_status = JOB_QUEUE_NOT_ACTIVE; + util_abort("%s: unrecognized lsf status code:%d \n",__func__ , lsf_status ); + } + return job_status; +} + + +int lsf_driver_get_job_status_lsf(void * __driver , void * __job) { + int lsf_status; + lsf_driver_type * driver = lsf_driver_safe_cast( __driver ); + + if (driver->submit_method == LSF_SUBMIT_INTERNAL) + lsf_status = lsf_driver_get_job_status_libary(__driver , __job); + else + lsf_status = lsf_driver_get_job_status_shell(__driver , __job); + + return lsf_status; +} + + + +job_status_type lsf_driver_get_job_status(void * __driver , void * __job) { + int lsf_status = lsf_driver_get_job_status_lsf( __driver , __job ); + return lsf_driver_convert_status( lsf_status ); +} + + + + +void lsf_driver_free_job(void * __job) { + lsf_job_type * job = lsf_job_safe_cast( __job ); + lsf_job_free(job); +} + + + +void lsf_driver_kill_job(void * __driver , void * __job) { + lsf_driver_type * driver = lsf_driver_safe_cast( __driver ); + lsf_job_type * job = lsf_job_safe_cast( __job ); + { + if (driver->submit_method == LSF_SUBMIT_INTERNAL) +#ifdef HAVE_LSF_LIBRARY + lsb_killjob( driver->lsb , job->lsf_jobnr); +#else + lsf_driver_internal_error( driver ); +#endif + else { + if (driver->submit_method == LSF_SUBMIT_REMOTE_SHELL) { + char ** argv = util_calloc( 2, sizeof * argv ); + argv[0] = driver->remote_lsf_server; + argv[1] = util_alloc_sprintf("%s %s" , driver->bkill_cmd , job->lsf_jobnr_char); + + util_fork_exec(driver->rsh_cmd , 2 , (const char **) argv , true , NULL , NULL , NULL , NULL , NULL); + + free( argv[1] ); + free( argv ); + } else if (driver->submit_method == LSF_SUBMIT_LOCAL_SHELL) + util_fork_exec(driver->bkill_cmd , 1 , (const char **) &job->lsf_jobnr_char , true , NULL , NULL , NULL , NULL , NULL); + } + } +} + + + + + +void * lsf_driver_submit_job(void * __driver , + const char * submit_cmd , + int num_cpu , + const char * run_path , + const char * job_name , + int argc, + const char ** argv ) { + lsf_driver_type * driver = lsf_driver_safe_cast( __driver ); + lsf_driver_assert_submit_method( driver ); + { + lsf_job_type * job = lsf_job_alloc(); + { + char * lsf_stdout = util_alloc_filename(run_path , job_name , "LSF-stdout"); + lsf_submit_method_enum submit_method = driver->submit_method; + pthread_mutex_lock( &driver->submit_lock ); + + if (submit_method == LSF_SUBMIT_INTERNAL) { + job->lsf_jobnr = lsf_driver_submit_internal_job( driver , run_path , job_name , submit_cmd , num_cpu , argc, argv); + } else { + job->lsf_jobnr = lsf_driver_submit_shell_job( driver , run_path , job_name , submit_cmd , num_cpu , argc, argv); + job->lsf_jobnr_char = util_alloc_sprintf("%ld" , job->lsf_jobnr); + hash_insert_ref( driver->my_jobs , job->lsf_jobnr_char , NULL ); + } + + pthread_mutex_unlock( &driver->submit_lock ); + free( lsf_stdout ); + } + + if (job->lsf_jobnr > 0) + return job; + else { + /* + The submit failed - the queue system shall handle + NULL return values. + */ + lsf_job_free(job); + return NULL; + } + } +} + + + +void lsf_driver_free(lsf_driver_type * driver ) { + util_safe_free(driver->login_shell); + util_safe_free(driver->queue_name); + util_safe_free(driver->resource_request ); + util_safe_free(driver->remote_lsf_server ); + util_safe_free(driver->rsh_cmd ); + free( driver->bkill_cmd ); + free( driver->bjobs_cmd ); + free( driver->bsub_cmd ); + + hash_free(driver->status_map); + hash_free(driver->bjobs_cache); + hash_free(driver->my_jobs); + +#ifdef HAVE_LSF_LIBRARY + if (driver->lsb != NULL) + lsb_free( driver->lsb ); +#endif + + free(driver); + driver = NULL; +} + +void lsf_driver_free__(void * __driver ) { + lsf_driver_type * driver = lsf_driver_safe_cast( __driver ); + lsf_driver_free( driver ); +} + + +static void lsf_driver_set_queue( lsf_driver_type * driver, const char * queue ) { + driver->queue_name = util_realloc_string_copy( driver->queue_name , queue); +} + + +static void lsf_driver_set_login_shell( lsf_driver_type * driver, const char * login_shell ) { + driver->login_shell = util_realloc_string_copy( driver->login_shell , login_shell); +} + +static void lsf_driver_set_rsh_cmd( lsf_driver_type * driver , const char * rsh_cmd) { + driver->rsh_cmd = util_realloc_string_copy( driver->rsh_cmd , rsh_cmd ); +} + +static void lsf_driver_set_bsub_cmd( lsf_driver_type * driver , const char * bsub_cmd) { + driver->bsub_cmd = util_realloc_string_copy( driver->bsub_cmd , bsub_cmd ); +} + +static void lsf_driver_set_bjobs_cmd( lsf_driver_type * driver , const char * bjobs_cmd) { + driver->bjobs_cmd = util_realloc_string_copy( driver->bjobs_cmd , bjobs_cmd ); +} + +static void lsf_driver_set_bkill_cmd( lsf_driver_type * driver , const char * bkill_cmd) { + driver->bkill_cmd = util_realloc_string_copy( driver->bkill_cmd , bkill_cmd ); +} + +static void lsf_driver_set_internal_submit( lsf_driver_type * driver) { + /* No remote server has been set - assuming we can issue proper library calls. */ + /* The BSUB_QUEUE variable must NOT be set when using the shell + function, because then stdout is redirected and read. */ + + util_setenv("BSUB_QUIET" , "yes"); + driver->submit_method = LSF_SUBMIT_INTERNAL; + util_safe_free( driver->remote_lsf_server ); + driver->remote_lsf_server = NULL; +} + + +static void lsf_driver_set_remote_server( lsf_driver_type * driver , const char * remote_server) { + if (remote_server == NULL) { +#ifdef HAVE_LSF_LIBRARY + if (driver->lsb) + lsf_driver_set_internal_submit( driver ); + else + lsf_driver_set_remote_server( driver , LOCAL_LSF_SERVER ); // If initializing the lsb layer failed we try the local shell commands. +#endif + } else { + driver->remote_lsf_server = util_realloc_string_copy( driver->remote_lsf_server , remote_server ); + util_unsetenv( "BSUB_QUIET" ); + { + char * tmp_server = util_alloc_strupr_copy( remote_server ); + + if (strcmp(tmp_server , LOCAL_LSF_SERVER) == 0) + driver->submit_method = LSF_SUBMIT_LOCAL_SHELL; + else if (strcmp(tmp_server , NULL_LSF_SERVER) == 0) // We trap the special string 'NULL' and call again with a true NULL pointer. + lsf_driver_set_remote_server( driver , NULL); + else + driver->submit_method = LSF_SUBMIT_REMOTE_SHELL; + + free( tmp_server ); + } + } +} + + + +lsf_submit_method_enum lsf_driver_get_submit_method( const lsf_driver_type * driver ) { + return driver->submit_method; +} + +/*****************************************************************/ +/* Generic functions for runtime manipulation of options. + + LSF_SERVER + LSF_QUEUE + LSF_RESOURCE +*/ + +bool lsf_driver_set_option( void * __driver , const char * option_key , const void * value) { + lsf_driver_type * driver = lsf_driver_safe_cast( __driver ); + bool has_option = true; + { + if (strcmp( LSF_RESOURCE , option_key ) == 0) + driver->resource_request = util_realloc_string_copy( driver->resource_request , value ); + else if (strcmp( LSF_SERVER , option_key) == 0) + lsf_driver_set_remote_server( driver , value ); + else if (strcmp( LSF_QUEUE , option_key) == 0) + lsf_driver_set_queue( driver , value ); + else if (strcmp( LSF_LOGIN_SHELL , option_key) == 0) + lsf_driver_set_login_shell( driver , value ); + else if (strcmp( LSF_RSH_CMD , option_key) == 0) + lsf_driver_set_rsh_cmd( driver , value ); + else if (strcmp( LSF_BSUB_CMD , option_key) == 0) + lsf_driver_set_bsub_cmd( driver , value ); + else if (strcmp( LSF_BJOBS_CMD , option_key) == 0) + lsf_driver_set_bjobs_cmd( driver , value ); + else if (strcmp( LSF_BKILL_CMD , option_key) == 0) + lsf_driver_set_bkill_cmd( driver , value ); + else + has_option = false; + } + return has_option; +} + + +const void * lsf_driver_get_option( const void * __driver , const char * option_key) { + const lsf_driver_type * driver = lsf_driver_safe_cast_const( __driver ); + { + if (strcmp( LSF_RESOURCE , option_key ) == 0) + return driver->resource_request; + else if (strcmp( LSF_SERVER , option_key ) == 0) + return driver->remote_lsf_server; + else if (strcmp( LSF_QUEUE , option_key ) == 0) + return driver->queue_name; + else if (strcmp( LSF_LOGIN_SHELL , option_key ) == 0) + return driver->login_shell; + else if (strcmp( LSF_RSH_CMD , option_key ) == 0) + return driver->rsh_cmd; + else if (strcmp( LSF_BJOBS_CMD , option_key ) == 0) + return driver->bjobs_cmd; + else if (strcmp( LSF_BSUB_CMD , option_key ) == 0) + return driver->bsub_cmd; + else if (strcmp( LSF_BKILL_CMD , option_key ) == 0) + return driver->bkill_cmd; + else { + util_abort("%s: option_id:%s not recognized for LSF driver \n",__func__ , option_key); + return NULL; + } + } +} + + + +bool lsf_driver_has_option( const void * __driver , const char * option_key) { + return false; +} + + + + +/*****************************************************************/ + +/* + Observe that this driver IS not properly initialized when returning + from this function, the option interface must be used to set the + keys: +*/ + +void lsf_driver_set_bjobs_refresh_interval( lsf_driver_type * driver , int refresh_interval) { + driver->bjobs_refresh_interval = refresh_interval; +} + + +static void lsf_driver_lib_init( lsf_driver_type * lsf_driver ) { +#ifdef HAVE_LSF_LIBRARY + memset(&lsf_driver->lsf_request , 0 , sizeof (lsf_driver->lsf_request)); + lsf_driver->lsf_request.beginTime = 0; + lsf_driver->lsf_request.termTime = 0; + lsf_driver->lsf_request.numProcessors = 1; + lsf_driver->lsf_request.maxNumProcessors = 1; + { + int i; + for (i=0; i < LSF_RLIM_NLIMITS; i++) + lsf_driver->lsf_request.rLimits[i] = DEFAULT_RLIMIT; + } + lsf_driver->lsf_request.options2 = 0; + + lsf_driver->lsb = lsb_alloc(); + if (lsb_ready(lsf_driver->lsb)) + lsb_initialize(lsf_driver->lsb); + else { + lsb_free( lsf_driver->lsb ); + lsf_driver->lsb = NULL; + } +#endif +} + + + +static void lsf_driver_shell_init( lsf_driver_type * lsf_driver ) { + lsf_driver->last_bjobs_update = time( NULL ); + lsf_driver->bjobs_cache = hash_alloc(); + lsf_driver->my_jobs = hash_alloc(); + lsf_driver->status_map = hash_alloc(); + lsf_driver->bsub_cmd = NULL; + lsf_driver->bjobs_cmd = NULL; + lsf_driver->bkill_cmd = NULL; + + + hash_insert_int(lsf_driver->status_map , "PEND" , JOB_STAT_PEND); + hash_insert_int(lsf_driver->status_map , "SSUSP" , JOB_STAT_SSUSP); + hash_insert_int(lsf_driver->status_map , "PSUSP" , JOB_STAT_PSUSP); + hash_insert_int(lsf_driver->status_map , "USUSP" , JOB_STAT_USUSP); + hash_insert_int(lsf_driver->status_map , "RUN" , JOB_STAT_RUN); + hash_insert_int(lsf_driver->status_map , "EXIT" , JOB_STAT_EXIT); + hash_insert_int(lsf_driver->status_map , "DONE" , JOB_STAT_DONE); + hash_insert_int(lsf_driver->status_map , "UNKWN" , JOB_STAT_UNKWN); /* Uncertain about this one */ + pthread_mutex_init( &lsf_driver->bjobs_mutex , NULL ); +} + + + +void * lsf_driver_alloc( ) { + lsf_driver_type * lsf_driver = util_malloc(sizeof * lsf_driver ); + UTIL_TYPE_ID_INIT( lsf_driver , LSF_DRIVER_TYPE_ID); + lsf_driver->submit_method = LSF_SUBMIT_INVALID; + lsf_driver->login_shell = NULL; + lsf_driver->queue_name = NULL; + lsf_driver->remote_lsf_server = NULL; + lsf_driver->rsh_cmd = NULL; + lsf_driver->resource_request = NULL; + lsf_driver_set_bjobs_refresh_interval( lsf_driver , BJOBS_REFRESH_TIME ); + pthread_mutex_init( &lsf_driver->submit_lock , NULL ); + + lsf_driver_lib_init( lsf_driver ); + lsf_driver_shell_init( lsf_driver ); + + lsf_driver_set_option( lsf_driver , LSF_SERVER , NULL ); + lsf_driver_set_option( lsf_driver , LSF_RSH_CMD , DEFAULT_RSH_CMD ); + lsf_driver_set_option( lsf_driver , LSF_BSUB_CMD , DEFAULT_BSUB_CMD ); + lsf_driver_set_option( lsf_driver , LSF_BJOBS_CMD , DEFAULT_BJOBS_CMD ); + lsf_driver_set_option( lsf_driver , LSF_BKILL_CMD , DEFAULT_BKILL_CMD ); + return lsf_driver; +} + + +/*****************************************************************/ + diff --git a/ThirdParty/Ert/devel/libjob_queue/src/lsf_driver_dummy.c b/ThirdParty/Ert/devel/libjob_queue/src/lsf_driver_dummy.c deleted file mode 100644 index b1e6917b9d..0000000000 --- a/ThirdParty/Ert/devel/libjob_queue/src/lsf_driver_dummy.c +++ /dev/null @@ -1,107 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'lsf_driver_dummy.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - - -static void lsf_driver_invalid_usage( const char * func) { - fprintf(stderr,"\n\n"); - fprintf(stderr,"-----------------------------------------------------------------\n"); - fprintf(stderr,"You have called the function %s() from the \n", func); - fprintf(stderr,"LSF driver. The current lsf_driver is only a dummy driver, \n"); - fprintf(stderr,"and not capable of actually doing proper things. You must \n"); - fprintf(stderr,"select another driver to run your simulations.\n"); - fprintf(stderr,"\n"); - fprintf(stderr,"If your computing site has access to LSF the current version \n"); - fprintf(stderr,"of the LSF driver must be recompiled: \n"); - fprintf(stderr,"\n"); - fprintf(stderr," 1. Rebuild the lsf_driver with the preprossor symbol \'INCLUDE_LSF\' defined.\n"); - fprintf(stderr," 2. Relink the whole application - with the libraries \'libbat\', \'libnsl\' and \'liblsf\'.\n"); - fprintf(stderr,"\n"); - fprintf(stderr,"-----------------------------------------------------------------\n"); - exit(1); -} - -job_status_type lsf_driver_get_job_status(void * driver , void * job) { - return 0; -} - - - -void lsf_driver_free_job(void * job) { - lsf_driver_invalid_usage( __func__ ); -} - - - -void lsf_driver_kill_job(void * driver , void * job) { - lsf_driver_invalid_usage( __func__ ); -} - - - - - -void * lsf_driver_submit_job(void * driver , - const char * submit_cmd , - int num_cpu , - const char * run_path , - const char * job_name , - int argc , - const char ** argv ) { - lsf_driver_invalid_usage( __func__ ); - return NULL; -} - - - -void lsf_driver_free(lsf_driver_type * driver ) { - /* No op */ -} - -void lsf_driver_free__(void * driver ) { - /* No op */ -} - - -bool lsf_driver_set_option( void * driver , const char * option_key , const void * value) { - return false; -} - - -const void * lsf_driver_get_option( const void * driver , const char * option_key) { - return NULL; -} - - - -bool lsf_driver_has_option( const void * driver , const char * option_key) { - return false; -} - -/*****************************************************************/ - - - -void * lsf_driver_alloc( ) { - fprintf(stderr,"** Warning - this is an unfunctional LSF driver ** \n"); - return NULL; -} - - -/*****************************************************************/ diff --git a/ThirdParty/Ert/devel/libjob_queue/src/lsf_driver_impl.c b/ThirdParty/Ert/devel/libjob_queue/src/lsf_driver_impl.c index 4dabc8d70e..cbfa8b9eb0 100644 --- a/ThirdParty/Ert/devel/libjob_queue/src/lsf_driver_impl.c +++ b/ThirdParty/Ert/devel/libjob_queue/src/lsf_driver_impl.c @@ -214,10 +214,24 @@ stringlist_type * lsf_driver_alloc_cmd(lsf_driver_type * driver , stringlist_type * argv = stringlist_alloc_new(); char * num_cpu_string = util_alloc_sprintf("%d" , num_cpu); char * quoted_resource_request = NULL; - - if (driver->resource_request != NULL) - quoted_resource_request = util_alloc_sprintf("\"%s\"" , driver->resource_request); + /* + The resource request string contains spaces, and when passed + through the shell it must be protected with \"..\"; this applies + when submitting to a remote lsf server with ssh. However when + submitting to the local workstation using a bsub command the + command will be invoked with the util_fork_exec() command - and no + shell is involved. In this latter case we must avoid the \"...\" + quoting. + */ + + if (driver->resource_request != NULL) { + if (driver->submit_method == LSF_SUBMIT_REMOTE_SHELL) + quoted_resource_request =util_alloc_sprintf("\"%s\"" , driver->resource_request); + else + quoted_resource_request = util_alloc_string_copy( driver->resource_request ); + } + if (driver->submit_method == LSF_SUBMIT_REMOTE_SHELL) stringlist_append_ref( argv , driver->bsub_cmd); @@ -317,6 +331,7 @@ static int lsf_driver_submit_shell_job(lsf_driver_type * driver , int job_id; char * tmp_file = util_alloc_tmp_file("/tmp" , "enkf-submit" , true); + printf("remote_lsf_server: %s \n",driver->remote_lsf_server); if (driver->remote_lsf_server != NULL) { stringlist_type * remote_argv = lsf_driver_alloc_cmd( driver , lsf_stdout , job_name , submit_cmd , num_cpu , job_argc , job_argv); if (driver->submit_method == LSF_SUBMIT_REMOTE_SHELL) { diff --git a/ThirdParty/Ert/devel/libjob_queue/src/rsh_driver.c b/ThirdParty/Ert/devel/libjob_queue/src/rsh_driver.c index a4df97372b..f7725f4d93 100644 --- a/ThirdParty/Ert/devel/libjob_queue/src/rsh_driver.c +++ b/ThirdParty/Ert/devel/libjob_queue/src/rsh_driver.c @@ -119,11 +119,15 @@ static bool rsh_host_available(rsh_host_type * rsh_host) { bool available; pthread_mutex_lock( &rsh_host->host_mutex ); - if ((rsh_host->max_running - rsh_host->running) > 0) { - available = true; - rsh_host->running++; - } else + { available = false; + if ((rsh_host->max_running - rsh_host->running) > 0) { // The host has free slots() + if (util_ping( rsh_host->host_name )) { // The host answers to ping() + available = true; + rsh_host->running++; + } + } + } pthread_mutex_unlock( &rsh_host->host_mutex ); return available; diff --git a/ThirdParty/Ert/devel/libjob_queue/src/workflow.c b/ThirdParty/Ert/devel/libjob_queue/src/workflow.c new file mode 100644 index 0000000000..1ea7a60c1e --- /dev/null +++ b/ThirdParty/Ert/devel/libjob_queue/src/workflow.c @@ -0,0 +1,229 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'workflow.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#define CMD_TYPE_ID 66153 +#define WORKFLOW_TYPE_ID 6762081 +#define WORKFLOW_COMMENT_STRING "--" +#define WORKFLOW_INCLUDE "INCLUDE" + +typedef struct cmd_struct cmd_type; + +struct cmd_struct { + UTIL_TYPE_ID_DECLARATION; + const workflow_job_type * workflow_job; + stringlist_type * arglist; +}; + + + + +struct workflow_struct { + UTIL_TYPE_ID_DECLARATION; + time_t compile_time; + bool compiled; + char * src_file; + vector_type * cmd_list; + workflow_joblist_type * joblist; + config_error_type * last_error; +}; + +/*****************************************************************/ + + +static cmd_type * cmd_alloc( const workflow_job_type * workflow_job , const stringlist_type * arglist) { + cmd_type * cmd = util_malloc( sizeof * cmd ); + UTIL_TYPE_ID_INIT(cmd , CMD_TYPE_ID ); + cmd->workflow_job = workflow_job; + cmd->arglist = stringlist_alloc_deep_copy( arglist ); + return cmd; +} + +static UTIL_SAFE_CAST_FUNCTION( cmd , CMD_TYPE_ID ); + +static void cmd_free( cmd_type * cmd ){ + stringlist_free( cmd->arglist ); + free( cmd ); +} + +static void cmd_free__( void * arg ) { + cmd_type * cmd = cmd_safe_cast( arg ); + cmd_free( cmd ); +} + +/*****************************************************************/ + +static void workflow_add_cmd( workflow_type * workflow , cmd_type * cmd ) { + vector_append_owned_ref( workflow->cmd_list , cmd , cmd_free__ ); +} + + +static void workflow_clear( workflow_type * workflow ) { + vector_clear( workflow->cmd_list ); +} + +static void workflow_store_error( workflow_type * workflow , const config_error_type * error) { + if (workflow->last_error) + config_error_free( workflow->last_error ); + + if (error) + workflow->last_error = config_error_alloc_copy( error ); + else + workflow->last_error = NULL; +} + + + + +static bool workflow_try_compile( workflow_type * script , const subst_list_type * context) { + if (util_file_exists( script->src_file )) { + const char * src_file = script->src_file; + char * tmp_file = NULL; + bool update = false; + if (context != NULL) { + tmp_file = util_alloc_tmp_file("/tmp" , "ert-workflow" , false ); + update = subst_list_filter_file( context , script->src_file , tmp_file ); + if (update) { + script->compiled = false; + src_file = tmp_file; + } else { + remove( tmp_file ); + free( tmp_file ); + tmp_file = NULL; + } + } + + { + time_t src_mtime = util_file_mtime( script->src_file ); + if (script->compiled) { + if (util_difftime_seconds( src_mtime , script->compile_time ) > 0 ) + return true; + else { + // Script has been compiled succesfully, but then changed afterwards. + // We try to recompile; if that fails we are left with 'nothing'. + } + } + } + + { + // Try to compile + config_type * config_compiler = workflow_joblist_get_compiler( script->joblist ); + script->compiled = false; + workflow_clear( script ); + config_clear( config_compiler ); + { + if (config_parse( config_compiler , src_file , WORKFLOW_COMMENT_STRING , WORKFLOW_INCLUDE , NULL , CONFIG_UNRECOGNIZED_ERROR , true )) { + int cmd_line; + for (cmd_line = 0; cmd_line < config_get_content_size(config_compiler); cmd_line++) { + const config_content_node_type * node = config_iget_content_node( config_compiler , cmd_line ); + const char * jobname = config_content_node_get_kw( node ); + const workflow_job_type * job = workflow_joblist_get_job( script->joblist , jobname ); + cmd_type * cmd = cmd_alloc( job , config_content_node_get_stringlist( node )); + + workflow_add_cmd( script , cmd ); + } + script->compiled = true; + } else + workflow_store_error( script , config_get_errors( config_compiler )); + } + } + + if (tmp_file != NULL) { + if (script->compiled) + remove( tmp_file ); + free( tmp_file ); + } + } + + // It is legal to remove the script after successfull compilation but + // then the context will not be applied at subsequent invocations. + return script->compiled; +} + + +bool workflow_run(workflow_type * workflow , void * self , bool verbose , const subst_list_type * context) { + workflow_try_compile( workflow , context); + + if (workflow->compiled) { + int icmd; + for (icmd = 0; icmd < vector_get_size( workflow->cmd_list ); icmd++) { + const cmd_type * cmd = vector_iget_const( workflow->cmd_list , icmd ); + workflow_job_run( cmd->workflow_job , self , verbose , cmd->arglist ); + } + return true; + } else + return false; +} + + + +workflow_type * workflow_alloc( const char * src_file , workflow_joblist_type * joblist) { + workflow_type * script = util_malloc( sizeof * script ); + UTIL_TYPE_ID_INIT( script , WORKFLOW_TYPE_ID ); + + script->src_file = util_alloc_string_copy( src_file ); + script->joblist = joblist; + script->cmd_list = vector_alloc_new(); + script->compiled = false; + script->last_error = NULL; + + workflow_try_compile( script , NULL ); + return script; +} + + +static UTIL_SAFE_CAST_FUNCTION( workflow , WORKFLOW_TYPE_ID ) + + +void workflow_free( workflow_type * workflow ) { + free( workflow->src_file ); + vector_free( workflow->cmd_list ); + + if (workflow->last_error) + config_error_free( workflow->last_error ); + + free( workflow ); +} + + +void workflow_free__( void * arg ) { + workflow_type * workflow = workflow_safe_cast( arg ); + workflow_free( workflow ); +} + + +const config_error_type * workflow_get_last_error( const workflow_type * workflow) { + return workflow->last_error; +} diff --git a/ThirdParty/Ert/devel/libjob_queue/src/workflow_job.c b/ThirdParty/Ert/devel/libjob_queue/src/workflow_job.c new file mode 100644 index 0000000000..7a25e7fc72 --- /dev/null +++ b/ThirdParty/Ert/devel/libjob_queue/src/workflow_job.c @@ -0,0 +1,356 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'workflow_job.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include + +#include +#include +#include + +#include + +#include + + +/* The default values are interepreted as no limit. */ +#define DEFAULT_INTERNAL false + + +#define MIN_ARG_KEY "MIN_ARG" +#define MAX_ARG_KEY "MAX_ARG" +#define ARG_TYPE_KEY "ARG_TYPE" +#define INTERNAL_KEY "INTERNAL" +#define MODULE_KEY "MODULE" +#define FUNCTION_KEY "FUNCTION" +#define EXECUTABLE_KEY "EXECUTABLE" + +#define NULL_STRING "NULL" +#define WORKFLOW_JOB_STRING_TYPE "STRING" +#define WORKFLOW_JOB_INT_TYPE "INT" +#define WORKFLOW_JOB_FLOAT_TYPE "FLOAT" + +#define WORKFLOW_JOB_TYPE_ID 614441 + + +struct workflow_job_struct { + UTIL_TYPE_ID_DECLARATION; + bool internal; + int min_arg; + int max_arg; + int_vector_type * arg_types; // Should contain values from the config_item_types enum in config.h. + char * executable; + char * module; + char * function; + char * name; + void * lib_handle; + workflow_job_ftype * dl_func; + bool valid; +}; + + +bool workflow_job_internal( const workflow_job_type * workflow_job ) { + return workflow_job->internal; +} + +const char * workflow_job_get_name( const workflow_job_type * workflow_job ) { + return workflow_job->name; +} + + +config_type * workflow_job_alloc_config() { + config_type * config = config_alloc(); + { + config_schema_item_type * item; + + item = config_add_schema_item( config , MIN_ARG_KEY , false ); + config_schema_item_set_argc_minmax( item , 1 , 1 ); + config_schema_item_iset_type( item , 0 , CONFIG_INT ); + + item = config_add_schema_item( config , MAX_ARG_KEY , false ); + config_schema_item_set_argc_minmax( item , 1 , 1 ); + config_schema_item_iset_type( item , 0 , CONFIG_INT ); + + item = config_add_schema_item( config , ARG_TYPE_KEY , false ); + config_schema_item_set_argc_minmax( item , 2 , 2 ); + config_schema_item_iset_type( item , 0 , CONFIG_INT ); + config_schema_item_set_indexed_selection_set( item , 1 , 3 , (const char *[3]) {WORKFLOW_JOB_STRING_TYPE , WORKFLOW_JOB_INT_TYPE , WORKFLOW_JOB_FLOAT_TYPE}); + + /*****************************************************************/ + item = config_add_schema_item( config , EXECUTABLE_KEY , false ); + config_schema_item_set_argc_minmax( item , 1 , 1 ); + config_schema_item_iset_type( item , 0 , CONFIG_PATH ); + + /*---------------------------------------------------------------*/ + + item = config_add_schema_item( config , FUNCTION_KEY , false ); + config_schema_item_set_argc_minmax( item , 1 , 1); + + item = config_add_schema_item( config , MODULE_KEY , false ); + config_schema_item_set_argc_minmax( item , 1 , 1); + /*****************************************************************/ + + item = config_add_schema_item( config , INTERNAL_KEY , false ); + config_schema_item_set_argc_minmax( item , 1 , 1); + config_schema_item_iset_type( item , 0 , CONFIG_BOOL); + } + return config; +} + + + +static UTIL_SAFE_CAST_FUNCTION(workflow_job , WORKFLOW_JOB_TYPE_ID ); + +void workflow_job_update_config_compiler( const workflow_job_type * workflow_job , config_type * config_compiler ) { + config_schema_item_type * item = config_add_schema_item( config_compiler , workflow_job->name , false ); + /* + Ensure that the arg_types mapping is at least as large as the + max_arg value. The arg_type vector will be left padded with + CONFIG_STRING values. + */ + { + int iarg; + config_schema_item_set_argc_minmax( item , workflow_job->min_arg , workflow_job->max_arg ); + for (iarg = 0; iarg < int_vector_size( workflow_job->arg_types ); iarg++) + config_schema_item_iset_type( item , iarg , int_vector_iget( workflow_job->arg_types , iarg )); + } +} + + +workflow_job_type * workflow_job_alloc( const char * name , bool internal ) { + workflow_job_type * workflow_job = util_malloc( sizeof * workflow_job ); + UTIL_TYPE_ID_INIT( workflow_job , WORKFLOW_JOB_TYPE_ID ); + workflow_job->internal = internal; // this can not be changed run-time. + workflow_job->min_arg = CONFIG_DEFAULT_ARG_MIN; + workflow_job->max_arg = CONFIG_DEFAULT_ARG_MAX; + workflow_job->arg_types = int_vector_alloc( 0 , CONFIG_STRING ); + + workflow_job->executable = NULL; + workflow_job->module = NULL; + workflow_job->function = NULL; + + if (name == NULL) + util_abort("%s: trying to create workflow_job with name == NULL - illegal\n",__func__); + else + workflow_job->name = util_alloc_string_copy( name ); + + workflow_job->valid = false; + + return workflow_job; +} + + +void workflow_job_set_executable( workflow_job_type * workflow_job , const char * executable ) { + workflow_job->executable = util_realloc_string_copy( workflow_job->executable , executable ); +} + + +void workflow_job_set_module( workflow_job_type * workflow_job , const char * module) { + if (strcmp(module ,NULL_STRING) == 0) + module = NULL; + + workflow_job->module = util_realloc_string_copy( workflow_job->module , module ); +} + + +void workflow_job_set_function( workflow_job_type * workflow_job , const char * function) { + workflow_job->function = util_realloc_string_copy( workflow_job->function , function ); +} + + +void workflow_job_iset_argtype( workflow_job_type * workflow_job , int iarg , config_item_types type) { + if (type == CONFIG_STRING || type == CONFIG_INT || type == CONFIG_FLOAT) + int_vector_iset( workflow_job->arg_types , iarg , type ); +} + +void workflow_job_set_min_arg( workflow_job_type * workflow_job , int min_arg) { + workflow_job->min_arg = min_arg; +} + +void workflow_job_set_max_arg( workflow_job_type * workflow_job , int max_arg) { + workflow_job->max_arg = max_arg; +} + +int workflow_job_get_min_arg( const workflow_job_type * workflow_job ) { + return workflow_job->min_arg; +} + +int workflow_job_get_max_arg( workflow_job_type * workflow_job ) { + return workflow_job->max_arg; +} + + + +static void workflow_job_iset_argtype_string( workflow_job_type * workflow_job , int iarg , const char * arg_type) { + config_item_types type = CONFIG_INVALID; + + if (strcmp( arg_type , WORKFLOW_JOB_STRING_TYPE) == 0) + type = CONFIG_STRING; + else if (strcmp( arg_type , WORKFLOW_JOB_INT_TYPE) == 0) + type = CONFIG_INT; + else if (strcmp( arg_type , WORKFLOW_JOB_FLOAT_TYPE) == 0) + type = CONFIG_FLOAT; + + if (type != CONFIG_INVALID) + workflow_job_iset_argtype( workflow_job , iarg , type ); + +} + + +static void workflow_job_validate_internal( workflow_job_type * workflow_job ) { + if ((workflow_job->executable == NULL) && (workflow_job->function != NULL)) { + workflow_job->lib_handle = dlopen( workflow_job->module , RTLD_NOW ); + if (workflow_job->lib_handle != NULL) { + workflow_job->dl_func = (workflow_job_ftype *) dlsym( workflow_job->lib_handle , workflow_job->function ); + if (workflow_job->dl_func != NULL) + workflow_job->valid = true; + else + fprintf(stderr,"Failed to load symbol:%s Error:%s \n",workflow_job->function , dlerror()); + } else { + if (workflow_job->module != NULL) + fprintf(stderr,"Failed to load module:%s Error:%s \n",workflow_job->module , dlerror()); + } + } else + fprintf(stderr,"Must have executable == NULL and function != NULL for internal jobs \n"); +} + + +static void workflow_job_validate_external( workflow_job_type * workflow_job ) { + if (workflow_job->executable != NULL) { + if (util_is_executable( workflow_job->executable ) && + (workflow_job->module == workflow_job->function) && + (workflow_job->module == NULL)) + workflow_job->valid = true; + } +} + + + +static void workflow_job_validate( workflow_job_type * workflow_job ) { + if (workflow_job->internal) + workflow_job_validate_internal( workflow_job ); + else + workflow_job_validate_external( workflow_job ); +} + + + + +workflow_job_type * workflow_job_config_alloc( const char * name , config_type * config , const char * config_file) { + config_clear( config ); + if (config_parse( config , config_file , "--", NULL , NULL , CONFIG_UNRECOGNIZED_WARN , true)) { + bool internal = DEFAULT_INTERNAL; + if (config_item_set( config , INTERNAL_KEY)) + internal = config_iget_as_bool( config , INTERNAL_KEY , 0 , 0 ); + + { + workflow_job_type * workflow_job = workflow_job_alloc( name , internal ); + + if (config_item_set( config , MIN_ARG_KEY)) + workflow_job_set_min_arg( workflow_job , config_iget_as_int( config , MIN_ARG_KEY , 0 , 0 )); + + if (config_item_set( config , MAX_ARG_KEY)) + workflow_job_set_max_arg( workflow_job , config_iget_as_int( config , MAX_ARG_KEY , 0 , 0 )); + + { + int i; + for (i=0; i < config_get_occurences( config , ARG_TYPE_KEY); i++) { + int iarg = config_iget_as_int( config , ARG_TYPE_KEY , i , 0 ); + const char * arg_type = config_iget( config , ARG_TYPE_KEY , i , 1 ); + + workflow_job_iset_argtype_string( workflow_job , iarg , arg_type ); + } + } + + if (config_item_set( config , MODULE_KEY)) + workflow_job_set_module( workflow_job , config_get_value( config , MODULE_KEY)); // Could be a pure so name; or a full path ..... Like executable + + if (config_item_set( config , FUNCTION_KEY)) + workflow_job_set_function( workflow_job , config_get_value( config , FUNCTION_KEY)); + + if (config_item_set( config , EXECUTABLE_KEY)) + workflow_job_set_executable( workflow_job , config_get_value_as_abspath( config , EXECUTABLE_KEY)); + + workflow_job_validate( workflow_job ); + + if (!workflow_job->valid) { + workflow_job_free( workflow_job ); + workflow_job = NULL; + } + + return workflow_job; + } + } else + return NULL; +} + + + + +void workflow_job_free( workflow_job_type * workflow_job ) { + util_safe_free( workflow_job->module ); + util_safe_free( workflow_job->function ); + util_safe_free( workflow_job->executable ); + int_vector_free( workflow_job->arg_types ); + free( workflow_job->name ); + free( workflow_job ); +} + + +void workflow_job_free__( void * arg) { + workflow_job_type * workflow_job = workflow_job_safe_cast( arg ); + workflow_job_free( workflow_job ); +} + + + +static void workflow_job_run_internal( const workflow_job_type * job , void * self , bool verbose , const stringlist_type * arg) { + job->dl_func( self , arg ); +} + + +static void workflow_job_run_external( const workflow_job_type * job , bool verbose , const stringlist_type * arg) { + char ** argv = stringlist_alloc_char_copy( arg ); + + util_fork_exec( job->executable , + stringlist_get_size( arg ), + (const char **) argv , + true , + NULL , + NULL , + NULL , + NULL , + NULL ); + + + if (argv != NULL) { + int i; + for (i=0; i < stringlist_get_size( arg ); i++) + free( argv[i] ); + free( argv ); + } +} + + +void workflow_job_run( const workflow_job_type * job , void * self , bool verbose , const stringlist_type * arg) { + if (job->internal) + workflow_job_run_internal( job , self , verbose , arg ); + else + workflow_job_run_external( job , verbose , arg ); +} diff --git a/ThirdParty/Ert/devel/libjob_queue/src/workflow_joblist.c b/ThirdParty/Ert/devel/libjob_queue/src/workflow_joblist.c new file mode 100644 index 0000000000..8d64d3de30 --- /dev/null +++ b/ThirdParty/Ert/devel/libjob_queue/src/workflow_joblist.c @@ -0,0 +1,85 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'workflow_joblist.c' is part of ERT - Ensemble based + Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include + +#include +#include +#include +#include + +#include + +#include +#include + + +struct workflow_joblist_struct { + config_type * workflow_compiler; + config_type * job_config; + + hash_type * joblist; +}; + + +workflow_joblist_type * workflow_joblist_alloc( ) { + workflow_joblist_type * joblist = util_malloc( sizeof * joblist ); + + joblist->job_config = workflow_job_alloc_config(); + joblist->workflow_compiler = config_alloc(); + joblist->joblist = hash_alloc(); + + return joblist; +} + + +void workflow_joblist_free( workflow_joblist_type * joblist) { + config_free( joblist->job_config ); + config_free( joblist->workflow_compiler ); + hash_free( joblist->joblist ); + free( joblist ); +} + + +const workflow_job_type * workflow_joblist_get_job( const workflow_joblist_type * joblist , const char * job_name) { + return hash_get( joblist->joblist , job_name ); +} + + +void workflow_joblist_add_job( workflow_joblist_type * joblist , const workflow_job_type * job) { + hash_insert_hash_owned_ref( joblist->joblist , workflow_job_get_name( job ) , job , workflow_job_free__ ); + workflow_job_update_config_compiler( job , joblist->workflow_compiler ); +} + + +bool workflow_joblist_add_job_from_file( workflow_joblist_type * joblist , const char * job_name , const char * config_file ) { + workflow_job_type * job = workflow_job_config_alloc( job_name , joblist->job_config , config_file ); + if (job != NULL) { + workflow_joblist_add_job( joblist , job ); + return true; + } else + return false; +} + + +config_type * workflow_joblist_get_compiler( const workflow_joblist_type * joblist ) { + return joblist->workflow_compiler; +} diff --git a/ThirdParty/Ert/devel/libjob_queue/tests/CMakeLists.txt b/ThirdParty/Ert/devel/libjob_queue/tests/CMakeLists.txt index e0087469e4..0b80bba663 100644 --- a/ThirdParty/Ert/devel/libjob_queue/tests/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libjob_queue/tests/CMakeLists.txt @@ -1,11 +1,37 @@ +add_executable( job_loadOK job_loadOK.c ) +add_executable( job_loadFail job_loadFail.c ) +add_executable( create_file create_file.c ) +add_executable( job_workflow_test job_workflow_test.c ) + + +target_link_libraries( job_workflow_test job_queue ) +target_link_libraries( create_file job_queue ) +target_link_libraries( job_loadOK job_queue ) +target_link_libraries( job_loadFail job_queue ) + + +add_test( job_workflow_test ${EXECUTABLE_OUTPUT_PATH}/job_workflow_test ${EXECUTABLE_OUTPUT_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/data/internal_job) + +add_test( job_loadOK1 ${EXECUTABLE_OUTPUT_PATH}/job_loadOK ${CMAKE_CURRENT_SOURCE_DIR}/data/internalOK) +add_test( job_loadOK2 ${EXECUTABLE_OUTPUT_PATH}/job_loadOK ${CMAKE_CURRENT_SOURCE_DIR}/data/externalOK) +add_test( job_loadOK3 ${EXECUTABLE_OUTPUT_PATH}/job_loadOK ${CMAKE_CURRENT_SOURCE_DIR}/data/internalOK ${CMAKE_CURRENT_SOURCE_DIR}/data/externalOK) + +add_test( job_loadFail1 ${EXECUTABLE_OUTPUT_PATH}/job_loadFail ${CMAKE_CURRENT_SOURCE_DIR}/data/internalFail) +add_test( job_loadFail2 ${EXECUTABLE_OUTPUT_PATH}/job_loadFail ${CMAKE_CURRENT_SOURCE_DIR}/data/externalFail) +add_test( job_loadFail3 ${EXECUTABLE_OUTPUT_PATH}/job_loadFail ${CMAKE_CURRENT_SOURCE_DIR}/data/internalFail ${CMAKE_CURRENT_SOURCE_DIR}/data/externalFail) + + +add_executable( job_queue_test job_queue_test.c ) +target_link_libraries( job_queue_test job_queue ) +add_test( job_queue_test ${EXECUTABLE_OUTPUT_PATH}/job_queue_test ) + + # This should be a space separated list of servers which will be # tried out when testing the LSF submit capability. The test program # will interpret the special string 'NULL' as submit with library # functions. set(LSF_SERVERS "LOCAL NULL" CACHE STRING "List of LSF servers for testing") -add_executable( loadOK loadOK.c ) -target_link_libraries( loadOK job_queue util ) add_executable( job_lsf_test job_lsf_test.c ) target_link_libraries( job_lsf_test job_queue util ) @@ -15,7 +41,13 @@ target_link_libraries( job_lsf_submit_test job_queue util ) add_executable( job_program job_program.c ) -add_test( loadOK ${EXECUTABLE_OUTPUT_PATH}/loadOK ${CMAKE_CURRENT_SOURCE_DIR}/data/internalOK) +if (HAVE_LSF_LIBRARY) + add_executable( job_lsb job_lsb.c ) + target_link_libraries( job_lsb job_queue util ) + add_test( job_lsb ${EXECUTABLE_OUTPUT_PATH}/job_lsb ) +endif() + + add_test( job_lsf_test ${EXECUTABLE_OUTPUT_PATH}/job_lsf_test ) if (LSF_SERVERS) add_test( job_lsf_submit_test ${EXECUTABLE_OUTPUT_PATH}/job_lsf_submit_test ${EXECUTABLE_OUTPUT_PATH}/job_program ${LSF_SERVERS}) diff --git a/ThirdParty/Ert/devel/libjob_queue/tests/create_file.c b/ThirdParty/Ert/devel/libjob_queue/tests/create_file.c new file mode 100644 index 0000000000..fbba657756 --- /dev/null +++ b/ThirdParty/Ert/devel/libjob_queue/tests/create_file.c @@ -0,0 +1,28 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'create_file.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include + + +int main( int argc , char ** argv) { + char * filename = argv[1]; + int value = atoi( argv[2] ); + FILE * stream = fopen( filename , "w"); + fprintf(stream , "%d\n", value ); + fclose( stream ); +} diff --git a/ThirdParty/Ert/devel/libjob_queue/tests/data/externalFail b/ThirdParty/Ert/devel/libjob_queue/tests/data/externalFail new file mode 100644 index 0000000000..0f53d812c3 --- /dev/null +++ b/ThirdParty/Ert/devel/libjob_queue/tests/data/externalFail @@ -0,0 +1,5 @@ +INTERNAL False +MIN_ARG 1 +MAX_ARG 2 +ARG_TYPE 0 STRING +ARG_TYPE 1 INT diff --git a/ThirdParty/Ert/devel/libjob_queue/tests/data/externalOK b/ThirdParty/Ert/devel/libjob_queue/tests/data/externalOK new file mode 100644 index 0000000000..67dec0bef2 --- /dev/null +++ b/ThirdParty/Ert/devel/libjob_queue/tests/data/externalOK @@ -0,0 +1,6 @@ +INTERNAL False +EXECUTABLE /usr/bin/python +MIN_ARG 1 +MAX_ARG 2 +ARG_TYPE 0 STRING +ARG_TYPE 1 INT diff --git a/ThirdParty/Ert/devel/libjob_queue/tests/data/external_job b/ThirdParty/Ert/devel/libjob_queue/tests/data/external_job new file mode 100644 index 0000000000..5b39223101 --- /dev/null +++ b/ThirdParty/Ert/devel/libjob_queue/tests/data/external_job @@ -0,0 +1,5 @@ +EXECUTABLE /private/joaho/ERT/git/ert/build/bin/create_file +ARG_TYPE 0 STRING +ARG_TYPE 1 INT +MIN_ARG 2 +MAX_ARG 2 \ No newline at end of file diff --git a/ThirdParty/Ert/devel/libjob_queue/tests/data/internalFail b/ThirdParty/Ert/devel/libjob_queue/tests/data/internalFail new file mode 100644 index 0000000000..40686fc1d5 --- /dev/null +++ b/ThirdParty/Ert/devel/libjob_queue/tests/data/internalFail @@ -0,0 +1,6 @@ +INTERNAL True +MODULE NULL +MIN_ARG 1 +MAX_ARG 2 +ARG_TYPE 0 STRING +ARG_TYPE 1 INT diff --git a/ThirdParty/Ert/devel/libjob_queue/tests/data/internalOK b/ThirdParty/Ert/devel/libjob_queue/tests/data/internalOK index b88ef7dffa..6252998faa 100644 --- a/ThirdParty/Ert/devel/libjob_queue/tests/data/internalOK +++ b/ThirdParty/Ert/devel/libjob_queue/tests/data/internalOK @@ -1,6 +1,6 @@ INTERNAL True MODULE NULL -FUNCTION ext_cmd_alloc +FUNCTION workflow_job_alloc MIN_ARG 1 MAX_ARG 2 ARG_TYPE 0 STRING diff --git a/ThirdParty/Ert/devel/libjob_queue/tests/data/internal_job b/ThirdParty/Ert/devel/libjob_queue/tests/data/internal_job new file mode 100644 index 0000000000..2c86544a44 --- /dev/null +++ b/ThirdParty/Ert/devel/libjob_queue/tests/data/internal_job @@ -0,0 +1,5 @@ +INTERNAL True +FUNCTION read_file +ARG_TYPE 0 STRING +MIN_ARG 1 +MAX_ARG 1 diff --git a/ThirdParty/Ert/devel/libjob_queue/tests/job_loadFail.c b/ThirdParty/Ert/devel/libjob_queue/tests/job_loadFail.c new file mode 100644 index 0000000000..6201572c36 --- /dev/null +++ b/ThirdParty/Ert/devel/libjob_queue/tests/job_loadFail.c @@ -0,0 +1,60 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'job_loadFail.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include + +#include + +#include + + + +bool loadConfig(config_type * config , const char * config_file, config_type * config_compiler) { + bool OK = false; + workflow_job_type * cmd = workflow_job_config_alloc( "NAME" , config , config_file); + + if (cmd != NULL) { + OK = true; + workflow_job_update_config_compiler( cmd , config_compiler ); + workflow_job_free( cmd ); + } + + return OK; +} + + + +int main( int argc , char ** argv) { + int status = 0; + { + config_type * config = workflow_job_alloc_config(); + config_type * config_compiler = config_alloc(); + int iarg; + bool OK = true; + + for (iarg = 1; iarg < argc; iarg++) + OK = OK && (loadConfig( config , argv[iarg] , config_compiler ) == false); + + if (!OK) + status = 1; + + config_free(config_compiler); + config_free(config); + } + exit( status ); +} diff --git a/ThirdParty/Ert/devel/libjob_queue/tests/loadOK.c b/ThirdParty/Ert/devel/libjob_queue/tests/job_loadOK.c similarity index 61% rename from ThirdParty/Ert/devel/libjob_queue/tests/loadOK.c rename to ThirdParty/Ert/devel/libjob_queue/tests/job_loadOK.c index 1f8920b01c..5b94f4e1f6 100644 --- a/ThirdParty/Ert/devel/libjob_queue/tests/loadOK.c +++ b/ThirdParty/Ert/devel/libjob_queue/tests/job_loadOK.c @@ -1,7 +1,7 @@ /* Copyright (C) 2012 Statoil ASA, Norway. - The file 'load_internal.c' is part of ERT - Ensemble based Reservoir Tool. + The file 'job_loadOK.c' is part of ERT - Ensemble based Reservoir Tool. ERT is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -20,17 +20,18 @@ #include -#include +#include -bool loadConfig(config_type * config , const char * config_file) { +bool loadConfig(config_type * config , const char * config_file , config_type * config_compiler) { bool OK = false; - ext_cmd_type * cmd = ext_cmd_config_alloc( config , config_file); + workflow_job_type * cmd = workflow_job_config_alloc( "NAME" , config , config_file); if (cmd != NULL) { OK = true; - ext_cmd_free( cmd ); + workflow_job_update_config_compiler( cmd , config_compiler ); + workflow_job_free( cmd ); } return OK; @@ -41,16 +42,18 @@ bool loadConfig(config_type * config , const char * config_file) { int main( int argc , char ** argv) { int status = 0; { - config_type * config = ext_cmd_alloc_config(); + config_type * config = workflow_job_alloc_config(); + config_type * config_compiler = config_alloc(); int iarg; bool OK = true; for (iarg = 1; iarg < argc; iarg++) - OK = OK && loadConfig( config , argv[iarg]); + OK = OK && loadConfig( config , argv[iarg] , config_compiler); if (!OK) status = 1; + config_free(config_compiler); config_free(config); } exit( status ); diff --git a/ThirdParty/Ert/devel/libjob_queue/tests/job_lsb.c b/ThirdParty/Ert/devel/libjob_queue/tests/job_lsb.c new file mode 100644 index 0000000000..efd340ce4a --- /dev/null +++ b/ThirdParty/Ert/devel/libjob_queue/tests/job_lsb.c @@ -0,0 +1,47 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'job_lsb.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include + +#include + +#include + +/* + This test should ideally be run twice in two different environments; + with and without dlopen() access to the lsf libraries. +*/ + +int main( int argc , char ** argv) { + lsb_type * lsb = lsb_alloc(); + + test_assert_not_NULL( lsb ); + if (!lsb_ready(lsb)) { + const stringlist_type * error_list = lsb_get_error_list( lsb ); + stringlist_fprintf(error_list , "\n", stdout); + } + + if (dlopen( "libbat.so" , RTLD_NOW | RTLD_GLOBAL)) + test_assert_true( lsb_ready( lsb )); + else + test_assert_false( lsb_ready( lsb )); + + lsb_free( lsb ); + exit(0); +} diff --git a/ThirdParty/Ert/devel/libjob_queue/tests/job_lsf_submit_test.c b/ThirdParty/Ert/devel/libjob_queue/tests/job_lsf_submit_test.c index 143cb5be81..42ce02fcbe 100644 --- a/ThirdParty/Ert/devel/libjob_queue/tests/job_lsf_submit_test.c +++ b/ThirdParty/Ert/devel/libjob_queue/tests/job_lsf_submit_test.c @@ -21,15 +21,14 @@ #include #include -//#include +#include #include void test_submit(lsf_driver_type * driver , const char * server , const char * bsub_cmd , const char * bjobs_cmd , const char * bkill_cmd , const char * cmd) { - if (server != NULL) - lsf_driver_set_option(driver , LSF_SERVER , server ); + lsf_driver_set_option(driver , LSF_SERVER , server ); if (bsub_cmd != NULL) lsf_driver_set_option(driver , LSF_BSUB_CMD , server ); @@ -75,11 +74,7 @@ int main( int argc , char ** argv) { int iarg; for (iarg = 0; iarg < stringlist_get_size( server_list ); iarg++) { const char * server = stringlist_iget( server_list , iarg ); - - if (strcmp(server , "NULL") == 0) - test_submit(driver , NULL , NULL , NULL , NULL , argv[1]); - else - test_submit(driver , server , NULL , NULL , NULL , argv[1]); + test_submit(driver , server , NULL , NULL , NULL , argv[1]); } stringlist_free( server_list ); diff --git a/ThirdParty/Ert/devel/libjob_queue/tests/job_lsf_test.c b/ThirdParty/Ert/devel/libjob_queue/tests/job_lsf_test.c index b858590b8b..3972d671b1 100644 --- a/ThirdParty/Ert/devel/libjob_queue/tests/job_lsf_test.c +++ b/ThirdParty/Ert/devel/libjob_queue/tests/job_lsf_test.c @@ -18,36 +18,36 @@ #include #include -//#include #include +#include + #include +#include void test_option(lsf_driver_type * driver , const char * option , const char * value) { - if (!lsf_driver_set_option( driver , option , value)) - exit(1); - - if (strcmp( lsf_driver_get_option( driver , option) , value) != 0) - exit(1); + test_assert_true( lsf_driver_set_option( driver , option , value)); + test_assert_string_equal(lsf_driver_get_option( driver , option) , value); } void test_server(lsf_driver_type * driver , const char * server, lsf_submit_method_enum submit_method) { lsf_driver_set_option(driver , LSF_SERVER , server ); - if (lsf_driver_get_submit_method( driver ) != submit_method) - exit(1); + test_assert_true( lsf_driver_get_submit_method( driver ) == submit_method ); } void test_status(int lsf_status , job_status_type job_status) { - if (lsf_driver_convert_status( lsf_status ) != job_status) { - printf("Error converting integer status:%d \n",lsf_status); - exit(1); - } + test_assert_true( lsf_driver_convert_status( lsf_status ) == job_status); } +/* + This test should ideally be run twice in two different environments; + with and without dlopen() access to the lsf libraries. +*/ + int main( int argc , char ** argv) { lsf_driver_type * driver = lsf_driver_alloc(); @@ -59,14 +59,27 @@ int main( int argc , char ** argv) { test_option( driver , LSF_BSUB_CMD , "bsub"); printf("Options OK\n"); - test_server( driver , NULL , LSF_SUBMIT_INTERNAL ); - test_server( driver , "LoCaL" , LSF_SUBMIT_LOCAL_SHELL ); - test_server( driver , "LOCAL" , LSF_SUBMIT_LOCAL_SHELL ); - test_server( driver , "XLOCAL" , LSF_SUBMIT_REMOTE_SHELL ); - test_server( driver , NULL , LSF_SUBMIT_INTERNAL ); - test_server( driver , "be-grid01" , LSF_SUBMIT_REMOTE_SHELL ); - printf("Servers OK\n"); + { + + lsf_submit_method_enum submit_NULL; + lsb_type * lsb = lsb_alloc(); + if (lsb_ready(lsb)) + submit_NULL = LSF_SUBMIT_INTERNAL; + else + submit_NULL = LSF_SUBMIT_LOCAL_SHELL; + + test_server( driver , NULL , submit_NULL ); + test_server( driver , "LoCaL" , LSF_SUBMIT_LOCAL_SHELL ); + test_server( driver , "LOCAL" , LSF_SUBMIT_LOCAL_SHELL ); + test_server( driver , "XLOCAL" , LSF_SUBMIT_REMOTE_SHELL ); + test_server( driver , NULL , submit_NULL ); + test_server( driver , "NULL" , submit_NULL ); + test_server( driver , "be-grid01" , LSF_SUBMIT_REMOTE_SHELL ); + printf("Servers OK\n"); + + lsb_free( lsb ); + } test_status( JOB_STAT_PEND , JOB_QUEUE_PENDING ); test_status( JOB_STAT_PSUSP , JOB_QUEUE_RUNNING ); test_status( JOB_STAT_USUSP , JOB_QUEUE_RUNNING ); @@ -77,7 +90,7 @@ int main( int argc , char ** argv) { test_status( JOB_STAT_EXIT , JOB_QUEUE_EXIT ); test_status( JOB_STAT_UNKWN , JOB_QUEUE_EXIT ); test_status( 192 , JOB_QUEUE_DONE ); - printf("Status OK \n"); + exit(0); } diff --git a/ThirdParty/Ert/devel/libjob_queue/tests/job_queue_test.c b/ThirdParty/Ert/devel/libjob_queue/tests/job_queue_test.c new file mode 100644 index 0000000000..b49edd7d6b --- /dev/null +++ b/ThirdParty/Ert/devel/libjob_queue/tests/job_queue_test.c @@ -0,0 +1,40 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'job_queue_test.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include + +#include + +#include +#include + +#include +#include +#include + + + +int main( int argc , char ** argv) { + job_queue_type * queue = job_queue_alloc( 10 , "OK" , "ERROR"); + queue_driver_type * driver = queue_driver_alloc( LSF_DRIVER ); + test_assert_false( job_queue_has_driver( queue )); + + job_queue_set_driver( queue , driver ); + test_assert_true( job_queue_has_driver( queue )); + exit(0); +} diff --git a/ThirdParty/Ert/devel/libjob_queue/tests/job_workflow_test.c b/ThirdParty/Ert/devel/libjob_queue/tests/job_workflow_test.c new file mode 100644 index 0000000000..a7b21a7bdb --- /dev/null +++ b/ThirdParty/Ert/devel/libjob_queue/tests/job_workflow_test.c @@ -0,0 +1,116 @@ +/* + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'job_workflow_test.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 +#include +#include +#include + +#include +#include + +#include + +#include +#include +#include + + +void create_workflow( const char * workflow_file , const char * tmp_file , int value) { + FILE * stream = util_fopen( workflow_file , "w"); + fprintf(stream , "CREATE_FILE %s %d\n" , tmp_file , value); + fprintf(stream , "READ_FILE %s\n" , tmp_file ); + fclose( stream ); + + printf("Have created:%s \n",workflow_file ); +} + + +void read_file( void * self , const stringlist_type * args) { + printf("Running read_file \n"); + int * value = (int *) self; + FILE * stream = util_fopen(stringlist_iget(args , 0 ) , "r"); + fscanf(stream , "%d" , value ); + fclose( stream ); +} + + +static void create_exworkflow( const char * workflow , const char * bin_path) +{ + FILE * stream = util_fopen( workflow , "w"); + fprintf(stream , "EXECUTABLE %s/create_file\n" , bin_path); + fprintf(stream , "ARG_TYPE 1 INT\n"); + fprintf(stream , "MIN_ARG 2\n"); + fprintf(stream , "MAX_ARG 2\n"); + fclose(stream); +} + + +int main( int argc , char ** argv) { +#ifdef ERT_LINUX + const char * exworkflow = "/tmp/xflow"; +#endif + + const char * bin_path = argv[1]; + const char * internal_workflow = argv[2]; + create_exworkflow( exworkflow , bin_path ); + { + + int int_value = rand(); + int read_value = 100; + workflow_joblist_type * joblist = workflow_joblist_alloc(); + + if (!workflow_joblist_add_job_from_file( joblist , "CREATE_FILE" , exworkflow)) { + remove( exworkflow ); + test_error_exit("Loading job CREATE_FILE failed\n"); + } else + remove( exworkflow ); + + if (!workflow_joblist_add_job_from_file( joblist , "READ_FILE" , internal_workflow)) + test_error_exit("Loading job READ_FILE failed\n"); + + { + config_type * workflow_compiler = workflow_joblist_get_compiler( joblist ); + + if (config_get_schema_size( workflow_compiler ) != 2) + test_error_exit("Config compiler - wrong size \n"); + } + + + { + const char * workflow_file = "/tmp/workflow"; + const char * tmp_file = "/tmp/fileX"; + workflow_type * workflow; + + create_workflow( workflow_file , tmp_file , int_value ); + workflow = workflow_alloc(workflow_file , joblist ); + unlink( workflow_file ); + + if (!workflow_run( workflow , &read_value , false , NULL)) { + config_type * workflow_compiler = workflow_joblist_get_compiler( joblist ); + config_fprintf_errors( workflow_compiler , true ,stdout); + unlink( tmp_file ); + test_error_exit("Workflow did not run\n"); + } + unlink( tmp_file ); + } + workflow_joblist_free( joblist ); + if (int_value != read_value) + test_error_exit("Wrong numeric value read back \n"); + } + exit(0); +} diff --git a/ThirdParty/Ert/devel/libplot/include/ert/plot/plot_dataset.h b/ThirdParty/Ert/devel/libplot/include/ert/plot/plot_dataset.h index 98a47ebb3f..bd9447141a 100644 --- a/ThirdParty/Ert/devel/libplot/include/ert/plot/plot_dataset.h +++ b/ThirdParty/Ert/devel/libplot/include/ert/plot/plot_dataset.h @@ -112,6 +112,7 @@ double * plot_dataset_get_vector_x1(const plot_dataset_type * d); double * plot_dataset_get_vector_y1(const plot_dataset_type * d); double * plot_dataset_get_vector_x2(const plot_dataset_type * d); double * plot_dataset_get_vector_y2(const plot_dataset_type * d); +int plot_dataset_get_size( const plot_dataset_type * dataset ); /*****************************************************************/ /* Functions for actually adding data to the dataset. */ diff --git a/ThirdParty/Ert/devel/libplot/src/CMakeLists.txt b/ThirdParty/Ert/devel/libplot/src/CMakeLists.txt index 6d0bb9130c..cfa0e164a5 100644 --- a/ThirdParty/Ert/devel/libplot/src/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libplot/src/CMakeLists.txt @@ -7,8 +7,9 @@ add_library( plot ${LIBRARY_TYPE} ${source_files} ) target_link_libraries( plot ert_util ${PLPLOT_LIBRARY} ) set_target_properties( plot PROPERTIES VERSION 1.0 SOVERSION 1.0 ) #----------------------------------------------------------------- -install(TARGETS plot DESTINATION ${CMAKE_INSTALL_LIBDIR}) -foreach(header ${header_files}) - install(FILES ../include/ert/plot/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/plot) -endforeach() - +if (INSTALL_ERT) + install(TARGETS plot DESTINATION ${CMAKE_INSTALL_LIBDIR}) + foreach(header ${header_files}) + install(FILES ../include/ert/plot/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/plot) + endforeach() +endif() diff --git a/ThirdParty/Ert/devel/librms/applications/CMakeLists.txt b/ThirdParty/Ert/devel/librms/applications/CMakeLists.txt index 4172084d3c..8ed1bafa79 100644 --- a/ThirdParty/Ert/devel/librms/applications/CMakeLists.txt +++ b/ThirdParty/Ert/devel/librms/applications/CMakeLists.txt @@ -15,9 +15,11 @@ foreach(prog ${program_list}) set (destination bin) endif() - install(TARGETS ${prog} DESTINATION ${destination}) - if (INSTALL_GROUP) - install(CODE "EXECUTE_PROCESS(COMMAND chgrp ${INSTALL_GROUP} ${destination}/${prog})") - install(CODE "EXECUTE_PROCESS(COMMAND chmod g+w ${destination}/${prog})") + if (INSTALL_ERT) + install(TARGETS ${prog} DESTINATION ${destination}) + if (INSTALL_GROUP) + install(CODE "EXECUTE_PROCESS(COMMAND chgrp ${INSTALL_GROUP} ${destination}/${prog})") + install(CODE "EXECUTE_PROCESS(COMMAND chmod g+w ${destination}/${prog})") + endif() endif() endforeach() diff --git a/ThirdParty/Ert/devel/librms/src/CMakeLists.txt b/ThirdParty/Ert/devel/librms/src/CMakeLists.txt index 0eb80e4871..bba790f2d5 100644 --- a/ThirdParty/Ert/devel/librms/src/CMakeLists.txt +++ b/ThirdParty/Ert/devel/librms/src/CMakeLists.txt @@ -5,9 +5,10 @@ add_library( rms ${LIBRARY_TYPE} ${source_files} ) set_target_properties( rms PROPERTIES VERSION 1.0 SOVERSION 1.0 ) #----------------------------------------------------------------- -install(TARGETS rms DESTINATION ${CMAKE_INSTALL_LIBDIR}) -foreach(header ${header_files}) - install(FILES ../include/ert/rms/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/rms) -endforeach() - +if (INSTALL_ERT) + install(TARGETS rms DESTINATION ${CMAKE_INSTALL_LIBDIR}) + foreach(header ${header_files}) + install(FILES ../include/ert/rms/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/rms) + endforeach() +endif() diff --git a/ThirdParty/Ert/devel/libsched/applications/CMakeLists.txt b/ThirdParty/Ert/devel/libsched/applications/CMakeLists.txt index 7dc2c1b50d..3416f7625b 100644 --- a/ThirdParty/Ert/devel/libsched/applications/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libsched/applications/CMakeLists.txt @@ -17,9 +17,11 @@ foreach(prog ${program_list}) set (destination bin) endif() - install(TARGETS ${prog} DESTINATION ${destination}) - if (INSTALL_GROUP) - install(CODE "EXECUTE_PROCESS(COMMAND chgrp ${INSTALL_GROUP} ${destination}/${prog})") - install(CODE "EXECUTE_PROCESS(COMMAND chmod g+w ${destination}/${prog})") + if (INSTALL_ERT) + install(TARGETS ${prog} DESTINATION ${destination}) + if (INSTALL_GROUP) + install(CODE "EXECUTE_PROCESS(COMMAND chgrp ${INSTALL_GROUP} ${destination}/${prog})") + install(CODE "EXECUTE_PROCESS(COMMAND chmod g+w ${destination}/${prog})") + endif() endif() endforeach() diff --git a/ThirdParty/Ert/devel/libsched/src/CMakeLists.txt b/ThirdParty/Ert/devel/libsched/src/CMakeLists.txt index 2e0ad4c657..ab88ff6800 100644 --- a/ThirdParty/Ert/devel/libsched/src/CMakeLists.txt +++ b/ThirdParty/Ert/devel/libsched/src/CMakeLists.txt @@ -12,10 +12,11 @@ set_target_properties( sched PROPERTIES VERSION 1.0 SOVERSION 1.0 ) target_link_libraries( sched ert_util ecl) #----------------------------------------------------------------- -install(TARGETS sched DESTINATION ${CMAKE_INSTALL_LIBDIR}) -foreach(header ${header_files}) - install(FILES ../include/ert/sched/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/sched) -endforeach() - +if (INSTALL_ERT) + install(TARGETS sched DESTINATION ${CMAKE_INSTALL_LIBDIR}) + foreach(header ${header_files}) + install(FILES ../include/ert/sched/${header} DESTINATION ${CMAKE_INSTALL_PREFIX}/include/ert/sched) + endforeach() +endif() diff --git a/ThirdParty/Ert/devel/libsched/src/history.c b/ThirdParty/Ert/devel/libsched/src/history.c index 2058691dd7..5c3f155b18 100644 --- a/ThirdParty/Ert/devel/libsched/src/history.c +++ b/ThirdParty/Ert/devel/libsched/src/history.c @@ -135,11 +135,10 @@ history_type * history_alloc_from_refcase(const ecl_sum_type * refcase , bool us -int history_get_last_restart(const history_type * history) -{ +int history_get_last_restart(const history_type * history) { if (history->refcase != NULL) return ecl_sum_get_last_report_step( history->refcase); - else + else return sched_history_get_last_history( history->sched_history ); } diff --git a/ThirdParty/Ert/devel/libsched/src/sched_kw_compdat.c b/ThirdParty/Ert/devel/libsched/src/sched_kw_compdat.c index 54341a4b26..f4bd8101cc 100644 --- a/ThirdParty/Ert/devel/libsched/src/sched_kw_compdat.c +++ b/ThirdParty/Ert/devel/libsched/src/sched_kw_compdat.c @@ -129,7 +129,7 @@ static well_dir_type comp_get_well_dir_from_string(const char * well_dir) { else if (strcmp(well_dir , WELL_DIR_Y_STRING) == 0) return Y; else if (strcmp(well_dir , WELL_DIR_Z_STRING) == 0) - return X; + return Z; else if (strcmp(well_dir , WELL_DIR_FX_STRING) == 0) return FX; else if (strcmp(well_dir , WELL_DIR_FY_STRING) == 0) diff --git a/ThirdParty/Ert/devel/python/ert/config/config_enums.py b/ThirdParty/Ert/devel/python/ert/config/config_enums.py new file mode 100644 index 0000000000..199c16dfd0 --- /dev/null +++ b/ThirdParty/Ert/devel/python/ert/config/config_enums.py @@ -0,0 +1,25 @@ +# Copyright (C) 2012 Statoil ASA, Norway. +# +# The file 'config.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import libconfig +from ert.cwrap.cenum import create_enum + + +# config_item_types from config_schema_item.h +create_enum( libconfig.lib , "config_schema_item_type_enum_iget" , "config_types_enum" , globals()) + +# config_item_types from config_schema_item.h +create_enum( libconfig.lib , "config_schema_item_unrecognized_enum_iget" , "config_unrecognized_enum" , name_space = globals()) diff --git a/ThirdParty/Ert/devel/python/ert/config/config_parser.py b/ThirdParty/Ert/devel/python/ert/config/config_parser.py new file mode 100644 index 0000000000..d3a7477b93 --- /dev/null +++ b/ThirdParty/Ert/devel/python/ert/config/config_parser.py @@ -0,0 +1,47 @@ +# Copyright (C) 2012 Statoil ASA, Norway. +# +# The file 'config_parser.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + + + +import ctypes +from ert.cwrap.cwrap import * +from ert.cwrap.cclass import CClass +from config_enums import * + +class ConfigParser(CClass): + + def __init__(self): + c_ptr = cfunc.alloc() + self.init_cobj( c_ptr , cfunc.free ) + + + def parse(self , filename , comment_string = "--" , include_kw = "INCLUDE" , define_kw = None , unrecognized = CONFIG_UNRECOGNIZED_WARN , validate = True): + return cfunc.parse(self , filename , comment_string , include_kw , define_kw , unrecognized , validate) + + + def add(self , kw , required = False): + cfunc.add_schema_item( self , kw , required ) + + +################################################################# + +cwrapper = CWrapper( libconfig.lib ) +cwrapper.registerType( "config" , ConfigParser ) +cfunc = CWrapperNameSpace("config") +cfunc.alloc = cwrapper.prototype("c_void_p config_alloc()") +cfunc.free = cwrapper.prototype("void config_free( config )") +cfunc.parse = cwrapper.prototype("bool config_parse( config , char* , char* , char* , char*, int , bool)") +cfunc.add_schema_item = cwrapper.prototype("bool config_add_schema_item( config , char* , bool)") diff --git a/ThirdParty/Ert/devel/python/python/CMakeLists.txt b/ThirdParty/Ert/devel/python/python/CMakeLists.txt index 5c2cc08914..5dbe86acad 100644 --- a/ThirdParty/Ert/devel/python/python/CMakeLists.txt +++ b/ThirdParty/Ert/devel/python/python/CMakeLists.txt @@ -1,2 +1,2 @@ -set(PYTHON_INSTALL_PREFIX "/python") +set(PYTHON_INSTALL_PREFIX "python") add_subdirectory( ert ) diff --git a/ThirdParty/Ert/devel/python/python/ert/config/CMakeLists.txt b/ThirdParty/Ert/devel/python/python/ert/config/CMakeLists.txt index e1749d5f3e..50bca4e099 100644 --- a/ThirdParty/Ert/devel/python/python/ert/config/CMakeLists.txt +++ b/ThirdParty/Ert/devel/python/python/ert/config/CMakeLists.txt @@ -1 +1 @@ -add_python_target(python_config ${PYTHON_INSTALL_PREFIX}/ert/config "config;__init__;libconfig") +add_python_target(python_config ${PYTHON_INSTALL_PREFIX}/ert/config "config;__init__;libconfig;config_enums;config_parser") diff --git a/ThirdParty/Ert/devel/python/python/ert/config/config.py b/ThirdParty/Ert/devel/python/python/ert/config/config.py index 256bca20d6..cc5a0a1458 100644 --- a/ThirdParty/Ert/devel/python/python/ert/config/config.py +++ b/ThirdParty/Ert/devel/python/python/ert/config/config.py @@ -1 +1,20 @@ +# Copyright (C) 2012 Statoil ASA, Norway. +# +# The file 'config.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. import libconfig + +from config_enums import * +from config_parser import ConfigParser , SchemaItem , ContentItem , ContentNode + diff --git a/ThirdParty/Ert/devel/python/python/ert/config/config_enums.py b/ThirdParty/Ert/devel/python/python/ert/config/config_enums.py new file mode 100644 index 0000000000..da30d1cf9b --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/config/config_enums.py @@ -0,0 +1,21 @@ +# Copyright (C) 2013 Statoil ASA, Norway. +# +# The file 'config_enums.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. +from ert.cwrap.cenum import create_enum +import libconfig + +create_enum( libconfig.lib , "config_schema_item_type_enum_iget" , "content_type" , name_space = globals()) + +create_enum( libconfig.lib , "config_schema_item_unrecognized_enum_iget" , "unrecognized" , name_space = globals()) diff --git a/ThirdParty/Ert/devel/python/python/ert/config/config_parser.py b/ThirdParty/Ert/devel/python/python/ert/config/config_parser.py new file mode 100644 index 0000000000..3b03978494 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/config/config_parser.py @@ -0,0 +1,165 @@ +# Copyright (C) 2013 Statoil ASA, Norway. +# +# The file 'config_parser.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import os.path +import libconfig +from ert.cwrap.cwrap import * +from ert.cwrap.cclass import CClass +import config_enums + + +class SchemaItem(CClass): + + def __init__(self , keyword , required = False): + c_ptr = cfunc.schema_alloc( keyword , required ) + self.init_cref( c_ptr , cfunc.schema_free) + + + @classmethod + def wrap(cls , c_ptr , parent): + obj = object.__new__( cls ) + obj.init_cref( c_ptr , parent ) + return obj + + + def iget_type( self , index ): + return cfunc.schema_iget_type( self , index ) + + def iset_type( self , index , type ): + cfunc.schema_iset_type( self , index , type ) + + def set_argc_minmax(self , min , max): + cfunc.schema_set_argc_minmax( self , min , max ) + +#----------------------------------------------------------------- + + +class ContentItem(CClass): + # Not possible to create new python instances of this class + + @classmethod + def wrap(cls , c_ptr , parent): + obj = object.__new__( cls ) + obj.init_cref( c_ptr , parent ) + return obj + + def __len__(self): + return cfunc.content_size( self ) + + + def __getitem__(self , index): + if isinstance(index , int): + if index >= 0 and index < self.__len__(): + c_ptr = cfunc.iget_content_node( self , index ) + return ContentNode.wrap( c_ptr , self ) + else: + raise IndexError + else: + raise ValueError("[] operator must have integer index") + + + + +#----------------------------------------------------------------- + + + +class ContentNode(CClass): + # Not possible to create new python instances of this class + + @classmethod + def wrap(cls , c_ptr , parent): + obj = object.__new__( cls ) + obj.init_cref( c_ptr , parent ) + return obj + + def __len__(self): + return cfunc.content_node_size( self ) + + def __getitem__(self , index): + if isinstance(index , int): + if index >= 0 and index < self.__len__(): + return cfunc.content_node_iget( self , index ) + else: + raise IndexError + else: + raise ValueError("[] operator must have integer index") + + def content(self , sep = " "): + return cfunc.content_full_string(self , sep) + + + +#----------------------------------------------------------------- + + +class ConfigParser(CClass): + + def __init__(self): + c_ptr = cfunc.config_alloc() + self.init_cobj(c_ptr , cfunc.config_free ) + + + def add(self , keyword , required = False): + c_ptr = cfunc.add( self , keyword , required ) + schema_item = SchemaItem.wrap(c_ptr , self) + return schema_item + + + def parse( self , config_file , comment_string = "--" , include_kw = "INCLUDE" , define_kw = "DEFINE" , unrecognized = config_enums.unrecognized.CONFIG_UNRECOGNIZED_WARN , validate = True): + if os.path.exists( config_file ): + return cfunc.parse( self , config_file , comment_string , include_kw , define_kw , unrecognized , validate ) + else: + raise IOError("File: %s does not exists") + + + def __getitem__(self , keyword): + if cfunc.has_content(self , keyword): + c_ptr = cfunc.get_content(self , keyword ) + return ContentItem.wrap( c_ptr , self ) + else: + return None + +#----------------------------------------------------------------- + + +cwrapper = CWrapper( libconfig.lib ) +cwrapper.registerType( "config_parser" , ConfigParser ) +cwrapper.registerType( "schema_item" , SchemaItem ) +cwrapper.registerType( "content_item" , ContentItem ) +cwrapper.registerType( "content_node" , ContentNode ) + +cfunc = CWrapperNameSpace("config") + +cfunc.add = cwrapper.prototype("c_void_p config_add_schema_item( config_parser , char* , bool)") +cfunc.config_alloc = cwrapper.prototype("c_void_p config_alloc( )") +cfunc.config_free = cwrapper.prototype("void config_free( config_parser )") +cfunc.parse = cwrapper.prototype("bool config_parse( config_parser , char* , char* , char* , char* , int , bool )") +cfunc.has_content = cwrapper.prototype("bool config_has_content_item( config_parser , char*) ") +cfunc.get_content = cwrapper.prototype("c_void_p config_get_content_item( config_parser , char*) ") + +cfunc.schema_alloc = cwrapper.prototype("c_void_p config_schema_item_alloc( char* , bool )") +cfunc.schema_free = cwrapper.prototype("void config_schema_item_free( schema_item )") +cfunc.schema_iget_type = cwrapper.prototype("int config_schema_item_iget_type( schema_item ,int)") +cfunc.schema_iset_type = cwrapper.prototype("void config_schema_item_iset_type( schema_item , int , int)") +cfunc.schema_set_argc_minmax = cwrapper.prototype("void config_schema_item_set_argc_minmax( schema_item , int , int)") + +cfunc.content_size = cwrapper.prototype("int config_content_item_get_size( content_item )") +cfunc.iget_content_node = cwrapper.prototype("int config_content_item_iget_node( content_item , int)") +cfunc.content_node_iget = cwrapper.prototype("char* config_content_node_iget( content_node , int)") +cfunc.content_node_size = cwrapper.prototype("int config_content_node_get_size( content_node )") +cfunc.content_full_string = cwrapper.prototype("char* config_content_node_get_full_string( content_node , char* )") + diff --git a/ThirdParty/Ert/devel/python/python/ert/cwrap/clib.py b/ThirdParty/Ert/devel/python/python/ert/cwrap/clib.py index ce3b36248e..f772ab6b11 100644 --- a/ThirdParty/Ert/devel/python/python/ert/cwrap/clib.py +++ b/ThirdParty/Ert/devel/python/python/ert/cwrap/clib.py @@ -93,7 +93,7 @@ def ert_load( *lib_list ): return __load__(lib_list , True ) except ImportError: # Try again - ignoring the ert_lib_path setting. - return load( lib_list ) + return load( *lib_list ) else: # The ert_lib_path variable has not been set; just try a normal load. - return load( lib_list ) + return load( *lib_list ) diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/CMakeLists.txt b/ThirdParty/Ert/devel/python/python/ert/ecl/CMakeLists.txt index db209125ed..7966d30103 100644 --- a/ThirdParty/Ert/devel/python/python/ert/ecl/CMakeLists.txt +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/CMakeLists.txt @@ -1,2 +1,5 @@ -set(PYTHON_INSTALL_PREFIX "/python/ert/ecl/") -add_python_target(python_ecl ${PYTHON_INSTALL_PREFIX} "ecl_case;ecl_default;ecl_file;ecl_grav_calc;ecl_grav;ecl_grid;ecl_kw;ecl;ecl_queue;ecl_region;ecl_rft;ecl_subsidence;ecl_sum;ecl_util;fortio;__init__;libecl") +add_python_target(python_ecl ${PYTHON_INSTALL_PREFIX}/ert/ecl "ecl_case;ecl_default;ecl_file;ecl_grav_calc;ecl_grav;ecl_grid;ecl_kw;ecl;ecl_queue;ecl_region;ecl_rft;ecl_subsidence;ecl_sum;ecl_util;fortio;__init__;libecl") + +if (EXISTS "ecl_local.py") + add_python_target( python_ecl_local ${PYTHON_INSTALL_PREFIX}/ert/ecl "ecl_local") +endif() diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl.py b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl.py index 55fbb6dc1d..8d4847e8c6 100644 --- a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl.py +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl.py @@ -51,6 +51,7 @@ import ecl_default + diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_case.py b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_case.py index 747070cbb4..5c29c919ad 100644 --- a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_case.py +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_case.py @@ -26,7 +26,6 @@ import ecl_grid import ecl_rft import ecl_default import ecl_util -import ert.job_queue.driver as queue_driver import warnings class EclCase: @@ -137,10 +136,10 @@ class EclCase: def run( self , - ecl_cmd = ecl_default.default.ecl_cmd , - ecl_version = ecl_default.default.ecl_version , + ecl_cmd = None, + ecl_version = None, driver = None , - driver_type = ecl_default.default.driver_type, + driver_type = None, driver_options = None, blocking = False ): """ @@ -190,8 +189,20 @@ class EclCase: you might want use an EclQueue() and the submit() method instead, in particular if you are running locally. """ + import ert.job_queue.driver as queue_driver + num_cpu = ecl_util.get_num_cpu( self.datafile ) argv = [ecl_version , self.datafile , num_cpu] + + if ecl_cmd is None: + ecl_cmd = ecl_default.default.ecl_cmd + + if driver_type is None: + driver_type = ecl_default.default.driver_type + + if ecl_version is None: + ecl_version = ecl_default.default.ecl_version + if driver is None: if driver_options is None: driver_options = ecl_default.default.driver_options[ driver_type ] diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_file.py b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_file.py index 9b930b2e39..2853089e47 100644 --- a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_file.py +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_file.py @@ -36,10 +36,12 @@ implementation from the libecl library. RestartFile class, there is some specialized functionality. """ +import os.path import datetime import ctypes import types import libecl +import re from ert.cwrap.cwrap import * from ert.cwrap.cclass import CClass @@ -102,7 +104,7 @@ class EclFile(CClass): print "OK - file contains report step 20" else: print "File does not contain report step 20" - + If you have already loaded the file into an EclFile instance you should use the has_report_step() method instead. """ @@ -133,18 +135,39 @@ class EclFile(CClass): obj = EclFile( filename ) return obj.has_sim_time( dtime ) + @property + def report_list(self): + report_steps = [] + try: + seqnum_list = self["SEQNUM"] + for s in seqnum_list: + report_steps.append( s[0] ) + except KeyError: + # OK - we did not have seqnum; that might be because this + # a non-unified restart file; or because this is not a + # restart file at all. + fname = self.name + matchObj = re.search("\.[XF](\d{4})$" , fname) + if matchObj: + report_steps.append( int(matchObj.group(1)) ) + else: + raise TypeError("Tried get list of report steps from file:%s - which is not a restart file" % fname) + + + return report_steps + @classmethod - def file_report_steps( cls , filename ): + def file_report_list( cls , filename ): """ Will identify the available report_steps from @filename. """ - report_steps = [] + file = EclFile( filename ) - for s in file["SEQNUM"]: - report_steps.append( s[0] ) - return report_steps + return file.report_list + + def __str__(self): return "EclFile: %s" % self.name @@ -563,9 +586,20 @@ class EclFile(CClass): INTEHEAD keyword. """ dates = [] - for index in range( self.num_named_kw( 'SEQNUM' )): - dates.append( self.iget_restart_sim_time( index )) + if self.has_kw('SEQNUM'): + for index in range( self.num_named_kw( 'SEQNUM' )): + dates.append( self.iget_restart_sim_time( index )) + else: + # This is a uber-hack; should export the ecl_rsthead + # object as ctypes structure. + intehead = self["INTEHEAD"][0] + year = intehead[66] + month = intehead[65] + day = intehead[64] + date = datetime.datetime( year , month , day ) + dates = [ date ] return dates + @property def dates( self ): @@ -617,7 +651,7 @@ class EclFile(CClass): """ return len( self["SEQNUM"] ) - + def has_sim_time( self , dtime ): """ diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_grid.py b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_grid.py index 7fb7ab7104..61148c1c13 100644 --- a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_grid.py +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_grid.py @@ -680,7 +680,7 @@ class EclGrid(CClass): cfunc.fwrite_GRID( self , filename ) - def write_grdecl( self , ecl_kw , pyfile , default_value = 0): + def write_grdecl( self , ecl_kw , pyfile , special_header = None , default_value = 0): """ Writes an EclKW instance as an ECLIPSE grdecl formatted file. @@ -705,7 +705,7 @@ class EclGrid(CClass): if ecl_kw.size == self.nactive or ecl_kw.size == self.size: cfile = CFILE( pyfile ) - cfunc.fwrite_grdecl( self , ecl_kw , cfile , default_value ) + cfunc.fwrite_grdecl( self , ecl_kw , special_header , cfile , default_value ) else: raise ValueError("Keyword: %s has invalid size(%d), must be either nactive:%d or nx*ny*nz:%d" % (ecl_kw.name , ecl_kw.size , self.nactive , self.size)) @@ -760,7 +760,7 @@ cfunc.grid_value = cwrapper.prototype("double ecl_grid_get_pro cfunc.get_cell_volume = cwrapper.prototype("double ecl_grid_get_cell_volume1( ecl_grid , int )") cfunc.get_cell_thickness = cwrapper.prototype("double ecl_grid_get_cell_thickness1( ecl_grid , int )") cfunc.get_depth = cwrapper.prototype("double ecl_grid_get_cdepth1( ecl_grid , int )") -cfunc.fwrite_grdecl = cwrapper.prototype("void ecl_grid_grdecl_fprintf_kw( ecl_grid , ecl_kw , FILE , double)") +cfunc.fwrite_grdecl = cwrapper.prototype("void ecl_grid_grdecl_fprintf_kw( ecl_grid , ecl_kw , char* , FILE , double)") cfunc.load_column = cwrapper.prototype("void ecl_grid_get_column_property( ecl_grid , ecl_kw , int , int , double_vector)") cfunc.get_top = cwrapper.prototype("double ecl_grid_get_top2( ecl_grid , int , int )") cfunc.get_bottom = cwrapper.prototype("double ecl_grid_get_bottom2( ecl_grid , int , int )") diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_local.py b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_local.py new file mode 100644 index 0000000000..a2c6642432 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_local.py @@ -0,0 +1,72 @@ +import os +import socket +import sys +import ert.job_queue.driver as driver + +################################################################# +# Only a quite few of the Linux computers in Statoil are proper LSF +# nodes, in the sense that they can talk directly to the LSF +# demons. When using LSF from a computer which is not properly part of +# the LSF cluster you must first ssh to a node which can serve as LSF +# server, and then issue the LSF commands there. This is controlled by +# the LSF_SERVER option in the LSF driver. +# +# In this configuration file the LSF server to use is determined by +# using the two first characters from the name of the submitting host +# as a lookup key in the server_list dictionary. +# +# If your workstation has proper access to LSF you can set the +# environment variable LOCAL_LSF; in that case the lsf_server variable +# will be left at None and the LSF driver instance will issue the LSF +# commands directly at the calling host without going through ssh. +# +# Observe that the ssh-based scheme requires that you have +# passwordless login to the server used as lsf server. +################################################################# + +server_list = { "be" : "be-grid01.be.statoil.no", + "st" : "st-grid01.st.statoil.no", + "tr" : "tr-grid01.tr.statoil.no", + "stj" : "tr-grid01.tr.statoil.no", + "rio" : "rio-grid01.rio.statoil.no" } + + +def get_lsf_server(): + if os.getenv("LOCAL_LSF"): + # The user has set the LOCAL_LSF environment variable - + # signalling that she has access to a proper LSF node. + return None + else: + host = socket.gethostname() + host_prefix = host.split("-")[0] + lsf_server = server_list.get( host_prefix , None) + # This will silently return None if no appropriate LSF server + # is found. In that case things will blow up at a later stage + # if/when someone tries to use the invalid lsf server. + return lsf_server + + +# The command used to run ECLIPSE. The executable will be called with +# commandline arguments: version data_file num_cpu +ecl_cmd = "/project/res/etc/ERT/Scripts/run_eclipse.py" + +# The ECLIPSE version which will be used, by default. +ecl_version = "2010.2" + +# The resource request passed to the LSF server. In practice every god-damn compute node +# in Statoil will satisfy these needs, so it could just be left as None. +lsf_resource_request = "select[cs && x86_64Linux] rusage[ecl100v2000=1:duration=5]" + +lsf_queue = "normal" +rsh_command = "/usr/bin/ssh" + +driver_options = { driver.LSF_DRIVER : [("LSF_QUEUE" , lsf_queue), + ("LSF_RESOURCE" , lsf_resource_request), + ("LSF_SERVER" , get_lsf_server())], + driver.RSH_DRIVER : [("RSH_COMMAND" , rsh_command)], + driver.LOCAL_DRIVER : []} + +driver_type = driver.LSF_DRIVER + + + diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_queue.py b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_queue.py index 353ac148d2..3487dcd9a1 100644 --- a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_queue.py +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_queue.py @@ -45,10 +45,10 @@ import ecl_util class EclQueue( JobQueue ): def __init__(self , driver = None , - driver_type = default.driver_type, + driver_type = None, driver_options = None, - ecl_version = default.ecl_version , - ecl_cmd = default.ecl_cmd , + ecl_version = None, + ecl_cmd = None, max_running = 0, size = 0): @@ -145,6 +145,14 @@ class EclQueue( JobQueue ): the queue stay alive and continue managing jobs even after the main thread has exited - not yet :-( """ + if ecl_cmd is None: + ecl_cmd = ecl_default.default.ecl_cmd + + if driver_type is None: + driver_type = ecl_default.default.driver_type + + if ecl_version is None: + ecl_version = ecl_default.default.ecl_version self.ecl_version = ecl_version self.ecl_cmd = ecl_cmd diff --git a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_sum.py b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_sum.py index c3dff1fe0d..d687e329e2 100644 --- a/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_sum.py +++ b/ThirdParty/Ert/devel/python/python/ert/ecl/ecl_sum.py @@ -394,6 +394,117 @@ class EclSumVector: ################################################################# + +class EclSMSPECNode( CClass ): + """ + Small class with some meta information about a summary variable. + + The summary variables have different attributes, like if they + represent a total quantity, a rate or a historical quantity. These + quantities, in addition to the underlying values like WGNAMES, + KEYWORD and NUMS taken from the the SMSPEC file are stored in this + structure. + """ + def __new__(cls , c_ptr , parent): + if c_ptr: + obj = object.__new__( cls ) + obj.init_cref( c_ptr , parent ) + return obj + else: + return None + + @property + def is_total(self): + """ + Will check if the node corresponds to a total quantity. + + The question of whether a variable corresponds to a 'total' + quantity or not can be interesting for e.g. interpolation + purposes. The actual question whether a quantity is total or + not is based on a hardcoded list in smspec_node_set_flags() in + smspec_node.c; this list again is based on the tables 2.7 - + 2.11 in the ECLIPSE fileformat documentation. + """ + return cfunc.node_is_total( self ) + + @property + def is_rate(self): + """ + Will check if the variable in question is a rate variable. + + The conecpt of rate variabel is important (internally) when + interpolation values to arbitrary times. + """ + return cfunc.node_is_rate( self ) + + + @property + def is_historical(self): + """ + Checks if the key corresponds to a historical variable. + + The check is only based on the last character; all variables + ending with 'H' are considered historical. + """ + return cfunc.node_is_historical( self ) + + + @property + def unit(self): + """ + Returns the unit of this node as a string. + """ + return cfunc.node_unit( self ) + + @property + def wgname(self): + """ + Returns the WGNAME property for this node. + + Many variables do not have the WGNAME property, i.e. the field + related variables like FOPT and the block properties like + BPR:10,10,10. For these variables the function will return + None, and not the ECLIPSE dummy value: ":+:+:+:+". + """ + return cfunc.node_wgname(self) + + + @property + def keyword(self): + """ + Returns the KEYWORD property for this node. + + The KEYWORD property is the main classification property in + the ECLIPSE SMSPEC file. The properties of a variable can be + read from the KEWYORD value; see table 3.4 in the ECLIPSE file + format reference manual. + """ + return cfunc.node_keyword( self ) + + @property + def num(self): + """ + Returns the NUMS value for this keyword; or None. + + Many of the summary keywords have an integer stored in the + vector NUMS as an attribute, i.e. the block properties have + the global index of the cell in the nums vector. If the + variable in question makes use of the NUMS value this property + will return the value, otherwise it will return None: + + sum.smspec_node("FOPT").num => None + sum.smspec_node("BPR:1000").num => 1000 + """ + if cfunc.node_need_num( self ): + return cfunc.node_num(self) + else: + return None + + + + + + class EclSum( CClass ): def __new__( cls , load_case , join_string = ":" , include_restart = True): @@ -490,6 +601,7 @@ class EclSum( CClass ): return index_list + def wells( self , pattern = None ): """ Will return a list of all the well names in case. @@ -634,6 +746,13 @@ class EclSum( CClass ): """ return self.get_vector( key ) + + def check_sim_time( self , date): + """ + Will check if the input date is in the time span [sim_start , sim_end]. + """ + return cfunc.check_sim_time( self , ctime(date) ) + def get_interp( self , key , days = None , date = None): """ @@ -658,7 +777,7 @@ class EclSum( CClass ): else: raise ValueError("days:%s is outside range of simulation: [%g,%g]" % (days , self.first_day , self.sim_length)) elif date: - if cfunc.check_sim_time( self , ctime(date) ): + if self.check_sim_time( date ): return cfunc.get_general_var_from_sim_time( self , ctime(date) , key ) else: raise ValueError("date:%s is outside range of simulation data" % date) @@ -735,7 +854,6 @@ class EclSum( CClass ): raise ValueError("Must supply either days_list or date_list") return vector - def get_from_report( self , key , report_step ): """ @@ -751,11 +869,30 @@ class EclSum( CClass ): """ return cfunc.has_key( self, key ) + + def smspec_node( self , key ): + """ + Will return a EclSMSPECNode instance corresponding to @key. + + The returned EclSMPECNode instance can then be used to ask for + various properties of the variable; i.e. if it is a rate + variable, what is the unit, if it is a total variable and so + on. + """ + if self.has_key( key ): + c_ptr = cfunc.get_var_node( self , key ) + return EclSMSPECNode( c_ptr , self ) + else: + raise KeyError("Summary case does not have key:%s" % key) + + def unit(self , key): """ Will return the unit of @key. """ - return cfunc.get_unit( self , key ) + node = self.smspec_node( key ) + return node.unit + @property def case(self): @@ -1094,6 +1231,7 @@ class EclSum( CClass ): # registering the type map : ecl_kw <-> EclKW cwrapper = CWrapper( libecl.lib ) cwrapper.registerType( "ecl_sum" , EclSum ) +cwrapper.registerType( "smspec_node" , EclSMSPECNode ) # 3. Installing the c-functions used to manipulate ecl_kw instances. @@ -1142,3 +1280,16 @@ cfunc.get_report_time = cwrapper.prototype("time_t ecl_sum_get_r cfunc.fwrite_sum = cwrapper.prototype("void ecl_sum_fwrite(ecl_sum)") cfunc.set_case = cwrapper.prototype("void ecl_sum_set_case(ecl_sum, char*)") + +#----------------------------------------------------------------- +# smspec node related stuff + +cfunc.get_var_node = cwrapper.prototype("c_void_p ecl_sum_get_general_var_node(ecl_sum , char* )") +cfunc.node_is_total = cwrapper.prototype("bool smspec_node_is_total( smspec_node )") +cfunc.node_is_historical = cwrapper.prototype("bool smspec_node_is_historical( smspec_node )") +cfunc.node_is_rate = cwrapper.prototype("bool smspec_node_is_rate( smspec_node )") +cfunc.node_unit = cwrapper.prototype("char* smspec_node_get_unit( smspec_node )") +cfunc.node_wgname = cwrapper.prototype("char* smspec_node_get_wgname( smspec_node )") +cfunc.node_keyword = cwrapper.prototype("char* smspec_node_get_keyword( smspec_node )") +cfunc.node_num = cwrapper.prototype("int smspec_node_get_num( smspec_node )") +cfunc.node_need_num = cwrapper.prototype("bool smspec_node_need_nums( smspec_node )") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/analysis_config.py b/ThirdParty/Ert/devel/python/python/ert/enkf/analysis_config.py new file mode 100644 index 0000000000..8425919f67 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/analysis_config.py @@ -0,0 +1,65 @@ +# Copyright (C) 2012 Statoil ASA, Norway. +# +# The file 'analysis_config.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import ctypes +from ert.cwrap.cwrap import * +from ert.cwrap.cclass import CClass +from ert.util.tvector import * +from enkf_enum import * +import libenkf +class AnalysisConfig(CClass): + + def __init__(self , c_ptr = None): + self.owner = False + self.c_ptr = c_ptr + + + def __del__(self): + if self.owner: + cfunc.free( self ) + + + def has_key(self , key): + return cfunc.has_key( self ,key ) + + + +################################################################## + +cwrapper = CWrapper( libenkf.lib ) +cwrapper.registerType( "analysis_config" , AnalysisConfig ) + +# 3. Installing the c-functions used to manipulate ecl_kw instances. +# These functions are used when implementing the EclKW class, not +# used outside this scope. +cfunc = CWrapperNameSpace("analysis_config") + + +cfunc.free = cwrapper.prototype("void analysis_config_free( analysis_config )") +cfunc.get_rerun = cwrapper.prototype("int analysis_config_get_rerun( analysis_config )") +cfunc.set_rerun = cwrapper.prototype("void analysis_config_set_rerun analysis_config, bool)") +cfunc.get_rerun_start = cwrapper.prototype("int analysis_config_get_rerun_start( analysis_config )") +cfunc.set_rerun_start = cwrapper.prototype("void analysis_config_set_rerun_start( analysis_config, int)") +cfunc.get_log_path = cwrapper.prototype("char* analysis_config_get_log_path( analysis_config)") +cfunc.set_log_path = cwrapper.prototype("void analysis_config_set_log_path( analysis_config, char*)") +cfunc.get_alpha = cwrapper.prototype("double analysis_config_get_alpha(analysis_config)") +cfunc.set_alpha = cwrapper.prototype("void analysis_config_set_alpha(analysis_config, double)") +cfunc.get_merge_observations = cwrapper.prototype("bool analysis_config_get_merge_observations(analysis_config)") +cfunc.set_merge_observations = cwrapper.prototype("void analysis_config_set_merge_observations(analysis_config, int)") +cfunc.get_enkf_mode = cwrapper.prototype("int analysis_config_get_enkf_mode(analysis_config)") +cfunc.set_enkf_mode = cwrapper.prototype("void analysis_config_set_enkf_mode(analysis_config, int)") +cfunc.get_truncation = cwrapper.prototype("double analysis_config_get_truncation(analysis_config)") +cfunc.get_truncation = cwrapper.prototype("void analysis_config_set_truncation(analysis_config, double)") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/ecl_config.py b/ThirdParty/Ert/devel/python/python/ert/enkf/ecl_config.py new file mode 100644 index 0000000000..fffec1a3aa --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/ecl_config.py @@ -0,0 +1,65 @@ +# Copyright (C) 2012 Statoil ASA, Norway. +# +# The file 'ecl_config.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import ctypes +from ert.cwrap.cwrap import * +from ert.cwrap.cclass import CClass +from ert.util.tvector import * +from enkf_enum import * +import libenkf +class EclConfig(CClass): + + def __init__(self , c_ptr = None): + self.owner = False + self.c_ptr = c_ptr + + + def __del__(self): + if self.owner: + cfunc.free( self ) + + + def has_key(self , key): + return cfunc.has_key( self ,key ) + + + +################################################################## + +cwrapper = CWrapper( libenkf.lib ) +cwrapper.registerType( "ecl_config" , EclConfig ) + +# 3. Installing the c-functions used to manipulate ecl_kw instances. +# These functions are used when implementing the EclKW class, not +# used outside this scope. +cfunc = CWrapperNameSpace("ecl_config") + + +cfunc.free = cwrapper.prototype("void ecl_config_free( ecl_config )") +cfunc.get_eclbase = cwrapper.prototype("char* ecl_config_get_eclbase( ecl_config )") +cfunc.get_data_file = cwrapper.prototype("char* ecl_config_get_data_file(ecl_config)") +cfunc.get_gridfile = cwrapper.prototype("char* ecl_config_get_gridfile(ecl_config)") +cfunc.set_gridfile = cwrapper.prototype("void ecl_config_set_grid(ecl_config, char*)") +cfunc.get_schedule = cwrapper.prototype("char* ecl_config_get_schedule_file(ecl_config)") +cfunc.set_schedule = cwrapper.prototype("void ecl_config_set_schedule_file(ecl_config, char*)") +cfunc.get_init_section = cwrapper.prototype("char* ecl_config_get_init_section(ecl_config)") +cfunc.set_init_section = cwrapper.prototype("void ecl_config_set_init_section(ecl_config, char*)") +cfunc.get_refcase_name = cwrapper.prototype("char* ecl_config_get_refcase_name(ecl_config)") +cfunc.set_refcase_name = cwrapper.prototype("void ecl_config_load_refcase(ecl_config, char*)") +cfunc.get_static_kw_list = cwrapper.prototype("c_void_p ecl_config_get_static_kw_list(ecl_config)") +cfunc.clear_static_kw = cwrapper.prototype("void ecl_config_clear_static_kw(ecl_config)") +cfunc.add_static_kw = cwrapper.prototype("void ecl_config_add_static_kw(ecl_config, char*)") +cfunc.get_grid = cwrapper.prototype("c_void_p ecl_config_get_grid(ecl_config)") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_config_node.py b/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_config_node.py new file mode 100644 index 0000000000..0bca2c408b --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_config_node.py @@ -0,0 +1,62 @@ +# Copyright (C) 2012 Statoil ASA, Norway. +# +# The file 'enkf_config_node.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import ctypes +from ert.cwrap.cwrap import * +from ert.cwrap.cclass import CClass +from ert.util.tvector import * +from enkf_enum import * +import libenkf +class EnkfConfigNode(CClass): + + def __init__(self , c_ptr = None): + self.owner = False + self.c_ptr = c_ptr + + + def __del__(self): + if self.owner: + cfunc.free( self ) + + + def has_key(self , key): + return cfunc.has_key( self ,key ) + + + +################################################################## + +cwrapper = CWrapper( libenkf.lib ) +cwrapper.registerType( "enkf_config_node" , EnkfConfigNode ) + +# 3. Installing the c-functions used to manipulate ecl_kw instances. +# These functions are used when implementing the EclKW class, not +# used outside this scope. +cfunc = CWrapperNameSpace("enkf_config_node") + + +cfunc.free = cwrapper.prototype("void enkf_config_node_free( enkf_config_node )") +cfunc.get_impl_type = cwrapper.prototype("c_void_p enkf_config_node_get_impl_type(enkf_config_node)") +cfunc.get_ref = cwrapper.prototype("c_void_p enkf_config_node_get_ref(enkf_config_node)") +cfunc.is_valid = cwrapper.prototype("bool enkf_config_node_is_valid(enkf_config_node)") +cfunc.get_min_std_file = cwrapper.prototype("char* enkf_config_node_get_min_std_file(enkf_config_node)") +cfunc.get_enkf_outfile = cwrapper.prototype("char* enkf_config_node_get_enkf_outfile(enkf_config_node)") +cfunc.get_enkf_infile = cwrapper.prototype("char* enkf_config_node_get_enkf_infile(enkf_config_node)") +cfunc.update_gen_kw = cwrapper.prototype("void enkf_config_node_update_gen_kw(enkf_config_node, char*, char*, char*, char*, char*)") +cfunc.update_state_field = cwrapper.prototype("void enkf_config_node_update_state_field(enkf_config_node, int, double, double)") +cfunc.update_parameter_field = cwrapper.prototype("void enkf_config_node_update_parameter_field(enkf_config_node, char*, char*, char*, int, double, double, char*, char*)") +cfunc.update_general_field = cwrapper.prototype("void enkf_config_node_update_general_field(enkf_config_node, char*, char*, char*, char*, int, double, double, char*, char*, char*)") +cfunc.update_gen_data = cwrapper.prototype("void enkf_config_node_update_gen_data(enkf_config_node, int, int, char*, char*, char*, char*, char*, char*)") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_main.py b/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_main.py index c988054b85..57b4a319e5 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_main.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_main.py @@ -21,6 +21,17 @@ from ert.util.tvector import * from ert.job_queue.job_queue import JobQueue from enkf_enum import * import ens_config +import ecl_config +import analysis_config +import local_config +import model_config +import enkf_config_node +import gen_kw_config +import gen_data_config +import field_config +import enkf_obs +import plot_config +import site_config import libenkf import ert_local @@ -80,10 +91,39 @@ cwrapper.registerType( "enkf_main" , EnKFMain ) cfunc = CWrapperNameSpace("enkf_main") -cfunc.bootstrap = cwrapper.prototype("c_void_p enkf_main_bootstrap(char*, char*, bool)") -cfunc.free = cwrapper.prototype("void enkf_main_free( enkf_main )") -cfunc.run = cwrapper.prototype("void enkf_main_run( enkf_main , int , bool_vector , int , int , int)") -cfunc.ens_size = cwrapper.prototype("int enkf_main_get_ensemble_size( enkf_main )") -cfunc.get_ens_config = cwrapper.prototype("c_void_p enkf_main_get_ensemble_config( enkf_main )") -cfunc.set_verbose = cwrapper.prototype("void enkf_main_set_verbose( enkf_main , bool )") -cfunc.update = cwrapper.prototype("void enkf_main_UPDATE(enkf_main , int_vector)") +cfunc.bootstrap = cwrapper.prototype("c_void_p enkf_main_bootstrap(char*, char*, bool)") +cfunc.free = cwrapper.prototype("void enkf_main_free( enkf_main )") +cfunc.run = cwrapper.prototype("void enkf_main_run( enkf_main , int , bool_vector , int , int , int)") +cfunc.ens_size = cwrapper.prototype("int enkf_main_get_ensemble_size( enkf_main )") +cfunc.get_ens_config = cwrapper.prototype("c_void_p enkf_main_get_ensemble_config( enkf_main )") +cfunc.set_verbose = cwrapper.prototype("void enkf_main_set_verbose( enkf_main , bool )") +cfunc.update = cwrapper.prototype("void enkf_main_UPDATE(enkf_main , int_vector)") +cfunc.get_model_config = cwrapper.prototype("c_void_p enkf_main_get_model_config( enkf_main )") +cfunc.get_local_config = cwrapper.prototype("c_void_p enkf_main_get_local_config( enkf_main )") +cfunc.set_eclbase = cwrapper.prototype("void enkf_main_set_eclbase( enkf_main, char*)") +cfunc.set_datafile = cwrapper.prototype("void enkf_main_set_data_file( enkf_main, char*)") +cfunc.get_schedule_prediction_file = cwrapper.prototype("char* enkf_main_get_schedule_prediction_file( enkf_main )") +cfunc.set_schedule_prediction_file = cwrapper.prototype("void enkf_main_set_schedule_prediction_file( enkf_main , char*)") +cfunc.get_data_kw = cwrapper.prototype("c_void_p enkf_main_get_data_kw(enkf_main)") +cfunc.clear_data_kw = cwrapper.prototype("void enkf_main_clear_data_kw(enkf_main)") +cfunc.add_data_kw = cwrapper.prototype("void enkf_main_add_data_kw(enkf_main, char*, char*)") +cfunc.get_ensemble_size = cwrapper.prototype("int enkf_main_get_ensemble_size(enkf_main)") +cfunc.resize_ensemble = cwrapper.prototype("void enkf_main_resize_ensemble(int)") +cfunc.del_node = cwrapper.prototype("void enkf_main_del_node(enkf_main, char*)") +cfunc.get_obs = cwrapper.prototype("c_void_p enkf_main_get_obs(enkf_main)") +cfunc.load_obs = cwrapper.prototype("void enkf_main_load_obs(enkf_main, char*)") +cfunc.reload_obs = cwrapper.prototype("void enkf_main_reload_obs(enkf_main)") +cfunc.set_case_table = cwrapper.prototype("void enkf_main_set_case_table(enkf_main, char*)") +cfunc.get_pre_clear_runpath = cwrapper.prototype("bool enkf_main_get_pre_clear_runpath(enkf_main)"), +cfunc.set_pre_clear_runpath = cwrapper.prototype("void enkf_main_set_pre_clear_runpath(enkf_main, bool)") +cfunc.get_ensemble_size = cwrapper.prototype("int enkf_main_get_ensemble_size(enkf_main)"), +cfunc.iget_keep_runpath = cwrapper.prototype("int enkf_main_iget_keep_runpath(enkf_main, int)"), +cfunc.iset_keep_runpath = cwrapper.prototype("void enkf_main_iset_keep_runpath(enkf_main, int, keep_runpath)") +cfunc.get_templates = cwrapper.prototype("c_void_p enkf_main_get_templates(enkf_main)") +cfunc.get_site_config_file = cwrapper.prototype("char* enkf_main_get_site_config_file(enkf_main)") +cfunc.initialize_from_scratch = cwrapper.prototype("int enkf_main_initialize_from_scratch(enkf_main, stringlist, int, int)") +cfunc.get_ensemble_size = cwrapper.prototype("int enkf_main_get_ensemble_size(enkf_main)") +cfunc.get_fs = cwrapper.prototype("c_void_p enkf_main_get_fs(enkf_main)") +cfunc.get_history_length = cwrapper.prototype("int enkf_main_get_history_length(enkf_main)") +cfunc.initialize_from_existing__ = cwrapper.prototype("void enkf_main_initialize_from_existing__(enkf_main, char*, int, int, bool_vector, char*, stringlist)") +cfunc.copy_ensemble = cwrapper.prototype("void enkf_main_copy_ensemble(enkf_main, char*, int, int, char*, int, int, bool_vector, char*, stringlist)") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_obs.py b/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_obs.py new file mode 100644 index 0000000000..2706af6419 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/enkf_obs.py @@ -0,0 +1,52 @@ +# Copyright (C) 2012 Statoil ASA, Norway. +# +# The file 'enkf_obs.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import ctypes +from ert.cwrap.cwrap import * +from ert.cwrap.cclass import CClass +from ert.util.tvector import * +from enkf_enum import * +import libenkf +class EnkfObs(CClass): + + def __init__(self , c_ptr = None): + self.owner = False + self.c_ptr = c_ptr + + + def __del__(self): + if self.owner: + cfunc.free( self ) + + + def has_key(self , key): + return cfunc.has_key( self ,key ) + + + +################################################################## + +cwrapper = CWrapper( libenkf.lib ) +cwrapper.registerType( "enkf_obs" , EnkfObs ) + +# 3. Installing the c-functions used to manipulate ecl_kw instances. +# These functions are used when implementing the EclKW class, not +# used outside this scope. +cfunc = CWrapperNameSpace("enkf_obs") + + +cfunc.free = cwrapper.prototype("void enkf_obs_free( enkf_obs )") +cfunc.get_config_file = cwrapper.prototype("char* enkf_obs_get_config_file( enkf_obs )") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/ens_config.py b/ThirdParty/Ert/devel/python/python/ert/enkf/ens_config.py index 9e80e8982e..49860688ba 100644 --- a/ThirdParty/Ert/devel/python/python/ert/enkf/ens_config.py +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/ens_config.py @@ -20,8 +20,6 @@ from ert.cwrap.cclass import CClass from ert.util.tvector import * from enkf_enum import * import libenkf -import ert_local - class EnsConfig(CClass): def __init__(self , c_ptr = None): @@ -50,5 +48,12 @@ cwrapper.registerType( "ens_config" , EnsConfig ) cfunc = CWrapperNameSpace("ens_config") -cfunc.free = cwrapper.prototype("void ensemble_config_free( ens_config )") -cfunc.has_key = cwrapper.prototype("bool ensemble_config_has_key( ens_config , char* )") +cfunc.free = cwrapper.prototype("void ensemble_config_free( ens_config )") +cfunc.has_key = cwrapper.prototype("bool ensemble_config_has_key( ens_config , char* )") +cfunc.get_node = cwrapper.prototype("c_void_p ensemble_config_get_node( ens_config , char*)") +cfunc.alloc_keylist = cwrapper.prototype("c_void_p ensemble_config_alloc_keylist( ens_config )") +cfunc.add_summary = cwrapper.prototype("c_void_p ensemble_config_add_summary( ens_config, char*)") +cfunc.add_gen_kw = cwrapper.prototype("c_void_p ensemble_config_add_gen_kw( ens_config, char*)") +cfunc.add_gen_data = cwrapper.prototype("c_void_p ensemble_config_add_gen_data( ens_config, char*)") +cfunc.add_field = cwrapper.prototype("c_void_p ensemble_config_add_field( ens_config, char*, ecl_grid)") +cfunc.alloc_keylist_from_var_type = cwrapper.prototype("c_void_p ensemble_config_alloc_keylist_from_var_type(ens_config, int)") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/ert_template.py b/ThirdParty/Ert/devel/python/python/ert/enkf/ert_template.py new file mode 100644 index 0000000000..dbb1ee5bd9 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/ert_template.py @@ -0,0 +1,58 @@ +# Copyright (C) 2012 Statoil ASA, Norway. +# +# The file 'ert_template.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import ctypes +from ert.cwrap.cwrap import * +from ert.cwrap.cclass import CClass +from ert.util.tvector import * +from enkf_enum import * +import libenkf +class ErtTemplate(CClass): + + def __init__(self , c_ptr = None): + self.owner = False + self.c_ptr = c_ptr + + + def __del__(self): + if self.owner: + cfunc.free( self ) + + + def has_key(self , key): + return cfunc.has_key( self ,key ) + + + +################################################################## + +cwrapper = CWrapper( libenkf.lib ) +cwrapper.registerType( "ert_template" , AnalysisConfig ) + +# 3. Installing the c-functions used to manipulate ecl_kw instances. +# These functions are used when implementing the EclKW class, not +# used outside this scope. +cfunc = CWrapperNameSpace("ert_template") + + +cfunc.free = cwrapper.prototype("void ert_template_free( ert_template )") +cfunc.alloc_list = cwrapper.prototype("c_void_p ert_templates_alloc_list(long)"), +cfunc.get_template = cwrapper.prototype("c_void_p ert_templates_get_template(long, char*)"), +cfunc.get_template_file = cwrapper.prototype("char* ert_template_get_template_file(long)"), +cfunc.get_target_file = cwrapper.prototype("char* ert_template_get_target_file(long)"), +cfunc.get_args_as_string = cwrapper.prototype("char* ert_template_get_args_as_string(long)"), +cfunc.clear = cwrapper.prototype("void ert_templates_clear(long)"), +cfunc.add_template = cwrapper.prototype("void ert_templates_add_template(long, char*, char*, char*, char*)"),] diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/field_config.py b/ThirdParty/Ert/devel/python/python/ert/enkf/field_config.py new file mode 100644 index 0000000000..3ff7b3a1f5 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/field_config.py @@ -0,0 +1,58 @@ +# Copyright (C) 2012 Statoil ASA, Norway. +# +# The file 'field_config.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import ctypes +from ert.cwrap.cwrap import * +from ert.cwrap.cclass import CClass +from ert.util.tvector import * +from enkf_enum import * +import libenkf +class GenDataConfig(CClass): + + def __init__(self , c_ptr = None): + self.owner = False + self.c_ptr = c_ptr + + + def __del__(self): + if self.owner: + cfunc.free( self ) + + + def has_key(self , key): + return cfunc.has_key( self ,key ) + + + +################################################################## + +cwrapper = CWrapper( libenkf.lib ) +cwrapper.registerType( "field_config" , GenDataConfig ) + +# 3. Installing the c-functions used to manipulate ecl_kw instances. +# These functions are used when implementing the EclKW class, not +# used outside this scope. +cfunc = CWrapperNameSpace("field_config") + + +cfunc.free = cwrapper.prototype("void field_config_free( field_config )") +cfunc.get_type = cwrapper.prototype("int field_config_get_type(field_config)") +cfunc.get_truncation_mode = cwrapper.prototype("int field_config_get_truncation_mode(field_config)") +cfunc.get_truncation_min = cwrapper.prototype("double field_config_get_truncation_min(field_config)") +cfunc.get_truncation_max = cwrapper.prototype("double field_config_get_truncation_max(field_config)") +cfunc.get_init_transform_name = cwrapper.prototype("char* field_config_get_init_transform_name(field_config)") +cfunc.get_output_transform_name = cwrapper.prototype("char* field_config_get_output_transform_name(field_config)") +cfunc.get_init_file_fmt = cwrapper.prototype("char* field_config_get_init_file_fmt(field_config)") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/gen_data_config.py b/ThirdParty/Ert/devel/python/python/ert/enkf/gen_data_config.py new file mode 100644 index 0000000000..b5f9f4dd07 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/gen_data_config.py @@ -0,0 +1,56 @@ +# Copyright (C) 2012 Statoil ASA, Norway. +# +# The file 'gen_data_config.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import ctypes +from ert.cwrap.cwrap import * +from ert.cwrap.cclass import CClass +from ert.util.tvector import * +from enkf_enum import * +import libenkf +class GenDataConfig(CClass): + + def __init__(self , c_ptr = None): + self.owner = False + self.c_ptr = c_ptr + + + def __del__(self): + if self.owner: + cfunc.free( self ) + + + def has_key(self , key): + return cfunc.has_key( self ,key ) + + + +################################################################## + +cwrapper = CWrapper( libenkf.lib ) +cwrapper.registerType( "gen_data_config" , GenDataConfig ) + +# 3. Installing the c-functions used to manipulate ecl_kw instances. +# These functions are used when implementing the EclKW class, not +# used outside this scope. +cfunc = CWrapperNameSpace("gen_data_config") + + +cfunc.free = cwrapper.prototype("void gen_data_config_free( gen_data_config )") +cfunc.get_output_format = cwrapper.prototype("c_void_p gen_data_config_get_output_format(gen_data_config)") +cfunc.get_input_format = cwrapper.prototype("c_void_p gen_data_config_get_input_format(gen_data_config)") +cfunc.get_template_file = cwrapper.prototype("char* gen_data_config_get_template_file(gen_data_config)") +cfunc.get_template_key = cwrapper.prototype("char* gen_data_config_get_template_key(gen_data_config)") +cfunc.get_init_file_fmt = cwrapper.prototype("char* gen_data_config_get_init_file_fmt(gen_data_config)") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/gen_kw_config.py b/ThirdParty/Ert/devel/python/python/ert/enkf/gen_kw_config.py new file mode 100644 index 0000000000..66cdf2795b --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/gen_kw_config.py @@ -0,0 +1,54 @@ +# Copyright (C) 2012 Statoil ASA, Norway. +# +# The file 'gen_kw_config.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import ctypes +from ert.cwrap.cwrap import * +from ert.cwrap.cclass import CClass +from ert.util.tvector import * +from enkf_enum import * +import libenkf +class GenKwConfig(CClass): + + def __init__(self , c_ptr = None): + self.owner = False + self.c_ptr = c_ptr + + + def __del__(self): + if self.owner: + cfunc.free( self ) + + + def has_key(self , key): + return cfunc.has_key( self ,key ) + + + +################################################################## + +cwrapper = CWrapper( libenkf.lib ) +cwrapper.registerType( "gen_kw_config" , GenKwConfig ) + +# 3. Installing the c-functions used to manipulate ecl_kw instances. +# These functions are used when implementing the EclKW class, not +# used outside this scope. +cfunc = CWrapperNameSpace("gen_kw_config") + + +cfunc.free = cwrapper.prototype("void gen_kw_config_free( gen_kw_config )") +cfunc.get_template_file = cwrapper.prototype("char* gen_kw_config_get_template_file(gen_kw_config)") +cfunc.get_init_file_fmt = cwrapper.prototype("char* gen_kw_config_get_init_file_fmt(gen_kw_config)") +cfunc.get_parameter_file = cwrapper.prototype("char* gen_kw_config_get_parameter_file(gen_kw_config)") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/local_config.py b/ThirdParty/Ert/devel/python/python/ert/enkf/local_config.py new file mode 100644 index 0000000000..3b28a60050 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/local_config.py @@ -0,0 +1,55 @@ +# Copyright (C) 2012 Statoil ASA, Norway. +# +# The file 'local_config.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import ctypes +from ert.cwrap.cwrap import * +from ert.cwrap.cclass import CClass +from ert.util.tvector import * +from enkf_enum import * +import libenkf +class LocalConfig(CClass): + + def __init__(self , c_ptr = None): + self.owner = False + self.c_ptr = c_ptr + + + def __del__(self): + if self.owner: + cfunc.free( self ) + + + def has_key(self , key): + return cfunc.has_key( self ,key ) + + + +################################################################## + +cwrapper = CWrapper( libenkf.lib ) +cwrapper.registerType( "local_config" , LocalConfig ) + +# 3. Installing the c-functions used to manipulate ecl_kw instances. +# These functions are used when implementing the EclKW class, not +# used outside this scope. +cfunc = CWrapperNameSpace("local_config") + + +cfunc.free = cwrapper.prototype("void local_config_free( local_config )") +cfunc.get_config_files = cwrapper.prototype("c_void_p local_config_get_config_files( local_config )") +cfunc.clear_config_files = cwrapper.prototype("void local_config_clear_config_files( local_config )") +cfunc.add_config_file = cwrapper.prototype("void local_config_add_config_file( local_config , char*)") + diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/model_config.py b/ThirdParty/Ert/devel/python/python/ert/enkf/model_config.py new file mode 100644 index 0000000000..ffb6fd8a11 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/model_config.py @@ -0,0 +1,62 @@ +# Copyright (C) 2012 Statoil ASA, Norway. +# +# The file 'model_config.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import ctypes +from ert.cwrap.cwrap import * +from ert.cwrap.cclass import CClass +from ert.util.tvector import * +from enkf_enum import * +import libenkf +class ModelConfig(CClass): + + def __init__(self , c_ptr = None): + self.owner = False + self.c_ptr = c_ptr + + + def __del__(self): + if self.owner: + cfunc.free( self ) + + + def has_key(self , key): + return cfunc.has_key( self ,key ) + + + +################################################################## + +cwrapper = CWrapper( libenkf.lib ) +cwrapper.registerType( "model_config" , ModelConfig ) + +# 3. Installing the c-functions used to manipulate ecl_kw instances. +# These functions are used when implementing the EclKW class, not +# used outside this scope. +cfunc = CWrapperNameSpace("model_config") + + +cfunc.free = cwrapper.prototype("void model_config_free( model_config )") +cfunc.get_enkf_sched_file = cwrapper.prototype("char* model_config_get_enkf_sched_file( model_config )") +cfunc.set_enkf_sched_file = cwrapper.prototype("void model_config_set_enkf_sched_file( model_config, char*)") +cfunc.get_history_source = cwrapper.prototype("int model_config_get_history_source(model_config)") +cfunc.set_history_source = cwrapper.prototype("void model_config_set_history_source(model_config, int)") +cfunc.get_forward_model = cwrapper.prototype("c_void_p model_config_get_forward_model(model_config)") +cfunc.get_max_resample = cwrapper.prototype("int model_config_get_max_resample(model_config)") +cfunc.set_max_resample = cwrapper.prototype("void model_config_set_max_resample(model_config, int)") +cfunc.get_case_table_file = cwrapper.prototype("char* model_config_get_case_table_file(model_config)") +cfunc.get_runpath_as_char = cwrapper.prototype("char* model_config_get_runpath_as_char(model_config)") +cfunc.set_runpath_fmt = cwrapper.prototype("void model_config_set_runpath_fmt(model_config, char*)") + diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/plot_config.py b/ThirdParty/Ert/devel/python/python/ert/enkf/plot_config.py new file mode 100644 index 0000000000..33ea1c309e --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/plot_config.py @@ -0,0 +1,65 @@ +# Copyright (C) 2012 Statoil ASA, Norway. +# +# The file 'plot_config.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import ctypes +from ert.cwrap.cwrap import * +from ert.cwrap.cclass import CClass +from ert.util.tvector import * +from enkf_enum import * +import libenkf +class PlotConfig(CClass): + + def __init__(self , c_ptr = None): + self.owner = False + self.c_ptr = c_ptr + + + def __del__(self): + if self.owner: + cfunc.free( self ) + + + def has_key(self , key): + return cfunc.has_key( self ,key ) + + + +################################################################## + +cwrapper = CWrapper( libenkf.lib ) +cwrapper.registerType( "plot_config" , PlotConfig ) + +# 3. Installing the c-functions used to manipulate ecl_kw instances. +# These functions are used when implementing the EclKW class, not +# used outside this scope. +cfunc = CWrapperNameSpace("plot_config") + + +cfunc.free = cwrapper.prototype("void plot_config_free( plot_config )") +cfunc.get_path = cwrapper.prototype("char* plot_config_get_path(plot_config)") +cfunc.set_path = cwrapper.prototype("void plot_config_set_path(plot_config, char*)") +cfunc.get_driver = cwrapper.prototype("char* plot_config_get_driver(plot_config)") +cfunc.set_driver = cwrapper.prototype("void plot_config_set_driver(plot_config, char*)") +cfunc.get_errorbar_max = cwrapper.prototype("int plot_config_get_errorbar_max(plot_config)") +cfunc.set_errorbar_max = cwrapper.prototype("void plot_config_set_errorbar_max(plot_config, int)") +cfunc.get_width = cwrapper.prototype("int plot_config_get_width(plot_config)") +cfunc.set_width = cwrapper.prototype("void plot_config_set_width(plot_config, int)") +cfunc.get_height = cwrapper.prototype("int plot_config_get_height(plot_config)") +cfunc.set_height = cwrapper.prototype("void plot_config_set_height(plot_config, int)") +cfunc.get_viewer = cwrapper.prototype("char* plot_config_get_viewer(plot_config)") +cfunc.set_viewer = cwrapper.prototype("void plot_config_set_viewer(plot_config, char*)") +cfunc.get_image_type = cwrapper.prototype("char* plot_config_get_image_type(plot_config)") +cfunc.set_image_type = cwrapper.prototype("void plot_config_set_image_type(plot_config, char*)") diff --git a/ThirdParty/Ert/devel/python/python/ert/enkf/site_config.py b/ThirdParty/Ert/devel/python/python/ert/enkf/site_config.py new file mode 100644 index 0000000000..a91da3a5b9 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/enkf/site_config.py @@ -0,0 +1,84 @@ +# Copyright (C) 2012 Statoil ASA, Norway. +# +# The file 'site_config.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import ctypes +from ert.cwrap.cwrap import * +from ert.cwrap.cclass import CClass +from ert.util.tvector import * +from enkf_enum import * +import libenkf +class SiteConfig(CClass): + + def __init__(self , c_ptr = None): + self.owner = False + self.c_ptr = c_ptr + + + def __del__(self): + if self.owner: + cfunc.free( self ) + + + def has_key(self , key): + return cfunc.has_key( self ,key ) + + + +################################################################## + +cwrapper = CWrapper( libenkf.lib ) +cwrapper.registerType( "site_config" , SiteConfig ) + +# 3. Installing the c-functions used to manipulate ecl_kw instances. +# These functions are used when implementing the EclKW class, not +# used outside this scope. +cfunc = CWrapperNameSpace("site_config") + + +cfunc.free = cwrapper.prototype("void site_config_free( site_config )") +cfunc.get_queue_name = cwrapper.prototype("char* site_config_get_queue_name(site_config)") +cfunc.set_job_queue = cwrapper.prototype("void site_config_set_job_queue(site_config, char*)") +cfunc.get_lsf_queue = cwrapper.prototype("char* site_config_get_lsf_queue(site_config)") +cfunc.set_lsf_queue = cwrapper.prototype("void site_config_set_lsf_queue(site_config, char*)") +cfunc.get_max_running_lsf = cwrapper.prototype("int site_config_get_max_running_lsf(site_config)") +cfunc.set_max_running_lsf = cwrapper.prototype("void site_config_set_max_running_lsf(site_config, int)") +cfunc.get_lsf_request = cwrapper.prototype("char* site_config_get_lsf_request(site_config)") +cfunc.set_lsf_request = cwrapper.prototype("void site_config_set_lsf_request(site_config, char*)") +cfunc.get_rsh_command = cwrapper.prototype("char* site_config_get_rsh_command(site_config)") +cfunc.set_rsh_command = cwrapper.prototype("void site_config_set_rsh_command(site_config, char*)") +cfunc.get_max_running_rsh = cwrapper.prototype("int site_config_get_max_running_rsh(site_config)") +cfunc.set_max_running_rsh = cwrapper.prototype("void site_config_set_max_running_rsh(site_config, int)") +cfunc.get_rsh_host_list = cwrapper.prototype("c_void_p site_config_get_rsh_host_list(site_config)") +cfunc.clear_rsh_host_list = cwrapper.prototype("void site_config_clear_rsh_host_list(site_config)") +cfunc.add_rsh_host = cwrapper.prototype("void site_config_add_rsh_host(site_config, char*, int)") +cfunc.get_max_running_local = cwrapper.prototype("int site_config_get_max_running_local(site_config)") +cfunc.set_max_running_local = cwrapper.prototype("void site_config_set_max_running_local(site_config, int)") +cfunc.get_installed_jobs = cwrapper.prototype("c_void_p site_config_get_installed_jobs(site_config)") +cfunc.get_max_submit = cwrapper.prototype("int site_config_get_max_submit(site_config)") +cfunc.set_max_submit = cwrapper.prototype("void site_config_set_max_submit(site_config, int)") +cfunc.get_license_root_path = cwrapper.prototype("char* site_config_get_license_root_path(site_config)") +cfunc.set_license_root_path = cwrapper.prototype("void site_config_set_license_root_path(site_config, char*)") +cfunc.get_job_script = cwrapper.prototype("char* site_config_get_job_script(site_config)"), +cfunc.set_job_script = cwrapper.prototype("void site_config_set_job_script(site_config, char*)") +cfunc.get_env_hash = cwrapper.prototype("c_void_p site_config_get_env_hash(site_config)"), +cfunc.clear_env = cwrapper.prototype("void site_config_clear_env(site_config)"), +cfunc.setenv = cwrapper.prototype("void site_config_setenv(site_config, char*, char*)") +cfunc.get_path_variables = cwrapper.prototype("c_void_p site_config_get_path_variables(site_config)"), +cfunc.get_path_values = cwrapper.prototype("c_void_p site_config_get_path_values(site_config)"), +cfunc.clear_pathvar = cwrapper.prototype("void site_config_clear_pathvar(site_config)"), +cfunc.update_pathvar = cwrapper.prototype("void site_config_update_pathvar(site_config, char*, char*)") +cfunc.get_installed_jobs = cwrapper.prototype("c_void_p site_config_get_installed_jobs(site_config)"), +cfunc.get_license_root_path = cwrapper.prototype("char* site_config_get_license_root_path(site_config)") diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert/__init__.py b/ThirdParty/Ert/devel/python/python/ert/ert/__init__.py similarity index 100% rename from ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert/__init__.py rename to ThirdParty/Ert/devel/python/python/ert/ert/__init__.py diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert/enums.py b/ThirdParty/Ert/devel/python/python/ert/ert/enums.py similarity index 100% rename from ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert/enums.py rename to ThirdParty/Ert/devel/python/python/ert/ert/enums.py diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert/erttypes.py b/ThirdParty/Ert/devel/python/python/ert/ert/erttypes.py similarity index 100% rename from ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert/erttypes.py rename to ThirdParty/Ert/devel/python/python/ert/ert/erttypes.py diff --git a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert/ertwrapper.py b/ThirdParty/Ert/devel/python/python/ert/ert/ertwrapper.py similarity index 98% rename from ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert/ertwrapper.py rename to ThirdParty/Ert/devel/python/python/ert/ert/ertwrapper.py index bb3e2441b8..b6528e8349 100644 --- a/ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert/ertwrapper.py +++ b/ThirdParty/Ert/devel/python/python/ert/ert/ertwrapper.py @@ -84,7 +84,7 @@ class ErtWrapper: else: sys.exit("Need a value for environment variable LSF_HOME") - self.util = self.__loadLibrary( "libutil" ) + self.util = self.__loadLibrary( "libert_util" ) self.__loadLibrary( "libgeometry" ) self.ecl = self.__loadLibrary( "libecl" ) self.__loadLibrary( "libsched" ) @@ -95,7 +95,6 @@ class ErtWrapper: self.enkf = self.__loadLibrary( "libenkf" ) self.enkf.enkf_main_install_SIGNALS() - self.enkf.enkf_main_init_debug("/prog/sdpsoft/python2.4/bin/python") def __registerDefaultTypes(self): diff --git a/ThirdParty/Ert/devel/python/python/ert/geo/libgeo.py b/ThirdParty/Ert/devel/python/python/ert/geo/libgeo.py index b56fe8b8e8..51a82db28b 100644 --- a/ThirdParty/Ert/devel/python/python/ert/geo/libgeo.py +++ b/ThirdParty/Ert/devel/python/python/ert/geo/libgeo.py @@ -23,4 +23,4 @@ import ctypes import ert.util.libutil import ert.cwrap.clib as clib -lib = clib.ert_load("libgeometry.so") +lib = clib.ert_load("libert_geometry.so") diff --git a/ThirdParty/Ert/devel/python/python/ert/job_queue/CMakeLists.txt b/ThirdParty/Ert/devel/python/python/ert/job_queue/CMakeLists.txt index 47054d17ee..01e8f151fe 100644 --- a/ThirdParty/Ert/devel/python/python/ert/job_queue/CMakeLists.txt +++ b/ThirdParty/Ert/devel/python/python/ert/job_queue/CMakeLists.txt @@ -1 +1 @@ -add_python_target(pythonjob_queue ${PYTHON_INSTALL_PREFIX}/ert/job_queue "driver;__init__;job;job_queue;libjob_queue;queue") +add_python_target(pythonjob_queue ${PYTHON_INSTALL_PREFIX}/ert/job_queue "driver;__init__;job;job_queue;libjob_queue;queue;ext_job") diff --git a/ThirdParty/Ert/devel/python/python/ert/job_queue/ext_job.py b/ThirdParty/Ert/devel/python/python/ert/job_queue/ext_job.py new file mode 100644 index 0000000000..68badc3553 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/job_queue/ext_job.py @@ -0,0 +1,77 @@ +# Copyright (C) 2012 Statoil ASA, Norway. +# +# The file 'ext_job.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import ctypes +from ert.cwrap.cwrap import * +from ert.cwrap.cclass import CClass +from ert.util.tvector import * +from enkf_enum import * +import libenkf +class ExtJob(CClass): + + def __init__(self , c_ptr = None): + self.owner = False + self.c_ptr = c_ptr + + + def __del__(self): + if self.owner: + cfunc.free( self ) + + + def has_key(self , key): + return cfunc.has_key( self ,key ) + + + +################################################################## + +cwrapper = CWrapper( libenkf.lib ) +cwrapper.registerType( "ext_job" , ExtJob ) + +# 3. Installing the c-functions used to manipulate ecl_kw instances. +# These functions are used when implementing the EclKW class, not +# used outside this scope. +cfunc = CWrapperNameSpace("ext_job") + + +cfunc.free = cwrapper.prototype("void ext_job_free( ext_job )") +cfunc.get_help_text = cwrapper.prototype("char* ext_job_get_help_text(ext_job)") +cfunc.get_private_args_as_string = cwrapper.prototype("char* ext_job_get_private_args_as_string(ext_job)") +cfunc.set_private_args_as_string = cwrapper.prototype("void ext_job_set_private_args_from_string(ext_job, char*)") +cfunc.is_private = cwrapper.prototype("int ext_job_is_private(ext_job)") +cfunc.get_config_file = cwrapper.prototype("char* ext_job_get_config_file(ext_job)") +cfunc.set_config_file = cwrapper.prototype("void ext_job_set_config_file(ext_job, char*)") +cfunc.alloc = cwrapper.prototype("c_void_p ext_job_alloc(char*, char*, int)") +cfunc.fscanf_alloc = cwrapper.prototype("c_void_p ext_job_fscanf_alloc(char*, char*, int, char*)") +cfunc.get_stdin_file = cwrapper.prototype("char* ext_job_get_stdin_file(ext_job)") +cfunc.set_stdin_file = cwrapper.prototype("void ext_job_set_stdin_file(ext_job, char*)") +cfunc.get_stdout_file = cwrapper.prototype("char* ext_job_get_stdout_file(ext_job)") +cfunc.set_stdout_file = cwrapper.prototype("void ext_job_set_stdout_file(ext_job, char*)") +cfunc.get_stderr_file = cwrapper.prototype("char* ext_job_get_stderr_file(ext_job)") +cfunc.set_stderr_file = cwrapper.prototype("void ext_job_set_stderr_file(ext_job, char*)") +cfunc.get_target_file = cwrapper.prototype("char* ext_job_get_target_file(ext_job)") +cfunc.set_target_file = cwrapper.prototype("void ext_job_set_target_file(ext_job, char*)") +cfunc.get_executable = cwrapper.prototype("char* ext_job_get_executable(ext_job)") +cfunc.set_executable = cwrapper.prototype("void ext_job_set_executable(ext_job, char*)") +cfunc.get_max_running = cwrapper.prototype("int ext_job_get_max_running(ext_job)") +cfunc.set_max_running = cwrapper.prototype("void ext_job_set_max_running(ext_job, int)") +cfunc.get_max_running_minutes = cwrapper.prototype("int ext_job_get_max_running_minutes(ext_job)") +cfunc.set_max_running_minutes = cwrapper.prototype("void ext_job_set_max_running_minutes(ext_job, int)") +cfunc.get_environment = cwrapper.prototype("c_void_p ext_job_get_environment(ext_job)") +cfunc.set_environment = cwrapper.prototype("void ext_job_add_environment(ext_job, char*, char*)") +cfunc.clear_environment = cwrapper.prototype("void ext_job_clear_environment(ext_job)") +cfunc.save = cwrapper.prototype("void ext_job_save(ext_job)") diff --git a/ThirdParty/Ert/devel/python/python/ert/job_queue/ext_joblist.py b/ThirdParty/Ert/devel/python/python/ert/job_queue/ext_joblist.py new file mode 100644 index 0000000000..d0eba9d220 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/job_queue/ext_joblist.py @@ -0,0 +1,57 @@ +# Copyright (C) 2012 Statoil ASA, Norway. +# +# The file 'ext_joblist.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import ctypes +from ert.cwrap.cwrap import * +from ert.cwrap.cclass import CClass +from ert.util.tvector import * +from enkf_enum import * +import libenkf +class ExtJoblist(CClass): + + def __init__(self , c_ptr = None): + self.owner = False + self.c_ptr = c_ptr + + + def __del__(self): + if self.owner: + cfunc.free( self ) + + + def has_key(self , key): + return cfunc.has_key( self ,key ) + + + +################################################################## + +cwrapper = CWrapper( libenkf.lib ) +cwrapper.registerType( "ext_joblist" , ExtJoblist ) + +# 3. Installing the c-functions used to manipulate ecl_kw instances. +# These functions are used when implementing the EclKW class, not +# used outside this scope. +cfunc = CWrapperNameSpace("ext_joblist") + + +cfunc.free = cwrapper.prototype("void ext_joblist_free( ext_joblist )") +cfunc.alloc_list = cwrapper.prototype("c_void_p ext_joblist_alloc_list(ext_joblist)") +cfunc.get_job = cwrapper.prototype("c_void_p ext_joblist_get_job(ext_joblist, char*)") +cfunc.del_job = cwrapper.prototype("int ext_joblist_del_job(ext_joblist, char*)") +cfunc.has_job = cwrapper.prototype("int ext_joblist_has_job(ext_joblist, char*)") +cfunc.add_job = cwrapper.prototype("void ext_joblist_add_job(ext_joblist, char*, ext_joblist)") +cfunc.get_jobs = cwrapper.prototype("c_void_p ext_joblist_get_jobs(ext_joblist)") diff --git a/ThirdParty/Ert/devel/python/python/ert/job_queue/forward_model.py b/ThirdParty/Ert/devel/python/python/ert/job_queue/forward_model.py new file mode 100644 index 0000000000..3d3de30e77 --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/job_queue/forward_model.py @@ -0,0 +1,54 @@ +# Copyright (C) 2012 Statoil ASA, Norway. +# +# The file 'forward_model.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import ctypes +from ert.cwrap.cwrap import * +from ert.cwrap.cclass import CClass +from ert.util.tvector import * +from enkf_enum import * +import libenkf +class ForwardModel(CClass): + + def __init__(self , c_ptr = None): + self.owner = False + self.c_ptr = c_ptr + + + def __del__(self): + if self.owner: + cfunc.free( self ) + + + def has_key(self , key): + return cfunc.has_key( self ,key ) + + + +################################################################## + +cwrapper = CWrapper( libenkf.lib ) +cwrapper.registerType( "forward_model" , ForwardModel ) + +# 3. Installing the c-functions used to manipulate ecl_kw instances. +# These functions are used when implementing the EclKW class, not +# used outside this scope. +cfunc = CWrapperNameSpace("forward_model") + + +cfunc.free = cwrapper.prototype("void forward_model_free( forward_model )") +cfunc.clear = cwrapper.prototype("void forward_model_clear(forward_model)") +cfunc.add_job = cwrapper.prototype("c_void_p forward_model_add_job(forward_model, char*)") +cfunc.alloc_joblist = cwrapper.prototype("c_void_p forward_model_alloc_joblist(forward_model)") diff --git a/ThirdParty/Ert/devel/python/python/ert/job_queue/job_queue.py b/ThirdParty/Ert/devel/python/python/ert/job_queue/job_queue.py index bf9df5a43b..1fcda04d1b 100644 --- a/ThirdParty/Ert/devel/python/python/ert/job_queue/job_queue.py +++ b/ThirdParty/Ert/devel/python/python/ert/job_queue/job_queue.py @@ -20,3 +20,7 @@ import libjob_queue from queue import JobQueue from driver import Driver from job import Job + +import ext_job +import ext_joblist +import forward_model diff --git a/ThirdParty/Ert/devel/python/python/ert/job_queue/libjob_queue.py b/ThirdParty/Ert/devel/python/python/ert/job_queue/libjob_queue.py index defdb93cca..2615a4c36b 100644 --- a/ThirdParty/Ert/devel/python/python/ert/job_queue/libjob_queue.py +++ b/ThirdParty/Ert/devel/python/python/ert/job_queue/libjob_queue.py @@ -18,19 +18,22 @@ import os import sys import ctypes import ert.util.libutil +import ert.config.libconfig import ert.cwrap.clib as clib -# Getting LSF to work properly is quite painful. The situation is a -# mix of internal dependencies comiled into the libjob_queue.so shared -# library, and external dependencies based on the LSF_xxx environment -# variables: +# Getting LSF to work properly is quite painful. The situation +# is a mix of build complexity and LSF specific requirements: # -# 1. If the C-libraries have been compiled with LSF support, -# i.e. the variable INCLUDE_LSF has been set to True in -# local_config.py then the shared library libjob_queue.so will -# depend on the libraries liblsf and libbat; this dependency -# exists even if you have no intention actually using LSF. +# 1. The LSF libraries are accessed from the libjob_queue.so +# library, but observe that the dependancy on the liblsf and +# libbat libraries is through dlopen(), i.e. runtime. This module +# will therefor load happily without access to the lsf libraries. +# +# If you at a later stage create a lsf driver the runtime +# environment must be able to locate the liblsf.so, libbat.so and +# libnsl.so shared libraries, either through LD_LIBRARY_PATH or +# other means. # # 2. To actually use LSF you need a whole list of environment # variables to be set: LSF_BINDIR , LSF_LIBDIR , XLDF_UIDDIR , @@ -38,9 +41,7 @@ import ert.cwrap.clib as clib # related to ERT or the Python bindings. The normal way to # achieve this is by sourcing a shell script. # -# In the current code we try three different things: -# -# 1: If the environment variable LSF_HOME is set we set the +# If the environment variable LSF_HOME is set we set the # remaining LSF variables according to: # # LSF_BINDIR = $LSF_HOME/bin @@ -54,80 +55,19 @@ import ert.cwrap.clib as clib # already have a value, furthermore it should be observed that # the use of an LSF_HOME variable is something invented with ERT, # and not standard LSF approach. -# -# 2: If the variable LSF_LIBDIR is set (either from 1: above, or -# from external scope), we try to load the lsf libraries from -# this location. -# -# 3. If we have no value for LSF_LIBDIR we just try a wild shot for -# loading the LSF libraries. -# -# -# When we have tried to load the LSF libraries we continue on to load -# the libjob_queue.so ERT library. Then the following possibilities -# exist: -# -# 1. The libjob_queue library has been built without LSF support, -# i.e. INCLUDE_LSF == False, in this case the loading of -# libjob_queue.so is "guaranteed" to suceed. -# -# 2. The libjob_queue library has been built with LSF support, -# i.e. INCLUDE_LSF == True: -# -# - If we succeeded in loading liblsf/libbat in the previous -# section, loading libjob_queue should.so work out OK. -# -# - If we failed to load libbat/liblsf libjob_queue will not -# load, and the whole thing will go up in flames. -# def setenv( var , value): if not os.getenv( var ): os.environ[ var ] = value -# 1: Setting up the full LSF environment +# Set up the full LSF environment - based onf LSF_HOME LSF_HOME = os.getenv( "LSF_HOME") if LSF_HOME: - setenv( "LSF_BINDIR" , "%s/bin" % LSF_HOME ) - setenv( "LSF_LIBDIR" , "%s/lib" % LSF_HOME ) - setenv( "XLSF_UIDDIR" , "%s/lib/uid" % LSF_HOME ) + setenv( "LSF_BINDIR" , "%s/bin" % LSF_HOME ) + setenv( "LSF_LIBDIR" , "%s/lib" % LSF_HOME ) + setenv( "XLSF_UIDDIR" , "%s/lib/uid" % LSF_HOME ) setenv( "LSF_SERVERDIR" , "%s/etc" % LSF_HOME) - setenv( "LSF_ENVDIR" , "%s/conf" % LSF_HOME) # This one might be too simple minded. - - -# 2: Loading the LSF libraries -LSF_LIBDIR = os.getenv("LSF_LIBDIR") -try: - clib.load("libnsl.so" , "libnsl.so.1") - clib.load("libnsl.so.1") - if LSF_LIBDIR: - clib.load("%s/liblsf.so" % LSF_LIBDIR) - clib.load("%s/libbat.so" % LSF_LIBDIR) - else: - clib.load( "liblsf.so" ) - clib.load( "libbat.so" ) - HAVE_LSF = True -except: - HAVE_LSF = False - - -# 3: Loading the libjob_queue library, which might (depending on the -# value of INCLUDE_LSF used when building) depend on the LSF -# libraries we tried to load at the previous step. -clib.ert_load("libconfig.so" ) -try: - lib = clib.ert_load("libjob_queue.so") -except: - if HAVE_LSF == False: - sys.stderr.write("** Failed to load the libjob_queue library, \n") - sys.stderr.write("** have previosuly failed to load the LSF\n") - sys.stderr.write("** libraries liblsf & libbat - that might be\n") - sys.stderr.write("** the reason ... ") - if LSF_LIBDIR: - sys.stderr.write("** LSF_LIBDIR = %s\n" % LSF_LIBDIR) - else: - sys.stderr.write("** LSF_LIBDIR = \n") - sys.exit("Failed to load library: libjob_queue") - + setenv( "LSF_ENVDIR" , "%s/conf" % LSF_HOME) # This is wrong: Statoil: /prog/LSF/conf +lib = clib.ert_load("libjob_queue.so") diff --git a/ThirdParty/Ert/devel/python/python/ert/util/latex.py b/ThirdParty/Ert/devel/python/python/ert/util/latex.py index e60d83ef56..6df9052cd8 100644 --- a/ThirdParty/Ert/devel/python/python/ert/util/latex.py +++ b/ThirdParty/Ert/devel/python/python/ert/util/latex.py @@ -32,8 +32,13 @@ class LaTeX(CClass): def runpath(self): return cfunc.get_runpath( self ) - def compile(self , ignore_errors = False , with_xref = False): - return cfunc.compile( self , ignore_errors , with_xref) + def compile(self , ignore_errors = False , with_xref = False , cleanup = True): + return cfunc.compile( self , ignore_errors , with_xref , cleanup) + + @property + def in_place(self): + return cfunc.compile_in_place( self ) + #----------------------------------------------------------------- def set_target( self , target_file): @@ -55,6 +60,12 @@ class LaTeX(CClass): timeout = property( get_timeout , set_timeout) #----------------------------------------------------------------- + def link_content( self , directory ): + cfunc.link_directory_content( self , directory ) + + def link_path( self , path): + cfunc.link_path( self , path) + cwrapper = CWrapper( libutil.lib ) cwrapper.registerType( "latex" , LaTeX ) @@ -63,9 +74,12 @@ cwrapper.registerType( "latex" , LaTeX ) cfunc = CWrapperNameSpace("latex") cfunc.alloc = cwrapper.prototype("c_void_p latex_alloc( char* , bool )") cfunc.free = cwrapper.prototype("void latex_free( latex )") -cfunc.compile = cwrapper.prototype("bool latex_compile(latex , bool , bool)") +cfunc.compile = cwrapper.prototype("bool latex_compile(latex , bool , bool , bool)") cfunc.get_runpath = cwrapper.prototype("char* latex_get_runpath( latex )") cfunc.get_target = cwrapper.prototype("char* latex_get_target_file( latex )") cfunc.set_target = cwrapper.prototype("void latex_set_target_file( latex , char* )") cfunc.set_timeout = cwrapper.prototype("void latex_set_timeout( latex , int )") cfunc.get_timeout = cwrapper.prototype("int latex_get_timeout( latex )") +cfunc.compile_in_place = cwrapper.prototype("bool latex_compile_in_place( latex )"); +cfunc.link_directory_content = cwrapper.prototype("void latex_link_directory_content( latex , char*)"); +cfunc.link_path = cwrapper.prototype("void latex_link_path( latex , char*)"); diff --git a/ThirdParty/Ert/devel/python/python/ert/util/log.py b/ThirdParty/Ert/devel/python/python/ert/util/log.py new file mode 100644 index 0000000000..29a597e95d --- /dev/null +++ b/ThirdParty/Ert/devel/python/python/ert/util/log.py @@ -0,0 +1,53 @@ +# Copyright (C) 2012 Statoil ASA, Norway. +# +# The file 'log.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import ctypes +from ert.cwrap.cwrap import * +from ert.cwrap.cclass import CClass +from ert.util.tvector import * +from enkf_enum import * +import libenkf +class Log(CClass): + + def __init__(self , c_ptr = None): + self.owner = False + self.c_ptr = c_ptr + + + def __del__(self): + if self.owner: + cfunc.free( self ) + + + def has_key(self , key): + return cfunc.has_key( self ,key ) + + + +################################################################## + +cwrapper = CWrapper( libenkf.lib ) +cwrapper.registerType( "log" , Log ) + +# 3. Installing the c-functions used to manipulate ecl_kw instances. +# These functions are used when implementing the EclKW class, not +# used outside this scope. +cfunc = CWrapperNameSpace("log") +cfunc.free = cwrapper.prototype("void log( log )") +cfunc.get_filename = cwrapper.prototype("char* log_get_filename(long)") +cfunc.reset_filename = cwrapper.prototype("void log_reset_filename(long, char*)") +cfunc.get_level = cwrapper.prototype("int log_get_level(long)") +cfunc.set_level = cwrapper.prototype("void log_set_level(long, int)") diff --git a/ThirdParty/Ert/devel/python/python/ert/util/stringlist.py b/ThirdParty/Ert/devel/python/python/ert/util/stringlist.py index 0606551e3e..6fa3ab7a7b 100644 --- a/ThirdParty/Ert/devel/python/python/ert/util/stringlist.py +++ b/ThirdParty/Ert/devel/python/python/ert/util/stringlist.py @@ -146,6 +146,18 @@ class StringList(CClass): return buffer + def pop(self): + """ + Will remove the last element from the list and return it. + + Will raise IndexError if list is empty. + """ + if len(self): + return cfunc.pop( self ) + else: + raise IndexError("pop() failed - the list is empty") + + def append(self, s): """ Appends a new string @s to list. @@ -169,6 +181,17 @@ class StringList(CClass): slist.append( s ) return slist + @property + def last(self): + """ + Will return the last element in list. Raise IndexError if empty. + """ + if len(self): + return cfunc.last( self ) + else: + raise IndexError("The list is empty") + + def sort(self , cmp_flag = 0): """ Will sort the list inplace. @@ -196,3 +219,5 @@ cfunc.stringlist_iget = cwrapper.prototype("char* stringlist_iget( stringl cfunc.stringlist_get_size = cwrapper.prototype("int stringlist_get_size( stringlist )") cfunc.contains = cwrapper.prototype("bool stringlist_contains(stringlist , char*)") cfunc.sort = cwrapper.prototype("void stringlist_python_sort( stringlist , int)") +cfunc.pop = cwrapper.prototype("char* stringlist_pop( stringlist )") +cfunc.last = cwrapper.prototype("char* stringlist_get_last( stringlist )") diff --git a/ThirdParty/Ert/devel/python/python/ert/util/tvector.py b/ThirdParty/Ert/devel/python/python/ert/util/tvector.py index 9813fb6a35..4b30ebe5ab 100644 --- a/ThirdParty/Ert/devel/python/python/ert/util/tvector.py +++ b/ThirdParty/Ert/devel/python/python/ert/util/tvector.py @@ -576,6 +576,31 @@ class BoolVector(TVector): obj = TVector.__new__( cls ) return obj + + + @classmethod + def active_mask(cls , range_string): + """ + Will create a BoolVector instance with the values from @range_string. + + The range_string input should be of the type "1,3-5,9,17", + i.e. integer values separated by commas, and dashes to + represent ranges. If the input string contains ANY invalid + characters the returned active list will be empty: + + "1,4-7,10" => {F,T,F,F,T,T,T,T,F,F,T} + "1,4-7,10X" => {} + + The empty list will evaluate to false + """ + new_obj = BoolVector.__new__(cls) + c_ptr = cfunc.create_active_mask( range_string ) + new_obj.init_cobj( c_ptr , new_obj.free ) + return new_obj + + + + @@ -622,6 +647,28 @@ class IntVector(TVector): obj = TVector.__new__( cls ) return obj + @classmethod + def active_list(cls , range_string): + """ + Will create a IntVector instance with the values from @range_string. + + The range_string input should be of the type "1,3-5,9,17", + i.e. integer values separated by commas, and dashes to + represent ranges. If the input string contains ANY invalid + characters the returned active list will be empty: + + "1,4-7,10" => {1,4,5,6,7,10} + "1,4-7,10X" => {} + + The empty list will evaluate to false + """ + new_obj = IntVector.__new__(cls) + c_ptr = cfunc.create_active_list( range_string ) + new_obj.init_cobj( c_ptr , new_obj.free ) + return new_obj + + + ################################################################# buffer_from_ptr = ctypes.pythonapi.PyBuffer_FromMemory @@ -734,3 +781,8 @@ cfunc.bool_vector_get_default = cwrapper.prototype("bool bool_vector_g cfunc.bool_vector_alloc_data_copy = cwrapper.prototype("bool* bool_vector_alloc_data_copy( bool_vector )") cfunc.bool_vector_data_ptr = cwrapper.prototype("bool* bool_vector_get_ptr( bool_vector )") cfunc.bool_vector_element_size = cwrapper.prototype("int bool_vector_element_size( bool_vector )") + +#----------------------------------------------------------------- + +cfunc.create_active_list = cwrapper.prototype("c_void_p string_util_alloc_active_list( char* )") +cfunc.create_active_mask = cwrapper.prototype("c_void_p string_util_alloc_active_mask( char* )") diff --git a/ThirdParty/Ert/devel/python/python/ert/well/libwell.py b/ThirdParty/Ert/devel/python/python/ert/well/libwell.py index 91e6d107b6..6666bbc502 100644 --- a/ThirdParty/Ert/devel/python/python/ert/well/libwell.py +++ b/ThirdParty/Ert/devel/python/python/ert/well/libwell.py @@ -1,4 +1,4 @@ import ert.ecl.libecl import ert.cwrap.clib as clib -lib = clib.load("libwell.so") +lib = clib.load("libecl_well.so") diff --git a/ThirdParty/Ert/devel/python/test/CMakeLists.txt b/ThirdParty/Ert/devel/python/test/CMakeLists.txt index 8194bac11f..62ac45fc5b 100644 --- a/ThirdParty/Ert/devel/python/test/CMakeLists.txt +++ b/ThirdParty/Ert/devel/python/test/CMakeLists.txt @@ -1,2 +1,2 @@ -set(PYTHON_INSTALL_PREFIX "/python/test") +set(PYTHON_INSTALL_PREFIX "python/test") add_python_target(python_tests ${PYTHON_INSTALL_PREFIX} "ecl_isosurf;enkf_test;ens_config_test;file_test;fortio_test;grav_test;grdecl_test;grid_test0;grid_test;import_test;job_test;kw_test;large_mem_test;latex_test;petrel_kw;poly_test;region_test;restart_test;rft_test;sched_test;stringlist_test;sum_test;test_all;test_fast;test_util;troll_test;util_test") diff --git a/ThirdParty/Ert/devel/python/test/config_test.py b/ThirdParty/Ert/devel/python/test/config_test.py new file mode 100644 index 0000000000..3086b4f0cf --- /dev/null +++ b/ThirdParty/Ert/devel/python/test/config_test.py @@ -0,0 +1,101 @@ +#!/usr/bin/env python +# Copyright (C) 2012 Statoil ASA, Norway. +# +# The file 'config_test.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + +import os +import unittest +import stat +import math +import ert +import ert.ecl.ecl as ecl +import ert.config.config as config +import ert.config.config_enums as config_enums + +import sys +from test_util import * + + + +class ConfigTest( unittest.TestCase ): + + def setUp( self ): + self.file_list = [] + + + def test_enums(self): + self.assertTrue( config_enums.content_type.CONFIG_STRING ) + self.assertTrue( config_enums.content_type.CONFIG_INVALID ) + self.assertTrue( config_enums.unrecognized.CONFIG_UNRECOGNIZED_ERROR ) + + + + def test_parse(self): + conf = config.ConfigParser() + conf.add("FIELD" , False) + schema_item = conf.add("RSH_HOST" , False) + self.assertTrue( isinstance( schema_item , config.SchemaItem )) + self.assertTrue( conf.parse("test-data/local/config/simple_config" , unrecognized = config_enums.unrecognized.CONFIG_UNRECOGNIZED_IGNORE) ) + + + content_item = conf["RSH_HOST"] + self.assertTrue( isinstance( content_item , config.ContentItem )) + self.assertTrue( conf["BJARNE"] is None ) + + self.assertTrue( len(content_item) == 1) + self.assertRaises( ValueError , content_item.__getitem__ , "BJARNE") + self.assertRaises( IndexError , content_item.__getitem__ , 10 ) + + content_node = content_item[0] + self.assertTrue( isinstance( content_node , config.ContentNode )) + + self.assertTrue( len(content_node) == 2) + self.assertRaises( ValueError , content_node.__getitem__ , "BJARNE") + self.assertRaises( IndexError , content_node.__getitem__ , 10 ) + self.assertTrue( content_node[1] == "be-lx633214:2") + + self.assertTrue( content_node.content( sep = ",") == "be-lx655082:2,be-lx633214:2") + self.assertTrue( content_node.content( ) == "be-lx655082:2 be-lx633214:2") + + + content_item = conf["FIELD"] + self.assertTrue( len(content_item) == 5) + self.assertRaises(IOError , config.ConfigParser.parse , conf , "DoesNotExits") + + + + def test_schema(self): + schema_item = config.SchemaItem("TestItem") + self.assertTrue( isinstance( schema_item , config.SchemaItem )) + self.assertTrue( schema_item.iget_type( 6 ) == config_enums.content_type.CONFIG_STRING ) + schema_item.iset_type( 0 , config_enums.content_type.CONFIG_INT ) + self.assertTrue( schema_item.iget_type( 0 ) == config_enums.content_type.CONFIG_INT ) + schema_item.set_argc_minmax( 3 , 6) + + + +def fast_suite(): + suite = unittest.TestSuite() + suite.addTest( ConfigTest( 'test_enums' )) + suite.addTest( ConfigTest( 'test_schema' )) + suite.addTest( ConfigTest( 'test_parse' )) + return suite + + + +if __name__ == "__main__": + unittest.TextTestRunner().run( fast_suite() ) + + diff --git a/ThirdParty/Ert/devel/python/test/latex_test.py b/ThirdParty/Ert/devel/python/test/latex_test.py index 9f9f4a4993..ae2de24f2f 100644 --- a/ThirdParty/Ert/devel/python/test/latex_test.py +++ b/ThirdParty/Ert/devel/python/test/latex_test.py @@ -41,15 +41,22 @@ class LaTeXTest( unittest.TestCase ): def test_cleanup( self ): lx = latex.LaTeX( "%s/report_OK.tex" % statoil_path , in_place = True ) + self.assertTrue( lx.in_place ) self.assertTrue( lx.compile() ) for ext in ["log" , "aux" , "nav" , "out" , "snm" , "toc"]: self.assertFalse( os.path.exists( "%s/report_OK.%s" % (statoil_path , ext) )) lx = latex.LaTeX( "%s/report_OK.tex" % statoil_path , in_place = False ) + self.assertFalse( lx.in_place ) run_path = lx.runpath self.assertTrue( lx.compile() ) self.assertFalse( os.path.exists( run_path ) ) + lx = latex.LaTeX( "%s/report_OK.tex" % statoil_path , in_place = False ) + run_path = lx.runpath + self.assertTrue( lx.compile( cleanup = False) ) + self.assertTrue( os.path.exists( "%s/report_OK.log" % run_path)) + def test_report(self): @@ -61,12 +68,19 @@ class LaTeXTest( unittest.TestCase ): self.assertTrue( lx.compile() ) + def test_target(self): + lx = latex.LaTeX( "%s/report_OK.tex" % statoil_path ) + self.assertTrue( lx.compile() ) + self.assertTrue( os.path.exists( lx.target )) + + def fast_suite(): suite = unittest.TestSuite() suite.addTest( LaTeXTest( 'test1' )) suite.addTest( LaTeXTest( 'test_report' )) suite.addTest( LaTeXTest( 'test_cleanup' )) + suite.addTest( LaTeXTest( 'test_target' )) return suite diff --git a/ThirdParty/Ert/devel/python/test/local_bash b/ThirdParty/Ert/devel/python/test/local_bash index 9c1b3b4173..828ca31a33 100644 --- a/ThirdParty/Ert/devel/python/test/local_bash +++ b/ThirdParty/Ert/devel/python/test/local_bash @@ -1,13 +1,14 @@ -ln -sf ../../../build/lib/libert_util.so ../lib/libert_util.so -ln -sf ../../../build/lib/libgeometry.so ../lib/libgeometry.so -ln -sf ../../../build/lib/libanalysis.so ../lib/libanalysis.so -ln -sf ../../../build/lib/libecl.so ../lib/libecl.so -ln -sf ../../../build/lib/librms.so ../lib/librms.so -ln -sf ../../../build/lib/libsched.so ../lib/libsched.so -ln -sf ../../../build/lib/libenkf.so ../lib/libenkf.so -ln -sf ../../../build/lib/libjob_queue.so ../lib/libjob_queue.so -ln -sf ../../../build/lib/libconfig.so ../lib/libconfig.so -ln -sf ../../../build/lib/libwell.so ../lib/libwell.so +mkdir -p ../lib64 +ln -sf ../../../build/lib64/libert_util.so ../lib64/libert_util.so +ln -sf ../../../build/lib64/libert_geometry.so ../lib64/libert_geometry.so +ln -sf ../../../build/lib64/libanalysis.so ../lib64/libanalysis.so +ln -sf ../../../build/lib64/libecl.so ../lib64/libecl.so +ln -sf ../../../build/lib64/librms.so ../lib64/librms.so +ln -sf ../../../build/lib64/libsched.so ../lib64/libsched.so +ln -sf ../../../build/lib64/libenkf.so ../lib64/libenkf.so +ln -sf ../../../build/lib64/libjob_queue.so ../lib64/libjob_queue.so +ln -sf ../../../build/lib64/libconfig.so ../lib64/libconfig.so +ln -sf ../../../build/lib64/libecl_well.so ../lib64/libecl_well.so export PYTHONPATH=$PWD/../python:$PYTHONPATH diff --git a/ThirdParty/Ert/devel/python/test/local_csh b/ThirdParty/Ert/devel/python/test/local_csh index 9b3f8a807a..874de02c90 100644 --- a/ThirdParty/Ert/devel/python/test/local_csh +++ b/ThirdParty/Ert/devel/python/test/local_csh @@ -1,12 +1,13 @@ -ln -sf ../../../build/lib/libert_util.so ../lib/libert_util.so -ln -sf ../../../build/lib/libgeometry.so ../lib/libgeometry.so -ln -sf ../../../build/lib/libanalysis.so ../lib/libanalysis.so -ln -sf ../../../build/lib/libecl.so ../lib/libecl.so -ln -sf ../../../build/lib/librms.so ../lib/librms.so -ln -sf ../../../build/lib/libsched.so ../lib/libsched.so -ln -sf ../../../build/lib/libenkf.so ../lib/libenkf.so -ln -sf ../../../build/lib/libjob_queue.so ../lib/libjob_queue.so -ln -sf ../../../build/lib/libconfig.so ../lib/libconfig.so -ln -sf ../../../build/lib/libwell.so ../lib/libwell.so +mkdir -p ../lib64 +ln -sf ../../../build/lib64/libert_util.so ../lib64/libert_util.so +ln -sf ../../../build/lib64/libert_geometry.so ../lib64/libert_geometry.so +ln -sf ../../../build/lib64/libanalysis.so ../lib64/libanalysis.so +ln -sf ../../../build/lib64/libecl.so ../lib64/libecl.so +ln -sf ../../../build/lib64/librms.so ../lib64/librms.so +ln -sf ../../../build/lib64/libsched.so ../lib64/libsched.so +ln -sf ../../../build/lib64/libenkf.so ../lib64/libenkf.so +ln -sf ../../../build/lib64/libjob_queue.so ../lib64/libjob_queue.so +ln -sf ../../../build/lib64/libconfig.so ../lib64/libconfig.so +ln -sf ../../../build/lib64/libecl_well.so ../lib64/libecl_well.so setenv PYTHONPATH $PWD/../python:$PYTHONPATH diff --git a/ThirdParty/Ert/devel/python/test/restart_test.py b/ThirdParty/Ert/devel/python/test/restart_test.py index d6bf3674d1..4aa7382244 100644 --- a/ThirdParty/Ert/devel/python/test/restart_test.py +++ b/ThirdParty/Ert/devel/python/test/restart_test.py @@ -26,9 +26,10 @@ import ert import ert.ecl.ecl as ecl from test_util import approx_equal, approx_equalv, file_equal - -file = "test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST" -fmt_file = "test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.FUNRST" +xfile0 = "test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.X0000" +file = "test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST" +fmt_file = "test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.FUNRST" +grid_file = "test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID" def load_missing(): ecl.EclFile( "No/Does/not/exist") @@ -47,15 +48,16 @@ class RestartTest( unittest.TestCase ): if os.path.exists( file ): os.unlink( file ) + - def test_report(self): - self.assertTrue( ecl.EclFile.contains_report_step( file , 4 )) - self.assertTrue( ecl.EclFile.contains_report_step( file , 0 )) - self.assertTrue( ecl.EclFile.contains_report_step( file , 62 )) - self.assertFalse( ecl.EclFile.contains_report_step( file , -1 )) - self.assertFalse( ecl.EclFile.contains_report_step( file , 100 )) + def test_report_file(self , fname): + self.assertTrue( ecl.EclFile.contains_report_step( fname , 4 )) + self.assertTrue( ecl.EclFile.contains_report_step( fname , 0 )) + self.assertTrue( ecl.EclFile.contains_report_step( fname , 62 )) + self.assertFalse( ecl.EclFile.contains_report_step( fname , -1 )) + self.assertFalse( ecl.EclFile.contains_report_step( fname , 100 )) - f = ecl.EclFile( file ) + f = ecl.EclFile( fname ) self.assertTrue( f.has_report_step( 4 )) self.assertTrue( f.has_report_step( 0 )) self.assertTrue( f.has_report_step( 62 )) @@ -64,9 +66,12 @@ class RestartTest( unittest.TestCase ): self.assertFalse( f.has_report_step( 100 )) + def test_report(self): + self.test_report_file(file) - def test_dates(self): + + def test_date(self): f = ecl.EclFile( file ) self.assertTrue( f.has_sim_time( datetime.datetime( 2001 , 6 , 1) )) self.assertFalse( f.has_sim_time( datetime.datetime( 2005 , 6 , 1) )) @@ -78,6 +83,50 @@ class RestartTest( unittest.TestCase ): self.assertFalse( ecl.EclFile.contains_sim_time( file , datetime.datetime( 1999 , 6 , 1) )) self.assertFalse( ecl.EclFile.contains_sim_time( file , datetime.datetime( 2001 , 6 , 11) )) + + + + def test_report_list_file(self , fname , rlist0): + rlist = ecl.EclFile.file_report_list( fname ) + self.assertTrue( approx_equalv( rlist , rlist0 )) + + f = ecl.EclFile( fname ) + rlist = f.report_list + self.assertTrue( approx_equalv( rlist , rlist0 )) + + + + def test_report_list(self): + rlist0 = range(63) + self.test_report_list_file( file , rlist0 ) + + rlist0 = [0] + self.test_report_list_file( xfile0 , rlist0 ) + + f = ecl.EclFile( grid_file ) + self.assertRaises( TypeError , ecl.EclFile.file_report_list) + + + def test_dates(self): + f = ecl.EclFile(file) + dates = f.dates + self.assertTrue( len(dates) == 63 ) + + f = ecl.EclFile(xfile0) + dates = f.dates + self.assertTrue( len(dates) == 1 ) + self.assertTrue( dates[0] == datetime.datetime(2000,1,1)) + + + + def test_name(self): + f = ecl.EclFile( file ) + self.assertTrue( f.name == file ) + + f = ecl.EclFile( xfile0 ) + self.assertTrue( f.name == xfile0 ) + + def test_kw( self ): f = ecl.EclFile( file ) @@ -93,16 +142,21 @@ class RestartTest( unittest.TestCase ): self.assertTrue( kw4 is None ) + def fast_suite(): suite = unittest.TestSuite() + suite.addTest( RestartTest( 'test_name' )) suite.addTest( RestartTest( 'test_report' )) - suite.addTest( RestartTest( 'test_dates' )) + suite.addTest( RestartTest( 'test_date' )) suite.addTest( RestartTest( 'test_kw' )) + suite.addTest( RestartTest( 'test_report_list' )) + suite.addTest( RestartTest( 'test_dates' )) return suite if __name__ == "__main__": unittest.TextTestRunner().run( fast_suite() ) + diff --git a/ThirdParty/Ert/devel/python/test/stringlist_test.py b/ThirdParty/Ert/devel/python/test/stringlist_test.py index 7b4d19d2aa..7a441f9176 100644 --- a/ThirdParty/Ert/devel/python/test/stringlist_test.py +++ b/ThirdParty/Ert/devel/python/test/stringlist_test.py @@ -32,6 +32,21 @@ path = "test-data/Statoil/ECLIPSE/Gurbat" case = "%s/%s" % (path , base) +def pop_empty(): + s = StringList( initial = initList ) + s.pop() + s.pop() + s.pop() + s.pop() + +def last_empty(): + s = StringList( initial = initList ) + s.pop() + s.pop() + s.pop() + s.last + + class StringListTest( unittest.TestCase ): def setUp( self ): @@ -44,6 +59,22 @@ class StringListTest( unittest.TestCase ): del s return st + def test_pop( self ): + s = StringList( initial = initList ) + s1 = s.pop() + self.assertTrue( len(s) == 2 ) + self.assertTrue( s1 == "S33") + + s1 = s.pop() + self.assertTrue( len(s) == 1 ) + self.assertTrue( s1 == "SABC") + + s1 = s.pop() + self.assertTrue( len(s) == 0 ) + self.assertTrue( s1 == "S1") + + self.assertRaises( IndexError , pop_empty ) + def test_create( self ): s = StringList() @@ -61,12 +92,19 @@ class StringListTest( unittest.TestCase ): for i in range(len(s)): self.assertTrue( s3[i] == initList[i] ) + def test_last( self ): + s = StringList( initial = initList ) + l = s.last + self.assertTrue( "S33" == l ) + self.assertRaises( IndexError , last_empty) + def test_reference(self): sum = ecl.EclSum( case ) wells = sum.wells() self.assertTrue( approx_equalv( wells , ['OP_1','OP_2','OP_3','OP_4','OP_5','WI_1','WI_2','WI_3'])) - + self.assertTrue( isinstance( wells , StringList )) + @@ -74,6 +112,8 @@ def fast_suite(): suite = unittest.TestSuite() suite.addTest( StringListTest( 'test_create' )) suite.addTest( StringListTest( 'test_reference' )) + suite.addTest( StringListTest( 'test_pop' )) + suite.addTest( StringListTest( 'test_last' )) return suite diff --git a/ThirdParty/Ert/devel/python/test/sum_test.py b/ThirdParty/Ert/devel/python/test/sum_test.py index 6fe607f3e2..c2b254f8fa 100644 --- a/ThirdParty/Ert/devel/python/test/sum_test.py +++ b/ThirdParty/Ert/devel/python/test/sum_test.py @@ -95,6 +95,8 @@ class SumTest( unittest.TestCase ): sum = self.sum d = sum.dates + self.assertEqual( d[0] , datetime.datetime( 2000 , 1 , 1 , 0 , 0 , 0)) + self.assertEqual( d[62] , datetime.datetime( 2004 , 12 , 31 , 0 , 0 , 0)) self.assertEqual( len(d) , 63 ) self.assertEqual( d[25] , datetime.datetime( 2001 , 12 , 1 , 0 , 0 , 0)) self.assertEqual( sum.iget_date( 25 ) , datetime.datetime( 2001 , 12 , 1 , 0 , 0 , 0)) @@ -105,6 +107,9 @@ class SumTest( unittest.TestCase ): days = sum.days self.assertTrue( approx_equal( days[50] , 1461 )) + self.assertEqual( sum.start_time , datetime.datetime( 2000 , 1 , 1 , 0 , 0 , 0)) + self.assertEqual( sum.end_time , datetime.datetime( 2004 , 12 , 31 , 0 , 0 , 0)) + self.assertTrue( sum.check_sim_time(datetime.datetime( 2004 , 12 , 31 , 0 , 0 , 0))) def test_keys(self): sum = self.sum @@ -176,6 +181,55 @@ class SumTest( unittest.TestCase ): os.chdir( cwd ) + + + def test_var_properties( self ): + sum = self.sum + self.assertRaises( KeyError , sum.smspec_node , "BJARNE" ) + + node = sum.smspec_node( "FOPT" ) + self.assertTrue( node.is_total ) + self.assertFalse( node.is_historical ) + + node = sum.smspec_node( "FOPR" ) + self.assertFalse( node.is_total ) + self.assertFalse( node.is_historical ) + self.assertTrue( node.keyword == "FOPR" ) + + node = sum.smspec_node( "FOPRH" ) + self.assertFalse( node.is_total ) + self.assertTrue( node.is_historical ) + self.assertTrue( node.is_rate ) + self.assertTrue( node.keyword == "FOPRH" ) + + node = sum.smspec_node( "WOPR:OP_1" ) + self.assertFalse( node.is_total ) + self.assertTrue( node.is_rate ) + self.assertTrue( node.keyword == "WOPR" ) + + node = sum.smspec_node( "WOPT:OP_1" ) + self.assertTrue( node.is_total ) + self.assertFalse( node.is_rate ) + self.assertTrue( node.unit == "SM3" ) + self.assertTrue( node.wgname == "OP_1") + self.assertTrue( node.keyword == "WOPT" ) + + self.assertTrue( sum.unit( "FOPR" ) == "SM3/DAY") + + + node = sum.smspec_node( "FOPTH" ) + self.assertTrue( node.is_total ) + self.assertFalse( node.is_rate ) + self.assertTrue( node.wgname is None ) + + node = sum.smspec_node( "FOPTH" ) + self.assertTrue( node.num is None ) + + node = sum.smspec_node( "BPR:1095" ) + self.assertTrue( node.num == 1095 ) + + + def fast_suite(): suite = unittest.TestSuite() suite.addTest( SumTest( 'test_load' )) @@ -191,6 +245,7 @@ def fast_suite(): suite.addTest( SumTest( 'test_fwrite' )) suite.addTest( SumTest( 'test_block' )) suite.addTest( SumTest( 'test_restart' )) + suite.addTest( SumTest( 'test_var_properties' )) return suite diff --git a/ThirdParty/Ert/devel/python/test/test-data/local/config/simple_config b/ThirdParty/Ert/devel/python/test/test-data/local/config/simple_config new file mode 100644 index 0000000000..413fd38a8f --- /dev/null +++ b/ThirdParty/Ert/devel/python/test/test-data/local/config/simple_config @@ -0,0 +1,226 @@ +QUEUE_OPTION LSF LSF_LOGIN_SHELL /bin/csh + +DEFINE __NAME__ EXAMPLE_01_BASE +DEFINE __INCLUDE_PATH__ /private/joaho/ERT/git/ert/Gurbat +DEFINE __GRID__ __NAME__.EGRID +DEFINE MULTIR_FILE MULTIR.INC + +JOB_SCRIPT /private/joaho/ERT/Statoil/etc/ERT/Scripts/job_dispatch.py + + +-- The ECLIPSE data files which are used as init. + +GRID __GRID__ +SCHEDULE_FILE target.SCH + + +--SCHEDULE_PREDICTION_FILE prediction.sch + +INSTALL_JOB RMS_BATCH /private/joaho/ERT/Statoil/etc/ERT/Config/jobs/resmod/RMS_BATCH_TEST +INSTALL_JOB ECLIPSE_TEST ECLIPSE_TEST +INSTALL_JOB AVGP jobs/AVGP +--INSTALL_JOB RMS_TEST /private/joaho/ERT/Statoil/etc/ERT/Config/jobs/resmod/RMS_BATCH +SETENV MANY_PATH $PATH:$LD_LIBRARY_PATH:$MANPATH:/lib + + +--SCHEDULE_PREDICTION_FILE prediction2.schi + +DATA_FILE Example_01_base.data + + +INIT_SECTION __INCLUDE_PATH__/EQUIL.INC +LICENSE_PATH /tmp/BJARNE_PATH + +--SETENV ERT_LINK_LSF True +--LSF_SERVER be-grid01 + +--CASE_TABLE CaseNames + + +--PRE_CLEAR_RUNPATH TRUE + +-- Where do you want to store things + + +RUNPATH /scratch/ert/joaho/Run1/Xrun%d +RERUN_PATH /scratch/ert/joaho/Rerun/Xrun%d + + + + + +ENSPATH /tmp/Gurbat/104BlockFS +ECLBASE ECL_%04d + +QC_PATH /tmp/QC + +-- How to simulate + + +INSTALL_JOB PVT jobs/PVT +INSTALL_JOB NULL jobs/NULL + +INSTALL_JOB RMS_TEST /private/joaho/ERT/Statoil/etc/ERT/Config/jobs/resmod/RUN_RMS_20XX +INSTALL_JOB PRESSURE33 jobs/Pressure33 + +--FORWARD_MODEL RMS_BATCH(=2012.0.1, =/rms/rms_project_2012 , =MAIN_WORKFLOW) +FORWARD_MODEL ECLIPSE100_2009.1 +--FORWARD_MODEL PRESSURE33 +--FORWARD_MODEL RMS_TEST( = , = , = 2011.0.2, =/rms/rms_project_2012 , =/d/proj/bg/ior_fsenter/GRM_TDP/Gimle/work/tfen/r0004/models/eclipse/refcase/, =Forward_Seismic,=SEISMIC_FORWARD_TARGET.INC) + +--FORWARD_MODEL AVGP +--FORWARD_MODEL NULL + + +UMASK 0 +MAX_SUBMIT 10 +MAX_RESAMPLE 1 + + +ADD_FIXED_LENGTH_SCHEDULE_KW Jalla 7 +ADD_FIXED_LENGTH_SCHEDULE_KW Jalla2 70 + + + +DBASE_TYPE BLOCK_FS + +-- The ensemble +NUM_REALIZATIONS 25 + +IMAGE_TYPE png +PLOT_DRIVER PLPLOT + +RUN_TEMPLATE Template1 File1 File:1 +RUN_TEMPLATE Template1 File2 File:2 + + +INSTALL_JOB PRESSURE100 PRESSURE100 + + +GEN_KW MULTFLT FAULT_TEMPLATE MULTFLT.INC Config/MULTFLT.txt +GEN_KW GRID_PARAMS GRID_PARAM_TEMPLATE GRID_PARAMS.INC Config/GRID_PARAMS.txt --MIN_STD:Config/GRID_PARAMS.min_std +GEN_KW FLUID_PARAMS FLUID_PARAM_TEMPLATE FLUID_PARAMS.INC Config/FLUID_PARAMS.txt --MIN_STD:Config/FLUID_PARAMS.min_std + +GEN_PARAM GP GP.txt INIT_FILES:GP/GP.txt INPUT_FORMAT:ASCII OUTPUT_FORMAT:ASCII + + + + +UPDATE_RESULTS TRUE +ENKF_RERUN FALSE +RERUN_START 0 + +INSTALL_JOB SGOF_TAB jobs/SGOF_TAB + + + +ENKF_MERGE_OBSERVATIONS TRUE +--ENKF_SCHED_FILE sched_config + + +--ADD_STATIC_KW __ALL__ +ADD_STATIC_KW BJARNE KW2 + +ENKF_ALPHA 1.50 +----------------------------------------------------------------- +IMAGE_VIEWER /tmp/echo.sh +IMAGE_VIEWER /usr/bin/display + + +QUEUE_SYSTEM LSF +QUEUE_SYSTEM LOCAL +QUEUE_SYSTEM RSH + +MAX_RUNNING_LOCAL 3 +MAX_RUNNING_LSF 100 +MAX_RUNNING_RSH 6 +--LSF_QUEUE SUPERKO + +RSH_HOST be-lx655082:2 be-lx633214:2 + + + +LOG_LEVEL 3 +LOG_FILE /tmp/log/log.txt +UPDATE_LOG_PATH /tmp/UP + +KEEP_RUNPATH 0 - 9 +DATA_KW __INCLUDE_PATH__ +DATA_KW WhatEver SomeThing + + + + +-- Quantities to estimate on + +HISTORY_SOURCE REFCASE_HISTORY +REFCASE __NAME__.DATA + + +STORE_SEED RandomSeed +LOAD_SEED RandomSeed + + +--EQUIL EQUIL EQUIL.INC equil_config + +RUN_TEMPLATE GEN_DATA_TEMPLATE GEN_DATA_FILE +--GEN_DATA PRESSURE100 INPUT_FORMAT:ASCII RESULT_FILE:PRESSURE%04d + + + +--ANALYSIS_LOAD RML_ENKF /project/res/x86_64_RH_5/lib/rml_enkf.so +--ANALYSIS_LOAD RML_ENKF rml_enkf.so +ANALYSIS_LOAD RML_ENKF /private/joaho/ERT/NR/libanalysis/src/rml_enkf.so + +--ANALYSIS_LOAD FWD_ENKF /private/joaho/ERT/NR/tmp-build/libanalysis/src/sqrt_enkf.so +--ANALYSIS_LOAD SFWD_ENKF /private/joaho/ERT/NR/tmp-build/libanalysis/src/std_enkf.so +ANALYSIS_SET_VAR STD_ENKF ENKF_TRUNCATION 0.95 +--ANALYSIS_SET_VAR SQRT_ENKF ENKF_TRUNCATION 0.99 +ANALYSIS_SET_VAR STD_ENKF ENKF_NCOMP 2 +ANALYSIS_SET_VAR STD_ENKF ENKF_TRUNCATION 0.98 +ANALYSIS_SELECT STD_ENKF + +ANALYSIS_LOAD TEST_ENKF /private/joaho/ERT/NR/libanalysis/src/test_enkf.so + + +QUEUE_OPTION LSF LSF_LOGIN_SHELL /bin/csh + + +FIELD PRESSURE DYNAMIC +FIELD SWAT DYNAMIC MIN:0 MAX:1 +FIELD SGAS DYNAMIC MIN:0 MAX:1 +FIELD RS DYNAMIC MIN:0 +FIELD RV DYNAMIC MIN:0.0034 + +--CONTAINER CXX PRESSURE SWAT + + +--SURFACE TOP OUTPUT_FILE:surf.irap INIT_FILES:Surfaces/d_BCU_%d.irap BASE_SURFACE:Surfaces/d_BCU_0.irap + +-- Observations +OBS_CONFIG observations + + +--SUMMARY F* RPR:* + +PLOT_PATH plots + + +IMAGE_VIEWER /tmp/noplot.sh + +REPORT_SEARCH_PATH /private/joaho/ERT/Statoil/etc/ERT/reports + +REPORT_WELL_LIST OP_1 OP_2 OP_3 +REPORT_WELL_LIST OP_4 OP_5 + +REPORT_LIST well_opt_report.tex + +REPORT_PATH Reports + + +----------------------------------------------------------------- + + + +WORKFLOW_JOB_DIRECTORY WorkflowJobs +LOAD_WORKFLOW Workflows/PLOT_AND_EXIT diff --git a/ThirdParty/Ert/devel/python/test/test_all.py b/ThirdParty/Ert/devel/python/test/test_all.py index 8f9c310294..e1f21e2322 100644 --- a/ThirdParty/Ert/devel/python/test/test_all.py +++ b/ThirdParty/Ert/devel/python/test/test_all.py @@ -14,7 +14,9 @@ import region_test import latex_test import fortio_test import restart_test +import config_test import stringlist_test +import tvector_test def run_suite(name , suite): print "Running tests from %12s:" % name, @@ -29,7 +31,7 @@ def run(name , module): if hasattr(module , "slow_suite"): run_suite( name , getattr(module , "slow_suite")()) - +run("config" , config_test) run("restart" , restart_test) run("kw" , kw_test) run("summary" , sum_test) @@ -43,3 +45,4 @@ run("region" , region_test) run("latex" , latex_test) run("fortio" , fortio_test) run("stringlist" , stringlist_test) +run("tvector" , tvector_test) diff --git a/ThirdParty/Ert/devel/python/test/tvector_test.py b/ThirdParty/Ert/devel/python/test/tvector_test.py new file mode 100644 index 0000000000..f3b5c4b70c --- /dev/null +++ b/ThirdParty/Ert/devel/python/test/tvector_test.py @@ -0,0 +1,83 @@ +#!/usr/bin/env python +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'tvector_test.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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. + + +import os +import datetime +import unittest +import ert +from ert.util.tvector import DoubleVector +from ert.util.tvector import IntVector +from ert.util.tvector import BoolVector + +from test_util import approx_equal, approx_equalv + + + +class TVectorTest( unittest.TestCase ): + + + def setUp(self): + pass + + + def test_activeList(self): + active_list = IntVector.active_list("1,10,100-105") + self.assertTrue( len(active_list) == 8 ) + self.assertTrue( active_list[0] == 1) + self.assertTrue( active_list[2] == 100) + self.assertTrue( active_list[7] == 105) + + active_list = IntVector.active_list("1,10,100-105X") + self.assertFalse( active_list ) + + + + def test_activeMask(self): + active_list = BoolVector.active_mask("1 , 4 - 7 , 10") + self.assertTrue( len(active_list) == 11 ) + self.assertTrue( active_list[1]) + self.assertTrue( active_list[4]) + self.assertTrue( active_list[10]) + self.assertFalse( active_list[9]) + self.assertFalse( active_list[8]) + + active_list = BoolVector.active_mask("1,4-7,10X") + self.assertFalse( active_list ) + + + + def test_true(self): + l = IntVector() + self.assertFalse( l ) # Will invoke the __len__ function; could override with __nonzero__ + l[0] = 1 + self.assertTrue( l ) + + + +def fast_suite(): + suite = unittest.TestSuite() + suite.addTest( TVectorTest( 'test_activeList' )) + suite.addTest( TVectorTest( 'test_activeMask' )) + suite.addTest( TVectorTest( 'test_true' )) + return suite + + +if __name__ == "__main__": + unittest.TextTestRunner().run( fast_suite() ) + + diff --git a/ThirdParty/Ert/devel/redhat/ert.ecl.spec b/ThirdParty/Ert/devel/redhat/ert.ecl.spec index cd206bfbf9..64f138af60 100644 --- a/ThirdParty/Ert/devel/redhat/ert.ecl.spec +++ b/ThirdParty/Ert/devel/redhat/ert.ecl.spec @@ -4,7 +4,7 @@ Name: ert.ecl Version: 1.0 -Release: 0 +Release: 1 Summary: ERT - Ensemble based Reservoir Tool - ECL library License: GPL-3+ Group: Development/Libraries/C and C++ @@ -38,6 +38,7 @@ Group: Development/Libraries/C and C++ Requires: %{name} = %{version} Requires: lapack-devel Requires: libert.ecl1 = %{version} +BuildArch: noarch %description devel This package contains the development and header files for ert.ecl @@ -47,7 +48,7 @@ This package contains the development and header files for ert.ecl %build cd devel -cmake28 -DSHARED_LIB=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%{_prefix} +cmake28 -DSHARED_LIB=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%{_prefix} -DBUILD_ECL_SUMMARY=1 make %install @@ -67,8 +68,13 @@ rm -rf %{buildroot} %files -n libert.ecl1 %defattr(-,root,root,-) %{_libdir}/*.so.* +%{_bindir}/* %files devel %defattr(-,root,root,-) %{_libdir}/*.so %{_includedir}/* + +%changelog +* Tue Feb 19 2013 Arne Morten Kvarving 1.0-1 +- Mark -devel package as architecture independent From 4a8a24c43341a60c67d90f859fa2dc18f69fe5a5 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 4 Apr 2013 11:27:38 +0200 Subject: [PATCH 180/242] Disable install of ERT libs and headers p4#: 21126 --- CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1770942634..9be751d659 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,6 +37,11 @@ include (ResInsightVersion.cmake) ################################################################################ # ERT ################################################################################ + +# Disable install of ERT libs and headers, as Ert code is compiled and linked directly +# into ResInsight +set (INSTALL_ERT false) + add_subdirectory(ThirdParty/Ert/devel) include_directories( From cc8568cca6ec49c0ee609a16976a3d0132012183 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 4 Apr 2013 12:08:36 +0200 Subject: [PATCH 181/242] Fixed inverted test for null pointer p4#: 21127 --- ApplicationCode/ReservoirDataModel/RigCaseData.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ReservoirDataModel/RigCaseData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseData.cpp index b10a189744..ad45aca665 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseData.cpp @@ -375,7 +375,7 @@ void RigCaseData::setActiveCellInfo(RifReaderInterface::PorosityModelResultType //-------------------------------------------------------------------------------------------------- void RigCaseData::computeActiveCellsGeometryBoundingBox() { - if (m_activeCellInfo.notNull() || m_fractureActiveCellInfo.notNull()) + if (m_activeCellInfo.isNull() || m_fractureActiveCellInfo.isNull()) { return; } From 75f089d0d4573999303fd531ab1be25502c4f900 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 4 Apr 2013 16:53:34 +0200 Subject: [PATCH 182/242] Statistics UI is now functional, together with two percentile evaluation methods Refurbished the calculation algorithm code somewhat p4#: 21134 --- .../ProjectDataModel/RimStatisticsCase.cpp | 58 ++- .../RimStatisticsCaseEvaluator.cpp | 465 ++++++++++-------- .../RimStatisticsCaseEvaluator.h | 44 +- .../RigCaseCellResultsData.cpp | 4 +- 4 files changed, 323 insertions(+), 248 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp index 891797524b..a2595f8b36 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp @@ -185,6 +185,12 @@ void RimStatisticsCase::computeStatistics() RimStatisticsConfig statisticsConfig; + statisticsConfig.m_calculatePercentiles = m_calculatePercentiles(); + statisticsConfig.m_pMaxPos = m_highPercentile(); + statisticsConfig.m_pMidPos = m_midPercentile(); + statisticsConfig.m_pMinPos = m_lowPercentile(); + statisticsConfig.m_pValMethod = m_percentileCalculationType(); + std::vector timeStepIndices; for (size_t i = 0; i < timeStepCount; i++) { @@ -193,31 +199,53 @@ void RimStatisticsCase::computeStatistics() RigCaseData* resultCase = reservoirData(); - QList > resultSpecification; + QList resultSpecification; - //resultSpecification.append(qMakePair(RimDefines::DYNAMIC_NATIVE, QString("PRESSURE"))); - - + for(size_t pIdx = 0; pIdx < m_selectedDynamicProperties().size(); ++pIdx) { - QStringList resultNames = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->resultNames(RimDefines::DYNAMIC_NATIVE); - foreach(QString resultName, resultNames) - { - resultSpecification.append(qMakePair(RimDefines::DYNAMIC_NATIVE, resultName)); - } + resultSpecification.append(RimStatisticsCaseEvaluator::ResSpec(RifReaderInterface::MATRIX_RESULTS, RimDefines::DYNAMIC_NATIVE, m_selectedDynamicProperties()[pIdx])); } + for(size_t pIdx = 0; pIdx < m_selectedStaticProperties().size(); ++pIdx) { - QStringList resultNames = sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->resultNames(RimDefines::STATIC_NATIVE); - foreach(QString resultName, resultNames) - { - resultSpecification.append(qMakePair(RimDefines::STATIC_NATIVE, resultName)); - } + resultSpecification.append(RimStatisticsCaseEvaluator::ResSpec(RifReaderInterface::MATRIX_RESULTS, RimDefines::STATIC_NATIVE, m_selectedStaticProperties()[pIdx])); + } + + for(size_t pIdx = 0; pIdx < m_selectedGeneratedProperties().size(); ++pIdx) + { + resultSpecification.append(RimStatisticsCaseEvaluator::ResSpec(RifReaderInterface::MATRIX_RESULTS, RimDefines::GENERATED, m_selectedGeneratedProperties()[pIdx])); + } + + for(size_t pIdx = 0; pIdx < m_selectedInputProperties().size(); ++pIdx) + { + resultSpecification.append(RimStatisticsCaseEvaluator::ResSpec(RifReaderInterface::MATRIX_RESULTS, RimDefines::INPUT_PROPERTY, m_selectedInputProperties()[pIdx])); + } + + for(size_t pIdx = 0; pIdx < m_selectedFractureDynamicProperties().size(); ++pIdx) + { + resultSpecification.append(RimStatisticsCaseEvaluator::ResSpec(RifReaderInterface::FRACTURE_RESULTS, RimDefines::DYNAMIC_NATIVE, m_selectedFractureDynamicProperties()[pIdx])); + } + + for(size_t pIdx = 0; pIdx < m_selectedFractureStaticProperties().size(); ++pIdx) + { + resultSpecification.append(RimStatisticsCaseEvaluator::ResSpec(RifReaderInterface::FRACTURE_RESULTS, RimDefines::STATIC_NATIVE, m_selectedFractureStaticProperties()[pIdx])); + } + + for(size_t pIdx = 0; pIdx < m_selectedFractureGeneratedProperties().size(); ++pIdx) + { + resultSpecification.append(RimStatisticsCaseEvaluator::ResSpec(RifReaderInterface::FRACTURE_RESULTS, RimDefines::GENERATED, m_selectedFractureGeneratedProperties()[pIdx])); + } + + for(size_t pIdx = 0; pIdx < m_selectedFractureInputProperties().size(); ++pIdx) + { + resultSpecification.append(RimStatisticsCaseEvaluator::ResSpec(RifReaderInterface::FRACTURE_RESULTS, RimDefines::INPUT_PROPERTY, m_selectedFractureInputProperties()[pIdx])); } - RimStatisticsCaseEvaluator stat(sourceCases, timeStepIndices, statisticsConfig, resultCase); stat.evaluateForResults(resultSpecification); + // Todo: Is this really the time and place to do the following ? JJS + for (size_t i = 0; i < reservoirViews().size(); i++) { RimReservoirView* reservoirView = reservoirViews()[i]; diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.cpp b/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.cpp index 8ce57e857e..6370dd1bcb 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.cpp @@ -30,80 +30,98 @@ //-------------------------------------------------------------------------------------------------- /// An internal class to do the actual computations //-------------------------------------------------------------------------------------------------- -class RimStatisticsEvaluator + +void calculateBasicStatistics(const std::vector& values, double* min, double* max, double* range, double* mean, double* dev) { -public: - RimStatisticsEvaluator(const std::vector& values) - : m_values(values), - m_min(HUGE_VAL), - m_max(-HUGE_VAL), - m_mean(HUGE_VAL), - m_dev(HUGE_VAL) + double m_min(HUGE_VAL); + double m_max(-HUGE_VAL); + double m_mean(HUGE_VAL); + double m_dev(HUGE_VAL); + + double sum = 0.0; + double sumSquared = 0.0; + + size_t validValueCount = 0; + + for (size_t i = 0; i < values.size(); i++) { + double val = values[i]; + if (val == HUGE_VAL) continue; + + validValueCount++; + + if (val < m_min) m_min = val; + if (val > m_max) m_max = val; + + sum += val; + sumSquared += (val * val); } - - void getStatistics(double& min, double& max, double& mean, double& dev, double& range) + if (validValueCount > 0) { - evaluate(); + m_mean = sum / validValueCount; - min = m_min; - max = m_max; - mean = m_mean; - dev = m_dev; - range = m_max - m_min; + // http://en.wikipedia.org/wiki/Standard_deviation#Rapid_calculation_methods + // Running standard deviation + + double s0 = validValueCount; + double s1 = sum; + double s2 = sumSquared; + + m_dev = cvf::Math::sqrt( (s0 * s2) - (s1 * s1) ) / s0; } -private: - void evaluate() + if (min) *min = m_min; + if (max) *max = m_max; + if (range) *range = m_max - m_min; + + if (mean) *mean = m_mean; + if (dev) *dev = m_dev; +} + + +//-------------------------------------------------------------------------------------------------- +/// Calculate the percentiles of /a inputValues at the pValPosition percentages using the "Nearest Rank" +/// method. This method treats HUGE_VAL as "undefined" values, and ignores these. Will return HUGE_VAL if +/// the inputValues does not contain any valid values +//-------------------------------------------------------------------------------------------------- + +std::vector calculateNearestRankPercentiles(const std::vector & inputValues, const std::vector& pValPositions) +{ + std::vector sortedValues; + sortedValues.reserve(inputValues.size()); + + for (size_t i = 0; i < inputValues.size(); ++i) { - double sum = 0.0; - double sumSquared = 0.0; - - size_t validValueCount = 0; - - for (size_t i = 0; i < m_values.size(); i++) + if (inputValues[i] != HUGE_VAL) { - double val = m_values[i]; - if (val == HUGE_VAL) continue; - - validValueCount++; - - if (val < m_min) m_min = val; - if (val > m_max) m_max = val; - - sum += val; - sumSquared += (val * val); - } - - if (validValueCount > 0) - { - m_mean = sum / validValueCount; - - - // http://en.wikipedia.org/wiki/Standard_deviation#Rapid_calculation_methods - // Running standard deviation - - double s0 = validValueCount; - double s1 = sum; - double s2 = sumSquared; - - m_dev = cvf::Math::sqrt( (s0 * s2) - (s1 * s1) ) / s0; + sortedValues.push_back(inputValues[i]); } } + std::sort(sortedValues.begin(), sortedValues.end()); -private: - const std::vector& m_values; + std::vector percentiles(pValPositions.size(), HUGE_VAL); + if (sortedValues.size()) + { + for (size_t i = 0; i < pValPositions.size(); ++i) + { + double pVal = HUGE_VAL; - double m_min; - double m_max; - double m_mean; - double m_dev; + size_t pValIndex = static_cast(sortedValues.size() * abs(pValPositions[i]) / 100); + pValIndex += 1; + + if (pValIndex >= sortedValues.size() ) pValIndex = sortedValues.size() - 1; + + pVal = sortedValues[pValIndex]; + percentiles[i] = pVal; + } + } + + return percentiles; }; - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -135,29 +153,28 @@ QString createResultNameMax(const QString& resultName) { return resultName + "_ QString createResultNameMean(const QString& resultName) { return resultName + "_MEAN"; } QString createResultNameDev(const QString& resultName) { return resultName + "_DEV"; } QString createResultNameRange(const QString& resultName) { return resultName + "_RANGE"; } +QString createResultNamePVal(const QString& resultName, double pValPos) { return resultName + "_P_" + QString::number(pValPos); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimStatisticsCaseEvaluator::buildSourceMetaData(RimDefines::ResultCatType resultType, const QString& resultName) +void RimStatisticsCaseEvaluator::buildSourceMetaData(RifReaderInterface::PorosityModelResultType poroModel, RimDefines::ResultCatType resultType, const QString& resultName) { if (m_sourceCases.size() == 0) return; - std::vector timeStepDates = m_sourceCases[0]->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->timeStepDates(0); + std::vector timeStepDates = m_sourceCases[0]->results(poroModel)->cellResults()->timeStepDates(0); for (size_t caseIdx = 1; caseIdx < m_sourceCases.size(); caseIdx++) { - RigCaseData* eclipseCase = m_sourceCases.at(caseIdx)->reservoirData(); - - RimReservoirCellResultsStorage* matrixResults = m_sourceCases[caseIdx]->results(RifReaderInterface::MATRIX_RESULTS); - size_t scalarResultIndex = matrixResults->findOrLoadScalarResult(resultType, resultName); + RimReservoirCellResultsStorage* cellResultsStorage = m_sourceCases[caseIdx]->results(poroModel); + size_t scalarResultIndex = cellResultsStorage->findOrLoadScalarResult(resultType, resultName); if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) { - size_t scalarResultIndex = matrixResults->cellResults()->addEmptyScalarResult(resultType, resultName, false); - matrixResults->cellResults()->setTimeStepDates(scalarResultIndex, timeStepDates); + size_t scalarResultIndex = cellResultsStorage->cellResults()->addEmptyScalarResult(resultType, resultName, false); + cellResultsStorage->cellResults()->setTimeStepDates(scalarResultIndex, timeStepDates); - std::vector< std::vector >& dataValues = matrixResults->cellResults()->cellScalarResults(scalarResultIndex); + std::vector< std::vector >& dataValues = cellResultsStorage->cellResults()->cellScalarResults(scalarResultIndex); dataValues.resize(timeStepDates.size()); } } @@ -166,222 +183,234 @@ void RimStatisticsCaseEvaluator::buildSourceMetaData(RimDefines::ResultCatType r //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimStatisticsCaseEvaluator::evaluateForResults(const QList >& resultSpecification) +void RimStatisticsCaseEvaluator::evaluateForResults(const QList& resultSpecification) { CVF_ASSERT(m_destinationCase); - - size_t activeMatrixCellCount = m_destinationCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->globalActiveCellCount(); - RigCaseCellResultsData* matrixResults = m_destinationCase->results(RifReaderInterface::MATRIX_RESULTS); + + // First build the destination result data structures to receive the statistics for (int i = 0; i < resultSpecification.size(); i++) { - RimDefines::ResultCatType resultType = resultSpecification[i].first; - QString resultName = resultSpecification[i].second; + RifReaderInterface::PorosityModelResultType poroModel = resultSpecification[i].m_poroModel; + RimDefines::ResultCatType resultType = resultSpecification[i].m_resType; + QString resultName = resultSpecification[i].m_resVarName; + + size_t activeCellCount = m_destinationCase->activeCellInfo(poroModel)->globalActiveCellCount(); + RigCaseCellResultsData* destCellResultsData = m_destinationCase->results(poroModel); // Special handling if SOIL is asked for // Build SGAS/SWAT meta data, SOIL is automatically generated as part of RigCaseCellResultsData::findOrLoadScalarResultForTimeStep if (resultName.toUpper() == "SOIL") { - size_t swatIndex = m_sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->findScalarResultIndex(resultType, "SWAT"); + size_t swatIndex = m_sourceCases.at(0)->results(poroModel)->cellResults()->findScalarResultIndex(resultType, "SWAT"); if (swatIndex != cvf::UNDEFINED_SIZE_T) { - buildSourceMetaData(resultType, "SWAT"); + buildSourceMetaData(poroModel, resultType, "SWAT"); } - size_t sgasIndex = m_sourceCases.at(0)->results(RifReaderInterface::MATRIX_RESULTS)->cellResults()->findScalarResultIndex(resultType, "SGAS"); + size_t sgasIndex = m_sourceCases.at(0)->results(poroModel)->cellResults()->findScalarResultIndex(resultType, "SGAS"); if (sgasIndex != cvf::UNDEFINED_SIZE_T) { - buildSourceMetaData(resultType, "SGAS"); + buildSourceMetaData(poroModel, resultType, "SGAS"); } } else { - // Meta info is loaded from disk for first case only - // Build metadata for all other source cases - buildSourceMetaData(resultType, resultName); + // Meta info is loaded from disk for first case only + // Build metadata for all other source cases + buildSourceMetaData(poroModel, resultType, resultName); } - QString minResultName = createResultNameMin(resultName); - QString maxResultName = createResultNameMax(resultName); - QString meanResultName = createResultNameMean(resultName); - QString devResultName = createResultNameDev(resultName); - QString rangeResultName = createResultNameRange(resultName); + // Create new result data structures to contain the statistical values + std::vector statisticalResultNames; - if (activeMatrixCellCount > 0) + statisticalResultNames.push_back(createResultNameMin(resultName)); + statisticalResultNames.push_back(createResultNameMax(resultName)); + statisticalResultNames.push_back(createResultNameMean(resultName)); + statisticalResultNames.push_back(createResultNameDev(resultName)); + statisticalResultNames.push_back(createResultNameRange(resultName)); + + if (m_statisticsConfig.m_calculatePercentiles) { - addNamedResult(matrixResults, resultType, minResultName, activeMatrixCellCount); - addNamedResult(matrixResults, resultType, maxResultName, activeMatrixCellCount); - addNamedResult(matrixResults, resultType, meanResultName, activeMatrixCellCount); - addNamedResult(matrixResults, resultType, devResultName, activeMatrixCellCount); - addNamedResult(matrixResults, resultType, rangeResultName, activeMatrixCellCount); + statisticalResultNames.push_back(createResultNamePVal(resultName, m_statisticsConfig.m_pMinPos)); + statisticalResultNames.push_back(createResultNamePVal(resultName, m_statisticsConfig.m_pMidPos)); + statisticalResultNames.push_back(createResultNamePVal(resultName, m_statisticsConfig.m_pMaxPos)); + } + + if (activeCellCount > 0) + { + for (size_t i = 0; i < statisticalResultNames.size(); ++i) + { + addNamedResult(destCellResultsData, resultType, statisticalResultNames[i], activeCellCount); + } } } - if (activeMatrixCellCount > 0) + // Start the loop that calculates the statistics + + caf::ProgressInfo progressInfo(m_timeStepIndices.size(), "Computing Statistics"); + + for (size_t timeIndicesIdx = 0; timeIndicesIdx < m_timeStepIndices.size(); timeIndicesIdx++) { - caf::ProgressInfo info(m_timeStepIndices.size(), "Computing Statistics"); + size_t timeStepIdx = m_timeStepIndices[timeIndicesIdx]; - for (size_t timeIndicesIdx = 0; timeIndicesIdx < m_timeStepIndices.size(); timeIndicesIdx++) + for (size_t gridIdx = 0; gridIdx < m_destinationCase->gridCount(); gridIdx++) { - size_t timeStepIdx = m_timeStepIndices[timeIndicesIdx]; + RigGridBase* grid = m_destinationCase->grid(gridIdx); - size_t gridCount = 0; - for (size_t gridIdx = 0; gridIdx < m_destinationCase->gridCount(); gridIdx++) + for (int i = 0; i < resultSpecification.size(); i++) { - RigGridBase* grid = m_destinationCase->grid(gridIdx); + RifReaderInterface::PorosityModelResultType poroModel = resultSpecification[i].m_poroModel; + RimDefines::ResultCatType resultType = resultSpecification[i].m_resType; + QString resultName = resultSpecification[i].m_resVarName; - for (int i = 0; i < resultSpecification.size(); i++) + size_t activeCellCount = m_destinationCase->activeCellInfo(poroModel)->globalActiveCellCount(); + + if (activeCellCount == 0) continue; + + RigCaseCellResultsData* destCellResultsData = m_destinationCase->results(poroModel); + + size_t dataAccessTimeStepIndex = timeStepIdx; + + // Always evaluate statistics once, and always use time step index zero + if (resultType == RimDefines::STATIC_NATIVE) { - RimDefines::ResultCatType resultType = resultSpecification[i].first; - QString resultName = resultSpecification[i].second; + if (timeIndicesIdx > 0) continue; - size_t dataAccessTimeStepIndex = timeStepIdx; + dataAccessTimeStepIndex = 0; + } - // Always evaluate statistics once, and always use time step index zero - if (resultType == RimDefines::STATIC_NATIVE) + // Build data access objects for source scalar results + + cvf::Collection sourceDataAccessList; + for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++) + { + RimCase* eclipseCase = m_sourceCases.at(caseIdx); + + size_t scalarResultIndex = eclipseCase->results(poroModel)->findOrLoadScalarResultForTimeStep(resultType, resultName, dataAccessTimeStepIndex); + + cvf::ref dataAccessObject = eclipseCase->reservoirData()->dataAccessObject(grid, poroModel, dataAccessTimeStepIndex, scalarResultIndex); + if (dataAccessObject.notNull()) { - if (timeIndicesIdx > 0) continue; - - dataAccessTimeStepIndex = 0; + sourceDataAccessList.push_back(dataAccessObject.p()); } + } - // Build data access objects for source scalar results - cvf::Collection dataAccesObjectList; - for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++) + // Build data access objects for destination scalar results + // Find the created result container, if any, and put its dataAccessObject into the enum indexed destination collection + + cvf::Collection destinationDataAccessList; + std::vector statisticalResultNames(STAT_PARAM_COUNT); + + statisticalResultNames[MIN] = createResultNameMin(resultName); + statisticalResultNames[MAX] = createResultNameMax(resultName); + statisticalResultNames[RANGE] = createResultNameRange(resultName); + statisticalResultNames[MEAN] = createResultNameMean(resultName); + statisticalResultNames[STDEV] = createResultNameDev(resultName); + statisticalResultNames[PMIN] = createResultNamePVal(resultName, m_statisticsConfig.m_pMinPos); + statisticalResultNames[PMID] = createResultNamePVal(resultName, m_statisticsConfig.m_pMidPos); + statisticalResultNames[PMAX] = createResultNamePVal(resultName, m_statisticsConfig.m_pMaxPos); + + for (size_t stIdx = 0; stIdx < statisticalResultNames.size(); ++stIdx) + { + size_t scalarResultIndex = destCellResultsData->findScalarResultIndex(resultType, statisticalResultNames[stIdx]); + if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) { - RimCase* eclipseCase = m_sourceCases.at(caseIdx); - - size_t scalarResultIndex = eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->findOrLoadScalarResultForTimeStep(resultType, resultName, dataAccessTimeStepIndex); - - cvf::ref dataAccessObject = eclipseCase->reservoirData()->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, dataAccessTimeStepIndex, scalarResultIndex); - if (dataAccessObject.notNull()) - { - dataAccesObjectList.push_back(dataAccessObject.p()); - } + destinationDataAccessList.push_back(m_destinationCase->dataAccessObject(grid, poroModel, dataAccessTimeStepIndex, scalarResultIndex).p()); } - - - // Build data access objects form destination scalar results - cvf::ref dataAccessObjectMin = NULL; - cvf::ref dataAccessObjectMax = NULL; - cvf::ref dataAccessObjectMean = NULL; - cvf::ref dataAccessObjectDev = NULL; - cvf::ref dataAccessObjectRange = NULL; - + else { - size_t scalarResultIndex = matrixResults->findScalarResultIndex(resultType, createResultNameMin(resultName)); - if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) - { - dataAccessObjectMin = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, dataAccessTimeStepIndex, scalarResultIndex); - } + destinationDataAccessList.push_back(NULL); } + } + // Loop over the cells in the grid, get the case values, and calculate the cell statistics + + for (size_t cellIdx = 0; cellIdx < grid->cellCount(); cellIdx++) + { + + size_t globalGridCellIdx = grid->globalGridCellIndex(cellIdx); + if (m_destinationCase->activeCellInfo(poroModel)->isActive(globalGridCellIdx)) { - size_t scalarResultIndex = matrixResults->findScalarResultIndex(resultType, createResultNameMax(resultName)); - if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) - { - dataAccessObjectMax = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, dataAccessTimeStepIndex, scalarResultIndex); - } - } + // Extract the cell values from each of the cases and assemble them into one vector - { - size_t scalarResultIndex = matrixResults->findScalarResultIndex(resultType, createResultNameMean(resultName)); - if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) - { - dataAccessObjectMean = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, dataAccessTimeStepIndex, scalarResultIndex); - } - } + std::vector values(sourceDataAccessList.size(), HUGE_VAL); - { - size_t scalarResultIndex = matrixResults->findScalarResultIndex(resultType, createResultNameDev(resultName)); - if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) + bool foundAnyValidValues = false; + for (size_t caseIdx = 0; caseIdx < sourceDataAccessList.size(); caseIdx++) { - dataAccessObjectDev = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, dataAccessTimeStepIndex, scalarResultIndex); - } - } + double val = sourceDataAccessList.at(caseIdx)->cellScalar(cellIdx); + values[caseIdx] = val; - { - size_t scalarResultIndex = matrixResults->findScalarResultIndex(resultType, createResultNameRange(resultName)); - if (scalarResultIndex != cvf::UNDEFINED_SIZE_T) - { - dataAccessObjectRange = m_destinationCase->dataAccessObject(grid, RifReaderInterface::MATRIX_RESULTS, dataAccessTimeStepIndex, scalarResultIndex); - } - } - - double min, max, mean, dev, range; - for (size_t cellIdx = 0; cellIdx < grid->cellCount(); cellIdx++) - { - std::vector values(dataAccesObjectList.size(), HUGE_VAL); - - size_t globalGridCellIdx = grid->globalGridCellIndex(cellIdx); - if (m_destinationCase->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->isActive(globalGridCellIdx)) - { - bool foundAnyValidValues = false; - for (size_t caseIdx = 0; caseIdx < dataAccesObjectList.size(); caseIdx++) + if (val != HUGE_VAL) { - double val = dataAccesObjectList.at(caseIdx)->cellScalar(cellIdx); - values[caseIdx] = val; + foundAnyValidValues = true; + } + } - if (val != HUGE_VAL) + // Do the real statistics calculations + std::vector statParams(STAT_PARAM_COUNT, HUGE_VAL); + + if (foundAnyValidValues) + { + calculateBasicStatistics(values, &statParams[MIN], &statParams[MAX], &statParams[RANGE], &statParams[MEAN], &statParams[STDEV]); + + // Calculate percentiles + if (m_statisticsConfig.m_calculatePercentiles ) + { + if (m_statisticsConfig.m_pValMethod == RimStatisticsCase::EXACT) { - foundAnyValidValues = true; + std::vector pValPoss; + pValPoss.push_back(m_statisticsConfig.m_pMinPos); + pValPoss.push_back(m_statisticsConfig.m_pMidPos); + pValPoss.push_back(m_statisticsConfig.m_pMaxPos); + std::vector pVals = calculateNearestRankPercentiles(values, pValPoss); + statParams[PMIN] = pVals[0]; + statParams[PMID] = pVals[1]; + statParams[PMAX] = pVals[2]; + } + else if (m_statisticsConfig.m_pValMethod == RimStatisticsCase::HISTOGRAM_ESTIMATED) + { + std::vector histogram; + RigHistogramCalculator histCalc(statParams[MIN], statParams[MAX], 100, &histogram); + histCalc.addData(values); + statParams[PMIN] = histCalc.calculatePercentil(m_statisticsConfig.m_pMinPos); + statParams[PMID] = histCalc.calculatePercentil(m_statisticsConfig.m_pMidPos); + statParams[PMAX] = histCalc.calculatePercentil(m_statisticsConfig.m_pMaxPos); + } + else + { + CVF_ASSERT(false); } } + } - min = HUGE_VAL; - max = HUGE_VAL; - mean = HUGE_VAL; - dev = HUGE_VAL; - range = HUGE_VAL; - - if (foundAnyValidValues) - { - RimStatisticsEvaluator stat(values); - stat.getStatistics(min, max, mean, dev, range); - } + // Set the results into the results data structures - if (dataAccessObjectMin.notNull()) + for (size_t stIdx = 0; stIdx < statParams.size(); ++stIdx) + { + if (destinationDataAccessList[stIdx].notNull()) { - dataAccessObjectMin->setCellScalar(cellIdx, min); - } - - if (dataAccessObjectMax.notNull()) - { - dataAccessObjectMax->setCellScalar(cellIdx, max); - } - - if (dataAccessObjectMean.notNull()) - { - dataAccessObjectMean->setCellScalar(cellIdx, mean); - } - - if (dataAccessObjectDev.notNull()) - { - dataAccessObjectDev->setCellScalar(cellIdx, dev); - } - - if (dataAccessObjectRange.notNull()) - { - dataAccessObjectRange->setCellScalar(cellIdx, range); + destinationDataAccessList[stIdx]->setCellScalar(cellIdx, statParams[stIdx]); } } } } } - - for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++) - { - RimCase* eclipseCase = m_sourceCases.at(caseIdx); - - // When one time step is completed, close all result files. - // Microsoft note: On Windows, the maximum number of files open at the same time is 512 - // http://msdn.microsoft.com/en-us/library/kdfaxaay%28vs.71%29.aspx - // - eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->readerInterface()->close(); - } - - info.setProgress(timeIndicesIdx); } + + // When one time step is completed, close all result files. + // Microsoft note: On Windows, the maximum number of files open at the same time is 512 + // http://msdn.microsoft.com/en-us/library/kdfaxaay%28vs.71%29.aspx + + for (size_t caseIdx = 0; caseIdx < m_sourceCases.size(); caseIdx++) + { + RimCase* eclipseCase = m_sourceCases.at(caseIdx); + eclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->readerInterface()->close(); + eclipseCase->results(RifReaderInterface::FRACTURE_RESULTS)->readerInterface()->close(); + } + + progressInfo.setProgress(timeIndicesIdx); } } diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.h b/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.h index 14a80a6b0d..772334213d 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.h +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.h @@ -26,6 +26,7 @@ #include #include "RimDefines.h" +#include "RimStatisticsCase.h" class RimCase; class RigCaseData; @@ -36,18 +37,20 @@ class RimStatisticsConfig { public: RimStatisticsConfig() - : m_min(true), - m_max(true), - m_mean(true), - m_stdDev(true) + : m_calculatePercentiles(true), + m_pMinPos(10.0), + m_pMidPos(50.0), + m_pMaxPos(90.0), + m_pValMethod(RimStatisticsCase::EXACT) { } public: - bool m_min; - bool m_max; - bool m_mean; - bool m_stdDev; + bool m_calculatePercentiles; + double m_pMinPos; + double m_pMidPos; + double m_pMaxPos; + RimStatisticsCase::PercentileCalcType m_pValMethod; }; @@ -59,21 +62,34 @@ public: const RimStatisticsConfig& statisticsConfig, RigCaseData* destinationCase); + struct ResSpec + { + ResSpec() : m_resType(RimDefines::DYNAMIC_NATIVE), m_poroModel(RifReaderInterface::MATRIX_RESULTS) {} + ResSpec( RifReaderInterface::PorosityModelResultType poroModel, + RimDefines::ResultCatType resType, + QString resVarName) : m_poroModel(poroModel), m_resType(resType), m_resVarName(resVarName) {} - void evaluateForResults(const QList >& resultSpecification); + RifReaderInterface::PorosityModelResultType m_poroModel; + RimDefines::ResultCatType m_resType; + QString m_resVarName; + }; + + void evaluateForResults(const QList& resultSpecification); void debugOutput(RimDefines::ResultCatType resultType, const QString& resultName, size_t timeStepIdx); private: void addNamedResult(RigCaseCellResultsData* cellResults, RimDefines::ResultCatType resultType, const QString& resultName, size_t activeCellCount); - void buildSourceMetaData(RimDefines::ResultCatType resultType, const QString& resultName); + void buildSourceMetaData(RifReaderInterface::PorosityModelResultType poroModel, RimDefines::ResultCatType resultType, const QString& resultName); + + enum StatisticsParamType { MIN, MAX, RANGE, MEAN, STDEV, PMIN, PMID, PMAX, STAT_PARAM_COUNT }; private: std::vector m_sourceCases; - std::vector m_timeStepIndices; + std::vector m_timeStepIndices; - size_t m_globalCellCount; - RimStatisticsConfig m_statisticsConfig; - RigCaseData* m_destinationCase; + size_t m_globalCellCount; + RimStatisticsConfig m_statisticsConfig; + RigCaseData* m_destinationCase; }; diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index 517aca7693..f3e162ebdd 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -180,7 +180,9 @@ const std::vector& RigCaseCellResultsData::cellScalarValuesHistogram(siz //-------------------------------------------------------------------------------------------------- void RigCaseCellResultsData::p10p90CellScalarValues(size_t scalarResultIndex, double& p10, double& p90) { - const std::vector& histogr = cellScalarValuesHistogram( scalarResultIndex); + // First make sure they are calculated + const std::vector& histogr = cellScalarValuesHistogram( scalarResultIndex); + // Then return them p10 = m_p10p90[scalarResultIndex].first; p90 = m_p10p90[scalarResultIndex].second; } From 2d5ed03b9bcd833ff87c8bff9e22b87584ad7098 Mon Sep 17 00:00:00 2001 From: CeetronResInsight Date: Fri, 5 Apr 2013 08:15:03 +0200 Subject: [PATCH 183/242] When ERT is configured to be not installed, do static linking of the Ert modules p4#: 21135 --- ThirdParty/Ert/devel/CMakeLists.txt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ThirdParty/Ert/devel/CMakeLists.txt b/ThirdParty/Ert/devel/CMakeLists.txt index 99eb2b8d12..6b683d5181 100644 --- a/ThirdParty/Ert/devel/CMakeLists.txt +++ b/ThirdParty/Ert/devel/CMakeLists.txt @@ -40,9 +40,14 @@ if (MSVC) set( LIBRARY_TYPE STATIC ) set( SHARED_LIB OFF ) else() - set( LIBRARY_TYPE SHARED ) - set( SHARED_LIB ON ) -endif() + if (INSTALL_ERT) + set( LIBRARY_TYPE SHARED ) + set( SHARED_LIB ON ) + else() + set( LIBRARY_TYPE STATIC ) + set( SHARED_LIB OFF ) + endif(INSTALL_ERT) +endif(MSVC) From ca63b9163a7c83b011832651013882e12cc653fd Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 5 Apr 2013 09:43:49 +0200 Subject: [PATCH 184/242] Set the variable to override in the CMake cache, then the default value for the option in the sub project will have no effect. p4#: 21136 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9be751d659..078d3478fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,7 +40,7 @@ include (ResInsightVersion.cmake) # Disable install of ERT libs and headers, as Ert code is compiled and linked directly # into ResInsight -set (INSTALL_ERT false) +SET(INSTALL_ERT OFF CACHE BOOL "Build ERT without installing") add_subdirectory(ThirdParty/Ert/devel) From db62f01e0a22972b7a4bd82ffbb9046b7bfb3e8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 5 Apr 2013 10:42:53 +0200 Subject: [PATCH 185/242] Differenced the compiler options on Windows and Linux, making a ton of stupid MSVC compiler warnings go away. p4#: 21138 --- ThirdParty/Ert/devel/CMakeLists.txt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/ThirdParty/Ert/devel/CMakeLists.txt b/ThirdParty/Ert/devel/CMakeLists.txt index 6b683d5181..5e984c5cf0 100644 --- a/ThirdParty/Ert/devel/CMakeLists.txt +++ b/ThirdParty/Ert/devel/CMakeLists.txt @@ -19,13 +19,15 @@ ENABLE_TESTING() if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") set(ERT_LINUX TRUE ) add_definitions( -DERT_LINUX ) + set( CMAKE_C_FLAGS "-g -O2 -Wall -std=gnu99" ) + set( CMAKE_CXX_FLAGS "-g -O2 -Wall" ) elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows") set(ERT_WINDOWS TRUE) add_definitions( -DERT_WINDOWS ) + set( CMAKE_C_FLAGS "-O2" ) + set( CMAKE_CXX_FLAGS "-O2" ) endif() -set( CMAKE_C_FLAGS "-g -O2 -Wall -std=gnu99" ) -set( CMAKE_CXX_FLAGS "-g -O2 -Wall" ) include(cmake/ert_check.cmake) include(cmake/ert_find.cmake) @@ -41,8 +43,8 @@ if (MSVC) set( SHARED_LIB OFF ) else() if (INSTALL_ERT) - set( LIBRARY_TYPE SHARED ) - set( SHARED_LIB ON ) + set( LIBRARY_TYPE SHARED ) + set( SHARED_LIB ON ) else() set( LIBRARY_TYPE STATIC ) set( SHARED_LIB OFF ) From 0fed66deb25b0290908df249304d5bfce5e958fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 5 Apr 2013 10:49:39 +0200 Subject: [PATCH 186/242] Moved the statistical calculation algorithm code into a separate file. Added unit test to these calculations, and fixed a calculation error. p4#: 21140 --- .../ProjectDataModel/RimStatisticsCase.cpp | 6 +- .../ProjectDataModel/RimStatisticsCase.h | 2 +- .../RimStatisticsCaseEvaluator.cpp | 102 +--------- .../RimStatisticsCaseEvaluator.h | 2 +- .../ReservoirDataModel/CMakeLists_files.cmake | 3 + .../CMakeLists.txt | 3 +- .../RigStatisticsMath-Test.cpp | 143 +++++++++++++ .../RigCaseCellResultsData.cpp | 2 + .../RigCaseCellResultsData.h | 83 -------- .../ReservoirDataModel/RigStatisticsMath.cpp | 192 ++++++++++++++++++ .../ReservoirDataModel/RigStatisticsMath.h | 53 +++++ 11 files changed, 404 insertions(+), 187 deletions(-) create mode 100644 ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigStatisticsMath-Test.cpp create mode 100644 ApplicationCode/ReservoirDataModel/RigStatisticsMath.cpp create mode 100644 ApplicationCode/ReservoirDataModel/RigStatisticsMath.h diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp index a2595f8b36..4e179784a0 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp @@ -32,9 +32,9 @@ namespace caf { template<> void caf::AppEnum::setUp() { - addItem(RimStatisticsCase::EXACT, "ExactPercentile", "Exact"); - addItem(RimStatisticsCase::HISTOGRAM_ESTIMATED, "HistogramEstimatedPercentile", "Estimated (Faster for large case counts)"); - setDefault(RimStatisticsCase::EXACT); + addItem(RimStatisticsCase::NEAREST_OBSERVATION, "NearestObservationPercentile", "Nearest Observation"); + addItem(RimStatisticsCase::HISTOGRAM_ESTIMATED, "HistogramEstimatedPercentile", "Histogram based estimate"); + setDefault(RimStatisticsCase::NEAREST_OBSERVATION); } } diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCase.h b/ApplicationCode/ProjectDataModel/RimStatisticsCase.h index cd4eeb1224..3b377ebe48 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCase.h +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCase.h @@ -53,7 +53,7 @@ public: enum PercentileCalcType { - EXACT, + NEAREST_OBSERVATION, HISTOGRAM_ESTIMATED }; diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.cpp b/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.cpp index 6370dd1bcb..05f90e9fd4 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.cpp @@ -22,106 +22,12 @@ #include "RimReservoirView.h" #include "RimCase.h" #include "RigCaseData.h" +#include "RigStatisticsMath.h" //#include "RigCaseData.h" #include #include "cafProgressInfo.h" -//-------------------------------------------------------------------------------------------------- -/// An internal class to do the actual computations -//-------------------------------------------------------------------------------------------------- - -void calculateBasicStatistics(const std::vector& values, double* min, double* max, double* range, double* mean, double* dev) -{ - double m_min(HUGE_VAL); - double m_max(-HUGE_VAL); - double m_mean(HUGE_VAL); - double m_dev(HUGE_VAL); - - double sum = 0.0; - double sumSquared = 0.0; - - size_t validValueCount = 0; - - for (size_t i = 0; i < values.size(); i++) - { - double val = values[i]; - if (val == HUGE_VAL) continue; - - validValueCount++; - - if (val < m_min) m_min = val; - if (val > m_max) m_max = val; - - sum += val; - sumSquared += (val * val); - } - - if (validValueCount > 0) - { - m_mean = sum / validValueCount; - - - // http://en.wikipedia.org/wiki/Standard_deviation#Rapid_calculation_methods - // Running standard deviation - - double s0 = validValueCount; - double s1 = sum; - double s2 = sumSquared; - - m_dev = cvf::Math::sqrt( (s0 * s2) - (s1 * s1) ) / s0; - } - - if (min) *min = m_min; - if (max) *max = m_max; - if (range) *range = m_max - m_min; - - if (mean) *mean = m_mean; - if (dev) *dev = m_dev; -} - - -//-------------------------------------------------------------------------------------------------- -/// Calculate the percentiles of /a inputValues at the pValPosition percentages using the "Nearest Rank" -/// method. This method treats HUGE_VAL as "undefined" values, and ignores these. Will return HUGE_VAL if -/// the inputValues does not contain any valid values -//-------------------------------------------------------------------------------------------------- - -std::vector calculateNearestRankPercentiles(const std::vector & inputValues, const std::vector& pValPositions) -{ - std::vector sortedValues; - sortedValues.reserve(inputValues.size()); - - for (size_t i = 0; i < inputValues.size(); ++i) - { - if (inputValues[i] != HUGE_VAL) - { - sortedValues.push_back(inputValues[i]); - } - } - - std::sort(sortedValues.begin(), sortedValues.end()); - - std::vector percentiles(pValPositions.size(), HUGE_VAL); - if (sortedValues.size()) - { - for (size_t i = 0; i < pValPositions.size(); ++i) - { - double pVal = HUGE_VAL; - - size_t pValIndex = static_cast(sortedValues.size() * abs(pValPositions[i]) / 100); - pValIndex += 1; - - if (pValIndex >= sortedValues.size() ) pValIndex = sortedValues.size() - 1; - - pVal = sortedValues[pValIndex]; - percentiles[i] = pVal; - } - } - - return percentiles; -}; - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -353,18 +259,18 @@ void RimStatisticsCaseEvaluator::evaluateForResults(const QList& result if (foundAnyValidValues) { - calculateBasicStatistics(values, &statParams[MIN], &statParams[MAX], &statParams[RANGE], &statParams[MEAN], &statParams[STDEV]); + RigStatisticsMath::calculateBasicStatistics(values, &statParams[MIN], &statParams[MAX], &statParams[RANGE], &statParams[MEAN], &statParams[STDEV]); // Calculate percentiles if (m_statisticsConfig.m_calculatePercentiles ) { - if (m_statisticsConfig.m_pValMethod == RimStatisticsCase::EXACT) + if (m_statisticsConfig.m_pValMethod == RimStatisticsCase::NEAREST_OBSERVATION) { std::vector pValPoss; pValPoss.push_back(m_statisticsConfig.m_pMinPos); pValPoss.push_back(m_statisticsConfig.m_pMidPos); pValPoss.push_back(m_statisticsConfig.m_pMaxPos); - std::vector pVals = calculateNearestRankPercentiles(values, pValPoss); + std::vector pVals = RigStatisticsMath::calculateNearestRankPercentiles(values, pValPoss); statParams[PMIN] = pVals[0]; statParams[PMID] = pVals[1]; statParams[PMAX] = pVals[2]; diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.h b/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.h index 772334213d..1c4cb49962 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.h +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCaseEvaluator.h @@ -41,7 +41,7 @@ public: m_pMinPos(10.0), m_pMidPos(50.0), m_pMaxPos(90.0), - m_pValMethod(RimStatisticsCase::EXACT) + m_pValMethod(RimStatisticsCase::NEAREST_OBSERVATION) { } diff --git a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake index 71c1ec37e7..e6f817fab5 100644 --- a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake @@ -17,6 +17,8 @@ ${CEE_CURRENT_LIST_DIR}RigMainGrid.h ${CEE_CURRENT_LIST_DIR}RigReservoirBuilderMock.h ${CEE_CURRENT_LIST_DIR}RigCaseCellResultsData.h ${CEE_CURRENT_LIST_DIR}RigSingleWellResultsData.h +${CEE_CURRENT_LIST_DIR}RigStatisticsMath.h + ) list(APPEND CODE_SOURCE_FILES @@ -31,6 +33,7 @@ ${CEE_CURRENT_LIST_DIR}RigMainGrid.cpp ${CEE_CURRENT_LIST_DIR}RigReservoirBuilderMock.cpp ${CEE_CURRENT_LIST_DIR}RigCaseCellResultsData.cpp ${CEE_CURRENT_LIST_DIR}RigSingleWellResultsData.cpp +${CEE_CURRENT_LIST_DIR}RigStatisticsMath.cpp ) diff --git a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/CMakeLists.txt b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/CMakeLists.txt index 9f20f90ac9..3ed2140ef2 100644 --- a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/CMakeLists.txt +++ b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/CMakeLists.txt @@ -24,7 +24,7 @@ include_directories( ${ResInsight_SOURCE_DIR}/CommonCode #Remove when RigStatistics is out - ${ResInsight_SOURCE_DIR}/ApplicationCode/ModelVisualization + #${ResInsight_SOURCE_DIR}/ApplicationCode/ModelVisualization ) # Populate the filenames into variable lists @@ -38,6 +38,7 @@ set( UNIT_TEST_CPP_SOURCES main.cpp RigActiveCellInfo-Test.cpp RigReservoir-Test.cpp + RigStatisticsMath-Test.cpp ) diff --git a/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigStatisticsMath-Test.cpp b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigStatisticsMath-Test.cpp new file mode 100644 index 0000000000..7be162ef86 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/ReservoirDataModel_UnitTests/RigStatisticsMath-Test.cpp @@ -0,0 +1,143 @@ + + +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 "RiaStdInclude.h" +#include "gtest/gtest.h" + +#include "RigStatisticsMath.h" + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RigStatisticsMath, BasicTest) +{ + std::vector values; + values.push_back(HUGE_VAL); + values.push_back(2788.2723335651900); + values.push_back(-22481.0927881701000); + values.push_back(68778.6851686236000); + values.push_back(-76092.8157632591000); + values.push_back(6391.97999909729003); + values.push_back(65930.1200169780000); + values.push_back(-27696.2320267235000); + values.push_back(HUGE_VAL); + values.push_back(HUGE_VAL); + values.push_back(96161.7546348456000); + values.push_back(73875.6716288563000); + values.push_back(80720.4378655615000); + values.push_back(-98649.8109937874000); + values.push_back(99372.9362079615000); + values.push_back(HUGE_VAL); + values.push_back(-57020.4389966513000); + + double min, max, range, mean, stdev; + RigStatisticsMath::calculateBasicStatistics(values, &min, &max, &range, &mean, &stdev); + + EXPECT_DOUBLE_EQ(-98649.8109937874000, min ); + EXPECT_DOUBLE_EQ(99372.9362079615000 , max ); + EXPECT_DOUBLE_EQ(198022.7472017490000, range ); + EXPECT_DOUBLE_EQ(16313.8051759152000 , mean ); + EXPECT_DOUBLE_EQ(66104.391542887200 , stdev ); + +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RigStatisticsMath, RankPercentiles) +{ + std::vector values; + values.push_back(HUGE_VAL); + values.push_back(2788.2723335651900); + values.push_back(-22481.0927881701000); + values.push_back(68778.6851686236000); + values.push_back(-76092.8157632591000); + values.push_back(6391.97999909729003); + values.push_back(65930.1200169780000); + values.push_back(-27696.2320267235000); + values.push_back(HUGE_VAL); + values.push_back(HUGE_VAL); + values.push_back(96161.7546348456000); + values.push_back(73875.6716288563000); + values.push_back(80720.4378655615000); + values.push_back(-98649.8109937874000); + values.push_back(99372.9362079615000); + values.push_back(HUGE_VAL); + values.push_back(-57020.4389966513000); + + std::vector pValPos; + pValPos.push_back(10); + pValPos.push_back(40); + pValPos.push_back(50); + pValPos.push_back(90); + std::vector pVals = RigStatisticsMath::calculateNearestRankPercentiles(values, pValPos); + + EXPECT_DOUBLE_EQ( -76092.8157632591000, pVals[0]); + EXPECT_DOUBLE_EQ( 2788.2723335651900 , pVals[1]); + EXPECT_DOUBLE_EQ( 6391.979999097290 , pVals[2]); + EXPECT_DOUBLE_EQ( 96161.7546348456000 , pVals[3]); +} + + + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RigStatisticsMath, HistogramPercentiles) +{ + std::vector values; + values.push_back(HUGE_VAL); + values.push_back(2788.2723335651900); + values.push_back(-22481.0927881701000); + values.push_back(68778.6851686236000); + values.push_back(-76092.8157632591000); + values.push_back(6391.97999909729003); + values.push_back(65930.1200169780000); + values.push_back(-27696.2320267235000); + values.push_back(HUGE_VAL); + values.push_back(HUGE_VAL); + values.push_back(96161.7546348456000); + values.push_back(73875.6716288563000); + values.push_back(80720.4378655615000); + values.push_back(-98649.8109937874000); + values.push_back(99372.9362079615000); + values.push_back(HUGE_VAL); + values.push_back(-57020.4389966513000); + + + double min, max, range, mean, stdev; + RigStatisticsMath::calculateBasicStatistics(values, &min, &max, &range, &mean, &stdev); + + std::vector histogram; + RigHistogramCalculator histCalc(min, max, 100, &histogram); + histCalc.addData(values); + std::vector pVals; + double p10, p50, p90; + p10 = histCalc.calculatePercentil(0.1); + p50 = histCalc.calculatePercentil(0.5); + p90 = histCalc.calculatePercentil(0.9); + + EXPECT_DOUBLE_EQ( -76273.240559989776, p10); + EXPECT_DOUBLE_EQ( 5312.1312871307755 , p50); + EXPECT_DOUBLE_EQ( 94818.413022321271 , p90); +} diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index f3e162ebdd..ee22a4306f 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -20,6 +20,8 @@ #include "RifReaderInterface.h" #include "RigMainGrid.h" +#include "RigStatisticsMath.h" + #include #include diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h index 31ec57dae4..ef94ff6ba6 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h @@ -116,86 +116,3 @@ private: RigMainGrid* m_ownerMainGrid; }; - -class RigHistogramCalculator -{ -public: - RigHistogramCalculator(double min, double max, size_t nBins, std::vector* histogram) - { - CVF_ASSERT(histogram); - CVF_ASSERT(nBins > 0); - - if (max == min) { nBins = 1; } // Avoid dividing on 0 range - - m_histogram = histogram; - m_min = min; - m_observationCount = 0; - - // Initialize bins - m_histogram->resize(nBins); - for (size_t i = 0; i < m_histogram->size(); ++i) (*m_histogram)[i] = 0; - - m_range = max - min; - maxIndex = nBins-1; - } - - void addData(const std::vector& data) - { - CVF_ASSERT(m_histogram); - for (size_t i = 0; i < data.size(); ++i) - { - if (data[i] == HUGE_VAL) - { - continue; - } - - size_t index = 0; - - if (maxIndex > 0) index = (size_t)(maxIndex*(data[i] - m_min)/m_range); - - if(index < m_histogram->size()) // Just clip to the max min range (-index will overflow to positive ) - { - (*m_histogram)[index]++; - m_observationCount++; - } - } - } - - /// Calculates the estimated percentile from the histogram. - /// the percentile is the domain value at which pVal of the observations are below it. - /// Will only consider observed values between min and max, as all other values are discarded from the histogram - - double calculatePercentil(double pVal) - { - CVF_ASSERT(m_histogram); - CVF_ASSERT(m_histogram->size()); - CVF_ASSERT( 0.0 <= pVal && pVal <= 1.0); - - double pValObservationCount = pVal*m_observationCount; - if (pValObservationCount == 0.0) return m_min; - - size_t accObsCount = 0; - double binWidth = m_range/m_histogram->size(); - for (size_t binIdx = 0; binIdx < m_histogram->size(); ++binIdx) - { - size_t binObsCount = (*m_histogram)[binIdx]; - - accObsCount += binObsCount; - if (accObsCount >= pValObservationCount) - { - double domainValueAtEndOfBin = m_min + (binIdx+1) * binWidth; - double unusedFractionOfLastBin = (double)(accObsCount - pValObservationCount)/binObsCount; - return domainValueAtEndOfBin - unusedFractionOfLastBin*binWidth; - } - } - CVF_ASSERT(false); - return HUGE_VAL; - } - -private: - size_t maxIndex; - double m_range; - double m_min; - size_t m_observationCount; - std::vector* m_histogram; -}; diff --git a/ApplicationCode/ReservoirDataModel/RigStatisticsMath.cpp b/ApplicationCode/ReservoirDataModel/RigStatisticsMath.cpp new file mode 100644 index 0000000000..4b16b45a38 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigStatisticsMath.cpp @@ -0,0 +1,192 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 "RigStatisticsMath.h" +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// A function to do basic statistical calculations +//-------------------------------------------------------------------------------------------------- + +void RigStatisticsMath::calculateBasicStatistics(const std::vector& values, double* min, double* max, double* range, double* mean, double* dev) +{ + double m_min(HUGE_VAL); + double m_max(-HUGE_VAL); + double m_mean(HUGE_VAL); + double m_dev(HUGE_VAL); + + double sum = 0.0; + double sumSquared = 0.0; + + size_t validValueCount = 0; + + for (size_t i = 0; i < values.size(); i++) + { + double val = values[i]; + if (val == HUGE_VAL) continue; + + validValueCount++; + + if (val < m_min) m_min = val; + if (val > m_max) m_max = val; + + sum += val; + sumSquared += (val * val); + } + + if (validValueCount > 0) + { + m_mean = sum / validValueCount; + + + // http://en.wikipedia.org/wiki/Standard_deviation#Rapid_calculation_methods + // Running standard deviation + + double s0 = static_cast(validValueCount); + double s1 = sum; + double s2 = sumSquared; + + m_dev = sqrt( (s0 * s2) - (s1 * s1) ) / s0; + } + + if (min) *min = m_min; + if (max) *max = m_max; + if (range) *range = m_max - m_min; + + if (mean) *mean = m_mean; + if (dev) *dev = m_dev; +} + + +//-------------------------------------------------------------------------------------------------- +/// Calculate the percentiles of /a inputValues at the pValPosition percentages using the "Nearest Rank" +/// method. This method treats HUGE_VAL as "undefined" values, and ignores these. Will return HUGE_VAL if +/// the inputValues does not contain any valid values +//-------------------------------------------------------------------------------------------------- + +std::vector RigStatisticsMath::calculateNearestRankPercentiles(const std::vector & inputValues, const std::vector& pValPositions) +{ + std::vector sortedValues; + sortedValues.reserve(inputValues.size()); + + for (size_t i = 0; i < inputValues.size(); ++i) + { + if (inputValues[i] != HUGE_VAL) + { + sortedValues.push_back(inputValues[i]); + } + } + + std::sort(sortedValues.begin(), sortedValues.end()); + + std::vector percentiles(pValPositions.size(), HUGE_VAL); + if (sortedValues.size()) + { + for (size_t i = 0; i < pValPositions.size(); ++i) + { + double pVal = HUGE_VAL; + + size_t pValIndex = static_cast(sortedValues.size() * abs(pValPositions[i]) / 100); + + if (pValIndex >= sortedValues.size() ) pValIndex = sortedValues.size() - 1; + + pVal = sortedValues[pValIndex]; + percentiles[i] = pVal; + } + } + + return percentiles; +}; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigHistogramCalculator::RigHistogramCalculator(double min, double max, size_t nBins, std::vector* histogram) +{ + assert(histogram); + assert(nBins > 0); + + if (max == min) { nBins = 1; } // Avoid dividing on 0 range + + m_histogram = histogram; + m_min = min; + m_observationCount = 0; + + // Initialize bins + m_histogram->resize(nBins); + for (size_t i = 0; i < m_histogram->size(); ++i) (*m_histogram)[i] = 0; + + m_range = max - min; + maxIndex = nBins-1; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigHistogramCalculator::addData(const std::vector& data) +{ + assert(m_histogram); + for (size_t i = 0; i < data.size(); ++i) + { + if (data[i] == HUGE_VAL) + { + continue; + } + + size_t index = 0; + + if (maxIndex > 0) index = (size_t)(maxIndex*(data[i] - m_min)/m_range); + + if(index < m_histogram->size()) // Just clip to the max min range (-index will overflow to positive ) + { + (*m_histogram)[index]++; + m_observationCount++; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigHistogramCalculator::calculatePercentil(double pVal) +{ + assert(m_histogram); + assert(m_histogram->size()); + assert( 0.0 <= pVal && pVal <= 1.0); + + double pValObservationCount = pVal*m_observationCount; + if (pValObservationCount == 0.0) return m_min; + + size_t accObsCount = 0; + double binWidth = m_range/m_histogram->size(); + for (size_t binIdx = 0; binIdx < m_histogram->size(); ++binIdx) + { + size_t binObsCount = (*m_histogram)[binIdx]; + + accObsCount += binObsCount; + if (accObsCount >= pValObservationCount) + { + double domainValueAtEndOfBin = m_min + (binIdx+1) * binWidth; + double unusedFractionOfLastBin = (double)(accObsCount - pValObservationCount)/binObsCount; + return domainValueAtEndOfBin - unusedFractionOfLastBin*binWidth; + } + } + assert(false); + return HUGE_VAL; +} diff --git a/ApplicationCode/ReservoirDataModel/RigStatisticsMath.h b/ApplicationCode/ReservoirDataModel/RigStatisticsMath.h new file mode 100644 index 0000000000..1daac809bc --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigStatisticsMath.h @@ -0,0 +1,53 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron 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 +#include + +class RigStatisticsMath +{ +public: + static void calculateBasicStatistics(const std::vector& values, double* min, double* max, double* range, double* mean, double* dev); + static std::vector calculateNearestRankPercentiles(const std::vector & inputValues, const std::vector& pValPositions); +}; + +//================================================================================================== +/// Class to calculate a histogram, and histogram based p-value estimates +//================================================================================================== + +class RigHistogramCalculator +{ +public: + RigHistogramCalculator(double min, double max, size_t nBins, std::vector* histogram); + + void addData(const std::vector& data); + + /// Calculates the estimated percentile from the histogram. + /// the percentile is the domain value at which pVal of the observations are below it. + /// Will only consider observed values between min and max, as all other values are discarded from the histogram + + double calculatePercentil(double pVal); + +private: + size_t maxIndex; + double m_range; + double m_min; + size_t m_observationCount; + std::vector* m_histogram; +}; From 700f18391beaeceb9bbc600cd4079c4a1522212e Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 5 Apr 2013 13:22:36 +0200 Subject: [PATCH 187/242] Added GUI for asking user to confirm change for grid case group p4#: 21142 --- .../ProjectDataModel/RimUiTreeModelPdm.cpp | 107 ++++++++++-------- .../ProjectDataModel/RimUiTreeModelPdm.h | 8 +- .../ProjectDataModel/RimUiTreeView.cpp | 97 ++++++++++++---- .../ProjectDataModel/RimUiTreeView.h | 3 + 4 files changed, 146 insertions(+), 69 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index 7d642a029e..8e46582d68 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -573,38 +573,7 @@ void RimUiTreeModelPdm::addObjects(const QModelIndex& itemIndex, caf::PdmObjectG RimProject* proj = RiaApplication::instance()->project(); CVF_ASSERT(proj); - caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex); - - RimIdenticalGridCaseGroup* gridCaseGroup = NULL; - RimCaseCollection* caseCollection = NULL; - - if (dynamic_cast(currentItem->dataObject().p())) - { - gridCaseGroup = dynamic_cast(currentItem->dataObject().p()); - caseCollection = gridCaseGroup->caseCollection(); - } - else if (dynamic_cast(currentItem->dataObject().p())) - { - caseCollection = dynamic_cast(currentItem->dataObject().p()); - CVF_ASSERT(caseCollection); - - gridCaseGroup = caseCollection->parentCaseGroup(); - } - else if (dynamic_cast(currentItem->dataObject().p())) - { - RimCase* rimReservoir = dynamic_cast(currentItem->dataObject().p()); - CVF_ASSERT(rimReservoir); - - caseCollection = rimReservoir->parentCaseCollection(); - if (caseCollection) - { - gridCaseGroup = caseCollection->parentCaseGroup(); - } - } - else - { - return; - } + RimIdenticalGridCaseGroup* gridCaseGroup = gridCaseGroupFromItemIndex(itemIndex); if (gridCaseGroup) { @@ -614,7 +583,7 @@ void RimUiTreeModelPdm::addObjects(const QModelIndex& itemIndex, caf::PdmObjectG RigCaseData* mainEclipseCase = NULL; if (gridCaseGroup->caseCollection()->reservoirs().size() > 0) { - RimCase* mainReservoir = gridCaseGroup->caseCollection()->reservoirs()[0];; + RimCase* mainReservoir = gridCaseGroup->caseCollection()->reservoirs()[0]; mainEclipseCase = mainReservoir->reservoirData(); } @@ -645,7 +614,7 @@ void RimUiTreeModelPdm::addObjects(const QModelIndex& itemIndex, caf::PdmObjectG caf::PdmObjectGroup::initAfterReadTraversal(rimResultReservoir); { - QModelIndex rootIndex = getModelIndexFromPdmObject(caseCollection); + QModelIndex rootIndex = getModelIndexFromPdmObject(gridCaseGroup->caseCollection()); caf::PdmUiTreeItem* caseCollectionUiItem = getTreeItemFromIndex(rootIndex); int position = rowCount(rootIndex); @@ -663,6 +632,24 @@ void RimUiTreeModelPdm::addObjects(const QModelIndex& itemIndex, caf::PdmObjectG } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUiTreeModelPdm::moveObjects(const QModelIndex& itemIndex, caf::PdmObjectGroup& pdmObjects) +{ + addObjects(itemIndex, pdmObjects); + + // Delete objects from original container + std::vector > typedObjects; + pdmObjects.objectsByType(&typedObjects); + + for (size_t i = 0; i < typedObjects.size(); i++) + { + RimCase* rimReservoir = typedObjects[i]; + deleteReservoir(rimReservoir); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -777,18 +764,13 @@ bool RimUiTreeModelPdm::dropMimeData(const QMimeData *data, Qt::DropAction actio pog.objects().push_back(pdmObj); } - addObjects(parent, pog); - - if (action == Qt::MoveAction) + if (action == Qt::CopyAction) { - std::vector > typedObjects; - pog.objectsByType(&typedObjects); - - for (size_t i = 0; i < typedObjects.size(); i++) - { - RimCase* rimReservoir = typedObjects[i]; - deleteReservoir(rimReservoir); - } + addObjects(parent, pog); + } + else if (action == Qt::MoveAction) + { + moveObjects(parent, pog); } return true; @@ -817,3 +799,38 @@ QStringList RimUiTreeModelPdm::mimeTypes() const return types; } +//-------------------------------------------------------------------------------------------------- +/// Return grid case group when QModelIndex points to grid case group, case collection or case in a grid case group +//-------------------------------------------------------------------------------------------------- +RimIdenticalGridCaseGroup* RimUiTreeModelPdm::gridCaseGroupFromItemIndex(const QModelIndex& itemIndex) +{ + caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex); + + RimIdenticalGridCaseGroup* gridCaseGroup = NULL; + + if (dynamic_cast(currentItem->dataObject().p())) + { + gridCaseGroup = dynamic_cast(currentItem->dataObject().p()); + } + else if (dynamic_cast(currentItem->dataObject().p())) + { + RimCaseCollection* caseCollection = dynamic_cast(currentItem->dataObject().p()); + CVF_ASSERT(caseCollection); + + gridCaseGroup = caseCollection->parentCaseGroup(); + } + else if (dynamic_cast(currentItem->dataObject().p())) + { + RimCase* rimReservoir = dynamic_cast(currentItem->dataObject().p()); + CVF_ASSERT(rimReservoir); + + RimCaseCollection* caseCollection = rimReservoir->parentCaseCollection(); + if (caseCollection) + { + gridCaseGroup = caseCollection->parentCaseGroup(); + } + } + + return gridCaseGroup; +} + diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h index af0372e21f..00ec38f540 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h @@ -111,9 +111,11 @@ public: RimCellRangeFilter* addRangeFilter(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); RimReservoirView* addReservoirView(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); void addInputProperty(const QModelIndex& itemIndex, const QStringList& fileNames); - void addObjects(const QModelIndex& itemIndex, caf::PdmObjectGroup& pdmObjects); - RimStatisticsCase* addStatisticalCalculation(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); + void addObjects(const QModelIndex& itemIndex, caf::PdmObjectGroup& pdmObjects); + void moveObjects(const QModelIndex& itemIndex, caf::PdmObjectGroup& pdmObjects); + + RimStatisticsCase* addStatisticalCalculation(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); RimIdenticalGridCaseGroup* addCaseGroup(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); bool deleteObjectFromPdmPointersField(const QModelIndex& itemIndex); @@ -126,6 +128,8 @@ public: virtual QMimeData* mimeData(const QModelIndexList &indexes) const; virtual QStringList mimeTypes() const; + RimIdenticalGridCaseGroup* gridCaseGroupFromItemIndex(const QModelIndex& itemIndex); + private slots: void slotRefreshScriptTree(QString path); diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index c4aee2049b..d6bcb25095 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -796,28 +796,31 @@ void RimUiTreeView::slotWriteBinaryResultAsInputProperty() //-------------------------------------------------------------------------------------------------- void RimUiTreeView::slotCloseCase() { - RimUiTreeModelPdm* myModel = dynamic_cast(model()); - if (myModel) + if (userConfirmedGridCaseGroupChange(currentIndex())) { - QItemSelectionModel* m = selectionModel(); - CVF_ASSERT(m); - - caf::PdmObjectGroup group; - - QModelIndexList mil = m->selectedRows(); - for (int i = 0; i < mil.size(); i++) + RimUiTreeModelPdm* myModel = dynamic_cast(model()); + if (myModel) { - caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(mil.at(i)); - group.addObject(uiItem->dataObject().p()); - } + QItemSelectionModel* m = selectionModel(); + CVF_ASSERT(m); - std::vector > typedObjects; - group.objectsByType(&typedObjects); + caf::PdmObjectGroup group; - for (size_t i = 0; i < typedObjects.size(); i++) - { - RimCase* rimReservoir = typedObjects[i]; - myModel->deleteReservoir(rimReservoir); + QModelIndexList mil = m->selectedRows(); + for (int i = 0; i < mil.size(); i++) + { + caf::PdmUiTreeItem* uiItem = myModel->getTreeItemFromIndex(mil.at(i)); + group.addObject(uiItem->dataObject().p()); + } + + std::vector > typedObjects; + group.objectsByType(&typedObjects); + + for (size_t i = 0; i < typedObjects.size(); i++) + { + RimCase* rimReservoir = typedObjects[i]; + myModel->deleteReservoir(rimReservoir); + } } } } @@ -918,11 +921,14 @@ void RimUiTreeView::slotPastePdmObjects() RimUiTreeModelPdm* myModel = dynamic_cast(model()); if (!myModel) return; - caf::PdmObjectGroup objectGroup; - createPdmObjectsFromClipboard(&objectGroup); - if (objectGroup.objects().size() == 0) return; + if (userConfirmedGridCaseGroupChange(currentIndex())) + { + caf::PdmObjectGroup objectGroup; + createPdmObjectsFromClipboard(&objectGroup); + if (objectGroup.objects().size() == 0) return; - myModel->addObjects(currentIndex(), objectGroup); + myModel->addObjects(currentIndex(), objectGroup); + } } //-------------------------------------------------------------------------------------------------- @@ -999,3 +1005,50 @@ bool RimUiTreeView::hasClipboardValidData() return false; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimUiTreeView::dropEvent(QDropEvent* dropEvent) +{ + if (userConfirmedGridCaseGroupChange(currentIndex())) + { + QTreeView::dropEvent(dropEvent); + } +} + +//-------------------------------------------------------------------------------------------------- +/// Displays a question to the user when a grid case group with statistical results is about to change +//-------------------------------------------------------------------------------------------------- +bool RimUiTreeView::userConfirmedGridCaseGroupChange(const QModelIndex & itemIndex) +{ + if (!itemIndex.isValid()) return true; + + RimUiTreeModelPdm* myModel = dynamic_cast(model()); + if (myModel) + { + RimIdenticalGridCaseGroup* gridCaseGroup = myModel->gridCaseGroupFromItemIndex(itemIndex); + if (gridCaseGroup) + { + // TODO: This test has to check if any of the statistical cases has result values + if (gridCaseGroup->statisticsCaseCollection()->reservoirs.size() > 0) + { + RiuMainWindow* mainWnd = RiuMainWindow::instance(); + + QMessageBox msgBox(mainWnd); + msgBox.setIcon(QMessageBox::Question); + msgBox.setText("The destination case group has existing statistic results, and these results will be deleted if you continue"); + msgBox.setInformativeText("Do you want to continue?"); + msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + + int ret = msgBox.exec(); + if (ret == QMessageBox::No) + { + return false; + } + } + } + } + + return true; +} + diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.h b/ApplicationCode/ProjectDataModel/RimUiTreeView.h index 960000be44..54576fdab4 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.h @@ -89,10 +89,13 @@ signals: void selectedObjectChanged( caf::PdmObject* pdmObject ); private: + bool userConfirmedGridCaseGroupChange(const QModelIndex & itemIndex); + void createPdmObjectsFromClipboard(caf::PdmObjectGroup* objectGroup); bool hasClipboardValidData(); virtual void keyPressEvent(QKeyEvent* keyEvent); + virtual void dropEvent(QDropEvent* dropEvent); private: QAction* m_pasteAction; From d07783ebaafb49238bb36e82e9a8880ebcbc571c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 5 Apr 2013 13:29:47 +0200 Subject: [PATCH 188/242] Start of calculation status/unlocking of Statistics results p4#: 21143 --- .../ProjectDataModel/RimStatisticsCase.cpp | 63 +++++++++++++++++++ .../ProjectDataModel/RimStatisticsCase.h | 12 ++++ cafUserInterface/cafPdmUiPushButtonEditor.cpp | 47 +++++++++++--- cafUserInterface/cafPdmUiPushButtonEditor.h | 3 +- 4 files changed, 116 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp index 4e179784a0..25ffd5c85f 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp @@ -27,6 +27,8 @@ #include "RimStatisticsCaseEvaluator.h" #include "RigMainGrid.h" #include "cafPdmUiTextEditor.h" +#include "cafPdmUiLineEditor.h" +#include "cafPdmUiPushButtonEditor.h" namespace caf { template<> @@ -39,6 +41,17 @@ namespace caf { } +namespace caf { + template<> + void caf::AppEnum::setUp() + { + addItem(RimStatisticsCase::CALCULATED, "CALCULATED", "OK"); + addItem(RimStatisticsCase::NOT_CALCULATED, "NOT_CALCULATED", "Needs Calculation"); + setDefault(RimStatisticsCase::NOT_CALCULATED); + } +} + + CAF_PDM_SOURCE_INIT(RimStatisticsCase, "RimStatisticalCalculation"); @@ -50,6 +63,18 @@ RimStatisticsCase::RimStatisticsCase() { CAF_PDM_InitObject("Case Group Statistics", ":/Histogram16x16.png", "", ""); + CAF_PDM_InitFieldNoDefault(&m_calculationStatus, "CalcStatus", "Status", "", "", ""); + m_calculationStatus.setIOWritable(false); + m_calculationStatus.setIOReadable(false); + m_calculationStatus.setUiReadOnly(true); + m_calculationStatus.setUiEditorTypeName(caf::PdmUiLineEditor::uiEditorTypeName()); + + CAF_PDM_InitFieldNoDefault(&m_editingAllowed, "m_editingAllowed", "Editing Locked", "", "", ""); + m_editingAllowed.setIOWritable(false); + m_editingAllowed.setIOReadable(false); + m_editingAllowed.setUiEditorTypeName(caf::PdmUiPushButtonEditor::uiEditorTypeName()); + m_editingAllowed = "UNLOCK"; + CAF_PDM_InitField(&m_selectionSummary, "SelectionSummary", QString(""), "Selected Properties", "", "", ""); m_selectionSummary.setIOWritable(false); m_selectionSummary.setIOReadable(false); @@ -255,6 +280,9 @@ void RimStatisticsCase::computeStatistics() reservoirView->createDisplayModelAndRedraw(); } + m_calculationStatus = CALCULATED; + m_calculationStatus.updateConnectedEditors(); + m_editingAllowed = "UNLOCK"; } //-------------------------------------------------------------------------------------------------- @@ -298,6 +326,8 @@ RimIdenticalGridCaseGroup* RimStatisticsCase::caseGroup() void RimStatisticsCase::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const { uiOrdering.add(&caseName); + uiOrdering.add(&m_calculationStatus); + uiOrdering.add(&m_editingAllowed); caf::PdmUiGroup * group = uiOrdering.addNewGroup("Property Selection"); group->add(&m_selectionSummary); @@ -401,6 +431,13 @@ void RimStatisticsCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField updateSelectionListVisibilities(); } + if (&m_editingAllowed == changedField) + { + clearComputedStatistics(); + m_calculationStatus = NOT_CALCULATED; + m_editingAllowed.setUiHidden(true); + } + updateSelectionSummaryLabel(); updatePercentileUiVisibility(); } @@ -496,3 +533,29 @@ void RimStatisticsCase::updatePercentileUiVisibility() m_midPercentile .setUiHidden( !m_calculatePercentiles()); m_highPercentile.setUiHidden( !m_calculatePercentiles()); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimStatisticsCase::hasComputedStatistics() +{ + if ( reservoirData()->results(RifReaderInterface::MATRIX_RESULTS)->resultCount() + || reservoirData()->results(RifReaderInterface::FRACTURE_RESULTS)->resultCount()) + { + return true; + } + else + { + return false; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimStatisticsCase::clearComputedStatistics() +{ + reservoirData()->results(RifReaderInterface::MATRIX_RESULTS)->clearAllResults(); + reservoirData()->results(RifReaderInterface::FRACTURE_RESULTS)->clearAllResults(); +} + diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCase.h b/ApplicationCode/ProjectDataModel/RimStatisticsCase.h index 3b377ebe48..53c786e2cc 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCase.h +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCase.h @@ -47,6 +47,9 @@ public: void setMainGrid(RigMainGrid* mainGrid); void computeStatistics(); + bool hasComputedStatistics(); + void clearComputedStatistics(); + virtual bool openEclipseGridFile(); RimCaseCollection* parentStatisticsCaseCollection(); @@ -57,6 +60,12 @@ public: HISTOGRAM_ESTIMATED }; + enum CalculationStatus + { + CALCULATED, + NOT_CALCULATED + }; + private: RimIdenticalGridCaseGroup* caseGroup(); @@ -74,6 +83,9 @@ private: virtual void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute ); // Fields + caf::PdmField< caf::AppEnum< CalculationStatus > > m_calculationStatus; + caf::PdmField< QString > m_editingAllowed; + caf::PdmField< caf::AppEnum< RimDefines::ResultCatType > > m_resultType; caf::PdmField< caf::AppEnum< RimDefines::PorosityModelType > > m_porosityModel; diff --git a/cafUserInterface/cafPdmUiPushButtonEditor.cpp b/cafUserInterface/cafPdmUiPushButtonEditor.cpp index b0f145ab6f..c64790c60b 100644 --- a/cafUserInterface/cafPdmUiPushButtonEditor.cpp +++ b/cafUserInterface/cafPdmUiPushButtonEditor.cpp @@ -55,14 +55,36 @@ void PdmUiPushButtonEditor::configureAndUpdateUi(const QString& uiConfigName) m_label->setText(field()->uiName(uiConfigName)); } - m_label->setEnabled(!field()->isUiReadOnly(uiConfigName)); - - //m_checkBox->setEnabled(!field()->isUiReadOnly(uiConfigName)); + //m_label->setEnabled(!field()->isUiReadOnly(uiConfigName)); + m_pushButton->setEnabled(!field()->isUiReadOnly(uiConfigName)); PdmUiPushButtonEditorAttribute attributes; field()->ownerObject()->editorAttribute(field(), uiConfigName, &attributes); - //m_checkBox->setChecked(field()->uiValue().toBool()); + QVariant variantFieldValue = field()->uiValue(); + + if (!attributes.m_buttonIcon.isNull()) + { + m_pushButton->setIcon(attributes.m_buttonIcon); + } + else + { + if (variantFieldValue.type() == QVariant::Bool) + { + m_pushButton->setText(variantFieldValue.toBool() ? "On" : "Off" ); + } + else + { + m_pushButton->setText(variantFieldValue.toString()); + } + } + + if (variantFieldValue.type() == QVariant::Bool) + { + m_pushButton->setChecked(field()->uiValue().toBool()); + } + + } @@ -71,7 +93,7 @@ void PdmUiPushButtonEditor::configureAndUpdateUi(const QString& uiConfigName) //-------------------------------------------------------------------------------------------------- QWidget* PdmUiPushButtonEditor::createEditorWidget(QWidget * parent) { - m_pushButton = new QPushButton("Ok", parent); + m_pushButton = new QPushButton("", parent); connect(m_pushButton, SIGNAL(clicked(bool)), this, SLOT(slotClicked(bool))); return m_pushButton; } @@ -90,9 +112,18 @@ QWidget* PdmUiPushButtonEditor::createLabelWidget(QWidget * parent) //-------------------------------------------------------------------------------------------------- void PdmUiPushButtonEditor::slotClicked(bool checked) { - QVariant v; - v = checked; - this->setValueToField(v); + + if (dynamic_cast *> (field())) + { + QVariant v; + v = checked; + this->setValueToField(v); + } + else + { + QVariant v = m_pushButton->text(); + this->setValueToField(v); + } } diff --git a/cafUserInterface/cafPdmUiPushButtonEditor.h b/cafUserInterface/cafPdmUiPushButtonEditor.h index d12a3eb830..e6be80efbc 100644 --- a/cafUserInterface/cafPdmUiPushButtonEditor.h +++ b/cafUserInterface/cafPdmUiPushButtonEditor.h @@ -34,7 +34,8 @@ namespace caf class PdmUiPushButtonEditorAttribute : public PdmUiEditorAttribute { - +public: + QIcon m_buttonIcon; }; From 593a53a5a651f9c4a5709b1c19c426fad0588378 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 5 Apr 2013 14:18:34 +0200 Subject: [PATCH 189/242] Added delete of a case not part of a case group p4#: 21144 --- .../ProjectDataModel/RimUiTreeModelPdm.cpp | 50 +++++++++++++------ 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index 8e46582d68..93e635d901 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -215,30 +215,48 @@ bool RimUiTreeModelPdm::deleteReservoirView(const QModelIndex& itemIndex) //-------------------------------------------------------------------------------------------------- void RimUiTreeModelPdm::deleteReservoir(RimCase* reservoir) { - RimCaseCollection* caseCollection = reservoir->parentCaseCollection(); - QModelIndex caseCollectionModelIndex = getModelIndexFromPdmObject(caseCollection); - if (!caseCollectionModelIndex.isValid()) return; - - QModelIndex mi = getModelIndexFromPdmObjectRecursive(caseCollectionModelIndex, reservoir); - if (mi.isValid()) + if (reservoir->parentCaseCollection()) { - caf::PdmUiTreeItem* uiItem = getTreeItemFromIndex(mi); - CVF_ASSERT(uiItem); + RimCaseCollection* caseCollection = reservoir->parentCaseCollection(); + QModelIndex caseCollectionModelIndex = getModelIndexFromPdmObject(caseCollection); + if (!caseCollectionModelIndex.isValid()) return; - // Remove Ui items pointing at the pdm object to delete - removeRows_special(mi.row(), 1, mi.parent()); - } + QModelIndex mi = getModelIndexFromPdmObjectRecursive(caseCollectionModelIndex, reservoir); + if (mi.isValid()) + { + caf::PdmUiTreeItem* uiItem = getTreeItemFromIndex(mi); + CVF_ASSERT(uiItem); - if (RimIdenticalGridCaseGroup::isStatisticsCaseCollection(caseCollection)) - { - RimIdenticalGridCaseGroup* caseGroup = caseCollection->parentCaseGroup(); - CVF_ASSERT(caseGroup); + // Remove Ui items pointing at the pdm object to delete + removeRows_special(mi.row(), 1, mi.parent()); + } - caseGroup->statisticsCaseCollection()->reservoirs.removeChildObject(reservoir); + if (RimIdenticalGridCaseGroup::isStatisticsCaseCollection(caseCollection)) + { + RimIdenticalGridCaseGroup* caseGroup = caseCollection->parentCaseGroup(); + CVF_ASSERT(caseGroup); + + caseGroup->statisticsCaseCollection()->reservoirs.removeChildObject(reservoir); + } + else + { + RimProject* proj = RiaApplication::instance()->project(); + proj->removeCaseFromAllGroups(reservoir); + } } else { RimProject* proj = RiaApplication::instance()->project(); + QModelIndex mi = getModelIndexFromPdmObject(reservoir); + if (mi.isValid()) + { + caf::PdmUiTreeItem* uiItem = getTreeItemFromIndex(mi); + CVF_ASSERT(uiItem); + + // Remove Ui items pointing at the pdm object to delete + removeRows_special(mi.row(), 1, mi.parent()); + } + proj->removeCaseFromAllGroups(reservoir); } From 2f14dbc411546b4ad738b29721b4214cb540c1ff Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 5 Apr 2013 14:25:33 +0200 Subject: [PATCH 190/242] Rename p4#: 21145 --- cafUserInterface/cafUiTreeModelPdm.cpp | 12 ++++++------ cafUserInterface/cafUiTreeModelPdm.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cafUserInterface/cafUiTreeModelPdm.cpp b/cafUserInterface/cafUiTreeModelPdm.cpp index f1195d9478..c2e4008225 100644 --- a/cafUserInterface/cafUiTreeModelPdm.cpp +++ b/cafUserInterface/cafUiTreeModelPdm.cpp @@ -380,18 +380,18 @@ PdmUiTreeItem* caf::UiTreeModelPdm::getTreeItemFromIndex(const QModelIndex& inde //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QModelIndex caf::UiTreeModelPdm::getModelIndexFromPdmObjectRecursive(const QModelIndex& root, const PdmObject * object) const +QModelIndex caf::UiTreeModelPdm::getModelIndexFromPdmObjectRecursive(const QModelIndex& index, const PdmObject * object) const { - if (root.internalPointer()) + if (index.internalPointer()) { - PdmUiTreeItem* treeItem = static_cast(root.internalPointer()); - if (treeItem->dataObject() == object) return root; + PdmUiTreeItem* treeItem = static_cast(index.internalPointer()); + if (treeItem->dataObject() == object) return index; } int row; - for (row = 0; row < rowCount(root); ++row) + for (row = 0; row < rowCount(index); ++row) { - QModelIndex foundIndex = getModelIndexFromPdmObjectRecursive(index(row, 0, root), object); + QModelIndex foundIndex = getModelIndexFromPdmObjectRecursive(index(row, 0, index), object); if (foundIndex.isValid()) return foundIndex; } return QModelIndex(); diff --git a/cafUserInterface/cafUiTreeModelPdm.h b/cafUserInterface/cafUiTreeModelPdm.h index b5f8f7de4e..5ccbfe706e 100644 --- a/cafUserInterface/cafUiTreeModelPdm.h +++ b/cafUserInterface/cafUiTreeModelPdm.h @@ -68,7 +68,7 @@ public: virtual bool removeRows_special(int position, int rows, const QModelIndex &parent = QModelIndex()); protected: - QModelIndex getModelIndexFromPdmObjectRecursive(const QModelIndex& root, const PdmObject * object) const; + QModelIndex getModelIndexFromPdmObjectRecursive(const QModelIndex& index, const PdmObject * object) const; private: PdmUiTreeItem* m_root; From 5911e2bf32cf4eee39f0e43edf465d90dcd8bbf5 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 5 Apr 2013 14:32:33 +0200 Subject: [PATCH 191/242] Do not use same name on a variable and a function p4#: 21147 --- cafUserInterface/cafUiTreeModelPdm.cpp | 12 ++++++------ cafUserInterface/cafUiTreeModelPdm.h | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cafUserInterface/cafUiTreeModelPdm.cpp b/cafUserInterface/cafUiTreeModelPdm.cpp index c2e4008225..fbd98a79b3 100644 --- a/cafUserInterface/cafUiTreeModelPdm.cpp +++ b/cafUserInterface/cafUiTreeModelPdm.cpp @@ -380,18 +380,18 @@ PdmUiTreeItem* caf::UiTreeModelPdm::getTreeItemFromIndex(const QModelIndex& inde //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QModelIndex caf::UiTreeModelPdm::getModelIndexFromPdmObjectRecursive(const QModelIndex& index, const PdmObject * object) const +QModelIndex caf::UiTreeModelPdm::getModelIndexFromPdmObjectRecursive(const QModelIndex& currentIndex, const PdmObject * object) const { - if (index.internalPointer()) + if (currentIndex.internalPointer()) { - PdmUiTreeItem* treeItem = static_cast(index.internalPointer()); - if (treeItem->dataObject() == object) return index; + PdmUiTreeItem* treeItem = static_cast(currentIndex.internalPointer()); + if (treeItem->dataObject() == object) return currentIndex; } int row; - for (row = 0; row < rowCount(index); ++row) + for (row = 0; row < rowCount(currentIndex); ++row) { - QModelIndex foundIndex = getModelIndexFromPdmObjectRecursive(index(row, 0, index), object); + QModelIndex foundIndex = getModelIndexFromPdmObjectRecursive(index(row, 0, currentIndex), object); if (foundIndex.isValid()) return foundIndex; } return QModelIndex(); diff --git a/cafUserInterface/cafUiTreeModelPdm.h b/cafUserInterface/cafUiTreeModelPdm.h index 5ccbfe706e..87b59fd043 100644 --- a/cafUserInterface/cafUiTreeModelPdm.h +++ b/cafUserInterface/cafUiTreeModelPdm.h @@ -68,7 +68,7 @@ public: virtual bool removeRows_special(int position, int rows, const QModelIndex &parent = QModelIndex()); protected: - QModelIndex getModelIndexFromPdmObjectRecursive(const QModelIndex& index, const PdmObject * object) const; + QModelIndex getModelIndexFromPdmObjectRecursive(const QModelIndex& currentIndex, const PdmObject * object) const; private: PdmUiTreeItem* m_root; From ae812a2bbfa6c022b1fc5cd199b054ca15d89e71 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 5 Apr 2013 14:39:34 +0200 Subject: [PATCH 192/242] Implemented check for any results of statistics cases p4#: 21148 --- .../ProjectDataModel/RimUiTreeView.cpp | 25 +++++++++++++++++-- .../ProjectDataModel/RimUiTreeView.h | 2 ++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index d6bcb25095..7d6be1c6e3 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -1029,8 +1029,7 @@ bool RimUiTreeView::userConfirmedGridCaseGroupChange(const QModelIndex & itemInd RimIdenticalGridCaseGroup* gridCaseGroup = myModel->gridCaseGroupFromItemIndex(itemIndex); if (gridCaseGroup) { - // TODO: This test has to check if any of the statistical cases has result values - if (gridCaseGroup->statisticsCaseCollection()->reservoirs.size() > 0) + if (hasAnyStatisticsResults(gridCaseGroup)) { RiuMainWindow* mainWnd = RiuMainWindow::instance(); @@ -1052,3 +1051,25 @@ bool RimUiTreeView::userConfirmedGridCaseGroupChange(const QModelIndex & itemInd return true; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimUiTreeView::hasAnyStatisticsResults(RimIdenticalGridCaseGroup* gridCaseGroup) +{ + CVF_ASSERT(gridCaseGroup); + + for (size_t i = 0; i < gridCaseGroup->statisticsCaseCollection()->reservoirs().size(); i++) + { + RimStatisticsCase* rimStaticsCase = dynamic_cast(gridCaseGroup->statisticsCaseCollection()->reservoirs[i]); + if (rimStaticsCase) + { + if (rimStaticsCase->hasComputedStatistics()) + { + return true; + } + } + } + + return false; +} + diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.h b/ApplicationCode/ProjectDataModel/RimUiTreeView.h index 54576fdab4..5c9784524b 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.h @@ -23,6 +23,7 @@ #include class QItemSelection; +class RimIdenticalGridCaseGroup; namespace caf { class PdmObjectGroup; @@ -90,6 +91,7 @@ signals: private: bool userConfirmedGridCaseGroupChange(const QModelIndex & itemIndex); + bool hasAnyStatisticsResults(RimIdenticalGridCaseGroup* gridCaseGroup); void createPdmObjectsFromClipboard(caf::PdmObjectGroup* objectGroup); bool hasClipboardValidData(); From c7d83893e041ce4e0da1c8a937490b29e1999295 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 5 Apr 2013 14:46:35 +0200 Subject: [PATCH 193/242] Fixed bug causing function to always return true p4#: 21149 --- .../ProjectDataModel/RimIdenticalGridCaseGroup.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index 10981db99b..c59972e211 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -367,7 +367,7 @@ bool RimIdenticalGridCaseGroup::contains(RimCase* reservoir) const for (size_t i = 0; i < caseCollection()->reservoirs().size(); i++) { RimCase* rimReservoir = caseCollection()->reservoirs()[i]; - if (reservoir->caseName == reservoir->caseName) + if (reservoir->caseName == rimReservoir->caseName) { return true; } @@ -376,6 +376,9 @@ bool RimIdenticalGridCaseGroup::contains(RimCase* reservoir) const return false; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- RigActiveCellInfo* RimIdenticalGridCaseGroup::unionOfActiveCells(RifReaderInterface::PorosityModelResultType porosityType) { if (porosityType == RifReaderInterface::MATRIX_RESULTS) From b0c3bc5fbab628454fa9c3dc83da56e4345fab6c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 5 Apr 2013 15:08:50 +0200 Subject: [PATCH 194/242] Added code for reading out grid dimensions from https://github.com/Ensembles/ert/commit/5c8ab75e76a58bfa3b17b1d8bca8fee4e99cca13 p4#: 21150 --- .../devel/libecl/include/ert/ecl/ecl_grid.h | 1 + ThirdParty/Ert/devel/libecl/src/ecl_grid.c | 101 ++++++++++++++++++ 2 files changed, 102 insertions(+) diff --git a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_grid.h b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_grid.h index 3d65451008..cbd8a73f1a 100644 --- a/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_grid.h +++ b/ThirdParty/Ert/devel/libecl/include/ert/ecl/ecl_grid.h @@ -79,6 +79,7 @@ extern "C" { ecl_grid_type * ecl_grid_alloc_GRDECL_data(int , int , int , const float * , const float * , const int * , const float * mapaxes); ecl_grid_type * ecl_grid_alloc_GRID_data(int num_coords , int nx, int ny , int nz , int coords_size , int ** coords , float ** corners , const float * mapaxes); ecl_grid_type * ecl_grid_alloc(const char * ); + bool ecl_grid_file_dims( const char * grid_filename , const char * init_restart_filename , int * dims); ecl_grid_type * ecl_grid_load_case( const char * case_input ); ecl_grid_type * ecl_grid_alloc_rectangular( int nx , int ny , int nz , double dx , double dy , double dz , const int * actnum); ecl_grid_type * ecl_grid_alloc_regular( int nx, int ny , int nz , const double * ivec, const double * jvec , const double * kvec , const int * actnum); diff --git a/ThirdParty/Ert/devel/libecl/src/ecl_grid.c b/ThirdParty/Ert/devel/libecl/src/ecl_grid.c index c1707800ac..56ca5a85c7 100644 --- a/ThirdParty/Ert/devel/libecl/src/ecl_grid.c +++ b/ThirdParty/Ert/devel/libecl/src/ecl_grid.c @@ -2395,8 +2395,109 @@ ecl_grid_type * ecl_grid_alloc(const char * grid_file ) { return ecl_grid; } +static void ecl_grid_file_nactive_dims( fortio_type * data_fortio , int * dims) { + if (data_fortio) { + if (ecl_kw_fseek_kw( INTEHEAD_KW , false , false , data_fortio )) { + ecl_kw_type * intehead_kw = ecl_kw_fread_alloc( data_fortio ); + dims[3] = ecl_kw_iget_int( intehead_kw , INTEHEAD_NACTIVE_INDEX ); + ecl_kw_free( intehead_kw ); + } + } +} +static bool ecl_grid_file_EGRID_dims( fortio_type * grid_fortio , fortio_type * data_fortio , int * dims ) { + + if (ecl_kw_fseek_kw( GRIDHEAD_KW , false , false , grid_fortio)) { + { + ecl_kw_type * gridhead_kw = ecl_kw_fread_alloc( grid_fortio ); + dims[0] = ecl_kw_iget_int( gridhead_kw , GRIDHEAD_NX_INDEX ); + dims[1] = ecl_kw_iget_int( gridhead_kw , GRIDHEAD_NY_INDEX ); + dims[2] = ecl_kw_iget_int( gridhead_kw , GRIDHEAD_NZ_INDEX ); + + ecl_kw_free( gridhead_kw ); + } + ecl_grid_file_nactive_dims( data_fortio , dims ); + return true; + } else + return false; + +} + +static bool ecl_grid_file_GRID_dims( fortio_type * grid_fortio , fortio_type * data_fortio , int * dims ) { + + if (ecl_kw_fseek_kw( DIMENS_KW , false , false , grid_fortio)) { + { + ecl_kw_type * dimens_kw = ecl_kw_fread_alloc( grid_fortio ); + dims[0] = ecl_kw_iget_int( dimens_kw , DIMENS_NX_INDEX ); + dims[1] = ecl_kw_iget_int( dimens_kw , DIMENS_NY_INDEX ); + dims[2] = ecl_kw_iget_int( dimens_kw , DIMENS_NZ_INDEX ); + + ecl_kw_free( dimens_kw ); + } + + ecl_grid_file_nactive_dims( data_fortio , dims ); + return true; + } else + return false; + +} + +/** + Will check the grid dimensions from the input grid file + @grid_filename; the input file must be a GRID/EGRID file. On exit + the dims array will be filled as: + + dims[0] = nx; + dims[1] = ny; + dims[2] = nz; + + Optionally you can in addition supply the name of a restart or INIT + file in the second file argument - if-and-only-if, that filename + points to an existing file the fourth element in the dims array + will be set as: + + dims[3] = nactive; + + The function as a whole will return true if the grid dimensions + (nx,ny,nz) are sucessfully set. If the dimensions are not set the + dims vector is not touched. +*/ + + + +bool ecl_grid_file_dims( const char * grid_filename , const char * init_restart_filename , int * dims) { + bool input_file_OK = false; + bool grid_fmt_file; + ecl_file_enum grid_file_type = ecl_util_get_file_type( grid_filename , &grid_fmt_file , NULL ); + + if ((grid_file_type == ECL_GRID_FILE) || (grid_file_type == ECL_EGRID_FILE)) { + fortio_type * grid_fortio = fortio_open_reader( grid_filename , grid_fmt_file , ECL_ENDIAN_FLIP ); + if (grid_fortio) { + fortio_type * data_fortio = NULL; + bool data_fmt_file; + + if (init_restart_filename) { + ecl_file_enum data_file_type = ecl_util_get_file_type( init_restart_filename , &data_fmt_file , NULL ); + data_fortio = fortio_open_reader( init_restart_filename , data_fmt_file , ECL_ENDIAN_FLIP ); + } + + + if (grid_file_type == ECL_GRID_FILE) + input_file_OK = ecl_grid_file_GRID_dims( grid_fortio , data_fortio , dims ); + else + input_file_OK = ecl_grid_file_EGRID_dims( grid_fortio , data_fortio , dims ); + + if (data_fortio) + fortio_fclose( data_fortio ); + + fortio_fclose( grid_fortio ); + } + } + + return input_file_OK; +} + /** From 1b07630239a7885997c34e01af10a0dbfc114e9f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sun, 7 Apr 2013 16:22:39 +0200 Subject: [PATCH 195/242] Fix for reading wells, verified to be working on case TestCase_LGR_Amalg https://github.com/Ensembles/ert/commit/806a18a1373e34a4a9bff649fcafc4e3ad1c46f9 p4#: 21153 --- ThirdParty/Ert/devel/libecl_well/src/well_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ThirdParty/Ert/devel/libecl_well/src/well_state.c b/ThirdParty/Ert/devel/libecl_well/src/well_state.c index cd7cadf552..ed4c3d06cc 100644 --- a/ThirdParty/Ert/devel/libecl_well/src/well_state.c +++ b/ThirdParty/Ert/devel/libecl_well/src/well_state.c @@ -169,7 +169,7 @@ static int well_state_get_lgr_well_nr( const well_state_type * well_state , cons if (ecl_file_has_kw( ecl_file , ZWEL_KW)) { ecl_rsthead_type * header = ecl_rsthead_alloc( ecl_file ); // const ecl_kw_type * zwel_kw = ecl_file_iget_named_kw( ecl_file , ZWEL_KW , 0); - int num_wells = ecl_kw_get_size( zwel_kw ); + int num_wells = header->nwells; well_nr = 0; while (true) { bool found = false; From 6c9f5d1978753196f3cd922af4ebf479d6b84484 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sun, 7 Apr 2013 16:33:45 +0200 Subject: [PATCH 196/242] Added reading of grid dimensions p4#: 21154 --- .../RifEclipseOutputFileTools.cpp | 18 ++++++++++++++++++ .../FileInterface/RifEclipseOutputFileTools.h | 2 ++ 2 files changed, 20 insertions(+) diff --git a/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp b/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp index 4be4484dbc..5cffc1a15c 100644 --- a/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp @@ -21,6 +21,7 @@ #include "util.h" #include "ecl_file.h" #include "ecl_kw_magic.h" +#include "ecl_grid.h" #include #include @@ -301,3 +302,20 @@ void RifEclipseOutputFileTools::findKeywordsAndDataItemCounts(ecl_file_type* ecl info.setProgress(i); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifEclipseOutputFileTools::readGridDimensions(const QString& gridFileName, std::vector< std::vector >& gridDimensions) +{ + int gridDims[3]; + + bool ret = ecl_grid_file_dims(gridFileName.toAscii().data(), NULL, gridDims); + if (ret) + { + gridDimensions.resize(1); + gridDimensions[0].push_back(gridDims[0]); + gridDimensions[0].push_back(gridDims[1]); + gridDimensions[0].push_back(gridDims[2]); + } +} diff --git a/ApplicationCode/FileInterface/RifEclipseOutputFileTools.h b/ApplicationCode/FileInterface/RifEclipseOutputFileTools.h index 052c1f258b..3824b9bc01 100644 --- a/ApplicationCode/FileInterface/RifEclipseOutputFileTools.h +++ b/ApplicationCode/FileInterface/RifEclipseOutputFileTools.h @@ -54,4 +54,6 @@ public: static QString fileNameByType(const QStringList& fileSet, ecl_file_enum fileType); static QStringList fileNamesByType(const QStringList& fileSet, ecl_file_enum fileType); + + static void readGridDimensions(const QString& gridFileName, std::vector< std::vector >& gridDimensions); }; From da8480a91bb8d316d1715a3e5aa7c9b19ada47db Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sun, 7 Apr 2013 17:20:58 +0200 Subject: [PATCH 197/242] Added constructor with three parameters Added reading of grid dimensions p4#: 21155 --- .../ProjectDataModel/RimResultCase.cpp | 23 +++++++++++++++++++ .../ProjectDataModel/RimResultCase.h | 2 ++ 2 files changed, 25 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/RimResultCase.cpp b/ApplicationCode/ProjectDataModel/RimResultCase.cpp index 4f4f7fca76..35df9639a0 100644 --- a/ApplicationCode/ProjectDataModel/RimResultCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultCase.cpp @@ -26,6 +26,7 @@ #include "RifReaderEclipseInput.h" #include "cafProgressInfo.h" #include "RimProject.h" +#include "RifEclipseOutputFileTools.h" CAF_PDM_SOURCE_INIT(RimResultCase, "EclipseCase"); @@ -41,6 +42,18 @@ RimResultCase::RimResultCase() CAF_PDM_InitField(&caseDirectory, "CaseFolder", QString(), "Directory", "", "" ,""); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimResultCase::RimResultCase(const QString& caseName, const QString& caseFileName, const QString& caseDirectory) +{ + RimResultCase(); + + this->caseName = caseName; + this->caseFileName = caseFileName; + this->caseDirectory = caseDirectory; +} + //-------------------------------------------------------------------------------------------------- /// @@ -286,3 +299,13 @@ QString RimResultCase::createAbsoluteFilenameFromCase(const QString& caseName) return QString(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimResultCase::readGridDimensions(std::vector< std::vector >& gridDimensions) +{ + QString fname = createAbsoluteFilenameFromCase(caseName); + + RifEclipseOutputFileTools::readGridDimensions(fname, gridDimensions); +} + diff --git a/ApplicationCode/ProjectDataModel/RimResultCase.h b/ApplicationCode/ProjectDataModel/RimResultCase.h index 1b2aa10235..3a2e5042bb 100644 --- a/ApplicationCode/ProjectDataModel/RimResultCase.h +++ b/ApplicationCode/ProjectDataModel/RimResultCase.h @@ -38,6 +38,7 @@ class RimResultCase : public RimCase public: RimResultCase(); + RimResultCase(const QString& caseName, const QString& caseFileName, const QString& caseDirectory); virtual ~RimResultCase(); @@ -47,6 +48,7 @@ public: virtual bool openEclipseGridFile(); bool openAndReadActiveCellData(RigCaseData* mainEclipseCase); + void readGridDimensions(std::vector< std::vector >& gridDimensions); //virtual caf::PdmFieldHandle* userDescriptionField() { return &caseName;} From 95d1c98bee2be0db5d6e4e1825e57a5f245ee951 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Sun, 7 Apr 2013 17:27:45 +0200 Subject: [PATCH 198/242] Read grid dimensions and verify equality before adding a result case Harmonized and refactored creation of RimResultCases p4#: 21156 --- .../Application/RiaApplication.cpp | 56 ++++++++++--------- .../RimIdenticalGridCaseGroup.cpp | 34 +++++++++-- .../RimIdenticalGridCaseGroup.h | 2 + .../ProjectDataModel/RimUiTreeModelPdm.cpp | 38 ++++++++++--- .../ReservoirDataModel/RigGridManager.cpp | 23 ++++++++ .../ReservoirDataModel/RigGridManager.h | 5 +- 6 files changed, 117 insertions(+), 41 deletions(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index c534ebc91d..503d3e2d9d 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -56,6 +56,7 @@ #include "RiaImageCompareReporter.h" #include "RiaImageFileCompare.h" #include "cafProgressInfo.h" +#include "RigGridManager.h" namespace caf { @@ -494,10 +495,7 @@ bool RiaApplication::openEclipseCase(const QString& caseName, const QString& cas QFileInfo gridFileName(caseFileName); QString casePath = gridFileName.absolutePath(); - RimResultCase* rimResultReservoir = new RimResultCase(); - rimResultReservoir->caseName = caseName; - rimResultReservoir->caseFileName = caseFileName; - rimResultReservoir->caseDirectory = casePath; + RimResultCase* rimResultReservoir = new RimResultCase(caseName, caseFileName, casePath); m_project->reservoirs.push_back(rimResultReservoir); @@ -1356,11 +1354,11 @@ bool RiaApplication::addEclipseCases(const QStringList& fileNames) { if (fileNames.size() == 0) return true; - // First file is read completely including grid. // The main grid from the first case is reused directly in for the other cases. // When reading active cell info, only the total cell count is tested for consistency - RigCaseData* mainEclipseCase = NULL; + RimResultCase* mainResultCase = NULL; + std::vector< std::vector > mainCaseGridDimensions; { QString firstFileName = fileNames[0]; @@ -1369,46 +1367,54 @@ bool RiaApplication::addEclipseCases(const QStringList& fileNames) QString caseName = gridFileName.completeBaseName(); QString casePath = gridFileName.absolutePath(); - RimResultCase* rimResultReservoir = new RimResultCase(); - rimResultReservoir->caseName = caseName; - rimResultReservoir->caseFileName = firstFileName; - rimResultReservoir->caseDirectory = casePath; - - m_project->reservoirs.push_back(rimResultReservoir); - + RimResultCase* rimResultReservoir = new RimResultCase(caseName, firstFileName, casePath); if (!rimResultReservoir->openEclipseGridFile()) { + delete rimResultReservoir; + return false; } + rimResultReservoir->readGridDimensions(mainCaseGridDimensions); + + m_project->reservoirs.push_back(rimResultReservoir); m_project->moveEclipseCaseIntoCaseGroup(rimResultReservoir); - mainEclipseCase = rimResultReservoir->reservoirData(); + mainResultCase = rimResultReservoir; } caf::ProgressInfo info(fileNames.size(), "Reading Active Cell data"); for (int i = 1; i < fileNames.size(); i++) { - QString fileName = fileNames[i]; - QFileInfo gridFileName(fileName); + QString caseFileName = fileNames[i]; + QFileInfo gridFileName(caseFileName); QString caseName = gridFileName.completeBaseName(); QString casePath = gridFileName.absolutePath(); - RimResultCase* rimResultReservoir = new RimResultCase(); - rimResultReservoir->caseName = caseName; - rimResultReservoir->caseFileName = fileName; - rimResultReservoir->caseDirectory = casePath; + RimResultCase* rimResultReservoir = new RimResultCase(caseName, caseFileName, casePath); - m_project->reservoirs.push_back(rimResultReservoir); + std::vector< std::vector > caseGridDimensions; + rimResultReservoir->readGridDimensions(caseGridDimensions); - if (!rimResultReservoir->openAndReadActiveCellData(mainEclipseCase)) + bool identicalGrid = RigGridManager::isGridDimensionsEqual(mainCaseGridDimensions, caseGridDimensions); + if (identicalGrid) { - return false; + if (rimResultReservoir->openAndReadActiveCellData(mainResultCase->reservoirData())) + { + m_project->reservoirs.push_back(rimResultReservoir); + m_project->moveEclipseCaseIntoCaseGroup(rimResultReservoir); + } + else + { + delete rimResultReservoir; + } + } + else + { + delete rimResultReservoir; } - - m_project->moveEclipseCaseIntoCaseGroup(rimResultReservoir); info.setProgress(i); } diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index c59972e211..919bc329d6 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -30,6 +30,7 @@ #include "RimResultCase.h" #include "cafProgressInfo.h" #include "RigActiveCellInfo.h" +#include "RigGridManager.h" CAF_PDM_SOURCE_INIT(RimIdenticalGridCaseGroup, "RimIdenticalGridCaseGroup"); @@ -78,15 +79,15 @@ void RimIdenticalGridCaseGroup::addCase(RimCase* reservoir) if (!reservoir) return; - RigMainGrid* incomingMainGrid = reservoir->reservoirData()->mainGrid(); - if (!m_mainGrid) { - m_mainGrid = incomingMainGrid; + m_mainGrid = reservoir->reservoirData()->mainGrid(); + } + else + { + reservoir->reservoirData()->setMainGrid(m_mainGrid); } - CVF_ASSERT(m_mainGrid == incomingMainGrid); - caseCollection()->reservoirs().push_back(reservoir); if (statisticsCaseCollection->reservoirs().size() == 0) @@ -423,3 +424,26 @@ RimCase* RimIdenticalGridCaseGroup::mainCase() return NULL; } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimIdenticalGridCaseGroup::canCaseBeAdded(RimCase* reservoir) const +{ + CVF_ASSERT(reservoir && reservoir->reservoirData() && reservoir->reservoirData()->mainGrid()); + + if (!m_mainGrid) + { + // Empty case group, reservoir can be added + return true; + } + + RigMainGrid* incomingMainGrid = reservoir->reservoirData()->mainGrid(); + + if (RigGridManager::isEqual(m_mainGrid, incomingMainGrid)) + { + return true; + } + + return false; +} diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h index c35eedb77e..fb9201a1fd 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.h @@ -49,7 +49,9 @@ public: void addCase(RimCase* reservoir); void removeCase(RimCase* reservoir); + bool contains(RimCase* reservoir) const; + bool canCaseBeAdded(RimCase* reservoir) const; RimStatisticsCase* createAndAppendStatisticsCase(); diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index 93e635d901..f0dce14774 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -37,6 +37,7 @@ #include "RimInputCase.h" #include "RimStatisticsCase.h" #include "RimResultCase.h" +#include "RigGridManager.h" //-------------------------------------------------------------------------------------------------- /// @@ -592,19 +593,29 @@ void RimUiTreeModelPdm::addObjects(const QModelIndex& itemIndex, caf::PdmObjectG CVF_ASSERT(proj); RimIdenticalGridCaseGroup* gridCaseGroup = gridCaseGroupFromItemIndex(itemIndex); - if (gridCaseGroup) { std::vector > typedObjects; pdmObjects.createCopyByType(&typedObjects); - RigCaseData* mainEclipseCase = NULL; - if (gridCaseGroup->caseCollection()->reservoirs().size() > 0) + if (typedObjects.size() == 0) { - RimCase* mainReservoir = gridCaseGroup->caseCollection()->reservoirs()[0]; - mainEclipseCase = mainReservoir->reservoirData(); + return; } + RimResultCase* mainResultCase = NULL; + std::vector< std::vector > mainCaseGridDimensions; + + // Read out main grid and main grid dimensions if present in case group + if (gridCaseGroup->mainCase()) + { + mainResultCase = dynamic_cast(gridCaseGroup->mainCase()); + CVF_ASSERT(mainResultCase); + + mainResultCase->readGridDimensions(mainCaseGridDimensions); + } + + // Add cases to case group for (size_t i = 0; i < typedObjects.size(); i++) { RimResultCase* rimResultReservoir = typedObjects[i]; @@ -614,14 +625,25 @@ void RimUiTreeModelPdm::addObjects(const QModelIndex& itemIndex, caf::PdmObjectG continue; } - if (gridCaseGroup->mainGrid() == NULL) + if (!mainResultCase) { rimResultReservoir->openEclipseGridFile(); - mainEclipseCase = rimResultReservoir->reservoirData(); + rimResultReservoir->readGridDimensions(mainCaseGridDimensions); + + mainResultCase = rimResultReservoir; } else { - if (!rimResultReservoir->openAndReadActiveCellData(mainEclipseCase)) + std::vector< std::vector > caseGridDimensions; + rimResultReservoir->readGridDimensions(caseGridDimensions); + + bool identicalGrid = RigGridManager::isGridDimensionsEqual(mainCaseGridDimensions, caseGridDimensions); + if (!identicalGrid) + { + continue; + } + + if (!rimResultReservoir->openAndReadActiveCellData(mainResultCase->reservoirData())) { CVF_ASSERT(false); } diff --git a/ApplicationCode/ReservoirDataModel/RigGridManager.cpp b/ApplicationCode/ReservoirDataModel/RigGridManager.cpp index 2c7fbbba91..e1b6eb459d 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridManager.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridManager.cpp @@ -96,6 +96,29 @@ void RigGridManager::clear() m_caseToGrid.clear(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigGridManager::isGridDimensionsEqual(const std::vector< std::vector >& mainCaseGridDimensions, const std::vector< std::vector >& caseGridDimensions) +{ + if (mainCaseGridDimensions.size() != caseGridDimensions.size()) + { + return false; + } + + for (size_t j = 0; j < mainCaseGridDimensions.size(); j++) + { + if (mainCaseGridDimensions[j].size() != 3) return false; + if (caseGridDimensions[j].size() != 3) return false; + + if (mainCaseGridDimensions[j][0] != caseGridDimensions[j][0]) return false; + if (mainCaseGridDimensions[j][1] != caseGridDimensions[j][1]) return false; + if (mainCaseGridDimensions[j][2] != caseGridDimensions[j][2]) return false; + } + + return true; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigGridManager.h b/ApplicationCode/ReservoirDataModel/RigGridManager.h index 3d6dada127..7f5f2adc45 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridManager.h +++ b/ApplicationCode/ReservoirDataModel/RigGridManager.h @@ -38,10 +38,9 @@ public: void clear(); -private: - static bool isEqual(RigMainGrid* gridA, RigMainGrid* gridB); - + static bool isGridDimensionsEqual(const std::vector< std::vector >& mainCaseGridDimensions, const std::vector< std::vector >& caseGridDimensions); +private: class CaseToGridMap : public cvf::Object { public: From e89b88e47e8f01eca5808bc14847c0ba49a7ae3d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 8 Apr 2013 08:23:06 +0200 Subject: [PATCH 199/242] Added NULL pointer guarding p4#: 21157 --- .../RimReservoirCellResultsCacher.cpp | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp index b88a70c3c3..bb417bc912 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp @@ -223,11 +223,10 @@ size_t RimReservoirCellResultsStorage::findOrLoadScalarResultForTimeStep(RimDefi loadOrComputeSOILForTimeStep(timeStepIndex); } - size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T; + if (!m_cellResults) return cvf::UNDEFINED_SIZE_T; - scalarResultIndex = m_cellResults->findScalarResultIndex(type, resultName); - - if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) return cvf::UNDEFINED_SIZE_T; + size_t scalarResultIndex = m_cellResults->findScalarResultIndex(type, resultName); + if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) return cvf::UNDEFINED_SIZE_T; if (type == RimDefines::GENERATED) { @@ -280,11 +279,10 @@ size_t RimReservoirCellResultsStorage::findOrLoadScalarResultForTimeStep(RimDefi //-------------------------------------------------------------------------------------------------- size_t RimReservoirCellResultsStorage::findOrLoadScalarResult(RimDefines::ResultCatType type, const QString& resultName) { - size_t resultGridIndex = cvf::UNDEFINED_SIZE_T; + if (!m_cellResults) return cvf::UNDEFINED_SIZE_T; - resultGridIndex = m_cellResults->findScalarResultIndex(type, resultName); - - if (resultGridIndex == cvf::UNDEFINED_SIZE_T) return cvf::UNDEFINED_SIZE_T; + size_t resultGridIndex = m_cellResults->findScalarResultIndex(type, resultName); + if (resultGridIndex == cvf::UNDEFINED_SIZE_T) return cvf::UNDEFINED_SIZE_T; // If we have any results on any timestep, assume we have loaded results already @@ -369,6 +367,8 @@ void RimReservoirCellResultsStorage::loadOrComputeSOILForTimeStep(size_t timeSte return; } + CVF_ASSERT(m_cellResults); + size_t soilResultValueCount = 0; size_t soilTimeStepCount = 0; @@ -444,6 +444,8 @@ void RimReservoirCellResultsStorage::loadOrComputeSOILForTimeStep(size_t timeSte //-------------------------------------------------------------------------------------------------- void RimReservoirCellResultsStorage::computeDepthRelatedResults() { + if (!m_cellResults) return; + size_t depthResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DEPTH"); size_t dxResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DX"); size_t dyResultGridIndex = findOrLoadScalarResult(RimDefines::STATIC_NATIVE, "DY"); @@ -549,6 +551,8 @@ void RimReservoirCellResultsStorage::computeDepthRelatedResults() //-------------------------------------------------------------------------------------------------- size_t RimReservoirCellResultsStorage::findOrLoadScalarResult(const QString& resultName) { + if (!m_cellResults) return cvf::UNDEFINED_SIZE_T; + size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T; scalarResultIndex = this->findOrLoadScalarResult(RimDefines::STATIC_NATIVE, resultName); From b9ed45af2c23c28a945a0bef5a80f3198fbd1176 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 8 Apr 2013 08:36:34 +0200 Subject: [PATCH 200/242] If project is moved on disk, execute initAfterRead() to propagate project file name changes to underlying objects p4#: 21159 --- .../Application/RiaApplication.cpp | 8 +- .../ProjectDataModel/RimResultCase.cpp | 99 +++++++++++-------- .../ProjectDataModel/RimResultCase.h | 11 +-- 3 files changed, 68 insertions(+), 50 deletions(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 503d3e2d9d..ce024743c7 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -235,7 +235,13 @@ bool RiaApplication::loadProject(const QString& projectFileName) m_project->fileName = projectFileName; m_project->readFile(); - m_project->fileName = projectFileName; // Make sure we overwrite the old filename read from the project file + + // If the project filename has changed, call initAfterRead once more to propagate new location of project + if (m_project->fileName() != projectFileName) + { + m_project->fileName = projectFileName; + caf::PdmDocument::initAfterReadTraversal(m_project); + } // On error, delete everything, and bail out. diff --git a/ApplicationCode/ProjectDataModel/RimResultCase.cpp b/ApplicationCode/ProjectDataModel/RimResultCase.cpp index 35df9639a0..41aa4bedd7 100644 --- a/ApplicationCode/ProjectDataModel/RimResultCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultCase.cpp @@ -27,6 +27,7 @@ #include "cafProgressInfo.h" #include "RimProject.h" #include "RifEclipseOutputFileTools.h" +#include "RiaApplication.h" CAF_PDM_SOURCE_INIT(RimResultCase, "EclipseCase"); @@ -76,15 +77,14 @@ bool RimResultCase::openEclipseGridFile() } else { - QString fname = createAbsoluteFilenameFromCase(caseName); - if (fname.isEmpty()) + if (!QFile::exists(caseFileName())) { return false; } cvf::ref eclipseCase = new RigCaseData; readerInterface = new RifReaderEclipseOutput; - if (!readerInterface->open(fname, eclipseCase.p())) + if (!readerInterface->open(caseFileName(), eclipseCase.p())) { return false; } @@ -119,8 +119,7 @@ bool RimResultCase::openAndReadActiveCellData(RigCaseData* mainEclipseCase) } else { - QString fname = createAbsoluteFilenameFromCase(caseName); - if (fname.isEmpty()) + if (!QFile::exists(caseFileName())) { return false; } @@ -140,7 +139,7 @@ bool RimResultCase::openAndReadActiveCellData(RigCaseData* mainEclipseCase) std::vector timeStepDates = mainEclipseCase->results(RifReaderInterface::MATRIX_RESULTS)->timeStepDates(scalarIndexWithMaxTimeStepCount); cvf::ref readerEclipseOutput = new RifReaderEclipseOutput; - if (!readerEclipseOutput->openAndReadActiveCellData(fname, timeStepDates, eclipseCase.p())) + if (!readerEclipseOutput->openAndReadActiveCellData(caseFileName(), timeStepDates, eclipseCase.p())) { return false; } @@ -262,50 +261,64 @@ QString RimResultCase::locationOnDisc() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimResultCase::createAbsoluteFilenameFromCase(const QString& caseName) +void RimResultCase::readGridDimensions(std::vector< std::vector >& gridDimensions) { - QString candidate; - - candidate = QDir::fromNativeSeparators(caseDirectory.v() + QDir::separator() + caseName + ".EGRID"); - if (QFile::exists(candidate)) return candidate; - - candidate = QDir::fromNativeSeparators(caseDirectory.v() + QDir::separator() + caseName + ".GRID"); - if (QFile::exists(candidate)) return candidate; - - std::vector parentObjects; - this->parentObjects(parentObjects); - - QString projectPath; - for (size_t i = 0; i < parentObjects.size(); i++) - { - caf::PdmObject* obj = parentObjects[i]; - RimProject* proj = dynamic_cast(obj); - if (proj) - { - QFileInfo fi(proj->fileName); - projectPath = fi.path(); - } - } - - if (!projectPath.isEmpty()) - { - candidate = QDir::fromNativeSeparators(projectPath + QDir::separator() + caseName + ".EGRID"); - if (QFile::exists(candidate)) return candidate; - - candidate = QDir::fromNativeSeparators(projectPath + QDir::separator() + caseName + ".GRID"); - if (QFile::exists(candidate)) return candidate; - } - - return QString(); + RifEclipseOutputFileTools::readGridDimensions(caseFileName, gridDimensions); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimResultCase::readGridDimensions(std::vector< std::vector >& gridDimensions) +void RimResultCase::initAfterRead() { - QString fname = createAbsoluteFilenameFromCase(caseName); + RimCase::initAfterRead(); - RifEclipseOutputFileTools::readGridDimensions(fname, gridDimensions); + // Update filename and folder paths when opening project from a different file location + if (!QFile::exists(caseFileName)) + { + QString candidate; + + candidate = QDir::fromNativeSeparators(caseDirectory.v() + QDir::separator() + caseName + ".EGRID"); + if (QFile::exists(candidate)) + { + caseFileName = candidate; + return; + } + + candidate = QDir::fromNativeSeparators(caseDirectory.v() + QDir::separator() + caseName + ".GRID"); + if (QFile::exists(candidate)) + { + caseFileName = candidate; + return; + } + + QString projPath = projectPath(); + + candidate = QDir::fromNativeSeparators(projPath + QDir::separator() + caseName + ".EGRID"); + if (QFile::exists(candidate)) + { + caseFileName = candidate; + caseDirectory = projectPath; + return; + } + + candidate = QDir::fromNativeSeparators(projPath + QDir::separator() + caseName + ".GRID"); + if (QFile::exists(candidate)) + { + caseFileName = candidate; + caseDirectory = projPath; + return; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimResultCase::projectPath() const +{ + QString projectFileName = RiaApplication::instance()->project()->fileName(); + QFileInfo fileInfo(projectFileName); + return fileInfo.path(); } diff --git a/ApplicationCode/ProjectDataModel/RimResultCase.h b/ApplicationCode/ProjectDataModel/RimResultCase.h index 3a2e5042bb..1037d230fd 100644 --- a/ApplicationCode/ProjectDataModel/RimResultCase.h +++ b/ApplicationCode/ProjectDataModel/RimResultCase.h @@ -41,7 +41,6 @@ public: RimResultCase(const QString& caseName, const QString& caseFileName, const QString& caseDirectory); virtual ~RimResultCase(); - // Fields: caf::PdmField caseFileName; caf::PdmField caseDirectory; @@ -50,13 +49,13 @@ public: bool openAndReadActiveCellData(RigCaseData* mainEclipseCase); void readGridDimensions(std::vector< std::vector >& gridDimensions); - //virtual caf::PdmFieldHandle* userDescriptionField() { return &caseName;} + virtual QString locationOnDisc() const; - virtual QString locationOnDisc() const; +protected: + virtual void initAfterRead(); private: + QString projectPath() const; + cvf::ref createMockModel(QString modelName); - - QString createAbsoluteFilenameFromCase(const QString& caseName); - }; From 4ae9182fc60bbb2545a7814af7242f44284b88e2 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 8 Apr 2013 08:44:33 +0200 Subject: [PATCH 201/242] Extract path from document file name in RimProject p4#: 21160 --- ApplicationCode/ProjectDataModel/RimProject.cpp | 9 +++++++++ ApplicationCode/ProjectDataModel/RimProject.h | 8 ++++---- ApplicationCode/ProjectDataModel/RimResultCase.cpp | 14 ++------------ ApplicationCode/ProjectDataModel/RimResultCase.h | 2 -- 4 files changed, 15 insertions(+), 18 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index a939da0784..a4aa5cb6dc 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -231,3 +231,12 @@ void RimProject::insertCaseInCaseGroup(RimIdenticalGridCaseGroup* caseGroup, Rim caseGroup->addCase(rimReservoir); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimProject::projectPath() const +{ + QFileInfo fileInfo(fileName()); + return fileInfo.path(); +} + diff --git a/ApplicationCode/ProjectDataModel/RimProject.h b/ApplicationCode/ProjectDataModel/RimProject.h index 084e92dff2..63744f1532 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.h +++ b/ApplicationCode/ProjectDataModel/RimProject.h @@ -34,12 +34,11 @@ class RimProject : public caf::PdmDocument CAF_PDM_HEADER_INIT; public: - caf::PdmPointersField reservoirs; + caf::PdmPointersField reservoirs; caf::PdmPointersField caseGroups; caf::PdmField scriptCollection; void setUserScriptPath(const QString& path); - //void updateProjectScriptPath(); QString projectFileVersionString() const; @@ -52,6 +51,8 @@ public: void moveEclipseCaseIntoCaseGroup(RimCase* rimReservoir); void removeCaseFromAllGroups(RimCase* rimReservoir); + + QString projectPath() const; private: RigMainGrid* registerCaseInGridCollection(RigCaseData* rigEclipseCase); @@ -63,6 +64,5 @@ protected: private: caf::PdmField m_projectFileVersionString; - - cvf::ref m_gridCollection; + cvf::ref m_gridCollection; }; diff --git a/ApplicationCode/ProjectDataModel/RimResultCase.cpp b/ApplicationCode/ProjectDataModel/RimResultCase.cpp index 41aa4bedd7..a8df1bc64c 100644 --- a/ApplicationCode/ProjectDataModel/RimResultCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultCase.cpp @@ -292,13 +292,13 @@ void RimResultCase::initAfterRead() return; } - QString projPath = projectPath(); + QString projPath = RiaApplication::instance()->project()->projectPath(); candidate = QDir::fromNativeSeparators(projPath + QDir::separator() + caseName + ".EGRID"); if (QFile::exists(candidate)) { caseFileName = candidate; - caseDirectory = projectPath; + caseDirectory = projPath; return; } @@ -312,13 +312,3 @@ void RimResultCase::initAfterRead() } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RimResultCase::projectPath() const -{ - QString projectFileName = RiaApplication::instance()->project()->fileName(); - QFileInfo fileInfo(projectFileName); - return fileInfo.path(); -} - diff --git a/ApplicationCode/ProjectDataModel/RimResultCase.h b/ApplicationCode/ProjectDataModel/RimResultCase.h index 1037d230fd..a666df6b8c 100644 --- a/ApplicationCode/ProjectDataModel/RimResultCase.h +++ b/ApplicationCode/ProjectDataModel/RimResultCase.h @@ -55,7 +55,5 @@ protected: virtual void initAfterRead(); private: - QString projectPath() const; - cvf::ref createMockModel(QString modelName); }; From 775b9e5bee3028a9b5e716072161db30d9e02c5c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 8 Apr 2013 09:57:40 +0200 Subject: [PATCH 202/242] Update file paths if project file is moved on disk p4#: 21162 --- .../ProjectDataModel/RimInputCase.cpp | 37 +++++++++++++++++++ .../ProjectDataModel/RimInputCase.h | 19 ++++++---- 2 files changed, 48 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimInputCase.cpp b/ApplicationCode/ProjectDataModel/RimInputCase.cpp index 229d25dd73..56bec0f678 100644 --- a/ApplicationCode/ProjectDataModel/RimInputCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimInputCase.cpp @@ -419,3 +419,40 @@ QString RimInputCase::locationOnDisc() const QFileInfo fi(m_gridFileName); return fi.absolutePath(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimInputCase::initAfterRead() +{ + RimCase::initAfterRead(); + + QString projPath = RiaApplication::instance()->project()->projectPath(); + + QString candidate; + + if (!QFile::exists(m_gridFileName)) + { + QString fileNameWithoutPath = QFileInfo(m_gridFileName).fileName(); + candidate = QDir::fromNativeSeparators(projPath + QDir::separator() + fileNameWithoutPath); + if (QFile::exists(candidate)) + { + m_gridFileName = candidate; + } + } + + for (size_t i = 0; i < m_additionalFileNames().size(); i++) + { + QString additionalFileName = m_additionalFileNames()[i]; + + if (!QFile::exists(additionalFileName)) + { + QString fileNameWithoutPath = QFileInfo(additionalFileName).fileName(); + candidate = QDir::fromNativeSeparators(projPath + QDir::separator() + fileNameWithoutPath); + if (QFile::exists(candidate)) + { + m_additionalFileNames.v()[i] = candidate; + } + } + } +} diff --git a/ApplicationCode/ProjectDataModel/RimInputCase.h b/ApplicationCode/ProjectDataModel/RimInputCase.h index 525937c9ab..75aba517cd 100644 --- a/ApplicationCode/ProjectDataModel/RimInputCase.h +++ b/ApplicationCode/ProjectDataModel/RimInputCase.h @@ -51,23 +51,26 @@ public: caf::PdmField m_inputPropertyCollection; // File open methods - void openDataFileSet(const QStringList& filenames); - void loadAndSyncronizeInputProperties(); + void openDataFileSet(const QStringList& filenames); + void loadAndSyncronizeInputProperties(); - void removeProperty(RimInputProperty* inputProperty); + void removeProperty(RimInputProperty* inputProperty); // RimCase overrides virtual bool openEclipseGridFile(); // Find grid file among file set. Read, Find read and validate property date. Syncronize child property sets. // PdmObject overrides - virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); - virtual QString locationOnDisc() const; + virtual QString locationOnDisc() const; + +protected: + virtual void initAfterRead(); private: - void addFiles(const QStringList& newFileNames); - void removeFiles(const QStringList& obsoleteFileNames); + void addFiles(const QStringList& newFileNames); + void removeFiles(const QStringList& obsoleteFileNames); + cvf::ref createMockModel(QString modelName); - }; From 64899f62c2337f486a8a0be0a10038764271a39d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 8 Apr 2013 12:01:40 +0200 Subject: [PATCH 203/242] Detect when project path has changed, and do a explicit update of file path for RimCases. Do not use initAfterRead p4#: 21165 --- .../Application/RiaApplication.cpp | 3 +-- ApplicationCode/ProjectDataModel/RimCase.h | 6 +++-- .../ProjectDataModel/RimInputCase.cpp | 12 ++++----- .../ProjectDataModel/RimInputCase.h | 6 ++--- .../ProjectDataModel/RimProject.cpp | 27 ++++++++++++++++--- ApplicationCode/ProjectDataModel/RimProject.h | 2 +- .../ProjectDataModel/RimResultCase.cpp | 14 ++++------ .../ProjectDataModel/RimResultCase.h | 5 ++-- 8 files changed, 44 insertions(+), 31 deletions(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index ce024743c7..96d23181df 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -239,8 +239,7 @@ bool RiaApplication::loadProject(const QString& projectFileName) // If the project filename has changed, call initAfterRead once more to propagate new location of project if (m_project->fileName() != projectFileName) { - m_project->fileName = projectFileName; - caf::PdmDocument::initAfterReadTraversal(m_project); + m_project->setProjectFileNameAndUpdateDependencies(projectFileName); } // On error, delete everything, and bail out. diff --git a/ApplicationCode/ProjectDataModel/RimCase.h b/ApplicationCode/ProjectDataModel/RimCase.h index 12b1b6aaff..861a55f96d 100644 --- a/ApplicationCode/ProjectDataModel/RimCase.h +++ b/ApplicationCode/ProjectDataModel/RimCase.h @@ -52,8 +52,8 @@ public: virtual bool openEclipseGridFile() { return false;}; // Should be pure virtual but PDM does not allow that. - RigCaseData* reservoirData(); - const RigCaseData* reservoirData() const; + RigCaseData* reservoirData(); + const RigCaseData* reservoirData() const; RimReservoirCellResultsStorage* results(RifReaderInterface::PorosityModelResultType porosityModel); @@ -63,8 +63,10 @@ public: void removeResult(const QString& resultName); virtual QString locationOnDisc() const { return QString(); } + virtual void updateFilePathsFromProjectPath(const QString& projectPath) { }; RimCaseCollection* parentCaseCollection(); + // Overridden methods from PdmObject public: diff --git a/ApplicationCode/ProjectDataModel/RimInputCase.cpp b/ApplicationCode/ProjectDataModel/RimInputCase.cpp index 56bec0f678..fc2d3a64b4 100644 --- a/ApplicationCode/ProjectDataModel/RimInputCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimInputCase.cpp @@ -420,21 +420,18 @@ QString RimInputCase::locationOnDisc() const return fi.absolutePath(); } + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimInputCase::initAfterRead() +void RimInputCase::updateFilePathsFromProjectPath(const QString& projectPath) { - RimCase::initAfterRead(); - - QString projPath = RiaApplication::instance()->project()->projectPath(); - QString candidate; if (!QFile::exists(m_gridFileName)) { QString fileNameWithoutPath = QFileInfo(m_gridFileName).fileName(); - candidate = QDir::fromNativeSeparators(projPath + QDir::separator() + fileNameWithoutPath); + candidate = QDir::fromNativeSeparators(projectPath + QDir::separator() + fileNameWithoutPath); if (QFile::exists(candidate)) { m_gridFileName = candidate; @@ -448,11 +445,12 @@ void RimInputCase::initAfterRead() if (!QFile::exists(additionalFileName)) { QString fileNameWithoutPath = QFileInfo(additionalFileName).fileName(); - candidate = QDir::fromNativeSeparators(projPath + QDir::separator() + fileNameWithoutPath); + candidate = QDir::fromNativeSeparators(projectPath + QDir::separator() + fileNameWithoutPath); if (QFile::exists(candidate)) { m_additionalFileNames.v()[i] = candidate; } } } + } diff --git a/ApplicationCode/ProjectDataModel/RimInputCase.h b/ApplicationCode/ProjectDataModel/RimInputCase.h index 75aba517cd..5ab1f1a009 100644 --- a/ApplicationCode/ProjectDataModel/RimInputCase.h +++ b/ApplicationCode/ProjectDataModel/RimInputCase.h @@ -62,15 +62,13 @@ public: // PdmObject overrides virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); + // Overrides from RimCase virtual QString locationOnDisc() const; - -protected: - virtual void initAfterRead(); + virtual void updateFilePathsFromProjectPath(const QString& projectPath); private: void addFiles(const QStringList& newFileNames); void removeFiles(const QStringList& obsoleteFileNames); - cvf::ref createMockModel(QString modelName); }; diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index a4aa5cb6dc..452c468b51 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -234,9 +234,30 @@ void RimProject::insertCaseInCaseGroup(RimIdenticalGridCaseGroup* caseGroup, Rim //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimProject::projectPath() const +void RimProject::setProjectFileNameAndUpdateDependencies(const QString& fileName) { - QFileInfo fileInfo(fileName()); - return fileInfo.path(); + this->fileName = fileName; + + // Loop over all reservoirs and update file path + + QFileInfo fileInfo(fileName); + QString projectPath = fileInfo.path(); + + for (size_t i = 0; i < reservoirs.size(); i++) + { + reservoirs[i]->updateFilePathsFromProjectPath(projectPath); + } + + // Case groups : Loop over all reservoirs in and update file path + + for (size_t i = 0; i < caseGroups.size(); i++) + { + RimIdenticalGridCaseGroup* cg = caseGroups()[i]; + + for (size_t j = 0; j < cg->caseCollection()->reservoirs().size(); j++) + { + cg->caseCollection()->reservoirs()[j]->updateFilePathsFromProjectPath(projectPath); + } + } } diff --git a/ApplicationCode/ProjectDataModel/RimProject.h b/ApplicationCode/ProjectDataModel/RimProject.h index 63744f1532..aa4f5f4b22 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.h +++ b/ApplicationCode/ProjectDataModel/RimProject.h @@ -52,7 +52,7 @@ public: void moveEclipseCaseIntoCaseGroup(RimCase* rimReservoir); void removeCaseFromAllGroups(RimCase* rimReservoir); - QString projectPath() const; + void setProjectFileNameAndUpdateDependencies(const QString& fileName); private: RigMainGrid* registerCaseInGridCollection(RigCaseData* rigEclipseCase); diff --git a/ApplicationCode/ProjectDataModel/RimResultCase.cpp b/ApplicationCode/ProjectDataModel/RimResultCase.cpp index a8df1bc64c..d7a8553131 100644 --- a/ApplicationCode/ProjectDataModel/RimResultCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultCase.cpp @@ -269,10 +269,8 @@ void RimResultCase::readGridDimensions(std::vector< std::vector >& gridDime //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimResultCase::initAfterRead() +void RimResultCase::updateFilePathsFromProjectPath(const QString& projectPath) { - RimCase::initAfterRead(); - // Update filename and folder paths when opening project from a different file location if (!QFile::exists(caseFileName)) { @@ -292,21 +290,19 @@ void RimResultCase::initAfterRead() return; } - QString projPath = RiaApplication::instance()->project()->projectPath(); - - candidate = QDir::fromNativeSeparators(projPath + QDir::separator() + caseName + ".EGRID"); + candidate = QDir::fromNativeSeparators(projectPath + QDir::separator() + caseName + ".EGRID"); if (QFile::exists(candidate)) { caseFileName = candidate; - caseDirectory = projPath; + caseDirectory = projectPath; return; } - candidate = QDir::fromNativeSeparators(projPath + QDir::separator() + caseName + ".GRID"); + candidate = QDir::fromNativeSeparators(projectPath + QDir::separator() + caseName + ".GRID"); if (QFile::exists(candidate)) { caseFileName = candidate; - caseDirectory = projPath; + caseDirectory = projectPath; return; } } diff --git a/ApplicationCode/ProjectDataModel/RimResultCase.h b/ApplicationCode/ProjectDataModel/RimResultCase.h index a666df6b8c..1b8463a61a 100644 --- a/ApplicationCode/ProjectDataModel/RimResultCase.h +++ b/ApplicationCode/ProjectDataModel/RimResultCase.h @@ -49,10 +49,9 @@ public: bool openAndReadActiveCellData(RigCaseData* mainEclipseCase); void readGridDimensions(std::vector< std::vector >& gridDimensions); + // Overrides from RimCase virtual QString locationOnDisc() const; - -protected: - virtual void initAfterRead(); + virtual void updateFilePathsFromProjectPath(const QString& projectPath); private: cvf::ref createMockModel(QString modelName); From c6f2b5221690329bedfdee42acc3fa3cc664fa1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 8 Apr 2013 12:09:43 +0200 Subject: [PATCH 204/242] Caf: Removed the const constrain on defineUiOrdering To make this be able to change visibility and names etc of fields, and generally be a "make sure you are updated" entry. p4#: 21168 --- cafProjectDataModel/cafPdmObject.cpp | 2 +- cafProjectDataModel/cafPdmObject.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cafProjectDataModel/cafPdmObject.cpp b/cafProjectDataModel/cafPdmObject.cpp index ed063420cd..d7d71f1ccd 100644 --- a/cafProjectDataModel/cafPdmObject.cpp +++ b/cafProjectDataModel/cafPdmObject.cpp @@ -237,7 +237,7 @@ void PdmObject::addFieldNoDefault(PdmFieldHandle* field, const QString& keyword, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void PdmObject::uiOrdering(QString uiConfigName, PdmUiOrdering& uiOrdering) const +void PdmObject::uiOrdering(QString uiConfigName, PdmUiOrdering& uiOrdering) { this->defineUiOrdering(uiConfigName, uiOrdering); if (!uiOrdering.forgetRemainingFields()) diff --git a/cafProjectDataModel/cafPdmObject.h b/cafProjectDataModel/cafPdmObject.h index 82861bf202..bf83a149c2 100644 --- a/cafProjectDataModel/cafPdmObject.h +++ b/cafProjectDataModel/cafPdmObject.h @@ -138,7 +138,7 @@ public: /// Method to be called from the Ui classes creating Auto Gui to get the group information /// supplied by the \sa defineUiOrdering method that can be reimplemented - void uiOrdering(QString uiConfigName, PdmUiOrdering& uiOrdering) const; + void uiOrdering(QString uiConfigName, PdmUiOrdering& uiOrdering) ; /// For a specific field, return editor specific parameters used to customize the editor behavior.. void editorAttribute(const PdmFieldHandle* field, QString uiConfigName, PdmUiEditorAttribute * attribute); @@ -169,7 +169,7 @@ protected: // Virtual /// Override to customize the order and grouping of the Gui. /// Fill up the uiOrdering object with groups and field references to create the gui structure /// If the uiOrdering is empty, it is interpreted as meaning all fields w/o grouping. - virtual void defineUiOrdering(QString uiConfigName, PdmUiOrdering& uiOrdering) const {} + virtual void defineUiOrdering(QString uiConfigName, PdmUiOrdering& uiOrdering) {} /// Override to provide editor specific data for the field and uiConfigName virtual void defineEditorAttribute(const PdmFieldHandle* field, QString uiConfigName, PdmUiEditorAttribute * attribute) {} From 1c65fe7e2c512ab4eb261fd680a30f5f1a683ff7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 8 Apr 2013 12:16:38 +0200 Subject: [PATCH 205/242] Statistics case User interface and behaviour working. p4#: 21171 --- .../Application/RiaPreferences.cpp | 2 +- ApplicationCode/Application/RiaPreferences.h | 2 +- ApplicationCode/ProjectDataModel/RimCase.cpp | 37 ++++-- ApplicationCode/ProjectDataModel/RimCase.h | 9 +- .../RimCellPropertyFilter.cpp | 2 +- .../ProjectDataModel/RimCellPropertyFilter.h | 2 +- .../ProjectDataModel/RimStatisticsCase.cpp | 106 +++++++++++------- .../ProjectDataModel/RimStatisticsCase.h | 7 +- .../ProjectDataModel/RimUiTreeModelPdm.cpp | 73 +++++++----- cafUserInterface/cafPdmUiPushButtonEditor.cpp | 12 +- cafUserInterface/cafPdmUiPushButtonEditor.h | 1 + 11 files changed, 160 insertions(+), 93 deletions(-) diff --git a/ApplicationCode/Application/RiaPreferences.cpp b/ApplicationCode/Application/RiaPreferences.cpp index 725e13a58c..2dcb049782 100644 --- a/ApplicationCode/Application/RiaPreferences.cpp +++ b/ApplicationCode/Application/RiaPreferences.cpp @@ -76,7 +76,7 @@ void RiaPreferences::defineEditorAttribute(const caf::PdmFieldHandle* field, QSt //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaPreferences::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const +void RiaPreferences::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { uiOrdering.add(&navigationPolicy); diff --git a/ApplicationCode/Application/RiaPreferences.h b/ApplicationCode/Application/RiaPreferences.h index 367c8ddbde..528fc147b3 100644 --- a/ApplicationCode/Application/RiaPreferences.h +++ b/ApplicationCode/Application/RiaPreferences.h @@ -51,5 +51,5 @@ public: // Pdm Fields protected: virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute); - virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const; + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) ; }; diff --git a/ApplicationCode/ProjectDataModel/RimCase.cpp b/ApplicationCode/ProjectDataModel/RimCase.cpp index d7f1beae97..24ad22cd8d 100644 --- a/ApplicationCode/ProjectDataModel/RimCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimCase.cpp @@ -90,6 +90,14 @@ const RigCaseData* RimCase::reservoirData() const return m_rigEclipseCase.p(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCase::removeReservoirData() +{ + this->setReservoirData(NULL); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -110,17 +118,6 @@ void RimCase::initAfterRead() //-------------------------------------------------------------------------------------------------- RimReservoirView* RimCase::createAndAddReservoirView() { - // If parent is collection, and number of views is zero, make sure rig is set to NULL to initiate normal case loading - if (parentCaseCollection() != NULL && reservoirViews().size() == 0) - { - if (this->reservoirData()) - { - CVF_ASSERT(this->reservoirData()->refCount() == 1); - } - - this->setReservoirData( NULL ); - } - RimReservoirView* riv = new RimReservoirView(); riv->setEclipseCase(this); @@ -293,6 +290,23 @@ RimCaseCollection* RimCase::parentCaseCollection() return NULL; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimIdenticalGridCaseGroup* RimCase::parentGridCaseGroup() +{ + RimCaseCollection* caseColl = parentCaseCollection(); + if (caseColl) + { + return caseColl->parentCaseGroup(); + } + else + { + return NULL; + } +} + + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -327,4 +341,3 @@ RimReservoirCellResultsStorage* RimCase::results(RifReaderInterface::PorosityMod return m_fractureModelResults(); } - diff --git a/ApplicationCode/ProjectDataModel/RimCase.h b/ApplicationCode/ProjectDataModel/RimCase.h index 861a55f96d..ab2b025555 100644 --- a/ApplicationCode/ProjectDataModel/RimCase.h +++ b/ApplicationCode/ProjectDataModel/RimCase.h @@ -31,6 +31,7 @@ class RigCaseData; class RigGridBase; class RimReservoirView; class RimCaseCollection; +class RimIdenticalGridCaseGroup; //class RimReservoirCellResultsCacher; //================================================================================================== @@ -52,8 +53,9 @@ public: virtual bool openEclipseGridFile() { return false;}; // Should be pure virtual but PDM does not allow that. - RigCaseData* reservoirData(); - const RigCaseData* reservoirData() const; + RigCaseData* reservoirData(); + const RigCaseData* reservoirData() const; + void removeReservoirData(); RimReservoirCellResultsStorage* results(RifReaderInterface::PorosityModelResultType porosityModel); @@ -66,7 +68,8 @@ public: virtual void updateFilePathsFromProjectPath(const QString& projectPath) { }; RimCaseCollection* parentCaseCollection(); - + RimIdenticalGridCaseGroup* parentGridCaseGroup(); + // Overridden methods from PdmObject public: diff --git a/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.cpp b/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.cpp index 8666c153d5..753cf5e676 100644 --- a/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.cpp @@ -163,7 +163,7 @@ void RimCellPropertyFilter::setDefaultValues() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCellPropertyFilter::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const +void RimCellPropertyFilter::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { // Fields declared in RimCellFilter uiOrdering.add(&name); diff --git a/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.h b/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.h index 344c2c5eb2..a6f2c3d415 100644 --- a/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.h +++ b/ApplicationCode/ProjectDataModel/RimCellPropertyFilter.h @@ -72,7 +72,7 @@ public: virtual QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly ); protected: - virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const; + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) ; virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute); private: diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp index 25ffd5c85f..bc642ab3ec 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp @@ -73,7 +73,7 @@ RimStatisticsCase::RimStatisticsCase() m_editingAllowed.setIOWritable(false); m_editingAllowed.setIOReadable(false); m_editingAllowed.setUiEditorTypeName(caf::PdmUiPushButtonEditor::uiEditorTypeName()); - m_editingAllowed = "UNLOCK"; + m_editingAllowed = false; CAF_PDM_InitField(&m_selectionSummary, "SelectionSummary", QString(""), "Selected Properties", "", "", ""); m_selectionSummary.setIOWritable(false); @@ -113,10 +113,6 @@ RimStatisticsCase::RimStatisticsCase() CAF_PDM_InitField(&m_lowPercentile, "LowPercentile", 10.0, "Low", "", "", ""); CAF_PDM_InitField(&m_midPercentile, "MidPercentile", 50.0, "Mid", "", "", ""); CAF_PDM_InitField(&m_highPercentile, "HighPercentile", 90.0, "High", "", "", ""); - - updateSelectionListVisibilities(); - updateSelectionSummaryLabel(); - updatePercentileUiVisibility(); } //-------------------------------------------------------------------------------------------------- @@ -280,9 +276,8 @@ void RimStatisticsCase::computeStatistics() reservoirView->createDisplayModelAndRedraw(); } - m_calculationStatus = CALCULATED; - m_calculationStatus.updateConnectedEditors(); - m_editingAllowed = "UNLOCK"; + + this->updateConnectedEditors(); } //-------------------------------------------------------------------------------------------------- @@ -323,8 +318,14 @@ RimIdenticalGridCaseGroup* RimStatisticsCase::caseGroup() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimStatisticsCase::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) const +void RimStatisticsCase::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { + + updateSelectionSummaryLabel(); + updateSelectionListVisibilities(); + updatePercentileUiVisibility(); + updateUnlockUiVisibility(); + uiOrdering.add(&caseName); uiOrdering.add(&m_calculationStatus); uiOrdering.add(&m_editingAllowed); @@ -343,6 +344,7 @@ void RimStatisticsCase::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderin group->add(&m_selectedFractureInputProperties); group = uiOrdering.addNewGroup("Percentiles"); + group->setUiHidden(hasComputedStatistics()); group->add(&m_calculatePercentiles); group->add(&m_percentileCalculationType); group->add(&m_lowPercentile); @@ -428,34 +430,13 @@ void RimStatisticsCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField { if (&m_resultType == changedField || &m_porosityModel == changedField) { - updateSelectionListVisibilities(); } if (&m_editingAllowed == changedField) { clearComputedStatistics(); - m_calculationStatus = NOT_CALCULATED; - m_editingAllowed.setUiHidden(true); + m_editingAllowed = false; } - - updateSelectionSummaryLabel(); - updatePercentileUiVisibility(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimStatisticsCase::updateSelectionListVisibilities() -{ - m_selectedDynamicProperties.setUiHidden( !(m_porosityModel() == RimDefines::MATRIX_MODEL && m_resultType() == RimDefines::DYNAMIC_NATIVE)); - m_selectedStaticProperties.setUiHidden( !(m_porosityModel() == RimDefines::MATRIX_MODEL && m_resultType() == RimDefines::STATIC_NATIVE)); - m_selectedGeneratedProperties.setUiHidden( !(m_porosityModel() == RimDefines::MATRIX_MODEL && m_resultType() == RimDefines::GENERATED)); - m_selectedInputProperties.setUiHidden( !(m_porosityModel() == RimDefines::MATRIX_MODEL && m_resultType() == RimDefines::INPUT_PROPERTY)); - - m_selectedFractureDynamicProperties.setUiHidden( !(m_porosityModel() == RimDefines::FRACTURE_MODEL && m_resultType() == RimDefines::DYNAMIC_NATIVE)); - m_selectedFractureStaticProperties.setUiHidden( !(m_porosityModel() == RimDefines::FRACTURE_MODEL && m_resultType() == RimDefines::STATIC_NATIVE)); - m_selectedFractureGeneratedProperties.setUiHidden( !(m_porosityModel() == RimDefines::FRACTURE_MODEL && m_resultType() == RimDefines::GENERATED)); - m_selectedFractureInputProperties.setUiHidden( !(m_porosityModel() == RimDefines::FRACTURE_MODEL && m_resultType() == RimDefines::INPUT_PROPERTY)); } //-------------------------------------------------------------------------------------------------- @@ -521,6 +502,31 @@ void RimStatisticsCase::defineEditorAttribute(const caf::PdmFieldHandle* field, textEditAttrib->textMode = caf::PdmUiTextEditorAttribute::HTML; } + if (&m_editingAllowed == field) + { + caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast (attribute); + attrib->m_buttonText = hasComputedStatistics() ? "UNLOCK": "Unlocked"; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimStatisticsCase::updateSelectionListVisibilities() +{ + bool isLocked = hasComputedStatistics(); + m_resultType.setUiHidden(isLocked); + m_porosityModel.setUiHidden(isLocked ); // || !caseGroup()->mainCase()->reservoirData()->results(RifReaderInterface::FRACTURE_RESULTS)->resultCount() + + m_selectedDynamicProperties.setUiHidden( isLocked || !(m_porosityModel() == RimDefines::MATRIX_MODEL && m_resultType() == RimDefines::DYNAMIC_NATIVE)); + m_selectedStaticProperties.setUiHidden( isLocked || !(m_porosityModel() == RimDefines::MATRIX_MODEL && m_resultType() == RimDefines::STATIC_NATIVE)); + m_selectedGeneratedProperties.setUiHidden( isLocked || !(m_porosityModel() == RimDefines::MATRIX_MODEL && m_resultType() == RimDefines::GENERATED)); + m_selectedInputProperties.setUiHidden( isLocked || !(m_porosityModel() == RimDefines::MATRIX_MODEL && m_resultType() == RimDefines::INPUT_PROPERTY)); + + m_selectedFractureDynamicProperties.setUiHidden( isLocked || !(m_porosityModel() == RimDefines::FRACTURE_MODEL && m_resultType() == RimDefines::DYNAMIC_NATIVE)); + m_selectedFractureStaticProperties.setUiHidden( isLocked || !(m_porosityModel() == RimDefines::FRACTURE_MODEL && m_resultType() == RimDefines::STATIC_NATIVE)); + m_selectedFractureGeneratedProperties.setUiHidden( isLocked || !(m_porosityModel() == RimDefines::FRACTURE_MODEL && m_resultType() == RimDefines::GENERATED)); + m_selectedFractureInputProperties.setUiHidden( isLocked || !(m_porosityModel() == RimDefines::FRACTURE_MODEL && m_resultType() == RimDefines::INPUT_PROPERTY)); } //-------------------------------------------------------------------------------------------------- @@ -528,19 +534,40 @@ void RimStatisticsCase::defineEditorAttribute(const caf::PdmFieldHandle* field, //-------------------------------------------------------------------------------------------------- void RimStatisticsCase::updatePercentileUiVisibility() { - m_percentileCalculationType.setUiHidden( !m_calculatePercentiles()); - m_lowPercentile .setUiHidden( !m_calculatePercentiles()); - m_midPercentile .setUiHidden( !m_calculatePercentiles()); - m_highPercentile.setUiHidden( !m_calculatePercentiles()); + bool isLocked = hasComputedStatistics(); + m_calculatePercentiles.setUiHidden(isLocked); + m_percentileCalculationType.setUiHidden( isLocked || !m_calculatePercentiles()); + m_lowPercentile .setUiHidden(isLocked || !m_calculatePercentiles()); + m_midPercentile .setUiHidden(isLocked || !m_calculatePercentiles()); + m_highPercentile.setUiHidden(isLocked || !m_calculatePercentiles()); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimStatisticsCase::hasComputedStatistics() +void RimStatisticsCase::updateUnlockUiVisibility() { - if ( reservoirData()->results(RifReaderInterface::MATRIX_RESULTS)->resultCount() - || reservoirData()->results(RifReaderInterface::FRACTURE_RESULTS)->resultCount()) + bool isLocked = hasComputedStatistics(); + if (isLocked) + { + m_calculationStatus = CALCULATED; + } + else + { + m_calculationStatus = NOT_CALCULATED; + } + + m_editingAllowed.setUiHidden(!isLocked ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimStatisticsCase::hasComputedStatistics() const +{ + if ( reservoirData() + && ( reservoirData()->results(RifReaderInterface::MATRIX_RESULTS)->resultCount() + || reservoirData()->results(RifReaderInterface::FRACTURE_RESULTS)->resultCount())) { return true; } @@ -557,5 +584,6 @@ void RimStatisticsCase::clearComputedStatistics() { reservoirData()->results(RifReaderInterface::MATRIX_RESULTS)->clearAllResults(); reservoirData()->results(RifReaderInterface::FRACTURE_RESULTS)->clearAllResults(); -} + this->updateConnectedEditors(); +} diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCase.h b/ApplicationCode/ProjectDataModel/RimStatisticsCase.h index 53c786e2cc..98d8df780b 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCase.h +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCase.h @@ -47,7 +47,7 @@ public: void setMainGrid(RigMainGrid* mainGrid); void computeStatistics(); - bool hasComputedStatistics(); + bool hasComputedStatistics() const; void clearComputedStatistics(); virtual bool openEclipseGridFile(); @@ -74,9 +74,10 @@ private: void updateSelectionListVisibilities(); void updateSelectionSummaryLabel(); void updatePercentileUiVisibility(); + void updateUnlockUiVisibility(); // Pdm system overrides - virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) const; + virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) ; virtual QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly ); virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); @@ -84,7 +85,7 @@ private: // Fields caf::PdmField< caf::AppEnum< CalculationStatus > > m_calculationStatus; - caf::PdmField< QString > m_editingAllowed; + caf::PdmField< bool > m_editingAllowed; caf::PdmField< caf::AppEnum< RimDefines::ResultCatType > > m_resultType; caf::PdmField< caf::AppEnum< RimDefines::PorosityModelType > > m_porosityModel; diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index f0dce14774..39a2d7a3a7 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -38,6 +38,8 @@ #include "RimStatisticsCase.h" #include "RimResultCase.h" #include "RigGridManager.h" +#include "RimCase.h" +#include "RigCaseData.h" //-------------------------------------------------------------------------------------------------- /// @@ -218,32 +220,32 @@ void RimUiTreeModelPdm::deleteReservoir(RimCase* reservoir) { if (reservoir->parentCaseCollection()) { - RimCaseCollection* caseCollection = reservoir->parentCaseCollection(); - QModelIndex caseCollectionModelIndex = getModelIndexFromPdmObject(caseCollection); - if (!caseCollectionModelIndex.isValid()) return; + RimCaseCollection* caseCollection = reservoir->parentCaseCollection(); + QModelIndex caseCollectionModelIndex = getModelIndexFromPdmObject(caseCollection); + if (!caseCollectionModelIndex.isValid()) return; - QModelIndex mi = getModelIndexFromPdmObjectRecursive(caseCollectionModelIndex, reservoir); - if (mi.isValid()) - { - caf::PdmUiTreeItem* uiItem = getTreeItemFromIndex(mi); - CVF_ASSERT(uiItem); + QModelIndex mi = getModelIndexFromPdmObjectRecursive(caseCollectionModelIndex, reservoir); + if (mi.isValid()) + { + caf::PdmUiTreeItem* uiItem = getTreeItemFromIndex(mi); + CVF_ASSERT(uiItem); - // Remove Ui items pointing at the pdm object to delete - removeRows_special(mi.row(), 1, mi.parent()); - } + // Remove Ui items pointing at the pdm object to delete + removeRows_special(mi.row(), 1, mi.parent()); + } - if (RimIdenticalGridCaseGroup::isStatisticsCaseCollection(caseCollection)) - { - RimIdenticalGridCaseGroup* caseGroup = caseCollection->parentCaseGroup(); - CVF_ASSERT(caseGroup); + if (RimIdenticalGridCaseGroup::isStatisticsCaseCollection(caseCollection)) + { + RimIdenticalGridCaseGroup* caseGroup = caseCollection->parentCaseGroup(); + CVF_ASSERT(caseGroup); - caseGroup->statisticsCaseCollection()->reservoirs.removeChildObject(reservoir); - } - else - { - RimProject* proj = RiaApplication::instance()->project(); - proj->removeCaseFromAllGroups(reservoir); - } + caseGroup->statisticsCaseCollection()->reservoirs.removeChildObject(reservoir); + } + else + { + RimProject* proj = RiaApplication::instance()->project(); + proj->removeCaseFromAllGroups(reservoir); + } } else { @@ -383,6 +385,23 @@ RimReservoirView* RimUiTreeModelPdm::addReservoirView(const QModelIndex& itemInd if (collectionItem) { RimCase* rimReservoir = dynamic_cast(collectionItem->dataObject().p()); + + // If the case is one of the source cases in a CaseGroup, but not the main case, we need to + // trigger a complete load of the case, if the new view is the first on the case. + + if (rimReservoir && rimReservoir->parentGridCaseGroup() + && rimReservoir->parentGridCaseGroup()->contains(rimReservoir) + && !(rimReservoir == rimReservoir->parentGridCaseGroup()->mainCase()) + && rimReservoir->reservoirViews().size() == 0) + { + if (rimReservoir->reservoirData()) + { + CVF_ASSERT(rimReservoir->reservoirData()->refCount() == 1); + } + + rimReservoir->removeReservoirData(); + } + RimReservoirView* insertedView = rimReservoir->createAndAddReservoirView(); int viewCount = rowCount(collectionIndex); @@ -599,16 +618,16 @@ void RimUiTreeModelPdm::addObjects(const QModelIndex& itemIndex, caf::PdmObjectG pdmObjects.createCopyByType(&typedObjects); if (typedObjects.size() == 0) - { - return; - } + { + return; + } RimResultCase* mainResultCase = NULL; std::vector< std::vector > mainCaseGridDimensions; // Read out main grid and main grid dimensions if present in case group if (gridCaseGroup->mainCase()) - { + { mainResultCase = dynamic_cast(gridCaseGroup->mainCase()); CVF_ASSERT(mainResultCase); @@ -806,7 +825,7 @@ bool RimUiTreeModelPdm::dropMimeData(const QMimeData *data, Qt::DropAction actio if (action == Qt::CopyAction) { - addObjects(parent, pog); + addObjects(parent, pog); } else if (action == Qt::MoveAction) { diff --git a/cafUserInterface/cafPdmUiPushButtonEditor.cpp b/cafUserInterface/cafPdmUiPushButtonEditor.cpp index c64790c60b..18aa383213 100644 --- a/cafUserInterface/cafPdmUiPushButtonEditor.cpp +++ b/cafUserInterface/cafPdmUiPushButtonEditor.cpp @@ -55,6 +55,8 @@ void PdmUiPushButtonEditor::configureAndUpdateUi(const QString& uiConfigName) m_label->setText(field()->uiName(uiConfigName)); } + m_pushButton->setCheckable(true); + //m_label->setEnabled(!field()->isUiReadOnly(uiConfigName)); m_pushButton->setEnabled(!field()->isUiReadOnly(uiConfigName)); @@ -67,6 +69,10 @@ void PdmUiPushButtonEditor::configureAndUpdateUi(const QString& uiConfigName) { m_pushButton->setIcon(attributes.m_buttonIcon); } + else if (!attributes.m_buttonText.isEmpty()) + { + m_pushButton->setText(attributes.m_buttonText); + } else { if (variantFieldValue.type() == QVariant::Bool) @@ -119,11 +125,7 @@ void PdmUiPushButtonEditor::slotClicked(bool checked) v = checked; this->setValueToField(v); } - else - { - QVariant v = m_pushButton->text(); - this->setValueToField(v); - } + } diff --git a/cafUserInterface/cafPdmUiPushButtonEditor.h b/cafUserInterface/cafPdmUiPushButtonEditor.h index e6be80efbc..596f0a5b6b 100644 --- a/cafUserInterface/cafPdmUiPushButtonEditor.h +++ b/cafUserInterface/cafPdmUiPushButtonEditor.h @@ -36,6 +36,7 @@ class PdmUiPushButtonEditorAttribute : public PdmUiEditorAttribute { public: QIcon m_buttonIcon; + QString m_buttonText; }; From 474d00994a8fb41b4d8fd3cecfdd626cc1487fe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 8 Apr 2013 14:10:49 +0200 Subject: [PATCH 206/242] Caf: Made groups become hidden if requested in the uiOrdering system p4#: 21175 --- .../cafPdmUiDefaultObjectEditor.cpp | 177 +++++++++--------- 1 file changed, 88 insertions(+), 89 deletions(-) diff --git a/cafUserInterface/cafPdmUiDefaultObjectEditor.cpp b/cafUserInterface/cafPdmUiDefaultObjectEditor.cpp index 0aa8cb2d41..53ddc42b9c 100644 --- a/cafUserInterface/cafPdmUiDefaultObjectEditor.cpp +++ b/cafUserInterface/cafPdmUiDefaultObjectEditor.cpp @@ -153,6 +153,8 @@ void PdmUiDefaultObjectEditor::recursiveSetupFieldsAndGroups(const std::vector

isUiHidden(uiConfigName)) continue; + if (uiItems[i]->isUiGroup()) { PdmUiGroup* group = static_cast(uiItems[i]); @@ -197,113 +199,110 @@ void PdmUiDefaultObjectEditor::recursiveSetupFieldsAndGroups(const std::vector

(uiItems[i]); PdmUiFieldEditorHandle* fieldEditor = NULL; - if (!field->isUiHidden(uiConfigName)) + // Find or create FieldEditor + std::map::iterator it; + it = m_fieldViews.find(field->keyword()); + + if (it == m_fieldViews.end()) { - - // Find or create FieldEditor - std::map::iterator it; - it = m_fieldViews.find(field->keyword()); - - if (it == m_fieldViews.end()) + // If editor type is specified, find in factory + if ( !uiItems[i]->uiEditorTypeName(uiConfigName).isEmpty() ) { - // If editor type is specified, find in factory - if ( !uiItems[i]->uiEditorTypeName(uiConfigName).isEmpty() ) - { - fieldEditor = caf::Factory::instance()->create(field->uiEditorTypeName(uiConfigName)); - } - else - { - // Find the default field editor - - QString editorTypeName = qStringTypeName(*field); - - // Handle a single value field with valueOptions: Make a combobox - - if (field->uiValue().type() != QVariant::List) - { - bool useOptionsOnly = true; - QList options = field->valueOptions( &useOptionsOnly); - - if (!options.empty()) - { - editorTypeName = caf::PdmUiComboBoxEditor::uiEditorTypeName(); - } - } - - fieldEditor = caf::Factory::instance()->create(editorTypeName); - } - - if (fieldEditor) - { - m_fieldViews[field->keyword()] = fieldEditor; - fieldEditor->createWidgets(parent); - } + fieldEditor = caf::Factory::instance()->create(field->uiEditorTypeName(uiConfigName)); } else - { - fieldEditor = it->second; + { + // Find the default field editor + + QString editorTypeName = qStringTypeName(*field); + + // Handle a single value field with valueOptions: Make a combobox + + if (field->uiValue().type() != QVariant::List) + { + bool useOptionsOnly = true; + QList options = field->valueOptions( &useOptionsOnly); + + if (!options.empty()) + { + editorTypeName = caf::PdmUiComboBoxEditor::uiEditorTypeName(); + } + } + + fieldEditor = caf::Factory::instance()->create(editorTypeName); } if (fieldEditor) { - fieldEditor->setField(field); + m_fieldViews[field->keyword()] = fieldEditor; + fieldEditor->createWidgets(parent); + } + } + else + { + fieldEditor = it->second; + } - // Place the widget(s) into the correct parent and layout - QWidget* fieldCombinedWidget = fieldEditor->combinedWidget(); + if (fieldEditor) + { + fieldEditor->setField(field); - if (fieldCombinedWidget) + // Place the widget(s) into the correct parent and layout + QWidget* fieldCombinedWidget = fieldEditor->combinedWidget(); + + if (fieldCombinedWidget) + { + fieldCombinedWidget->setParent(parent); + parentLayout->addWidget(fieldCombinedWidget, currentRowIndex, 0, 1, 2); + } + else + { + + PdmUiItemInfo::LabelPosType labelPos = field->uiLabelPosition(uiConfigName); + bool labelOnTop = (labelPos == PdmUiItemInfo::TOP); + bool editorSpanBoth = labelOnTop; + + if (labelPos != PdmUiItemInfo::HIDDEN) { - fieldCombinedWidget->setParent(parent); - parentLayout->addWidget(fieldCombinedWidget, currentRowIndex, 0, 1, 2); + QWidget* fieldLabelWidget = fieldEditor->labelWidget(); + if (fieldLabelWidget ) + { + fieldLabelWidget->setParent(parent); + + // Label widget will span two columns if aligned on top + int colSpan = labelOnTop ? 2 : 1; + parentLayout->addWidget(fieldLabelWidget, currentRowIndex, 0, 1, colSpan, Qt::AlignTop); + fieldLabelWidget->show(); + + if (labelOnTop) currentRowIndex++; + } } else { - - PdmUiItemInfo::LabelPosType labelPos = field->uiLabelPosition(uiConfigName); - bool labelOnTop = (labelPos == PdmUiItemInfo::TOP); - bool editorSpanBoth = labelOnTop; - - if (labelPos != PdmUiItemInfo::HIDDEN) - { - QWidget* fieldLabelWidget = fieldEditor->labelWidget(); - if (fieldLabelWidget ) - { - fieldLabelWidget->setParent(parent); - - // Label widget will span two columns if aligned on top - int colSpan = labelOnTop ? 2 : 1; - parentLayout->addWidget(fieldLabelWidget, currentRowIndex, 0, 1, colSpan, Qt::AlignTop); - fieldLabelWidget->show(); - - if (labelOnTop) currentRowIndex++; - } - } - else - { - QWidget* fieldLabelWidget = fieldEditor->labelWidget(); - if (fieldLabelWidget ) fieldLabelWidget->hide(); - editorSpanBoth = true; // To span both columns when there is no label - } - - QWidget* fieldEditorWidget = fieldEditor->editorWidget(); - - if (fieldEditorWidget) - { - fieldEditorWidget->setParent(parent); // To make sure this widget has the current group box as parent. - - // Label widget will span two columns if aligned on top - int colSpan = editorSpanBoth ? 2 : 1; - int colIndex = editorSpanBoth ? 0 : 1; - parentLayout->addWidget(fieldEditorWidget, currentRowIndex, colIndex, 1, colSpan, Qt::AlignTop); - } - + QWidget* fieldLabelWidget = fieldEditor->labelWidget(); + if (fieldLabelWidget ) fieldLabelWidget->hide(); + editorSpanBoth = true; // To span both columns when there is no label + } + + QWidget* fieldEditorWidget = fieldEditor->editorWidget(); + + if (fieldEditorWidget) + { + fieldEditorWidget->setParent(parent); // To make sure this widget has the current group box as parent. + + // Label widget will span two columns if aligned on top + int colSpan = editorSpanBoth ? 2 : 1; + int colIndex = editorSpanBoth ? 0 : 1; + parentLayout->addWidget(fieldEditorWidget, currentRowIndex, colIndex, 1, colSpan, Qt::AlignTop); } - fieldEditor->updateUi(uiConfigName); - - currentRowIndex++; } + + fieldEditor->updateUi(uiConfigName); + + currentRowIndex++; } + } } } From fd67c9dc18e6f7ccea610a3eb889f6f240d41bee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 8 Apr 2013 14:17:39 +0200 Subject: [PATCH 207/242] Statistics ui: Replaced status and unlock button with a Calculate/Edit button. Made Summary description complete and more compact p4#: 21176 --- .../Application/RiaApplication.cpp | 2 +- .../ProjectDataModel/RimStatisticsCase.cpp | 153 ++++++++---------- .../ProjectDataModel/RimStatisticsCase.h | 11 +- 3 files changed, 68 insertions(+), 98 deletions(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 96d23181df..ff331c7cd9 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -236,7 +236,7 @@ bool RiaApplication::loadProject(const QString& projectFileName) m_project->fileName = projectFileName; m_project->readFile(); - // If the project filename has changed, call initAfterRead once more to propagate new location of project + // If the project filename has changed, propagate new location of project if (m_project->fileName() != projectFileName) { m_project->setProjectFileNameAndUpdateDependencies(projectFileName); diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp index bc642ab3ec..8aca3eff9c 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp @@ -41,18 +41,6 @@ namespace caf { } -namespace caf { - template<> - void caf::AppEnum::setUp() - { - addItem(RimStatisticsCase::CALCULATED, "CALCULATED", "OK"); - addItem(RimStatisticsCase::NOT_CALCULATED, "NOT_CALCULATED", "Needs Calculation"); - setDefault(RimStatisticsCase::NOT_CALCULATED); - } -} - - - CAF_PDM_SOURCE_INIT(RimStatisticsCase, "RimStatisticalCalculation"); //-------------------------------------------------------------------------------------------------- @@ -63,24 +51,20 @@ RimStatisticsCase::RimStatisticsCase() { CAF_PDM_InitObject("Case Group Statistics", ":/Histogram16x16.png", "", ""); - CAF_PDM_InitFieldNoDefault(&m_calculationStatus, "CalcStatus", "Status", "", "", ""); - m_calculationStatus.setIOWritable(false); - m_calculationStatus.setIOReadable(false); - m_calculationStatus.setUiReadOnly(true); - m_calculationStatus.setUiEditorTypeName(caf::PdmUiLineEditor::uiEditorTypeName()); + CAF_PDM_InitFieldNoDefault(&m_calculateEditCommand, "m_editingAllowed", "", "", "", ""); + m_calculateEditCommand.setIOWritable(false); + m_calculateEditCommand.setIOReadable(false); + m_calculateEditCommand.setUiEditorTypeName(caf::PdmUiPushButtonEditor::uiEditorTypeName()); + m_calculateEditCommand.setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); - CAF_PDM_InitFieldNoDefault(&m_editingAllowed, "m_editingAllowed", "Editing Locked", "", "", ""); - m_editingAllowed.setIOWritable(false); - m_editingAllowed.setIOReadable(false); - m_editingAllowed.setUiEditorTypeName(caf::PdmUiPushButtonEditor::uiEditorTypeName()); - m_editingAllowed = false; + m_calculateEditCommand = false; - CAF_PDM_InitField(&m_selectionSummary, "SelectionSummary", QString(""), "Selected Properties", "", "", ""); + CAF_PDM_InitField(&m_selectionSummary, "SelectionSummary", QString(""), "Summary of calculation setup", "", "", ""); m_selectionSummary.setIOWritable(false); m_selectionSummary.setIOReadable(false); m_selectionSummary.setUiReadOnly(true); m_selectionSummary.setUiEditorTypeName(caf::PdmUiTextEditor::uiEditorTypeName()); - m_selectionSummary.setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + m_selectionSummary.setUiLabelPosition(caf::PdmUiItemInfo::TOP); CAF_PDM_InitFieldNoDefault(&m_resultType, "ResultType", "Result Type", "", "", ""); m_resultType.setIOWritable(false); @@ -324,14 +308,13 @@ void RimStatisticsCase::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderin updateSelectionSummaryLabel(); updateSelectionListVisibilities(); updatePercentileUiVisibility(); - updateUnlockUiVisibility(); uiOrdering.add(&caseName); - uiOrdering.add(&m_calculationStatus); - uiOrdering.add(&m_editingAllowed); + uiOrdering.add(&m_calculateEditCommand); + uiOrdering.add(&m_selectionSummary); - caf::PdmUiGroup * group = uiOrdering.addNewGroup("Property Selection"); - group->add(&m_selectionSummary); + caf::PdmUiGroup * group = uiOrdering.addNewGroup("Properties to consider"); + group->setUiHidden(hasComputedStatistics()); group->add(&m_resultType); group->add(&m_porosityModel); group->add(&m_selectedDynamicProperties); @@ -343,7 +326,7 @@ void RimStatisticsCase::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderin group->add(&m_selectedFractureGeneratedProperties); group->add(&m_selectedFractureInputProperties); - group = uiOrdering.addNewGroup("Percentiles"); + group = uiOrdering.addNewGroup("Percentile setup"); group->setUiHidden(hasComputedStatistics()); group->add(&m_calculatePercentiles); group->add(&m_percentileCalculationType); @@ -432,10 +415,35 @@ void RimStatisticsCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField { } - if (&m_editingAllowed == changedField) + if (&m_calculateEditCommand == changedField) { - clearComputedStatistics(); - m_editingAllowed = false; + if (hasComputedStatistics()) + { + clearComputedStatistics(); + } + else + { + computeStatistics(); + } + m_calculateEditCommand = false; + } + + //updateSelectionSummaryLabel(); +} + +void addPropertySetToHtmlText(QString& html, const QString& heading, const std::vector& varNames) +{ + if (varNames.size()) + { + html += "

" + heading + "

"; + html += "

"; + for (size_t pIdx = 0; pIdx < varNames.size(); ++pIdx) + { + html += varNames[pIdx]; + if ( (pIdx+1)%6 == 0 ) html += "
"; + else if (pIdx != varNames.size() -1) html += ", "; + } + html += "

"; } } @@ -447,47 +455,34 @@ void RimStatisticsCase::updateSelectionSummaryLabel() QString html; html += ""; - if (m_selectedDynamicProperties().size()) + html += "

Statistical variables to compute:

"; + html += "

"; + html += "Min, Max, Range, Mean, Std.dev"; ; + if (m_calculatePercentiles()) { - html += "

Dynamic properties:

"; - for (size_t pIdx = 0; pIdx < m_selectedDynamicProperties().size(); ++pIdx) - { - html += "" + m_selectedDynamicProperties()[pIdx] + "
"; - } - html += "

"; + html += "
"; + html += "Percentiles for : " + + QString::number(m_lowPercentile()) + ", " + + QString::number(m_midPercentile()) + ", " + + QString::number(m_highPercentile()); } + html += "

"; + + addPropertySetToHtmlText(html, "Dynamic properties", m_selectedDynamicProperties()); + addPropertySetToHtmlText(html, "Static properties", m_selectedStaticProperties()); + addPropertySetToHtmlText(html, "Generated properties", m_selectedGeneratedProperties()); + addPropertySetToHtmlText(html, "Input properties", m_selectedInputProperties()); + + addPropertySetToHtmlText(html, "Dynamic properties, fracture model" , m_selectedFractureDynamicProperties()); + addPropertySetToHtmlText(html, "Static properties, fracture model" , m_selectedFractureStaticProperties()); + addPropertySetToHtmlText(html, "Generated properties, fracture model", m_selectedFractureGeneratedProperties()); + addPropertySetToHtmlText(html, "Input properties, fracture model" , m_selectedFractureInputProperties()); - if (m_selectedStaticProperties().size()) - { - html += "Static properties:

"; - for (size_t pIdx = 0; pIdx < m_selectedStaticProperties().size(); ++pIdx) - { - html += " " + m_selectedStaticProperties()[pIdx] + "
"; - } - html += "

"; - } - if (m_selectedGeneratedProperties().size()) - { - html += "Generated properties:

"; - for (size_t pIdx = 0; pIdx < m_selectedGeneratedProperties().size(); ++pIdx) - { - html += " " + m_selectedGeneratedProperties()[pIdx] + "
"; - } - html += "

"; - } - if (m_selectedInputProperties().size()) - { - html += "Input properties:

"; - for (size_t pIdx = 0; pIdx < m_selectedInputProperties().size(); ++pIdx) - { - html += " " + m_selectedInputProperties()[pIdx] + "
"; - } - html += "

"; - } m_selectionSummary = html; } @@ -502,10 +497,10 @@ void RimStatisticsCase::defineEditorAttribute(const caf::PdmFieldHandle* field, textEditAttrib->textMode = caf::PdmUiTextEditorAttribute::HTML; } - if (&m_editingAllowed == field) + if (&m_calculateEditCommand == field) { caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast (attribute); - attrib->m_buttonText = hasComputedStatistics() ? "UNLOCK": "Unlocked"; + attrib->m_buttonText = hasComputedStatistics() ? "Edit (Will DELETE current results)": "Compute"; } } @@ -542,24 +537,6 @@ void RimStatisticsCase::updatePercentileUiVisibility() m_highPercentile.setUiHidden(isLocked || !m_calculatePercentiles()); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimStatisticsCase::updateUnlockUiVisibility() -{ - bool isLocked = hasComputedStatistics(); - if (isLocked) - { - m_calculationStatus = CALCULATED; - } - else - { - m_calculationStatus = NOT_CALCULATED; - } - - m_editingAllowed.setUiHidden(!isLocked ); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCase.h b/ApplicationCode/ProjectDataModel/RimStatisticsCase.h index 98d8df780b..b72ec6a98a 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCase.h +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCase.h @@ -60,12 +60,7 @@ public: HISTOGRAM_ESTIMATED }; - enum CalculationStatus - { - CALCULATED, - NOT_CALCULATED - }; - + private: RimIdenticalGridCaseGroup* caseGroup(); @@ -74,7 +69,6 @@ private: void updateSelectionListVisibilities(); void updateSelectionSummaryLabel(); void updatePercentileUiVisibility(); - void updateUnlockUiVisibility(); // Pdm system overrides virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) ; @@ -84,8 +78,7 @@ private: virtual void defineEditorAttribute( const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute ); // Fields - caf::PdmField< caf::AppEnum< CalculationStatus > > m_calculationStatus; - caf::PdmField< bool > m_editingAllowed; + caf::PdmField< bool > m_calculateEditCommand; caf::PdmField< caf::AppEnum< RimDefines::ResultCatType > > m_resultType; caf::PdmField< caf::AppEnum< RimDefines::PorosityModelType > > m_porosityModel; From bd563df02eda14ccb2df6f39cce9ece14cba6400 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Mon, 8 Apr 2013 14:29:43 +0200 Subject: [PATCH 208/242] Use setter instead of overloaded constructor p4#: 21177 --- .../Application/RiaApplication.cpp | 9 +++++--- .../ProjectDataModel/RimResultCase.cpp | 21 +++++++++---------- .../ProjectDataModel/RimResultCase.h | 3 ++- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index ff331c7cd9..ff270910a6 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -500,7 +500,8 @@ bool RiaApplication::openEclipseCase(const QString& caseName, const QString& cas QFileInfo gridFileName(caseFileName); QString casePath = gridFileName.absolutePath(); - RimResultCase* rimResultReservoir = new RimResultCase(caseName, caseFileName, casePath); + RimResultCase* rimResultReservoir = new RimResultCase(); + rimResultReservoir->setCaseInfo(caseName, caseFileName, casePath); m_project->reservoirs.push_back(rimResultReservoir); @@ -1372,7 +1373,8 @@ bool RiaApplication::addEclipseCases(const QStringList& fileNames) QString caseName = gridFileName.completeBaseName(); QString casePath = gridFileName.absolutePath(); - RimResultCase* rimResultReservoir = new RimResultCase(caseName, firstFileName, casePath); + RimResultCase* rimResultReservoir = new RimResultCase(); + rimResultReservoir->setCaseInfo(caseName, firstFileName, casePath); if (!rimResultReservoir->openEclipseGridFile()) { delete rimResultReservoir; @@ -1398,7 +1400,8 @@ bool RiaApplication::addEclipseCases(const QStringList& fileNames) QString caseName = gridFileName.completeBaseName(); QString casePath = gridFileName.absolutePath(); - RimResultCase* rimResultReservoir = new RimResultCase(caseName, caseFileName, casePath); + RimResultCase* rimResultReservoir = new RimResultCase(); + rimResultReservoir->setCaseInfo(caseName, caseFileName, casePath); std::vector< std::vector > caseGridDimensions; rimResultReservoir->readGridDimensions(caseGridDimensions); diff --git a/ApplicationCode/ProjectDataModel/RimResultCase.cpp b/ApplicationCode/ProjectDataModel/RimResultCase.cpp index d7a8553131..4fdf6275cf 100644 --- a/ApplicationCode/ProjectDataModel/RimResultCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultCase.cpp @@ -43,17 +43,6 @@ RimResultCase::RimResultCase() CAF_PDM_InitField(&caseDirectory, "CaseFolder", QString(), "Directory", "", "" ,""); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimResultCase::RimResultCase(const QString& caseName, const QString& caseFileName, const QString& caseDirectory) -{ - RimResultCase(); - - this->caseName = caseName; - this->caseFileName = caseFileName; - this->caseDirectory = caseDirectory; -} //-------------------------------------------------------------------------------------------------- @@ -308,3 +297,13 @@ void RimResultCase::updateFilePathsFromProjectPath(const QString& projectPath) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimResultCase::setCaseInfo(const QString& caseName, const QString& caseFileName, const QString& caseDirectory) +{ + this->caseName = caseName; + this->caseFileName = caseFileName; + this->caseDirectory = caseDirectory; +} + diff --git a/ApplicationCode/ProjectDataModel/RimResultCase.h b/ApplicationCode/ProjectDataModel/RimResultCase.h index 1b8463a61a..bceeeec3b6 100644 --- a/ApplicationCode/ProjectDataModel/RimResultCase.h +++ b/ApplicationCode/ProjectDataModel/RimResultCase.h @@ -38,13 +38,14 @@ class RimResultCase : public RimCase public: RimResultCase(); - RimResultCase(const QString& caseName, const QString& caseFileName, const QString& caseDirectory); virtual ~RimResultCase(); // Fields: caf::PdmField caseFileName; caf::PdmField caseDirectory; + void setCaseInfo(const QString& caseName, const QString& caseFileName, const QString& caseDirectory); + virtual bool openEclipseGridFile(); bool openAndReadActiveCellData(RigCaseData* mainEclipseCase); void readGridDimensions(std::vector< std::vector >& gridDimensions); From 12294ca85309c8bab6ca1a7ed348eec628cfdcff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 8 Apr 2013 17:02:07 +0200 Subject: [PATCH 209/242] Statistics Ui: Added default selected properties p4#: 21185 --- .../ProjectDataModel/RimStatisticsCase.cpp | 46 +++++++++++++++++++ .../ProjectDataModel/RimStatisticsCase.h | 2 + 2 files changed, 48 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp index 8aca3eff9c..ee9370eb8d 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp @@ -142,6 +142,8 @@ bool RimStatisticsCase::openEclipseGridFile() this->setReservoirData( eclipseCase.p() ); + this->populateWithDefaultsIfNeeded(); + return true; } @@ -564,3 +566,47 @@ void RimStatisticsCase::clearComputedStatistics() this->updateConnectedEditors(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimStatisticsCase::populateWithDefaultsIfNeeded() +{ + RimIdenticalGridCaseGroup* idgcg = caseGroup(); + if (!(caseGroup() && caseGroup()->mainCase() && caseGroup()->mainCase()->reservoirData())) + { + return ; + } + + RigCaseData* caseData = idgcg->mainCase()->reservoirData(); + + if (m_selectedDynamicProperties().size() == 0) + { + QStringList varList = caseData->results(RifReaderInterface::MATRIX_RESULTS)->resultNames(RimDefines::DYNAMIC_NATIVE); + if (varList.contains("SOIL")) m_selectedDynamicProperties.v().push_back("SOIL"); + if (varList.contains("PRESSURE")) m_selectedDynamicProperties.v().push_back("PRESSURE"); + } + + if (m_selectedStaticProperties().size() == 0) + { + QStringList varList = caseData->results(RifReaderInterface::MATRIX_RESULTS)->resultNames(RimDefines::STATIC_NATIVE); + if (varList.contains("PERMX")) m_selectedStaticProperties.v().push_back("PERMX"); + if (varList.contains("PERMY")) m_selectedStaticProperties.v().push_back("PERMY"); + if (varList.contains("PORO")) m_selectedStaticProperties.v().push_back("PORO"); + } + + if (m_selectedFractureDynamicProperties().size() == 0) + { + QStringList varList = caseData->results(RifReaderInterface::FRACTURE_RESULTS)->resultNames(RimDefines::DYNAMIC_NATIVE); + if (varList.contains("SOIL")) m_selectedFractureDynamicProperties.v().push_back("SOIL"); + if (varList.contains("PRESSURE")) m_selectedFractureDynamicProperties.v().push_back("PRESSURE"); + } + + if (m_selectedFractureStaticProperties().size() == 0) + { + QStringList varList = caseData->results(RifReaderInterface::FRACTURE_RESULTS)->resultNames(RimDefines::STATIC_NATIVE); + if (varList.contains("PERMX")) m_selectedFractureStaticProperties.v().push_back("PERMX"); + if (varList.contains("PERMY")) m_selectedFractureStaticProperties.v().push_back("PERMY"); + if (varList.contains("PORO")) m_selectedFractureStaticProperties.v().push_back("PORO"); + } +} diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCase.h b/ApplicationCode/ProjectDataModel/RimStatisticsCase.h index b72ec6a98a..48891dc982 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCase.h +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCase.h @@ -66,6 +66,8 @@ private: void getSourceCases(std::vector& sourceCases); + void populateWithDefaultsIfNeeded(); + void updateSelectionListVisibilities(); void updateSelectionSummaryLabel(); void updatePercentileUiVisibility(); From 2a6fce1d648e3c41805544e1331a61021cc66488 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 9 Apr 2013 07:27:55 +0200 Subject: [PATCH 210/242] Added missing include (discovered on Ubuntu 12 build server) p4#: 21186 --- ApplicationCode/ReservoirDataModel/RigStatisticsMath.h | 1 + 1 file changed, 1 insertion(+) diff --git a/ApplicationCode/ReservoirDataModel/RigStatisticsMath.h b/ApplicationCode/ReservoirDataModel/RigStatisticsMath.h index 1daac809bc..b8fb91a8a1 100644 --- a/ApplicationCode/ReservoirDataModel/RigStatisticsMath.h +++ b/ApplicationCode/ReservoirDataModel/RigStatisticsMath.h @@ -19,6 +19,7 @@ #include #include +#include class RigStatisticsMath { From 812aee9be42fd70080b9c2a6e7e6a6d8f6beb464 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Tue, 9 Apr 2013 07:52:34 +0200 Subject: [PATCH 211/242] Text changes p4#: 21187 --- ApplicationCode/ProjectDataModel/RimUiTreeView.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index 7d6be1c6e3..e04f21a7e7 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -1035,7 +1035,7 @@ bool RimUiTreeView::userConfirmedGridCaseGroupChange(const QModelIndex & itemInd QMessageBox msgBox(mainWnd); msgBox.setIcon(QMessageBox::Question); - msgBox.setText("The destination case group has existing statistic results, and these results will be deleted if you continue"); + msgBox.setText("This operation will invalidate statistics results. These results will be deleted if you continue."); msgBox.setInformativeText("Do you want to continue?"); msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); From 1cfd103f30288cc522e2a4c426293be7bc3b062c Mon Sep 17 00:00:00 2001 From: CeetronResInsight Date: Tue, 9 Apr 2013 07:59:41 +0200 Subject: [PATCH 212/242] Linux compile warning fixes p4#: 21189 --- .../FileInterface/RifEclipseRestartFilesetAccess.cpp | 2 +- ApplicationCode/ReservoirDataModel/RigStatisticsMath.cpp | 2 +- cafViewer/cafViewer.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp b/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp index 208a6b48bc..d998810f39 100644 --- a/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp +++ b/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp @@ -99,7 +99,7 @@ void RifEclipseRestartFilesetAccess::close() //-------------------------------------------------------------------------------------------------- void RifEclipseRestartFilesetAccess::setTimeSteps(const std::vector& timeSteps) { - CVF_ASSERT(m_fileNames.size() == timeSteps.size()); + CVF_ASSERT((size_t)m_fileNames.size() == timeSteps.size()); m_timeSteps = timeSteps; } diff --git a/ApplicationCode/ReservoirDataModel/RigStatisticsMath.cpp b/ApplicationCode/ReservoirDataModel/RigStatisticsMath.cpp index 4b16b45a38..4abdd28e0b 100644 --- a/ApplicationCode/ReservoirDataModel/RigStatisticsMath.cpp +++ b/ApplicationCode/ReservoirDataModel/RigStatisticsMath.cpp @@ -102,7 +102,7 @@ std::vector RigStatisticsMath::calculateNearestRankPercentiles(const std { double pVal = HUGE_VAL; - size_t pValIndex = static_cast(sortedValues.size() * abs(pValPositions[i]) / 100); + size_t pValIndex = static_cast(sortedValues.size() * fabs(pValPositions[i]) / 100); if (pValIndex >= sortedValues.size() ) pValIndex = sortedValues.size() - 1; diff --git a/cafViewer/cafViewer.cpp b/cafViewer/cafViewer.cpp index ccc4e257db..b1b7356911 100644 --- a/cafViewer/cafViewer.cpp +++ b/cafViewer/cafViewer.cpp @@ -436,7 +436,7 @@ void caf::Viewer::paintEvent(QPaintEvent* event) // Convert the QImage into the cvf::TextureImage, // handling vertical mirroring and (possible) byteswapping - if (m_overlayTextureImage->height() != this->height() || m_overlayTextureImage->width() != this->width()) + if (((int)m_overlayTextureImage->height()) != this->height() || ((int)m_overlayTextureImage->width() != this->width())) { m_overlayTextureImage->allocate(this->width(), this->height()); } From d0eebb92a8fa5f946d96ebde3834fddb192306b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 9 Apr 2013 14:36:38 +0200 Subject: [PATCH 213/242] Removed PERMY as default statistics property p4#: 21204 --- ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp index ee9370eb8d..f00554eb90 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp @@ -591,7 +591,6 @@ void RimStatisticsCase::populateWithDefaultsIfNeeded() { QStringList varList = caseData->results(RifReaderInterface::MATRIX_RESULTS)->resultNames(RimDefines::STATIC_NATIVE); if (varList.contains("PERMX")) m_selectedStaticProperties.v().push_back("PERMX"); - if (varList.contains("PERMY")) m_selectedStaticProperties.v().push_back("PERMY"); if (varList.contains("PORO")) m_selectedStaticProperties.v().push_back("PORO"); } @@ -606,7 +605,6 @@ void RimStatisticsCase::populateWithDefaultsIfNeeded() { QStringList varList = caseData->results(RifReaderInterface::FRACTURE_RESULTS)->resultNames(RimDefines::STATIC_NATIVE); if (varList.contains("PERMX")) m_selectedFractureStaticProperties.v().push_back("PERMX"); - if (varList.contains("PERMY")) m_selectedFractureStaticProperties.v().push_back("PERMY"); if (varList.contains("PORO")) m_selectedFractureStaticProperties.v().push_back("PORO"); } } From 09810bf5868735e4e9b24617e1372efb78dc0ed5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 9 Apr 2013 15:38:37 +0200 Subject: [PATCH 214/242] Fixed error in path update logic p4#: 21209 --- ApplicationCode/Application/RiaApplication.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index ff270910a6..dc0e9c446c 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -236,11 +236,9 @@ bool RiaApplication::loadProject(const QString& projectFileName) m_project->fileName = projectFileName; m_project->readFile(); - // If the project filename has changed, propagate new location of project - if (m_project->fileName() != projectFileName) - { - m_project->setProjectFileNameAndUpdateDependencies(projectFileName); - } + // Propagate possible new location of project + + m_project->setProjectFileNameAndUpdateDependencies(projectFileName); // On error, delete everything, and bail out. From a246e288ba1cc7fc7a9af49a0720860fde863cf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 10 Apr 2013 11:02:10 +0200 Subject: [PATCH 215/242] Renamed some methods and variables in the eclipse result file access system To make things more readable and understandable p4#: 21218 --- .../RifEclipseOutputFileTools.cpp | 20 +++++------ .../FileInterface/RifEclipseOutputFileTools.h | 6 ++-- .../RifEclipseRestartDataAccess.h | 2 +- .../RifEclipseRestartFilesetAccess.cpp | 3 +- .../RifEclipseRestartFilesetAccess.h | 2 +- .../RifEclipseUnifiedRestartFileAccess.cpp | 2 +- .../RifEclipseUnifiedRestartFileAccess.h | 2 +- .../FileInterface/RifReaderEclipseOutput.cpp | 36 +++++++++---------- .../FileInterface/RifReaderEclipseOutput.h | 8 ++--- 9 files changed, 41 insertions(+), 40 deletions(-) diff --git a/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp b/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp index 5cffc1a15c..416f7a6513 100644 --- a/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp @@ -198,7 +198,7 @@ bool RifEclipseOutputFileTools::keywordData(ecl_file_type* ecl_file, const QStri //-------------------------------------------------------------------------------------------------- /// Get first occurrence of file of given type in given list of filenames, as filename or NULL if not found //-------------------------------------------------------------------------------------------------- -QString RifEclipseOutputFileTools::fileNameByType(const QStringList& fileSet, ecl_file_enum fileType) +QString RifEclipseOutputFileTools::firstFileNameOfType(const QStringList& fileSet, ecl_file_enum fileType) { int i; for (i = 0; i < fileSet.count(); i++) @@ -216,9 +216,9 @@ QString RifEclipseOutputFileTools::fileNameByType(const QStringList& fileSet, ec //-------------------------------------------------------------------------------------------------- -/// Get all files of file of given type in given list of filenames, as filename or NULL if not found +/// Get all files of the given type from the provided list of filenames //-------------------------------------------------------------------------------------------------- -QStringList RifEclipseOutputFileTools::fileNamesByType(const QStringList& fileSet, ecl_file_enum fileType) +QStringList RifEclipseOutputFileTools::filterFileNamesOfType(const QStringList& fileSet, ecl_file_enum fileType) { QStringList fileNames; @@ -240,14 +240,14 @@ QStringList RifEclipseOutputFileTools::fileNamesByType(const QStringList& fileSe //-------------------------------------------------------------------------------------------------- /// Get set of Eclipse files based on an input file and its path //-------------------------------------------------------------------------------------------------- -bool RifEclipseOutputFileTools::fileSet(const QString& fileName, QStringList* fileSet) +bool RifEclipseOutputFileTools::findSiblingFilesWithSameBaseName(const QString& fullPathFileName, QStringList* baseNameFiles) { - CVF_ASSERT(fileSet); - fileSet->clear(); + CVF_ASSERT(baseNameFiles); + baseNameFiles->clear(); - QString filePath = QFileInfo(fileName).absoluteFilePath(); + QString filePath = QFileInfo(fullPathFileName).absoluteFilePath(); filePath = QFileInfo(filePath).path(); - QString fileNameBase = QFileInfo(fileName).baseName(); + QString fileNameBase = QFileInfo(fullPathFileName).baseName(); stringlist_type* eclipseFiles = stringlist_alloc_new(); ecl_util_select_filelist(filePath.toAscii().data(), fileNameBase.toAscii().data(), ECL_OTHER_FILE, false, eclipseFiles); @@ -255,12 +255,12 @@ bool RifEclipseOutputFileTools::fileSet(const QString& fileName, QStringList* fi int i; for (i = 0; i < stringlist_get_size(eclipseFiles); i++) { - fileSet->append(stringlist_safe_iget(eclipseFiles, i)); + baseNameFiles->append(stringlist_safe_iget(eclipseFiles, i)); } stringlist_free(eclipseFiles); - return fileSet->count() > 0; + return baseNameFiles->count() > 0; } diff --git a/ApplicationCode/FileInterface/RifEclipseOutputFileTools.h b/ApplicationCode/FileInterface/RifEclipseOutputFileTools.h index 3824b9bc01..a46c83e4b9 100644 --- a/ApplicationCode/FileInterface/RifEclipseOutputFileTools.h +++ b/ApplicationCode/FileInterface/RifEclipseOutputFileTools.h @@ -50,10 +50,10 @@ public: // static void timeStepsText(ecl_file_type* ecl_file, QStringList* timeSteps); static void timeSteps(ecl_file_type* ecl_file, std::vector* timeSteps, bool* detectedFractionOfDay = NULL); - static bool fileSet(const QString& fileName, QStringList* fileSet); + static bool findSiblingFilesWithSameBaseName(const QString& fileName, QStringList* fileSet); - static QString fileNameByType(const QStringList& fileSet, ecl_file_enum fileType); - static QStringList fileNamesByType(const QStringList& fileSet, ecl_file_enum fileType); + static QString firstFileNameOfType(const QStringList& fileSet, ecl_file_enum fileType); + static QStringList filterFileNamesOfType(const QStringList& fileSet, ecl_file_enum fileType); static void readGridDimensions(const QString& gridFileName, std::vector< std::vector >& gridDimensions); }; diff --git a/ApplicationCode/FileInterface/RifEclipseRestartDataAccess.h b/ApplicationCode/FileInterface/RifEclipseRestartDataAccess.h index dd8bff2460..757e324e02 100644 --- a/ApplicationCode/FileInterface/RifEclipseRestartDataAccess.h +++ b/ApplicationCode/FileInterface/RifEclipseRestartDataAccess.h @@ -43,7 +43,7 @@ public: virtual ~RifEclipseRestartDataAccess(); virtual bool open() = 0; - virtual void setFileSet(const QStringList& fileSet) = 0; + virtual void setRestartFiles(const QStringList& fileSet) = 0; virtual void close() = 0; virtual void setTimeSteps(const std::vector& timeSteps) {}; diff --git a/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp b/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp index d998810f39..fe28ec07be 100644 --- a/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp +++ b/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp @@ -63,12 +63,13 @@ bool RifEclipseRestartFilesetAccess::open() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RifEclipseRestartFilesetAccess::setFileSet(const QStringList& fileSet) +void RifEclipseRestartFilesetAccess::setRestartFiles(const QStringList& fileSet) { close(); m_ecl_files.clear(); m_fileNames = fileSet; + m_fileNames.sort(); // To make sure they are sorted in increasing *.X000N order. Hack. Should probably be actual time stored on file. for (int i = 0; i < m_fileNames.size(); i++) { diff --git a/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.h b/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.h index 00403233d3..645f641fc4 100644 --- a/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.h +++ b/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.h @@ -36,7 +36,7 @@ public: virtual ~RifEclipseRestartFilesetAccess(); bool open(); - void setFileSet(const QStringList& fileSet); + void setRestartFiles(const QStringList& fileSet); void close(); void setTimeSteps(const std::vector& timeSteps); diff --git a/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp b/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp index c8fb1391fc..0586ef8d1e 100644 --- a/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp +++ b/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp @@ -156,7 +156,7 @@ void RifEclipseUnifiedRestartFileAccess::readWellData(well_info_type* well_info) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RifEclipseUnifiedRestartFileAccess::setFileSet(const QStringList& fileSet) +void RifEclipseUnifiedRestartFileAccess::setRestartFiles(const QStringList& fileSet) { m_filename = fileSet[0]; diff --git a/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.h b/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.h index f80d11fe11..066f685153 100644 --- a/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.h +++ b/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.h @@ -37,7 +37,7 @@ public: RifEclipseUnifiedRestartFileAccess(); virtual ~RifEclipseUnifiedRestartFileAccess(); - void setFileSet(const QStringList& fileSet); + void setRestartFiles(const QStringList& fileSet); bool open(); void close(); diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index e7fa03c1bd..9b066e68e3 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -192,7 +192,7 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigActiveCellInfo* activeCellIn RifReaderEclipseOutput::RifReaderEclipseOutput() { m_fileName.clear(); - m_fileSet.clear(); + m_filesWithSameBaseName.clear(); m_timeSteps.clear(); @@ -349,13 +349,13 @@ bool RifReaderEclipseOutput::open(const QString& fileName, RigCaseData* eclipseC // Get set of files QStringList fileSet; - if (!RifEclipseOutputFileTools::fileSet(fileName, &fileSet)) return false; + if (!RifEclipseOutputFileTools::findSiblingFilesWithSameBaseName(fileName, &fileSet)) return false; progInfo.incrementProgress(); progInfo.setNextProgressIncrement(20); // Keep the set of files of interest - m_fileSet = fileSet; + m_filesWithSameBaseName = fileSet; // Read geometry ecl_grid_type * mainEclGrid = ecl_grid_alloc( fileName.toAscii().data() ); @@ -408,10 +408,10 @@ bool RifReaderEclipseOutput::openAndReadActiveCellData(const QString& fileName, // Get set of files QStringList fileSet; - if (!RifEclipseOutputFileTools::fileSet(fileName, &fileSet)) return false; + if (!RifEclipseOutputFileTools::findSiblingFilesWithSameBaseName(fileName, &fileSet)) return false; // Keep the set of files of interest - m_fileSet = fileSet; + m_filesWithSameBaseName = fileSet; m_eclipseCase = eclipseCase; @@ -425,7 +425,7 @@ bool RifReaderEclipseOutput::openAndReadActiveCellData(const QString& fileName, //if (!buildMetaData()) return false; // readWellCells(); - m_dynamicResultsAccess = createDynamicResultsAccess(m_fileSet); + m_dynamicResultsAccess = createDynamicResultsAccess(); m_dynamicResultsAccess->setTimeSteps(mainCaseTimeSteps); @@ -442,7 +442,7 @@ bool RifReaderEclipseOutput::readActiveCellInfo() CVF_ASSERT(m_eclipseCase); CVF_ASSERT(m_eclipseCase->mainGrid()); - QString egridFileName = RifEclipseOutputFileTools::fileNameByType(m_fileSet, ECL_EGRID_FILE); + QString egridFileName = RifEclipseOutputFileTools::firstFileNameOfType(m_filesWithSameBaseName, ECL_EGRID_FILE); if (egridFileName.size() > 0) { ecl_file_type* ecl_file = ecl_file_open(egridFileName.toAscii().data()); @@ -526,14 +526,14 @@ bool RifReaderEclipseOutput::readActiveCellInfo() bool RifReaderEclipseOutput::buildMetaData() { CVF_ASSERT(m_eclipseCase); - CVF_ASSERT(m_fileSet.size() > 0); + CVF_ASSERT(m_filesWithSameBaseName.size() > 0); - caf::ProgressInfo progInfo(m_fileSet.size() + 3,""); + caf::ProgressInfo progInfo(m_filesWithSameBaseName.size() + 3,""); - progInfo.setNextProgressIncrement(m_fileSet.size()); + progInfo.setNextProgressIncrement(m_filesWithSameBaseName.size()); // Create access object for dynamic results - m_dynamicResultsAccess = createDynamicResultsAccess(m_fileSet); + m_dynamicResultsAccess = createDynamicResultsAccess(); if (m_dynamicResultsAccess.isNull()) { return false; @@ -641,25 +641,25 @@ bool RifReaderEclipseOutput::buildMetaData() //-------------------------------------------------------------------------------------------------- /// Create results access object (.UNRST or .X0001 ... .XNNNN) //-------------------------------------------------------------------------------------------------- -RifEclipseRestartDataAccess* RifReaderEclipseOutput::createDynamicResultsAccess(const QStringList& fileSet) +RifEclipseRestartDataAccess* RifReaderEclipseOutput::createDynamicResultsAccess() { RifEclipseRestartDataAccess* resultsAccess = NULL; // Look for unified restart file - QString unrstFileName = RifEclipseOutputFileTools::fileNameByType(fileSet, ECL_UNIFIED_RESTART_FILE); + QString unrstFileName = RifEclipseOutputFileTools::firstFileNameOfType(m_filesWithSameBaseName, ECL_UNIFIED_RESTART_FILE); if (unrstFileName.size() > 0) { resultsAccess = new RifEclipseUnifiedRestartFileAccess(); - resultsAccess->setFileSet(QStringList(unrstFileName)); + resultsAccess->setRestartFiles(QStringList(unrstFileName)); } else { // Look for set of restart files (one file per time step) - QStringList restartFiles = RifEclipseOutputFileTools::fileNamesByType(fileSet, ECL_RESTART_FILE); + QStringList restartFiles = RifEclipseOutputFileTools::filterFileNamesOfType(m_filesWithSameBaseName, ECL_RESTART_FILE); if (restartFiles.size() > 0) { resultsAccess = new RifEclipseRestartFilesetAccess(); - resultsAccess->setFileSet(restartFiles); + resultsAccess->setRestartFiles(restartFiles); } } @@ -703,7 +703,7 @@ bool RifReaderEclipseOutput::dynamicResult(const QString& result, PorosityModelR { if (m_dynamicResultsAccess.isNull()) { - m_dynamicResultsAccess = createDynamicResultsAccess(m_fileSet); + m_dynamicResultsAccess = createDynamicResultsAccess(); } if (m_dynamicResultsAccess.isNull()) @@ -1023,7 +1023,7 @@ bool RifReaderEclipseOutput::openInitFile() return true; } - QString initFileName = RifEclipseOutputFileTools::fileNameByType(m_fileSet, ECL_INIT_FILE); + QString initFileName = RifEclipseOutputFileTools::firstFileNameOfType(m_filesWithSameBaseName, ECL_INIT_FILE); if (initFileName.size() > 0) { m_ecl_init_file = ecl_file_open(initFileName.toAscii().data()); diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.h b/ApplicationCode/FileInterface/RifReaderEclipseOutput.h index 8217b58ca5..cfd5f829ce 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.h +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.h @@ -62,18 +62,18 @@ private: void extractResultValuesBasedOnPorosityModel(PorosityModelResultType matrixOrFracture, std::vector* values, const std::vector& fileValues); - static RifEclipseRestartDataAccess* createDynamicResultsAccess(const QStringList& fileSet); + RifEclipseRestartDataAccess* createDynamicResultsAccess(); QStringList validKeywordsForPorosityModel(const QStringList& keywords, const std::vector& keywordDataItemCounts, const RigActiveCellInfo* activeCellInfo, const RigActiveCellInfo* fractureActiveCellInfo, PorosityModelResultType matrixOrFracture, size_t timeStepCount) const; virtual std::vector timeSteps(); private: QString m_fileName; // Name of file used to start accessing Eclipse output files - QStringList m_fileSet; // Set of files in filename's path with same base name as filename + QStringList m_filesWithSameBaseName; // Set of files in filename's path with same base name as filename - RigCaseData* m_eclipseCase; + RigCaseData* m_eclipseCase; - std::vector m_timeSteps; + std::vector m_timeSteps; ecl_file_type* m_ecl_init_file; // File access to static results cvf::ref m_dynamicResultsAccess; // File access to dynamic results From de56495c13493036b8e477e9c237a7d3a9660a94 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 10 Apr 2013 11:21:41 +0200 Subject: [PATCH 216/242] Always select SOIL as default result p4#: 21219 --- ApplicationCode/Application/RiaApplication.cpp | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index dc0e9c446c..1e66c042ab 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -505,13 +505,10 @@ bool RiaApplication::openEclipseCase(const QString& caseName, const QString& cas RimReservoirView* riv = rimResultReservoir->createAndAddReservoirView(); - if (m_preferences->autocomputeSOIL) - { - // Select SOIL as default result variable - riv->cellResult()->resultType = RimDefines::DYNAMIC_NATIVE; - riv->cellResult()->resultVariable = "SOIL"; - riv->animationMode = true; - } + // Select SOIL as default result variable + riv->cellResult()->resultType = RimDefines::DYNAMIC_NATIVE; + riv->cellResult()->resultVariable = "SOIL"; + riv->animationMode = true; riv->loadDataAndUpdate(); From 927fa6c5e746697ac855289977971e052aecce2c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 10 Apr 2013 11:37:34 +0200 Subject: [PATCH 217/242] Fixed issue related to computation of SOIL. Mark metadata for derived SOIL with mustBeCalculated. p4#: 21220 --- .../RimReservoirCellResultsCacher.cpp | 38 ++++++++++++++++--- .../RimReservoirCellResultsCacher.h | 2 +- .../RigCaseCellResultsData.cpp | 34 ++++++++++++++++- .../RigCaseCellResultsData.h | 9 ++++- 4 files changed, 74 insertions(+), 9 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp index bb417bc912..38c20c8256 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.cpp @@ -217,13 +217,31 @@ RifReaderInterface* RimReservoirCellResultsStorage::readerInterface() //-------------------------------------------------------------------------------------------------- size_t RimReservoirCellResultsStorage::findOrLoadScalarResultForTimeStep(RimDefines::ResultCatType type, const QString& resultName, size_t timeStepIndex) { + if (!m_cellResults) return cvf::UNDEFINED_SIZE_T; + // Special handling for SOIL if (type == RimDefines::DYNAMIC_NATIVE && resultName.toUpper() == "SOIL") { - loadOrComputeSOILForTimeStep(timeStepIndex); - } + size_t soilScalarResultIndex = m_cellResults->findScalarResultIndex(type, resultName); - if (!m_cellResults) return cvf::UNDEFINED_SIZE_T; + // If SOIL is not found, try to compute and return computed scalar index + // Will return cvf::UNDEFINED_SIZE_T if no SGAS/SWAT is found + if (soilScalarResultIndex == cvf::UNDEFINED_SIZE_T) + { + computeSOILForTimeStep(timeStepIndex); + + soilScalarResultIndex = m_cellResults->findScalarResultIndex(type, resultName); + return soilScalarResultIndex; + } + + // If we have found SOIL and SOIL must be calculated, calculate and return + if (soilScalarResultIndex != cvf::UNDEFINED_SIZE_T && m_cellResults->mustBeCalculated(soilScalarResultIndex)) + { + computeSOILForTimeStep(timeStepIndex); + + return soilScalarResultIndex; + } + } size_t scalarResultIndex = m_cellResults->findScalarResultIndex(type, resultName); if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) return cvf::UNDEFINED_SIZE_T; @@ -341,14 +359,21 @@ size_t RimReservoirCellResultsStorage::findOrLoadScalarResult(RimDefines::Result return resultGridIndex; } + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimReservoirCellResultsStorage::loadOrComputeSOIL() { + size_t scalarIndexSOIL = findOrLoadScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL"); + if (scalarIndexSOIL != cvf::UNDEFINED_SIZE_T) + { + return; + } + for (size_t timeStepIdx = 0; timeStepIdx < m_cellResults->maxTimeStepCount(); timeStepIdx++) { - loadOrComputeSOILForTimeStep(timeStepIdx); + computeSOILForTimeStep(timeStepIdx); } } @@ -356,7 +381,7 @@ void RimReservoirCellResultsStorage::loadOrComputeSOIL() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimReservoirCellResultsStorage::loadOrComputeSOILForTimeStep(size_t timeStepIndex) +void RimReservoirCellResultsStorage::computeSOILForTimeStep(size_t timeStepIndex) { size_t scalarIndexSWAT = findOrLoadScalarResultForTimeStep(RimDefines::DYNAMIC_NATIVE, "SWAT", timeStepIndex); size_t scalarIndexSGAS = findOrLoadScalarResultForTimeStep(RimDefines::DYNAMIC_NATIVE, "SGAS", timeStepIndex); @@ -410,6 +435,9 @@ void RimReservoirCellResultsStorage::loadOrComputeSOILForTimeStep(size_t timeSte soilResultGridIndex = m_cellResults->addEmptyScalarResult(RimDefines::DYNAMIC_NATIVE, "SOIL", false); CVF_ASSERT(soilResultGridIndex != cvf::UNDEFINED_SIZE_T); + // Set this result to be calculated + m_cellResults->setMustBeCalculated(soilResultGridIndex); + m_cellResults->cellScalarResults(soilResultGridIndex).resize(soilTimeStepCount); for (size_t timeStepIdx = 0; timeStepIdx < soilTimeStepCount; timeStepIdx++) diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h index dd0e154388..2806b145f6 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsCacher.h @@ -59,7 +59,7 @@ protected: virtual void setupBeforeSave(); private: - void loadOrComputeSOILForTimeStep(size_t timeStepIndex); + void computeSOILForTimeStep(size_t timeStepIndex); QString getValidCacheFileName(); QString getCacheDirectoryPath(); diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index ee22a4306f..465abd03f7 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -350,7 +350,7 @@ size_t RigCaseCellResultsData::addEmptyScalarResult(RimDefines::ResultCatType ty { scalarResultIndex = this->resultCount(); m_cellScalarResults.push_back(std::vector >()); - ResultInfo resInfo(type, needsToBeStored, resultName, scalarResultIndex); + ResultInfo resInfo(type, needsToBeStored, false, resultName, scalarResultIndex); m_resultInfos.push_back(resInfo); } @@ -540,3 +540,35 @@ RifReaderInterface::PorosityModelResultType RigCaseCellResultsData::convertFromP return RifReaderInterface::FRACTURE_RESULTS; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigCaseCellResultsData::mustBeCalculated(size_t scalarResultIndex) const +{ + std::vector::const_iterator it; + for (it = m_resultInfos.begin(); it != m_resultInfos.end(); it++) + { + if (it->m_gridScalarResultIndex == scalarResultIndex) + { + return it->m_mustBeCalculated; + } + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigCaseCellResultsData::setMustBeCalculated(size_t scalarResultIndex) +{ + std::vector::iterator it; + for (it = m_resultInfos.begin(); it != m_resultInfos.end(); it++) + { + if (it->m_gridScalarResultIndex == scalarResultIndex) + { + it->m_mustBeCalculated = true; + } + } +} + diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h index ef94ff6ba6..e87009b436 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h @@ -80,18 +80,23 @@ public: class ResultInfo { public: - ResultInfo(RimDefines::ResultCatType resultType, bool needsToBeStored, QString resultName, size_t gridScalarResultIndex) - : m_resultType(resultType), m_needsToBeStored(needsToBeStored), m_resultName(resultName), m_gridScalarResultIndex(gridScalarResultIndex) { } + ResultInfo(RimDefines::ResultCatType resultType, bool needsToBeStored, bool mustBeCalculated, QString resultName, size_t gridScalarResultIndex) + : m_resultType(resultType), m_needsToBeStored(needsToBeStored), m_resultName(resultName), m_gridScalarResultIndex(gridScalarResultIndex), m_mustBeCalculated(mustBeCalculated) { } public: RimDefines::ResultCatType m_resultType; bool m_needsToBeStored; + bool m_mustBeCalculated; QString m_resultName; size_t m_gridScalarResultIndex; std::vector m_timeStepDates; }; const std::vector& infoForEachResultIndex() { return m_resultInfos;} + + bool mustBeCalculated(size_t scalarResultIndex) const; + void setMustBeCalculated(size_t scalarResultIndex); + public: size_t addStaticScalarResult(RimDefines::ResultCatType type, From be8b627e6930b4cf31717827980513a5ad351010 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 10 Apr 2013 12:01:38 +0200 Subject: [PATCH 218/242] Added application icon on Windows p4#: 21221 --- ApplicationCode/CMakeLists.txt | 5 +++++ ApplicationCode/Resources/AppLogo48x48.ico | Bin 0 -> 16958 bytes ApplicationCode/Resources/ResInsight.rc | 1 + 3 files changed, 6 insertions(+) create mode 100644 ApplicationCode/Resources/AppLogo48x48.ico create mode 100644 ApplicationCode/Resources/ResInsight.rc diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index ba0d50800c..13d19b1a95 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -148,6 +148,10 @@ set( QRC_FILES # Runs RCC on specified files qt4_add_resources( QRC_FILES_CPP ${QRC_FILES} ) +# Adding resource (RC) files for Windows +if ( MSVC ) + set( WIN_RESOURCE Resources/ResInsight.rc ) +endif() ############################################################################# # creating PCH's for MSVC and GCC on Linux @@ -208,6 +212,7 @@ add_executable(ResInsight ${MOC_FILES_CPP} ${FORM_FILES_CPP} ${QRC_FILES_CPP} + ${WIN_RESOURCE} ${HEADER_FILES} ) diff --git a/ApplicationCode/Resources/AppLogo48x48.ico b/ApplicationCode/Resources/AppLogo48x48.ico new file mode 100644 index 0000000000000000000000000000000000000000..70cbfee6f9e5056362d43fccc1ec088ffc808383 GIT binary patch literal 16958 zcmeHN2Ut~Swq5jI6f0_CoS0-%j9(_nGm|$NC&?s}M4gy8nq(%ipvHz$73nHX1r$-R z0g56vii#jo1t|h5A~wVtd+#Dx-r7H0az!ljp1wD4KCj>Qzvpo8IcKfC_uA{+djTE( z>)Eq2E0tqFWrsUjax7?Asa#Q z8xgT457B8wSe8|WB)3J(!)e2_t62wO+e&GnSFP&iiRehL#=?KeS&d=gb7FTk|r z8Ssc&3;Xbu_$eqBe|8PWn?wB2_FFgNbcFt&?VBEly-!U8Y{1yL^orauvT&FZUcdg^B~mA?MwD^b`)BIH&sTJYOR{ zC;BOT+$JBIYnAnBJmffX+&Ug#bbM>oQ3S8ZWdBB>%in!q!TL2|Zl$huJ{j}){1U6Y zt}(Q*OMM7_*SU%Ke8Oy{4+B|Cqr;YCBztLK&|=sHFU7dotKh=dI7cR8GIJn0Bix+e ze7R9mdmj(~Qx58G-&XlJ!kHD9Sqg_atMQi!bI|#FZcowdu)yc0s4m~ zU`%W_9OCm~AD4%pqcibS#Cq;e#E)S~&Ejvari4?2&&I--JeYBo$n0p5_%TtKRKr8cXQXFy-#u^^=R;3W_;1{eklZT#;2)!Et!Zz``DLH>b;!0M^KT+vf*KpxG!pFE?`kC=xoOo#J|0_M0Jp_}$&IwL5%3R9ThiR*S?eDZdshL>3=Gc;O*T%h?aF)Lq254R%Y4 z@k3NTdWC1=t67=oGdmmK%+1BukvZr!I}4xB%)loh>F7Ca13nGih`y1zNGaWm;Dk*W zI%6fi^p3)S-~_xqY6j2gt)j~yKcy!xaqaMTUvy%h*?#YXHh=Sg4f|hSCpv4|Fq@=C zq!z@Ji0|%29s-x8XD;cJtFPn))gGMlH^Q z-GVgqpFzJcDHb0vC-07%g>Ium(bX=9JaA5ZDVklc4Xw#fXKGnb$C;QgKN*Sn<;dMp zrL^HPeN^PyJUB+I#(>FDND*VQLy|o#J6Sd=c~pM?rVcLKOx>qF^#C29_gY(PH!x#f|yTi(oV~1_nc-RkRx$ zhv^$CF{j`l=59HHh@!)+t%E#Q6#_R_s@@99*o7I~mUGU`-;b$TyWvBQoR@FL&;{xE zF?=n)4PJ$hy`s_irzz|Q`fv7w)PtHAGKa~-n|6Lm+a2j=CM{l%x$E-P{1i{|#^5PR z^Q6!9nR9FQ`kNy|sO2l+${r8N-G^XmmG_2Sa7Zl2u(%RcyYEd|hxW{;fn5}Ih#Ld% z580{~ z?nlU`YJ}!hlLtl~H7A?8MV>s8N-!ug1>MJls9v=uUQ6nO=(XsV(C(d3W$eOd;xq@E8xSNJ13Xp$Cx7ghkq*by&UGO zX?>N)2K>aUunvoZ&hU8X$T}(kx=!gZ@Ge2ydFNmobG1IAxiUH}x`vlxuVYE!e)OM{ zjW;|JR4ui#Uy2r^mZ-3yPPBK3M`vows}mFOrdKk$`>r8RDfnz=rmDjL){E$H*yd{Z zrB%RgUK)A_#Nh+iNaeT1XKT+;4Hw$09`kR-nbM7(txw=`>P!wi)@kQ^<7t0(I^SJden3xB%$=lH~ct31r9)eByF|?k04jq@& z;)P{*nvJxIqZk&QkM3THXi40LJho_vc3tU`U(pOByBMW0^1LOv>E@Hn+Stte>|pPZ zhk`@&R6F68P^@(GUB}sKR>&OH#;g5Y_-V~rdCwsn17;*qXY=94x$T^|9fM5+FQC)Xx@NI9$HD5-gBTvO z8SgQ#ZS3P!yf>LlpFWAR$T49X`tdk#cqTK~%NnmoM}u2>U9M|%A}j(bR8I@0=5pI~ zpS-T)(pq$ktwD!HH}P`x1vswQiVuP|qQm%PSUDuZY+NFY>=U8S&?UdR)DfMLtAU@F zH_VRv@k?z;&xmGprJwjBEE6N+OX0g=H+}d%HM_j&%LmR$L2v(MyeFH_d`GCd_Z4&Y1y`ES}2q8Y|RqtTIGq({Jd&Z^CDO4_b`ip+-@^e_IrH*s7h_n;YY zqJQvB*{1GOg4r*VIa9u)&b>j6HKfjH*Sb7cJh0~ViQUw{0_~~c+E|-Dm;APmx{7uS zF2iQd8CZuNg?V5VG3|h!V;(Rj6Bxbm*JDTxX=2GObd0`+_Vdo8ZNw?G3Ofo5zwL^5 z-BGI)4?5x{n)nUb79PylL!H=9AF;1SuolEu%%Nu$eI7;^w(={s_DFb)!)o}tMF5>4n7PkhOWm}!0A`af?E@fylJpE ztevD!ga_%B#W!FZbs23VPop(wN{iqsnEDh0qu3Xs4dOW(xDZX$qxUqX_muhBm2>k? z)G_gFew>w|c?T5sP|*k8yG+gAuRL8B_Kq3ny5Q8tukx<&N5hge*?!@rN8)cEbp<9~ zTVd>821BgvgvjMx59~S%r&%TU0AUP&3%es=$N8Bhc0_l zbXoLCe5Zu*utiG8-k^^6oSu%q%*w)7^i*GP{d5NJ$3ipkF1?n%9XVv3YezlyXz0<; zSa=sI{vUR|((7#_&%u0hC3NgFp-apE^F=rI30+RQwF z7SvA@$93c&j`tdi$pPmS`=JqE6TMLLRdTM`-;n=C{LH(VcM;E1tNOZWPDI;9<66%? z1>=b&&=F002!6q=HztGLKLdtiGhj3>gZavMfYYYuc<8o9FBAvY(P6=Pv1*?cp{M&mNk$uke{Pc6nb^R^?V=s4C_o>lSt_zUPV{}kGUpFm3+^n_f;+gbAukp`hw(#z0fiG3T)?}V=Wv+3%{+f_R5DD>%nMbJPd{}QC#Q` zUkZZ}@zCci)ssF^_odX05vy3|Ik52E!hYJRbhjyP*;d$jez`7lzuolx>~mslie2_e zo?DL3!S9HB;Nl8QO+SF7@>4i}trnWcpcPekefl<7c~Zy57ear0L48c%wg5F-1&^oXj*6vxba9IzNaY-<9PKEh| zESM9kDK*2yaXpNk(_!ejh4*O>^D_;{7S4%XW_!ySzrct!FSs@Rta+|)zmdFW;x|70 zEG%*xCZ$#*WyeVzI&)P6yKx=5VlUpAUW#^}1+W;u2`0`tFmlX>!MH5mTQD55895B` zK)En*&V#W>DZS?&<)u2%SIIRs;@7H+PQruKMC2*73py{k=o~ zn4S3Dv=Y4JyBW3~d1yOv6IxBkg_TP-OdT@S@${$}q8+*td@dZAdToRCv;(RpY@@H! zSJ(GMW6erUsC+f_2JgQ+#E^>x7nPT2^jc4-v$o=2Ip11_9HGwdWG*(b?lV;G^%`p3 z$~jx*ywBY2h|D{RT_+yQcVprkp7fblj{giT#rxB@;QeXED&A$kbPFg%7uHW}_K&4g zmg2&sfe%Bc9GJKja`tbBWx!sgzmh-EW2Fa=z@*WQMxL5`Z6kNAbskrGy+!B|deB|; zHS{#BM-aQzyC&zaPTGvm!ngAC(A`Sk4xhi#6l$~E{TA-PH}iSF8B>9wal6#}$E@7L z&lY!~-@_AYuDyWb8SIqJx)EaNr_Rcb!F4;W2ou z-4DCCN(_kFfj@+n;5WYcXu-NLXT2FYWWj*CpzpF7`fkP4%PM~EasqA0M?2PRJNBzB z@4vM1%l()w^|RfAOKN_1;CxZrrW`8&J%kRo!4hCwwjQG z9;{s-_WGtOe)mZ1w~1Z8XLyoF#@=%%ICv2|k6(e*%;_t)aPfMriqltWaPZs>#YF<= zhVUDZeh_v`E75aisj7H3-u+{e$XDq-qd0TXY&hq_|KxufUGeABz@PF-KBOj9jnadw>vkysCYC~n*sORDDs#(f`XQM6?@?H#ZZy5D zUE6A3Lyv3r%dus)nR2#CKmIwqOx0!~^LPAG4Q|%nx$nB0ZfL%H(q5as=3(1XQ#Z-c z6>=fx+IsXd;>%8AR?ZQn74HNUbLM7oPCV#EG}o_I$)((n*>fFTuVMH7UBh3KRs4+f zy6Deq)Ve`SDiNG@7+L$yH~c2&9&>kp-kM?&+;{HC?|ACt?%hZ8rTu>OUcO&=xK(!t z=h-8>PhLam;mcS~9-I^Q;Z45+)eDd1;0bU`uH`sVQ{v;K$GUN*e-~YWkj%pg&E9`_ul7 zvgmFR`%q@Zr?blN3TyP$$(xlQX-}Q9aLR@y=Y`a-U=x2Oe#M;LLVShXqX=K(x!Str z;zQ0EndPGEQ>ZmkV>^yrp_i-uXJP-Zyk65EC7i$Fy`0z&6W8qL_w0L=zj&K|N_6t~ z^b;S=D8YO5SQ4`T73R5v`zEv_?k?W>O4CJOcOJj0`b~OHqw8{>f8~dGZJDET?c0C3 zqP)bqoo5s$5#(h7XQ+6MFzV*&ZKtq`v9#m_R&tel(j4lUc$n(5*CBJ~|Kme`_apis zGxciCZJeQ}s6KNY`x$~uR`KRCM^0U?!AXYbSPgYm-uv(V5S^BK77de`s;TXNcib9$ zg1=siwSN!v=-I7#@ALIJ1J4Af#(c7XW%&l&l&jdGjQ*L$5rmRWOeVJ z*2-Hl^|G3V)wjvY)932&UFtGkY*?)tR=swXB&=#yve!Ve+I{a{&5LTgajoBa%K!ft%XRUN literal 0 HcmV?d00001 diff --git a/ApplicationCode/Resources/ResInsight.rc b/ApplicationCode/Resources/ResInsight.rc new file mode 100644 index 0000000000..c39e833bbb --- /dev/null +++ b/ApplicationCode/Resources/ResInsight.rc @@ -0,0 +1 @@ +IDI_ICON1 ICON "AppLogo48x48.ico" From 33729d5ed43a7f2e444ddf0920bd8acabaea564d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 10 Apr 2013 13:22:43 +0200 Subject: [PATCH 219/242] Removed invalid assert p4#: 21222 --- ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index 39a2d7a3a7..44891ec865 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -787,7 +787,6 @@ Qt::ItemFlags RimUiTreeModelPdm::flags(const QModelIndex &index) const { caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(index); CVF_ASSERT(currentItem); - CVF_ASSERT(currentItem->dataObject().p()); if (dynamic_cast(currentItem->dataObject().p()) || dynamic_cast(currentItem->dataObject().p())) From ff1dcd8c8d8115331fb3ff382332bcf45243cb3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Wed, 10 Apr 2013 14:24:35 +0200 Subject: [PATCH 220/242] Overlay info: Adjusted colors and transparency To reclaim the transparent feeling lost, and to increase readability p4#: 21225 --- ApplicationCode/UserInterface/RiuViewer.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index ff5a2d6657..551f86df9e 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -67,8 +67,13 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent) QColor c; QPalette p = QApplication::palette(); - QColor frameAndTextColor(255, 255, 255, 255); - p.setColor(QPalette::Window, QColor(144, 173, 208, 180)); + //QColor frameAndTextColor(255, 255, 255, 255); + QColor frameAndTextColor(0, 0, 0, 255); + QColor progressAndHistogramColor(0,0,90,70); // Also Progressbar dark text color + + //p.setColor(QPalette::Window, QColor(144, 173, 208, 180)); + p.setColor(QPalette::Window, QColor(255, 255, 255, 50)); + p.setColor(QPalette::WindowText, frameAndTextColor); c = p.color(QPalette::Base ); @@ -80,11 +85,14 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent) //p.setColor(QPalette::AlternateBase, c); - p.setColor(QPalette::Highlight, QColor(20, 20, 130, 100)); + //p.setColor(QPalette::Highlight, QColor(20, 20, 130, 40)); + p.setColor(QPalette::Highlight, progressAndHistogramColor); - p.setColor(QPalette::HighlightedText, frameAndTextColor); + //p.setColor(QPalette::HighlightedText, frameAndTextColor); + p.setColor(QPalette::HighlightedText, QColor(255, 255, 255, 255)); //Progressbar light text color - p.setColor(QPalette::Dark, QColor(230, 250, 255, 100)); + //p.setColor(QPalette::Dark, QColor(230, 250, 255, 100)); + p.setColor(QPalette::Dark, progressAndHistogramColor); // Info Text m_InfoLabel = new QLabel(); From 687bc8aecf0b7325887119beae6221699b14051c Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 10 Apr 2013 14:55:50 +0200 Subject: [PATCH 221/242] Return true when a dynamic result has only one time step p4#: 21226 --- .../ProjectDataModel/RimResultDefinition.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp index 9af564420b..6016b2a3a5 100644 --- a/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultDefinition.cpp @@ -183,10 +183,21 @@ bool RimResultDefinition::hasResult() const bool RimResultDefinition::hasDynamicResult() const { const RigCaseCellResultsData* gridCellResults = m_reservoirView->currentGridCellResults()->cellResults(); - if (hasResult() && gridCellResults->timeStepCount(m_gridScalarResultIndex) > 1 ) - return true; - else - return false; + + if (hasResult()) + { + if (resultType() == RimDefines::DYNAMIC_NATIVE) + { + return true; + } + + if (gridCellResults->timeStepCount(m_gridScalarResultIndex) > 1 ) + { + return true; + } + } + + return false; } //-------------------------------------------------------------------------------------------------- From a20640f25f7dfdded118db66180a3ed0b0e6ed9f Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 10 Apr 2013 15:09:41 +0200 Subject: [PATCH 222/242] Only enable animation control when there are more than one time step string available p4#: 21229 --- ApplicationCode/UserInterface/RiuMainWindow.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index 2314a57329..07d8e3e145 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -580,6 +580,13 @@ void RiuMainWindow::refreshAnimationActions() timeStepStrings.push_back(tr("Static Property")); } } + + // Animation control is only relevant for more than one time step + if (timeStepStrings.size() < 2) + { + enableAnimControls = false; + } + m_animationToolBar->setFrameRate(app->activeReservoirView()->maximumFrameRate()); } From 665c2ace8b897d6e367ef19641bb0b5dca9f794d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Wed, 10 Apr 2013 15:33:34 +0200 Subject: [PATCH 223/242] Handle when it is not possible to read cases from disk in a grid group p4#: 21230 --- .../ProjectDataModel/RimIdenticalGridCaseGroup.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index 919bc329d6..e19f4dd119 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -152,7 +152,11 @@ void RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo() RimCase* mainCase = caseCollection()->reservoirs[0]; mainCase->openEclipseGridFile(); RigCaseData* mainEclipseCase = mainCase->reservoirData(); - CVF_ASSERT(mainEclipseCase); + if (!mainEclipseCase) + { + // Error message + return; + } // Read active cell info from all source cases @@ -164,7 +168,8 @@ void RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo() if (!rimReservoir->openAndReadActiveCellData(mainEclipseCase)) { - CVF_ASSERT(false); + // Error message + continue; } info.incrementProgress(); From 807c6de823883ddc8078a13a3e2b2739142de038 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 11 Apr 2013 08:45:56 +0200 Subject: [PATCH 224/242] Moved adding of one statistics case to contstructor to make sure the statistics case UI is displayed when creating a new grid case group p4#: 21232 --- .../ProjectDataModel/RimIdenticalGridCaseGroup.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index e19f4dd119..9051b2ac36 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -54,6 +54,8 @@ RimIdenticalGridCaseGroup::RimIdenticalGridCaseGroup() m_unionOfMatrixActiveCells = new RigActiveCellInfo; m_unionOfFractureActiveCells = new RigActiveCellInfo; + + createAndAppendStatisticsCase(); } //-------------------------------------------------------------------------------------------------- @@ -90,11 +92,6 @@ void RimIdenticalGridCaseGroup::addCase(RimCase* reservoir) caseCollection()->reservoirs().push_back(reservoir); - if (statisticsCaseCollection->reservoirs().size() == 0) - { - createAndAppendStatisticsCase(); - } - clearActiveCellUnions(); clearStatisticsResults(); updateMainGridAndActiveCellsForStatisticsCases(); From 04a987d99bec4d755a6a1c1ff84a4ab872301b2e Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 11 Apr 2013 10:11:57 +0200 Subject: [PATCH 225/242] Show context menu when selection is empty p4#: 21233 --- ApplicationCode/ProjectDataModel/RimUiTreeView.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index e04f21a7e7..6334ef97d8 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -62,6 +62,16 @@ void RimUiTreeView::contextMenuEvent(QContextMenuEvent* event) { m_pasteAction->setEnabled(hasClipboardValidData()); + if (selectionModel() && selectionModel()->selection().size() == 0) + { + // Clicking in blank space in tree view + QMenu menu; + menu.addAction(QString("New Grid Case Group"), this, SLOT(slotAddCaseGroup())); + menu.exec(event->globalPos()); + + return; + } + RimUiTreeModelPdm* myModel = dynamic_cast(model()); if (myModel) { From dbc9869f61e7ef043f857e35af431cc2ac83fdae Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 11 Apr 2013 10:35:33 +0200 Subject: [PATCH 226/242] Fix missing display of wells in tree view p4#: 21234 --- ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index 44891ec865..170e906897 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -404,6 +404,9 @@ RimReservoirView* RimUiTreeModelPdm::addReservoirView(const QModelIndex& itemInd RimReservoirView* insertedView = rimReservoir->createAndAddReservoirView(); + // Must be run before buildViewItems, as wells are created in this function + insertedView->loadDataAndUpdate(); + int viewCount = rowCount(collectionIndex); beginInsertRows(collectionIndex, viewCount, viewCount); @@ -412,8 +415,6 @@ RimReservoirView* RimUiTreeModelPdm::addReservoirView(const QModelIndex& itemInd endInsertRows(); - insertedView->loadDataAndUpdate(); - return insertedView; } From e70615d02a32f3ef67bdc587433be8aff65f809d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 11 Apr 2013 10:42:35 +0200 Subject: [PATCH 227/242] Check for valid pointer p4#: 21235 --- .../ProjectDataModel/RimUiTreeModelPdm.cpp | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index 170e906897..5efd28d9b3 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -578,27 +578,29 @@ RimIdenticalGridCaseGroup* RimUiTreeModelPdm::addCaseGroup(const QModelIndex& it CVF_ASSERT(proj); caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex); - - if (dynamic_cast(currentItem->dataObject().p()) || - dynamic_cast(currentItem->dataObject().p())) + if (currentItem) { - QModelIndex rootIndex = itemIndex.parent(); - caf::PdmUiTreeItem* rootTreeItem = currentItem->parent(); + if (dynamic_cast(currentItem->dataObject().p()) || + dynamic_cast(currentItem->dataObject().p())) + { + QModelIndex rootIndex = itemIndex.parent(); + caf::PdmUiTreeItem* rootTreeItem = currentItem->parent(); - // New case group is inserted before the last item, the script item - int position = rootTreeItem->childCount() - 1; + // New case group is inserted before the last item, the script item + int position = rootTreeItem->childCount() - 1; - beginInsertRows(rootIndex, position, position); + beginInsertRows(rootIndex, position, position); - RimIdenticalGridCaseGroup* createdObject = new RimIdenticalGridCaseGroup; - proj->caseGroups().push_back(createdObject); + RimIdenticalGridCaseGroup* createdObject = new RimIdenticalGridCaseGroup; + proj->caseGroups().push_back(createdObject); - caf::PdmUiTreeItem* childItem = caf::UiTreeItemBuilderPdm::buildViewItems(rootTreeItem, position, createdObject); - endInsertRows(); + caf::PdmUiTreeItem* childItem = caf::UiTreeItemBuilderPdm::buildViewItems(rootTreeItem, position, createdObject); + endInsertRows(); - insertedModelIndex = index(position, 0, rootIndex); + insertedModelIndex = index(position, 0, rootIndex); - return createdObject; + return createdObject; + } } return NULL; From 94a4d83885de58dc59400da183dd173d0c112e03 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 11 Apr 2013 11:03:52 +0200 Subject: [PATCH 228/242] Made adding of grid group more robust p4#: 21236 --- .../ProjectDataModel/RimUiTreeModelPdm.cpp | 38 +++++++++---------- .../ProjectDataModel/RimUiTreeModelPdm.h | 2 +- .../ProjectDataModel/RimUiTreeView.cpp | 2 +- 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index 5efd28d9b3..307ddc9201 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -572,38 +572,34 @@ RimStatisticsCase* RimUiTreeModelPdm::addStatisticalCalculation(const QModelInde //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimIdenticalGridCaseGroup* RimUiTreeModelPdm::addCaseGroup(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex) +RimIdenticalGridCaseGroup* RimUiTreeModelPdm::addCaseGroup(QModelIndex& insertedModelIndex) { RimProject* proj = RiaApplication::instance()->project(); CVF_ASSERT(proj); - caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(itemIndex); - if (currentItem) - { - if (dynamic_cast(currentItem->dataObject().p()) || - dynamic_cast(currentItem->dataObject().p())) - { - QModelIndex rootIndex = itemIndex.parent(); - caf::PdmUiTreeItem* rootTreeItem = currentItem->parent(); + QModelIndex scriptModelIndex = getModelIndexFromPdmObject(proj->scriptCollection()); + if (!scriptModelIndex.isValid()) return NULL; - // New case group is inserted before the last item, the script item - int position = rootTreeItem->childCount() - 1; + caf::PdmUiTreeItem* currentItem = getTreeItemFromIndex(scriptModelIndex); + if (!currentItem) return NULL; - beginInsertRows(rootIndex, position, position); + QModelIndex rootIndex = scriptModelIndex.parent(); + caf::PdmUiTreeItem* rootTreeItem = currentItem->parent(); - RimIdenticalGridCaseGroup* createdObject = new RimIdenticalGridCaseGroup; - proj->caseGroups().push_back(createdObject); + // New case group is inserted before the last item, the script item + int position = rootTreeItem->childCount() - 1; - caf::PdmUiTreeItem* childItem = caf::UiTreeItemBuilderPdm::buildViewItems(rootTreeItem, position, createdObject); - endInsertRows(); + beginInsertRows(rootIndex, position, position); - insertedModelIndex = index(position, 0, rootIndex); + RimIdenticalGridCaseGroup* createdObject = new RimIdenticalGridCaseGroup; + proj->caseGroups().push_back(createdObject); - return createdObject; - } - } + caf::PdmUiTreeItem* childItem = caf::UiTreeItemBuilderPdm::buildViewItems(rootTreeItem, position, createdObject); + endInsertRows(); - return NULL; + insertedModelIndex = index(position, 0, rootIndex); + + return createdObject; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h index 00ec38f540..dc265b738f 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.h @@ -116,7 +116,7 @@ public: void moveObjects(const QModelIndex& itemIndex, caf::PdmObjectGroup& pdmObjects); RimStatisticsCase* addStatisticalCalculation(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); - RimIdenticalGridCaseGroup* addCaseGroup(const QModelIndex& itemIndex, QModelIndex& insertedModelIndex); + RimIdenticalGridCaseGroup* addCaseGroup(QModelIndex& insertedModelIndex); bool deleteObjectFromPdmPointersField(const QModelIndex& itemIndex); diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index 6334ef97d8..9483a56237 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -878,7 +878,7 @@ void RimUiTreeView::slotAddCaseGroup() if (myModel) { QModelIndex insertedIndex; - myModel->addCaseGroup(currentIndex(), insertedIndex); + myModel->addCaseGroup(insertedIndex); setCurrentIndex(insertedIndex); setExpanded(insertedIndex, true); From db1dd5dd0df65beccfbd958b396ad7e9e1f84959 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 11 Apr 2013 11:18:40 +0200 Subject: [PATCH 229/242] Do not create statistics case in constructor p4#: 21237 --- ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp | 2 -- ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index 9051b2ac36..267ec4c953 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -54,8 +54,6 @@ RimIdenticalGridCaseGroup::RimIdenticalGridCaseGroup() m_unionOfMatrixActiveCells = new RigActiveCellInfo; m_unionOfFractureActiveCells = new RigActiveCellInfo; - - createAndAppendStatisticsCase(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index 307ddc9201..e8303e0a01 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -592,6 +592,7 @@ RimIdenticalGridCaseGroup* RimUiTreeModelPdm::addCaseGroup(QModelIndex& inserted beginInsertRows(rootIndex, position, position); RimIdenticalGridCaseGroup* createdObject = new RimIdenticalGridCaseGroup; + createdObject->createAndAppendStatisticsCase(); proj->caseGroups().push_back(createdObject); caf::PdmUiTreeItem* childItem = caf::UiTreeItemBuilderPdm::buildViewItems(rootTreeItem, position, createdObject); From 9ae4ac94b6f43972cb1adc2e7ba699bd8f651478 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 11 Apr 2013 12:00:06 +0200 Subject: [PATCH 230/242] Added count p4#: 21239 --- cafProjectDataModel/cafPdmField.h | 1 + cafProjectDataModel/cafPdmField.inl | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/cafProjectDataModel/cafPdmField.h b/cafProjectDataModel/cafPdmField.h index 7c77f03997..35dfb51042 100644 --- a/cafProjectDataModel/cafPdmField.h +++ b/cafProjectDataModel/cafPdmField.h @@ -213,6 +213,7 @@ public: void set(size_t index, DataType* pointer); void insert(size_t indexAfter, DataType* pointer); void insert(size_t indexAfter, const std::vector >& objects); + size_t count(const DataType* pointer) const; void clear(); void erase(size_t index); diff --git a/cafProjectDataModel/cafPdmField.inl b/cafProjectDataModel/cafPdmField.inl index 9d8c635f41..6a7c2d0bc5 100644 --- a/cafProjectDataModel/cafPdmField.inl +++ b/cafProjectDataModel/cafPdmField.inl @@ -482,6 +482,26 @@ void PdmPointersField::insert(size_t indexAfter, const std::vector +size_t PdmPointersField::count(const DataType* pointer) const +{ + size_t itemCount = 0; + + typename std::vector< PdmPointer< DataType > >::const_iterator it; + for (it = m_pointers.begin(); it != m_pointers.end(); ++it) + { + if (*it == pointer) + { + itemCount++; + } + } + + return itemCount; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- From 48d2a6c598e2bf8b3e564bb7f2cc1961d9b85677 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 11 Apr 2013 12:06:38 +0200 Subject: [PATCH 231/242] Use model index at drop position when asking user for confirm of drop event causing statistics to be deleted p4#: 21242 --- .../Application/RiaApplication.cpp | 17 ++---- .../Rim3dOverlayInfoConfig.cpp | 2 +- ApplicationCode/ProjectDataModel/RimCase.cpp | 12 +++- ApplicationCode/ProjectDataModel/RimCase.h | 16 ++++-- .../RimIdenticalGridCaseGroup.cpp | 9 ++- .../ProjectDataModel/RimInputCase.cpp | 13 +++-- .../ProjectDataModel/RimInputCase.h | 10 +++- .../ProjectDataModel/RimReservoirView.cpp | 6 +- .../ProjectDataModel/RimResultCase.cpp | 55 +++++++++++++------ .../ProjectDataModel/RimResultCase.h | 16 ++++-- .../ProjectDataModel/RimStatisticsCase.cpp | 2 +- .../ProjectDataModel/RimUiTreeView.cpp | 3 +- .../SocketInterface/RiaSocketServer.cpp | 6 +- 13 files changed, 111 insertions(+), 56 deletions(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 1e66c042ab..a06f9679dc 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -305,7 +305,7 @@ bool RiaApplication::loadProject(const QString& projectFileName) RimCase* ri = casesToLoad[cIdx]; CVF_ASSERT(ri); - caseProgress.setProgressDescription(ri->caseName()); + caseProgress.setProgressDescription(ri->caseUserDescription()); caf::ProgressInfo viewProgress(ri->reservoirViews().size() , "Creating Views"); @@ -495,11 +495,8 @@ bool RiaApplication::openEclipseCaseFromFile(const QString& fileName) //-------------------------------------------------------------------------------------------------- bool RiaApplication::openEclipseCase(const QString& caseName, const QString& caseFileName) { - QFileInfo gridFileName(caseFileName); - QString casePath = gridFileName.absolutePath(); - RimResultCase* rimResultReservoir = new RimResultCase(); - rimResultReservoir->setCaseInfo(caseName, caseFileName, casePath); + rimResultReservoir->setCaseInfo(caseName, caseFileName); m_project->reservoirs.push_back(rimResultReservoir); @@ -529,7 +526,7 @@ bool RiaApplication::openEclipseCase(const QString& caseName, const QString& cas bool RiaApplication::openInputEclipseCase(const QString& caseName, const QStringList& caseFileNames) { RimInputCase* rimInputReservoir = new RimInputCase(); - rimInputReservoir->caseName = caseName; + rimInputReservoir->caseUserDescription = caseName; rimInputReservoir->openDataFileSet(caseFileNames); m_project->reservoirs.push_back(rimInputReservoir); @@ -1205,7 +1202,7 @@ void RiaApplication::saveSnapshotForAllViews(const QString& snapshotFolderName) // Process all events to avoid a black image when grabbing frame buffer QCoreApplication::processEvents(); - QString fileName = ri->caseName() + "-" + riv->name(); + QString fileName = ri->caseUserDescription() + "-" + riv->name(); QString absoluteFileName = caf::Utils::constructFullFileName(snapshotPath, fileName, ".png"); saveSnapshotAs(absoluteFileName); @@ -1366,10 +1363,9 @@ bool RiaApplication::addEclipseCases(const QStringList& fileNames) QFileInfo gridFileName(firstFileName); QString caseName = gridFileName.completeBaseName(); - QString casePath = gridFileName.absolutePath(); RimResultCase* rimResultReservoir = new RimResultCase(); - rimResultReservoir->setCaseInfo(caseName, firstFileName, casePath); + rimResultReservoir->setCaseInfo(caseName, firstFileName); if (!rimResultReservoir->openEclipseGridFile()) { delete rimResultReservoir; @@ -1393,10 +1389,9 @@ bool RiaApplication::addEclipseCases(const QStringList& fileNames) QFileInfo gridFileName(caseFileName); QString caseName = gridFileName.completeBaseName(); - QString casePath = gridFileName.absolutePath(); RimResultCase* rimResultReservoir = new RimResultCase(); - rimResultReservoir->setCaseInfo(caseName, caseFileName, casePath); + rimResultReservoir->setCaseInfo(caseName, caseFileName); std::vector< std::vector > caseGridDimensions; rimResultReservoir->readGridDimensions(caseGridDimensions); diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index 09ec328590..0aa4acad71 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -89,7 +89,7 @@ void Rim3dOverlayInfoConfig::update3DInfo() if (m_reservoirView->eclipseCase() && m_reservoirView->eclipseCase()->reservoirData() && m_reservoirView->eclipseCase()->reservoirData()->mainGrid()) { - caseName = m_reservoirView->eclipseCase()->caseName(); + caseName = m_reservoirView->eclipseCase()->caseUserDescription(); totCellCount = QString::number(m_reservoirView->eclipseCase()->reservoirData()->mainGrid()->cells().size()); size_t mxActCellCount = m_reservoirView->eclipseCase()->reservoirData()->activeCellInfo(RifReaderInterface::MATRIX_RESULTS)->globalActiveCellCount(); size_t frActCellCount = m_reservoirView->eclipseCase()->reservoirData()->activeCellInfo(RifReaderInterface::FRACTURE_RESULTS)->globalActiveCellCount(); diff --git a/ApplicationCode/ProjectDataModel/RimCase.cpp b/ApplicationCode/ProjectDataModel/RimCase.cpp index 24ad22cd8d..a65675f6a5 100644 --- a/ApplicationCode/ProjectDataModel/RimCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimCase.cpp @@ -43,7 +43,7 @@ CAF_PDM_SOURCE_INIT(RimCase, "RimReservoir"); //-------------------------------------------------------------------------------------------------- RimCase::RimCase() { - CAF_PDM_InitField(&caseName, "CaseName", QString(), "Case name", "", "" ,""); + CAF_PDM_InitField(&caseUserDescription, "CaseUserDescription", QString(), "Case name", "", "" ,""); CAF_PDM_InitFieldNoDefault(&reservoirViews, "ReservoirViews", "", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_matrixModelResults, "MatrixModelResults", "", "", "", ""); @@ -51,6 +51,11 @@ RimCase::RimCase() CAF_PDM_InitFieldNoDefault(&m_fractureModelResults, "FractureModelResults", "", "", "", ""); m_fractureModelResults.setUiHidden(true); + // Obsolete field + CAF_PDM_InitField(&caseName, "CaseName", QString(), "Obsolete", "", "" ,""); + caseName.setIOWritable(false); + caseName.setUiHidden(true); + m_matrixModelResults = new RimReservoirCellResultsStorage; m_fractureModelResults = new RimReservoirCellResultsStorage; @@ -111,6 +116,11 @@ void RimCase::initAfterRead() riv->setEclipseCase(this); } + + if (caseUserDescription().isEmpty() && !caseName().isEmpty()) + { + caseUserDescription = caseName; + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimCase.h b/ApplicationCode/ProjectDataModel/RimCase.h index ab2b025555..bb913e6393 100644 --- a/ApplicationCode/ProjectDataModel/RimCase.h +++ b/ApplicationCode/ProjectDataModel/RimCase.h @@ -46,15 +46,16 @@ public: RimCase(); virtual ~RimCase(); + // Fields: - caf::PdmField caseName; + caf::PdmField caseUserDescription; caf::PdmField releaseResultMemory; caf::PdmPointersField reservoirViews; virtual bool openEclipseGridFile() { return false;}; // Should be pure virtual but PDM does not allow that. - RigCaseData* reservoirData(); - const RigCaseData* reservoirData() const; + RigCaseData* reservoirData(); + const RigCaseData* reservoirData() const; void removeReservoirData(); RimReservoirCellResultsStorage* results(RifReaderInterface::PorosityModelResultType porosityModel); @@ -65,6 +66,8 @@ public: void removeResult(const QString& resultName); virtual QString locationOnDisc() const { return QString(); } + virtual QString gridFileName() const { return QString(); } + virtual void updateFilePathsFromProjectPath(const QString& projectPath) { }; RimCaseCollection* parentCaseCollection(); @@ -73,7 +76,7 @@ public: // Overridden methods from PdmObject public: - virtual caf::PdmFieldHandle* userDescriptionField() { return &caseName; } + virtual caf::PdmFieldHandle* userDescriptionField() { return &caseUserDescription; } protected: virtual void initAfterRead(); virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ); @@ -85,10 +88,13 @@ protected: private: - cvf::ref m_rigEclipseCase; + cvf::ref m_rigEclipseCase; private: caf::PdmField m_matrixModelResults; caf::PdmField m_fractureModelResults; + // Obsolete fields +protected: + caf::PdmField caseName; }; diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index 267ec4c953..fc9ee8b431 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -100,6 +100,11 @@ void RimIdenticalGridCaseGroup::addCase(RimCase* reservoir) //-------------------------------------------------------------------------------------------------- void RimIdenticalGridCaseGroup::removeCase(RimCase* reservoir) { + if (caseCollection()->reservoirs().count(reservoir) == 0) + { + return; + } + caseCollection()->reservoirs().removeChildObject(reservoir); if (caseCollection()->reservoirs().size() == 0) @@ -300,7 +305,7 @@ RimStatisticsCase* RimIdenticalGridCaseGroup::createAndAppendStatisticsCase() { RimStatisticsCase* newStatisticsCase = new RimStatisticsCase; - newStatisticsCase->caseName = QString("Statistics ") + QString::number(statisticsCaseCollection()->reservoirs.size()+1); + newStatisticsCase->caseUserDescription = QString("Statistics ") + QString::number(statisticsCaseCollection()->reservoirs.size()+1); statisticsCaseCollection()->reservoirs.push_back(newStatisticsCase); newStatisticsCase->openEclipseGridFile(); @@ -368,7 +373,7 @@ bool RimIdenticalGridCaseGroup::contains(RimCase* reservoir) const for (size_t i = 0; i < caseCollection()->reservoirs().size(); i++) { RimCase* rimReservoir = caseCollection()->reservoirs()[i]; - if (reservoir->caseName == rimReservoir->caseName) + if (reservoir->gridFileName() == rimReservoir->gridFileName()) { return true; } diff --git a/ApplicationCode/ProjectDataModel/RimInputCase.cpp b/ApplicationCode/ProjectDataModel/RimInputCase.cpp index fc2d3a64b4..d3825f5e01 100644 --- a/ApplicationCode/ProjectDataModel/RimInputCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimInputCase.cpp @@ -47,8 +47,9 @@ RimInputCase::RimInputCase() { CAF_PDM_InitObject("RimInputCase", ":/EclipseInput48x48.png", "", ""); CAF_PDM_InitField(&m_gridFileName, "GridFileName", QString(), "Case grid filename", "", "" ,""); + m_gridFileName.setUiReadOnly(true); CAF_PDM_InitFieldNoDefault(&m_additionalFileNames, "AdditionalFileNames", "Additional files", "", "" ,""); - + m_additionalFileNames.setUiReadOnly(true); CAF_PDM_InitFieldNoDefault(&m_inputPropertyCollection, "InputPropertyCollection", "", "", "", ""); m_inputPropertyCollection = new RimInputPropertyCollection; @@ -69,9 +70,9 @@ RimInputCase::~RimInputCase() //-------------------------------------------------------------------------------------------------- void RimInputCase::openDataFileSet(const QStringList& filenames) { - if (caseName().contains("Input Mock Debug Model")) + if (filenames.contains("Input Mock Debug Model")) { - cvf::ref readerInterface = this->createMockModel(this->caseName()); + cvf::ref readerInterface = this->createMockModel(filenames[0]); results(RifReaderInterface::MATRIX_RESULTS)->setReaderInterface(readerInterface.p()); results(RifReaderInterface::FRACTURE_RESULTS)->setReaderInterface(readerInterface.p()); @@ -161,9 +162,9 @@ bool RimInputCase::openEclipseGridFile() { cvf::ref readerInterface; - if (caseName().contains("Input Mock Debug Model")) + if (m_gridFileName().contains("Input Mock Debug Model")) { - readerInterface = this->createMockModel(this->caseName()); + readerInterface = this->createMockModel(this->m_gridFileName()); } else { @@ -375,6 +376,8 @@ cvf::ref RimInputCase::createMockModel(QString modelName) if (modelName == "Input Mock Debug Model Simple") { + m_gridFileName = modelName; + // Create the mock file interface and and RigSerervoir and set them up. mockFileInterface->setWorldCoordinates(cvf::Vec3d(10, 10, 10), cvf::Vec3d(20, 20, 20)); mockFileInterface->setGridPointDimensions(cvf::Vec3st(4, 5, 6)); diff --git a/ApplicationCode/ProjectDataModel/RimInputCase.h b/ApplicationCode/ProjectDataModel/RimInputCase.h index 5ab1f1a009..dd74303efb 100644 --- a/ApplicationCode/ProjectDataModel/RimInputCase.h +++ b/ApplicationCode/ProjectDataModel/RimInputCase.h @@ -45,9 +45,6 @@ public: virtual ~RimInputCase(); // Fields - caf::PdmField > m_additionalFileNames; - caf::PdmField m_gridFileName; - caf::PdmField m_inputPropertyCollection; // File open methods @@ -64,6 +61,8 @@ public: // Overrides from RimCase virtual QString locationOnDisc() const; + virtual QString gridFileName() const { return m_gridFileName();} + virtual void updateFilePathsFromProjectPath(const QString& projectPath); private: @@ -71,4 +70,9 @@ private: void removeFiles(const QStringList& obsoleteFileNames); cvf::ref createMockModel(QString modelName); + + // Fields + caf::PdmField > m_additionalFileNames; + caf::PdmField m_gridFileName; + }; diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp index 8135349553..f8e807fcbd 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp @@ -255,7 +255,7 @@ void RimReservoirView::updateViewerWidgetWindowTitle() QString windowTitle; if (m_reservoir.notNull()) { - windowTitle = QString("%1 - %2").arg(m_reservoir->caseName()).arg(name); + windowTitle = QString("%1 - %2").arg(m_reservoir->caseUserDescription()).arg(name); } else { @@ -702,7 +702,9 @@ void RimReservoirView::loadDataAndUpdate() { if (!m_reservoir->openEclipseGridFile()) { - QMessageBox::warning(RiuMainWindow::instance(), "Error when opening project file", "Could not open the Eclipse Grid file (EGRID/GRID): \n"+ m_reservoir->caseName()); + QMessageBox::warning(RiuMainWindow::instance(), + "Error when opening project file", + "Could not open the Eclipse Grid file: \n"+ m_reservoir->gridFileName()); m_reservoir = NULL; return; } diff --git a/ApplicationCode/ProjectDataModel/RimResultCase.cpp b/ApplicationCode/ProjectDataModel/RimResultCase.cpp index 4fdf6275cf..bf23b21470 100644 --- a/ApplicationCode/ProjectDataModel/RimResultCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultCase.cpp @@ -40,7 +40,13 @@ RimResultCase::RimResultCase() CAF_PDM_InitObject("Eclipse Case", ":/AppLogo48x48.png", "", ""); CAF_PDM_InitField(&caseFileName, "CaseFileName", QString(), "Case file name", "", "" ,""); + caseFileName.setUiReadOnly(true); + + // Obsolete, unused field CAF_PDM_InitField(&caseDirectory, "CaseFolder", QString(), "Directory", "", "" ,""); + caseDirectory.setIOWritable(false); + caseDirectory.setUiHidden(true); + } @@ -59,9 +65,9 @@ bool RimResultCase::openEclipseGridFile() cvf::ref readerInterface; - if (caseName().contains("Result Mock Debug Model")) + if (caseFileName().contains("Result Mock Debug Model")) { - readerInterface = this->createMockModel(this->caseName()); + readerInterface = this->createMockModel(this->caseFileName()); } else @@ -102,9 +108,9 @@ bool RimResultCase::openAndReadActiveCellData(RigCaseData* mainEclipseCase) { cvf::ref readerInterface; - if (caseName().contains("Result Mock Debug Model")) + if (caseFileName().contains("Result Mock Debug Model")) { - readerInterface = this->createMockModel(this->caseName()); + readerInterface = this->createMockModel(this->caseFileName()); } else { @@ -244,7 +250,8 @@ RimResultCase::~RimResultCase() //-------------------------------------------------------------------------------------------------- QString RimResultCase::locationOnDisc() const { - return caseDirectory; + QFileInfo fi(caseFileName()); + return fi.absolutePath(); } //-------------------------------------------------------------------------------------------------- @@ -252,7 +259,7 @@ QString RimResultCase::locationOnDisc() const //-------------------------------------------------------------------------------------------------- void RimResultCase::readGridDimensions(std::vector< std::vector >& gridDimensions) { - RifEclipseOutputFileTools::readGridDimensions(caseFileName, gridDimensions); + RifEclipseOutputFileTools::readGridDimensions(caseFileName(), gridDimensions); } //-------------------------------------------------------------------------------------------------- @@ -261,37 +268,37 @@ void RimResultCase::readGridDimensions(std::vector< std::vector >& gridDime void RimResultCase::updateFilePathsFromProjectPath(const QString& projectPath) { // Update filename and folder paths when opening project from a different file location - if (!QFile::exists(caseFileName)) + if (!QFile::exists(caseFileName())) { + QFileInfo gridFileInfo(caseFileName()); + QString gridFileBaseName = gridFileInfo.completeBaseName(); QString candidate; - candidate = QDir::fromNativeSeparators(caseDirectory.v() + QDir::separator() + caseName + ".EGRID"); + candidate = QDir::fromNativeSeparators(locationOnDisc() + QDir::separator() + gridFileBaseName + ".EGRID"); if (QFile::exists(candidate)) { caseFileName = candidate; return; } - candidate = QDir::fromNativeSeparators(caseDirectory.v() + QDir::separator() + caseName + ".GRID"); + candidate = QDir::fromNativeSeparators(locationOnDisc() + QDir::separator() + gridFileBaseName + ".GRID"); if (QFile::exists(candidate)) { caseFileName = candidate; return; } - candidate = QDir::fromNativeSeparators(projectPath + QDir::separator() + caseName + ".EGRID"); + candidate = QDir::fromNativeSeparators(projectPath + QDir::separator() + gridFileBaseName + ".EGRID"); if (QFile::exists(candidate)) { caseFileName = candidate; - caseDirectory = projectPath; return; } - candidate = QDir::fromNativeSeparators(projectPath + QDir::separator() + caseName + ".GRID"); + candidate = QDir::fromNativeSeparators(projectPath + QDir::separator() + gridFileBaseName + ".GRID"); if (QFile::exists(candidate)) { caseFileName = candidate; - caseDirectory = projectPath; return; } } @@ -300,10 +307,26 @@ void RimResultCase::updateFilePathsFromProjectPath(const QString& projectPath) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimResultCase::setCaseInfo(const QString& caseName, const QString& caseFileName, const QString& caseDirectory) +void RimResultCase::setCaseInfo(const QString& userDescription, const QString& caseFileName) { - this->caseName = caseName; + this->caseUserDescription = userDescription; this->caseFileName = caseFileName; - this->caseDirectory = caseDirectory; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimResultCase::initAfterRead() +{ + RimCase::initAfterRead(); + + // Convert from old (9.0.2) way of storing the case file + if (caseFileName().isEmpty()) + { + if (!this->caseName().isEmpty() && !caseDirectory().isEmpty()) + { + caseFileName = QDir::fromNativeSeparators(caseDirectory()) + "/" + caseName() + ".EGRID"; + } + } } diff --git a/ApplicationCode/ProjectDataModel/RimResultCase.h b/ApplicationCode/ProjectDataModel/RimResultCase.h index bceeeec3b6..b8123fa996 100644 --- a/ApplicationCode/ProjectDataModel/RimResultCase.h +++ b/ApplicationCode/ProjectDataModel/RimResultCase.h @@ -40,11 +40,7 @@ public: RimResultCase(); virtual ~RimResultCase(); - // Fields: - caf::PdmField caseFileName; - caf::PdmField caseDirectory; - - void setCaseInfo(const QString& caseName, const QString& caseFileName, const QString& caseDirectory); + void setCaseInfo(const QString& userDescription, const QString& caseFileName); virtual bool openEclipseGridFile(); bool openAndReadActiveCellData(RigCaseData* mainEclipseCase); @@ -52,8 +48,18 @@ public: // Overrides from RimCase virtual QString locationOnDisc() const; + virtual QString gridFileName() const { return caseFileName();} virtual void updateFilePathsFromProjectPath(const QString& projectPath); private: cvf::ref createMockModel(QString modelName); + + virtual void initAfterRead(); + + // Fields: + caf::PdmField caseFileName; + + // Obsolete field + caf::PdmField caseDirectory; + }; diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp index f00554eb90..95cccce438 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp @@ -311,7 +311,7 @@ void RimStatisticsCase::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderin updateSelectionListVisibilities(); updatePercentileUiVisibility(); - uiOrdering.add(&caseName); + uiOrdering.add(&caseUserDescription); uiOrdering.add(&m_calculateEditCommand); uiOrdering.add(&m_selectionSummary); diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index 9483a56237..c8b206af47 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -1020,7 +1020,8 @@ bool RimUiTreeView::hasClipboardValidData() //-------------------------------------------------------------------------------------------------- void RimUiTreeView::dropEvent(QDropEvent* dropEvent) { - if (userConfirmedGridCaseGroupChange(currentIndex())) + QModelIndex dropIndex = indexAt(dropEvent->pos()); + if (dropIndex.isValid() && userConfirmedGridCaseGroupChange(dropIndex)) { QTreeView::dropEvent(dropEvent); } diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.cpp b/ApplicationCode/SocketInterface/RiaSocketServer.cpp index ca25c15ea8..ad676d6462 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.cpp +++ b/ApplicationCode/SocketInterface/RiaSocketServer.cpp @@ -179,7 +179,7 @@ RimCase* RiaSocketServer::findReservoir(const QString& caseName) { for (size_t cIdx = 0; cIdx < project->reservoirs.size(); ++cIdx) { - if (project->reservoirs[cIdx] && project->reservoirs[cIdx]->caseName() == caseName ) + if (project->reservoirs[cIdx] && project->reservoirs[cIdx]->caseUserDescription() == caseName ) { return project->reservoirs[cIdx]; } @@ -452,9 +452,9 @@ void RiaSocketServer::readPropertyDataFromOctave() if (cellCountFromOctave != gridActiveCellCount && cellCountFromOctave != gridTotalCellCount) { m_errorMessageDialog->showMessage(tr("ResInsight SocketServer: \n") + - tr("The number of cells in the data coming from octave does not match the case") + ":\"" + m_currentReservoir->caseName() + "\"\n" + tr("The number of cells in the data coming from octave does not match the case") + ":\"" + m_currentReservoir->caseUserDescription() + "\"\n" " Octave: " + QString::number(cellCountFromOctave) + "\n" - " " + m_currentReservoir->caseName() + ": Active cell count: " + QString::number(gridActiveCellCount) + " Total cell count: " + QString::number(gridTotalCellCount)) ; + " " + m_currentReservoir->caseUserDescription() + ": Active cell count: " + QString::number(gridActiveCellCount) + " Total cell count: " + QString::number(gridTotalCellCount)) ; cellCountFromOctave = 0; m_invalidActiveCellCountDetected = true; From 67535b648c7f287a1e626adb2273818ad04f38ed Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 11 Apr 2013 14:08:06 +0200 Subject: [PATCH 232/242] Add default name/number to new grid cases p4#: 21246 --- ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index e8303e0a01..6b93a1c52b 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -593,6 +593,7 @@ RimIdenticalGridCaseGroup* RimUiTreeModelPdm::addCaseGroup(QModelIndex& inserted RimIdenticalGridCaseGroup* createdObject = new RimIdenticalGridCaseGroup; createdObject->createAndAppendStatisticsCase(); + createdObject->name = QString("Grid Case Group %1").arg(position + 1); proj->caseGroups().push_back(createdObject); caf::PdmUiTreeItem* childItem = caf::UiTreeItemBuilderPdm::buildViewItems(rootTreeItem, position, createdObject); From 464565f1bf2ade5033372a22f1f0c3852f2e76e7 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 11 Apr 2013 14:14:52 +0200 Subject: [PATCH 233/242] List all grid case groups where statistics data will be deleted based on a drop action p4#: 21247 --- .../ProjectDataModel/RimUiTreeView.cpp | 97 +++++++++++++++---- .../ProjectDataModel/RimUiTreeView.h | 2 +- 2 files changed, 79 insertions(+), 20 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp index c8b206af47..7dbdeea1d3 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.cpp @@ -806,7 +806,10 @@ void RimUiTreeView::slotWriteBinaryResultAsInputProperty() //-------------------------------------------------------------------------------------------------- void RimUiTreeView::slotCloseCase() { - if (userConfirmedGridCaseGroupChange(currentIndex())) + QModelIndexList miList; + miList << currentIndex(); + + if (userConfirmedGridCaseGroupChange(miList)) { RimUiTreeModelPdm* myModel = dynamic_cast(model()); if (myModel) @@ -931,7 +934,9 @@ void RimUiTreeView::slotPastePdmObjects() RimUiTreeModelPdm* myModel = dynamic_cast(model()); if (!myModel) return; - if (userConfirmedGridCaseGroupChange(currentIndex())) + QModelIndexList miList; + miList << currentIndex(); + if (userConfirmedGridCaseGroupChange(miList)) { caf::PdmObjectGroup objectGroup; createPdmObjectsFromClipboard(&objectGroup); @@ -1020,8 +1025,24 @@ bool RimUiTreeView::hasClipboardValidData() //-------------------------------------------------------------------------------------------------- void RimUiTreeView::dropEvent(QDropEvent* dropEvent) { + QModelIndexList affectedModels; + + if (dropEvent->dropAction() == Qt::MoveAction) + { + const MimeDataWithIndexes* myMimeData = qobject_cast(dropEvent->mimeData()); + if (myMimeData) + { + affectedModels = myMimeData->indexes(); + } + } + QModelIndex dropIndex = indexAt(dropEvent->pos()); - if (dropIndex.isValid() && userConfirmedGridCaseGroupChange(dropIndex)) + if (dropIndex.isValid()) + { + affectedModels.push_back(dropIndex); + } + + if (userConfirmedGridCaseGroupChange(affectedModels)) { QTreeView::dropEvent(dropEvent); } @@ -1030,33 +1051,71 @@ void RimUiTreeView::dropEvent(QDropEvent* dropEvent) //-------------------------------------------------------------------------------------------------- /// Displays a question to the user when a grid case group with statistical results is about to change //-------------------------------------------------------------------------------------------------- -bool RimUiTreeView::userConfirmedGridCaseGroupChange(const QModelIndex & itemIndex) +bool RimUiTreeView::userConfirmedGridCaseGroupChange(const QModelIndexList& itemIndexList) { - if (!itemIndex.isValid()) return true; + if (itemIndexList.size() == 0) return true; RimUiTreeModelPdm* myModel = dynamic_cast(model()); if (myModel) { - RimIdenticalGridCaseGroup* gridCaseGroup = myModel->gridCaseGroupFromItemIndex(itemIndex); - if (gridCaseGroup) + caf::PdmObjectGroup pog; + + for (int i = 0; i < itemIndexList.size(); i++) { - if (hasAnyStatisticsResults(gridCaseGroup)) + QModelIndex itemIndex = itemIndexList.at(i); + if (!itemIndex.isValid()) continue; + + RimIdenticalGridCaseGroup* gridCaseGroup = myModel->gridCaseGroupFromItemIndex(itemIndex); + if (gridCaseGroup) { - RiuMainWindow* mainWnd = RiuMainWindow::instance(); - - QMessageBox msgBox(mainWnd); - msgBox.setIcon(QMessageBox::Question); - msgBox.setText("This operation will invalidate statistics results. These results will be deleted if you continue."); - msgBox.setInformativeText("Do you want to continue?"); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - - int ret = msgBox.exec(); - if (ret == QMessageBox::No) + if (hasAnyStatisticsResults(gridCaseGroup)) { - return false; + if (pog.objects().count(gridCaseGroup) == 0) + { + pog.addObject(gridCaseGroup); + } } } } + + std::vector > typedObjects; + pog.objectsByType(&typedObjects); + + if (typedObjects.size() > 0) + { + RiuMainWindow* mainWnd = RiuMainWindow::instance(); + + QMessageBox msgBox(mainWnd); + msgBox.setIcon(QMessageBox::Question); + + QString questionText; + if (typedObjects.size() == 1) + { + questionText = QString("This operation will invalidate statistics results in grid case group\n\"%1\".\n").arg(typedObjects[0]->name()); + questionText += "Computed results in this group will be deleted if you continue."; + } + else + { + questionText = "This operation will invalidate statistics results in grid case groups\n"; + for (int i = 0; i < typedObjects.size(); i++) + { + questionText += QString("\"%1\"\n").arg(typedObjects[i]->name()); + } + + questionText += "Computed results in these groups will be deleted if you continue."; + } + + msgBox.setText(questionText); + msgBox.setInformativeText("Do you want to continue?"); + msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + + int ret = msgBox.exec(); + if (ret == QMessageBox::No) + { + return false; + } + } + } return true; diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeView.h b/ApplicationCode/ProjectDataModel/RimUiTreeView.h index 5c9784524b..a18672b20a 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeView.h +++ b/ApplicationCode/ProjectDataModel/RimUiTreeView.h @@ -90,7 +90,7 @@ signals: void selectedObjectChanged( caf::PdmObject* pdmObject ); private: - bool userConfirmedGridCaseGroupChange(const QModelIndex & itemIndex); + bool userConfirmedGridCaseGroupChange(const QModelIndexList& itemIndexList); bool hasAnyStatisticsResults(RimIdenticalGridCaseGroup* gridCaseGroup); void createPdmObjectsFromClipboard(caf::PdmObjectGroup* objectGroup); From 462bc16aceb130bcc72361239ae5bc30fa0fcb9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 12 Apr 2013 08:31:59 +0200 Subject: [PATCH 234/242] Rewrite of the searchpath system for external file references The Relocation code is not yet completely working for the advanced cases p4#: 21251 --- ApplicationCode/ProjectDataModel/RimCase.cpp | 128 ++++++++++++++++++ ApplicationCode/ProjectDataModel/RimCase.h | 5 +- .../ProjectDataModel/RimInputCase.cpp | 29 +--- .../ProjectDataModel/RimInputCase.h | 2 +- .../ProjectDataModel/RimProject.cpp | 13 +- .../ProjectDataModel/RimResultCase.cpp | 39 +----- .../ProjectDataModel/RimResultCase.h | 2 +- 7 files changed, 153 insertions(+), 65 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimCase.cpp b/ApplicationCode/ProjectDataModel/RimCase.cpp index a65675f6a5..5c5f99bbc5 100644 --- a/ApplicationCode/ProjectDataModel/RimCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimCase.cpp @@ -351,3 +351,131 @@ RimReservoirCellResultsStorage* RimCase::results(RifReaderInterface::PorosityMod return m_fractureModelResults(); } + + +//-------------------------------------------------------------------------------------------------- +/// Relocate the supplied file name, based on the search path as follows: +/// fileName, newProjectPath/fileNameWoPath, relocatedPath/fileNameWoPath +/// If the file is not found in any of the positions, the fileName is returned unchanged +/// +/// The relocatedPath is found in this way: +/// use the start of newProjectPath +/// plus the end of the path to m_gridFileName +/// such that the common start of oldProjectPath and m_gridFileName is removed from m_gridFileName +/// and replaced with the start of newProjectPath up to where newProjectPath starts to be equal to oldProjectPath +//-------------------------------------------------------------------------------------------------- +QString RimCase::relocateFile(const QString& fileName, const QString& newProjectPath, const QString& oldProjectPath, + bool* foundFile, std::vector* searchedPaths) +{ + if (foundFile) *foundFile = true; + + if (searchedPaths) searchedPaths->push_back(fileName); + if (QFile::exists(fileName)) + { + return fileName; + } + + // First check in the new project file directory + { + QString fileNameWithoutPath = QFileInfo(fileName).fileName(); + QString candidate = QDir::fromNativeSeparators(newProjectPath + QDir::separator() + fileNameWithoutPath); + if (searchedPaths) searchedPaths->push_back(candidate); + + if (QFile::exists(candidate)) + { + return candidate; + } + } + + QFileInfo gridFileInfo(fileName); + QFileInfo oldProjPathInfo(oldProjectPath); + QFileInfo newProjPathInfo(newProjectPath); + + QString gridFilePath = gridFileInfo.canonicalPath(); + QStringList gridPathElements = gridFilePath.split("/", QString::KeepEmptyParts); + QString oldProjPath = oldProjPathInfo.canonicalPath(); + QStringList oldProjPathElements = oldProjPath.split("/", QString::KeepEmptyParts); + QString newProjPath = newProjPathInfo.canonicalPath(); + QStringList newProjPathElements = newProjPath.split("/", QString::KeepEmptyParts); + + bool pathStartsAreEqual = false; + bool pathEndsDiffer = false; + int firstDiffIdx = 0; + for ( firstDiffIdx = 0; firstDiffIdx < gridPathElements.size() && firstDiffIdx < oldProjPathElements.size(); ++firstDiffIdx) + { + if (gridPathElements[firstDiffIdx] == oldProjPathElements[firstDiffIdx]) + { + pathStartsAreEqual = pathStartsAreEqual || !gridPathElements[firstDiffIdx].isEmpty(); + } + else + { + pathEndsDiffer = true; + break; + } + } + + if (!pathEndsDiffer && firstDiffIdx < gridPathElements.size() || firstDiffIdx < oldProjPathElements.size()) + { + pathEndsDiffer = true; + } + + if (pathStartsAreEqual) + { + if (pathEndsDiffer) + { + QString oldGridFilePathEnd; + for (int i = firstDiffIdx; i < gridPathElements.size(); ++i) + { + oldGridFilePathEnd += gridPathElements[i]; + oldGridFilePathEnd += "/"; + } + + // Find the new Project File Start Path + + QStringList oldProjectFilePathEndElements; + for (int i = firstDiffIdx; i < oldProjPathElements.size(); ++i) + { + oldProjectFilePathEndElements.push_back(oldProjPathElements[i]); + } + + int ppIdx = oldProjectFilePathEndElements.size() -1; + int lastDiffIdx = newProjPathElements.size() -1; + + for (; lastDiffIdx >= 0 && ppIdx >= 0; --lastDiffIdx, --ppIdx) + { + if (oldProjectFilePathEndElements[ppIdx] != newProjPathElements[lastDiffIdx]) + { + break; + } + } + + QString newProjecetFileStartPath; + for (int i = 0; i <= lastDiffIdx; ++i) + { + newProjecetFileStartPath += newProjPathElements[i]; + newProjecetFileStartPath += "/"; + } + + QString relocationPath = newProjecetFileStartPath + oldGridFilePathEnd; + + QString relocatedFileName = relocationPath + gridFileInfo.fileName(); + + if (searchedPaths) searchedPaths->push_back(relocatedFileName); + + if (QFile::exists(relocatedFileName)) + { + return relocatedFileName; + } + } + else + { + // The Grid file was located in the same dir as the Project file. This is supposed to be handled above. + CVF_ASSERT(false); + } + } + + // return the unchanged filename, if we could not find a valid relocation file + if (foundFile) *foundFile = false; + + return fileName; +} diff --git a/ApplicationCode/ProjectDataModel/RimCase.h b/ApplicationCode/ProjectDataModel/RimCase.h index bb913e6393..aa2fa9bd1f 100644 --- a/ApplicationCode/ProjectDataModel/RimCase.h +++ b/ApplicationCode/ProjectDataModel/RimCase.h @@ -68,7 +68,7 @@ public: virtual QString locationOnDisc() const { return QString(); } virtual QString gridFileName() const { return QString(); } - virtual void updateFilePathsFromProjectPath(const QString& projectPath) { }; + virtual void updateFilePathsFromProjectPath(const QString& projectPath, const QString& oldProjectPath) { }; RimCaseCollection* parentCaseCollection(); RimIdenticalGridCaseGroup* parentGridCaseGroup(); @@ -85,7 +85,8 @@ protected: protected: void computeCachedData(); void setReservoirData(RigCaseData* eclipseCase); - + static QString relocateFile(const QString& fileName, const QString& newProjectPath, const QString& oldProjectPath, + bool* foundFile, std::vector* searchedPaths); private: cvf::ref m_rigEclipseCase; diff --git a/ApplicationCode/ProjectDataModel/RimInputCase.cpp b/ApplicationCode/ProjectDataModel/RimInputCase.cpp index d3825f5e01..b81c30d8ae 100644 --- a/ApplicationCode/ProjectDataModel/RimInputCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimInputCase.cpp @@ -423,37 +423,18 @@ QString RimInputCase::locationOnDisc() const return fi.absolutePath(); } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimInputCase::updateFilePathsFromProjectPath(const QString& projectPath) +void RimInputCase::updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath) { - QString candidate; + bool foundFile = false; + std::vector searchedPaths; - if (!QFile::exists(m_gridFileName)) - { - QString fileNameWithoutPath = QFileInfo(m_gridFileName).fileName(); - candidate = QDir::fromNativeSeparators(projectPath + QDir::separator() + fileNameWithoutPath); - if (QFile::exists(candidate)) - { - m_gridFileName = candidate; - } - } + m_gridFileName = relocateFile(m_gridFileName(), newProjectPath, oldProjectPath, &foundFile, &searchedPaths); for (size_t i = 0; i < m_additionalFileNames().size(); i++) { - QString additionalFileName = m_additionalFileNames()[i]; - - if (!QFile::exists(additionalFileName)) - { - QString fileNameWithoutPath = QFileInfo(additionalFileName).fileName(); - candidate = QDir::fromNativeSeparators(projectPath + QDir::separator() + fileNameWithoutPath); - if (QFile::exists(candidate)) - { - m_additionalFileNames.v()[i] = candidate; - } - } + m_additionalFileNames.v()[i] = relocateFile(m_additionalFileNames()[i], newProjectPath, oldProjectPath, &foundFile, &searchedPaths); } - } diff --git a/ApplicationCode/ProjectDataModel/RimInputCase.h b/ApplicationCode/ProjectDataModel/RimInputCase.h index dd74303efb..1766fc9f3d 100644 --- a/ApplicationCode/ProjectDataModel/RimInputCase.h +++ b/ApplicationCode/ProjectDataModel/RimInputCase.h @@ -63,7 +63,7 @@ public: virtual QString locationOnDisc() const; virtual QString gridFileName() const { return m_gridFileName();} - virtual void updateFilePathsFromProjectPath(const QString& projectPath); + virtual void updateFilePathsFromProjectPath(const QString& projectPath, const QString& oldProjectPath); private: void addFiles(const QStringList& newFileNames); diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 452c468b51..166e05c4d3 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -236,16 +236,23 @@ void RimProject::insertCaseInCaseGroup(RimIdenticalGridCaseGroup* caseGroup, Rim //-------------------------------------------------------------------------------------------------- void RimProject::setProjectFileNameAndUpdateDependencies(const QString& fileName) { + // Extract the filename of the project file when it was saved + QString oldProjectFileName = this->fileName; + // Replace with the new actual filename this->fileName = fileName; // Loop over all reservoirs and update file path QFileInfo fileInfo(fileName); - QString projectPath = fileInfo.path(); + QString newProjectPath = fileInfo.path(); + + QFileInfo fileInfoOld(oldProjectFileName); + QString oldProjectPath = fileInfoOld.path(); + for (size_t i = 0; i < reservoirs.size(); i++) { - reservoirs[i]->updateFilePathsFromProjectPath(projectPath); + reservoirs[i]->updateFilePathsFromProjectPath(newProjectPath, oldProjectPath); } // Case groups : Loop over all reservoirs in and update file path @@ -256,7 +263,7 @@ void RimProject::setProjectFileNameAndUpdateDependencies(const QString& fileName for (size_t j = 0; j < cg->caseCollection()->reservoirs().size(); j++) { - cg->caseCollection()->reservoirs()[j]->updateFilePathsFromProjectPath(projectPath); + cg->caseCollection()->reservoirs()[j]->updateFilePathsFromProjectPath(newProjectPath, oldProjectPath); } } } diff --git a/ApplicationCode/ProjectDataModel/RimResultCase.cpp b/ApplicationCode/ProjectDataModel/RimResultCase.cpp index bf23b21470..7cbd9fe12d 100644 --- a/ApplicationCode/ProjectDataModel/RimResultCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultCase.cpp @@ -265,43 +265,14 @@ void RimResultCase::readGridDimensions(std::vector< std::vector >& gridDime //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimResultCase::updateFilePathsFromProjectPath(const QString& projectPath) +void RimResultCase::updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath) { + bool foundFile = false; + std::vector searchedPaths; + // Update filename and folder paths when opening project from a different file location - if (!QFile::exists(caseFileName())) - { - QFileInfo gridFileInfo(caseFileName()); - QString gridFileBaseName = gridFileInfo.completeBaseName(); - QString candidate; + caseFileName = relocateFile(caseFileName(), newProjectPath, oldProjectPath, &foundFile, &searchedPaths); - candidate = QDir::fromNativeSeparators(locationOnDisc() + QDir::separator() + gridFileBaseName + ".EGRID"); - if (QFile::exists(candidate)) - { - caseFileName = candidate; - return; - } - - candidate = QDir::fromNativeSeparators(locationOnDisc() + QDir::separator() + gridFileBaseName + ".GRID"); - if (QFile::exists(candidate)) - { - caseFileName = candidate; - return; - } - - candidate = QDir::fromNativeSeparators(projectPath + QDir::separator() + gridFileBaseName + ".EGRID"); - if (QFile::exists(candidate)) - { - caseFileName = candidate; - return; - } - - candidate = QDir::fromNativeSeparators(projectPath + QDir::separator() + gridFileBaseName + ".GRID"); - if (QFile::exists(candidate)) - { - caseFileName = candidate; - return; - } - } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimResultCase.h b/ApplicationCode/ProjectDataModel/RimResultCase.h index b8123fa996..b85dbde04e 100644 --- a/ApplicationCode/ProjectDataModel/RimResultCase.h +++ b/ApplicationCode/ProjectDataModel/RimResultCase.h @@ -49,7 +49,7 @@ public: // Overrides from RimCase virtual QString locationOnDisc() const; virtual QString gridFileName() const { return caseFileName();} - virtual void updateFilePathsFromProjectPath(const QString& projectPath); + virtual void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath); private: cvf::ref createMockModel(QString modelName); From e5f9b41c0f999d6d6facb97abe18d140a8f4d4d0 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 12 Apr 2013 09:20:40 +0200 Subject: [PATCH 235/242] Moved font creation into RivReservoirPipesPartMgr Added clearGeometryCache p4#: 21252 --- .../RivReservoirPipesPartMgr.cpp | 82 +++++++++++-------- .../RivReservoirPipesPartMgr.h | 5 +- .../ModelVisualization/RivWellHeadPartMgr.cpp | 6 +- .../ModelVisualization/RivWellHeadPartMgr.h | 2 +- 4 files changed, 57 insertions(+), 38 deletions(-) diff --git a/ApplicationCode/ModelVisualization/RivReservoirPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirPipesPartMgr.cpp index 156b3d572e..f54d82e035 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirPipesPartMgr.cpp @@ -33,6 +33,8 @@ RivReservoirPipesPartMgr::RivReservoirPipesPartMgr(RimReservoirView* reservoirVi m_reservoirView = reservoirView; m_scaleTransform = new cvf::Transform(); + + m_font = new cvf::FixedAtlasFont(cvf::FixedAtlasFont::LARGE); } //-------------------------------------------------------------------------------------------------- @@ -46,42 +48,25 @@ RivReservoirPipesPartMgr::~RivReservoirPipesPartMgr() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivReservoirPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex) +void RivReservoirPipesPartMgr::clearGeometryCache() { - if (m_reservoirView->wellCollection()->wellPipeVisibility() == RimWellCollection::FORCE_ALL_OFF) return; - - if (m_reservoirView->wellCollection()->wells.size() != m_wellPipesPartMgrs.size()) - { - m_wellPipesPartMgrs.clear(); - m_wellHeadPartMgrs.clear(); - - for (size_t i = 0; i < m_reservoirView->wellCollection()->wells.size(); ++i) - { - RivWellPipesPartMgr * wppmgr = new RivWellPipesPartMgr(m_reservoirView, m_reservoirView->wellCollection()->wells[i]); - m_wellPipesPartMgrs.push_back(wppmgr); - wppmgr->setScaleTransform(m_scaleTransform.p()); - - RivWellHeadPartMgr* wellHeadMgr = new RivWellHeadPartMgr(m_reservoirView, m_reservoirView->wellCollection()->wells[i]); - m_wellHeadPartMgrs.push_back(wellHeadMgr); - wellHeadMgr->setScaleTransform(m_scaleTransform.p()); - } - } - - for (size_t wIdx = 0; wIdx != m_wellPipesPartMgrs.size(); ++ wIdx) - { - m_wellPipesPartMgrs[wIdx]->appendDynamicGeometryPartsToModel(model, frameIndex); - m_wellHeadPartMgrs[wIdx]->appendDynamicGeometryPartsToModel(model, frameIndex); - } + m_wellPipesPartMgrs.clear(); + m_wellHeadPartMgrs.clear(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivReservoirPipesPartMgr::updatePipeResultColor(size_t frameIndex) +void RivReservoirPipesPartMgr::scheduleGeometryRegen() { for (size_t wIdx = 0; wIdx != m_wellPipesPartMgrs.size(); ++ wIdx) { - m_wellPipesPartMgrs[wIdx]->updatePipeResultColor( frameIndex); + m_wellPipesPartMgrs[wIdx]->scheduleGeometryRegen(); + } + + for (size_t wIdx = 0; wIdx != m_wellHeadPartMgrs.size(); ++ wIdx) + { + //m_wellHeadPartMgrs[wIdx]->scheduleGeometryRegen(scaleTransform); } } @@ -103,15 +88,44 @@ void RivReservoirPipesPartMgr::setScaleTransform(cvf::Transform * scaleTransform } } -void RivReservoirPipesPartMgr::scheduleGeometryRegen() +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivReservoirPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex) +{ + if (m_reservoirView->wellCollection()->wellPipeVisibility() == RimWellCollection::FORCE_ALL_OFF) return; + + if (m_reservoirView->wellCollection()->wells.size() != m_wellPipesPartMgrs.size()) + { + clearGeometryCache(); + + for (size_t i = 0; i < m_reservoirView->wellCollection()->wells.size(); ++i) + { + RivWellPipesPartMgr * wppmgr = new RivWellPipesPartMgr(m_reservoirView, m_reservoirView->wellCollection()->wells[i]); + m_wellPipesPartMgrs.push_back(wppmgr); + wppmgr->setScaleTransform(m_scaleTransform.p()); + + RivWellHeadPartMgr* wellHeadMgr = new RivWellHeadPartMgr(m_reservoirView, m_reservoirView->wellCollection()->wells[i], m_font.p()); + m_wellHeadPartMgrs.push_back(wellHeadMgr); + wellHeadMgr->setScaleTransform(m_scaleTransform.p()); + } + } + + for (size_t wIdx = 0; wIdx != m_wellPipesPartMgrs.size(); ++ wIdx) + { + m_wellPipesPartMgrs[wIdx]->appendDynamicGeometryPartsToModel(model, frameIndex); + m_wellHeadPartMgrs[wIdx]->appendDynamicGeometryPartsToModel(model, frameIndex); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivReservoirPipesPartMgr::updatePipeResultColor(size_t frameIndex) { for (size_t wIdx = 0; wIdx != m_wellPipesPartMgrs.size(); ++ wIdx) { - m_wellPipesPartMgrs[wIdx]->scheduleGeometryRegen(); - } - - for (size_t wIdx = 0; wIdx != m_wellHeadPartMgrs.size(); ++ wIdx) - { - //m_wellHeadPartMgrs[wIdx]->scheduleGeometryRegen(scaleTransform); + m_wellPipesPartMgrs[wIdx]->updatePipeResultColor( frameIndex); } } + diff --git a/ApplicationCode/ModelVisualization/RivReservoirPipesPartMgr.h b/ApplicationCode/ModelVisualization/RivReservoirPipesPartMgr.h index ce6209af96..7d830a503d 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirPipesPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivReservoirPipesPartMgr.h @@ -33,15 +33,18 @@ public: RivReservoirPipesPartMgr(RimReservoirView* reservoirView); ~RivReservoirPipesPartMgr(); - void setScaleTransform(cvf::Transform * scaleTransform); + void clearGeometryCache(); void scheduleGeometryRegen(); + void setScaleTransform(cvf::Transform * scaleTransform); + void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex); void updatePipeResultColor(size_t frameIndex); private: caf::PdmPointer m_reservoirView; cvf::ref m_scaleTransform; + cvf::ref m_font; cvf::Collection< RivWellPipesPartMgr > m_wellPipesPartMgrs; cvf::Collection< RivWellHeadPartMgr > m_wellHeadPartMgrs; diff --git a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp index d578779940..8933231fa3 100644 --- a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp @@ -46,12 +46,12 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivWellHeadPartMgr::RivWellHeadPartMgr(RimReservoirView* reservoirView, RimWell* well) +RivWellHeadPartMgr::RivWellHeadPartMgr(RimReservoirView* reservoirView, RimWell* well, cvf::Font* font) { m_rimReservoirView = reservoirView; m_rimWell = well; - m_font = new cvf::FixedAtlasFont(cvf::FixedAtlasFont::LARGE); + m_font = font; } //-------------------------------------------------------------------------------------------------- @@ -232,6 +232,8 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex) if (m_rimReservoirView->wellCollection()->showWellLabel() && well->showWellLabel()) { + CVF_ASSERT(m_font.p()); + cvf::ref drawableText = new cvf::DrawableText; drawableText->setFont(m_font.p()); drawableText->setCheckPosVisible(false); diff --git a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.h b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.h index 8a593e45df..9ef0bf0d40 100644 --- a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.h @@ -38,7 +38,7 @@ class RimReservoirView; class RivWellHeadPartMgr : public cvf::Object { public: - RivWellHeadPartMgr(RimReservoirView* reservoirView, RimWell* well); + RivWellHeadPartMgr(RimReservoirView* reservoirView, RimWell* well, cvf::Font* font); ~RivWellHeadPartMgr(); void setScaleTransform(cvf::Transform * scaleTransform) { m_scaleTransform = scaleTransform;} From 432106c9c5d5f895f29a64aae677baf5ffb4bc64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 12 Apr 2013 09:43:40 +0200 Subject: [PATCH 236/242] External file references: Fixed the relocation in the advanced cases p4#: 21253 --- ApplicationCode/ProjectDataModel/RimCase.cpp | 22 +++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimCase.cpp b/ApplicationCode/ProjectDataModel/RimCase.cpp index 5c5f99bbc5..a140847734 100644 --- a/ApplicationCode/ProjectDataModel/RimCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimCase.cpp @@ -387,17 +387,21 @@ QString RimCase::relocateFile(const QString& fileName, const QString& newProjec } } - QFileInfo gridFileInfo(fileName); - QFileInfo oldProjPathInfo(oldProjectPath); - QFileInfo newProjPathInfo(newProjectPath); + // Then find the possible move of a directory structure where projects and files referenced are moved in "paralell" - QString gridFilePath = gridFileInfo.canonicalPath(); + QFileInfo gridFileInfo(QDir::fromNativeSeparators(fileName)); + QString gridFilePath = gridFileInfo.path(); + QString gridFileNameWoPath = gridFileInfo.fileName(); QStringList gridPathElements = gridFilePath.split("/", QString::KeepEmptyParts); - QString oldProjPath = oldProjPathInfo.canonicalPath(); + + QString oldProjPath = QDir::fromNativeSeparators(oldProjectPath); QStringList oldProjPathElements = oldProjPath.split("/", QString::KeepEmptyParts); - QString newProjPath = newProjPathInfo.canonicalPath(); + + QString newProjPath = QDir::fromNativeSeparators(newProjectPath); QStringList newProjPathElements = newProjPath.split("/", QString::KeepEmptyParts); + // Find the possible equal start of the old project path, and the referenced file + bool pathStartsAreEqual = false; bool pathEndsDiffer = false; int firstDiffIdx = 0; @@ -419,6 +423,8 @@ QString RimCase::relocateFile(const QString& fileName, const QString& newProjec pathEndsDiffer = true; } + // If the path starts are equal, try to substitute it in the referenced file, with the corresponding new project path start + if (pathStartsAreEqual) { if (pathEndsDiffer) @@ -458,7 +464,7 @@ QString RimCase::relocateFile(const QString& fileName, const QString& newProjec QString relocationPath = newProjecetFileStartPath + oldGridFilePathEnd; - QString relocatedFileName = relocationPath + gridFileInfo.fileName(); + QString relocatedFileName = relocationPath + gridFileNameWoPath; if (searchedPaths) searchedPaths->push_back(relocatedFileName); @@ -470,7 +476,7 @@ QString RimCase::relocateFile(const QString& fileName, const QString& newProjec else { // The Grid file was located in the same dir as the Project file. This is supposed to be handled above. - CVF_ASSERT(false); + // So we did not find it } } From aea13e1810b534157877967775223b17570ec0b6 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 12 Apr 2013 11:12:53 +0200 Subject: [PATCH 237/242] Whitespace p4#: 21256 --- ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index 6b93a1c52b..383b7d0262 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -619,16 +619,16 @@ void RimUiTreeModelPdm::addObjects(const QModelIndex& itemIndex, caf::PdmObjectG pdmObjects.createCopyByType(&typedObjects); if (typedObjects.size() == 0) - { - return; - } + { + return; + } RimResultCase* mainResultCase = NULL; std::vector< std::vector > mainCaseGridDimensions; // Read out main grid and main grid dimensions if present in case group if (gridCaseGroup->mainCase()) - { + { mainResultCase = dynamic_cast(gridCaseGroup->mainCase()); CVF_ASSERT(mainResultCase); From 9b0378f8e0329a26be2af2e2bbfc15990f50460d Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 12 Apr 2013 12:03:04 +0200 Subject: [PATCH 238/242] Added support for selected well data in a statistics case Now possible to show well data from selected source case for a statistics case Added state to RimResultCase to monitor data actually read from disk p4#: 21258 --- ApplicationCode/ProjectDataModel/RimCase.cpp | 8 --- ApplicationCode/ProjectDataModel/RimCase.h | 1 - .../ProjectDataModel/RimCaseCollection.cpp | 16 +++++ .../ProjectDataModel/RimCaseCollection.h | 4 +- .../ProjectDataModel/RimReservoirView.cpp | 21 ++++++ .../ProjectDataModel/RimReservoirView.h | 12 ++-- .../ProjectDataModel/RimResultCase.cpp | 22 +++--- .../ProjectDataModel/RimResultCase.h | 2 + .../ProjectDataModel/RimStatisticsCase.cpp | 68 ++++++++++++++++++- .../ProjectDataModel/RimStatisticsCase.h | 4 ++ .../ProjectDataModel/RimUiTreeModelPdm.cpp | 17 +---- .../ReservoirDataModel/RigCaseData.h | 10 +-- 12 files changed, 137 insertions(+), 48 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimCase.cpp b/ApplicationCode/ProjectDataModel/RimCase.cpp index a140847734..49b52305cb 100644 --- a/ApplicationCode/ProjectDataModel/RimCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimCase.cpp @@ -95,14 +95,6 @@ const RigCaseData* RimCase::reservoirData() const return m_rigEclipseCase.p(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimCase::removeReservoirData() -{ - this->setReservoirData(NULL); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimCase.h b/ApplicationCode/ProjectDataModel/RimCase.h index aa2fa9bd1f..dea48e04e9 100644 --- a/ApplicationCode/ProjectDataModel/RimCase.h +++ b/ApplicationCode/ProjectDataModel/RimCase.h @@ -56,7 +56,6 @@ public: RigCaseData* reservoirData(); const RigCaseData* reservoirData() const; - void removeReservoirData(); RimReservoirCellResultsStorage* results(RifReaderInterface::PorosityModelResultType porosityModel); diff --git a/ApplicationCode/ProjectDataModel/RimCaseCollection.cpp b/ApplicationCode/ProjectDataModel/RimCaseCollection.cpp index 0df12839a9..67e932b0c2 100644 --- a/ApplicationCode/ProjectDataModel/RimCaseCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimCaseCollection.cpp @@ -59,3 +59,19 @@ RimIdenticalGridCaseGroup* RimCaseCollection::parentCaseGroup() return NULL; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCase* RimCaseCollection::findByDescription(const QString& caseDescription) const +{ + for (size_t i = 0; i < reservoirs.size(); i++) + { + if (caseDescription == reservoirs[i]->caseUserDescription()) + { + return reservoirs[i]; + } + } + + return NULL; +} diff --git a/ApplicationCode/ProjectDataModel/RimCaseCollection.h b/ApplicationCode/ProjectDataModel/RimCaseCollection.h index bd1e1a48b2..136b6fa766 100644 --- a/ApplicationCode/ProjectDataModel/RimCaseCollection.h +++ b/ApplicationCode/ProjectDataModel/RimCaseCollection.h @@ -38,10 +38,10 @@ class RimCaseCollection : public caf::PdmObject public: RimCaseCollection(); virtual ~RimCaseCollection(); - caf::PdmPointersField reservoirs; - RimIdenticalGridCaseGroup* parentCaseGroup(); + RimIdenticalGridCaseGroup* parentCaseGroup(); + RimCase* findByDescription(const QString& caseDescription) const; private: diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp index f8e807fcbd..f6d4d84849 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.cpp @@ -1284,3 +1284,24 @@ void RimReservoirView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibl } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimReservoirView::updateDisplayModelForWellResults() +{ + m_geometry->clearGeometryCache(); + m_pipesPartManager->clearGeometryCache(); + + syncronizeWellsWithResults(); + + createDisplayModel(); + updateDisplayModelVisibility(); + + overlayInfoConfig()->update3DInfo(); + + if (animationMode && m_viewer) + { + m_viewer->slotSetCurrentFrame(m_currentTimeStep); + } +} + diff --git a/ApplicationCode/ProjectDataModel/RimReservoirView.h b/ApplicationCode/ProjectDataModel/RimReservoirView.h index 68ecde5cac..c77a67d263 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirView.h +++ b/ApplicationCode/ProjectDataModel/RimReservoirView.h @@ -117,11 +117,11 @@ public: caf::PdmField animationMode; // Access internal objects - RimReservoirCellResultsStorage* currentGridCellResults(); + RimReservoirCellResultsStorage* currentGridCellResults(); RigActiveCellInfo* currentActiveCellInfo(); void setEclipseCase(RimCase* reservoir); - RimCase* eclipseCase(); + RimCase* eclipseCase(); // Animation int currentTimeStep() { return m_currentTimeStep;} @@ -148,6 +148,8 @@ public: void createDisplayModelAndRedraw(); void scheduleGeometryRegen(unsigned short geometryType); void schedulePipeGeometryRegen(); + void updateDisplayModelForWellResults(); + // Display model generation private: @@ -178,9 +180,7 @@ private: private: caf::PdmField m_currentTimeStep; - QPointer m_viewer; - caf::PdmPointer m_reservoir; - - + QPointer m_viewer; + caf::PdmPointer m_reservoir; }; diff --git a/ApplicationCode/ProjectDataModel/RimResultCase.cpp b/ApplicationCode/ProjectDataModel/RimResultCase.cpp index 7cbd9fe12d..1d16fda647 100644 --- a/ApplicationCode/ProjectDataModel/RimResultCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimResultCase.cpp @@ -47,10 +47,10 @@ RimResultCase::RimResultCase() caseDirectory.setIOWritable(false); caseDirectory.setUiHidden(true); + m_activeCellInfoIsReadFromFile = false; + m_gridAndWellDataIsReadFromFile = false; } - - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -60,15 +60,15 @@ bool RimResultCase::openEclipseGridFile() progInfo.setProgressDescription("Open Grid File"); progInfo.setNextProgressIncrement(48); - // Early exit if reservoir data is created - if (this->reservoirData()) return true; + + // Early exit if data is already read + if (m_gridAndWellDataIsReadFromFile) return true; cvf::ref readerInterface; if (caseFileName().contains("Result Mock Debug Model")) { readerInterface = this->createMockModel(this->caseFileName()); - } else { @@ -98,6 +98,9 @@ bool RimResultCase::openEclipseGridFile() progInfo.setProgressDescription("Computing Case Cache"); computeCachedData(); + m_gridAndWellDataIsReadFromFile = true; + m_activeCellInfoIsReadFromFile = true; + return true; } @@ -106,8 +109,10 @@ bool RimResultCase::openEclipseGridFile() //-------------------------------------------------------------------------------------------------- bool RimResultCase::openAndReadActiveCellData(RigCaseData* mainEclipseCase) { - cvf::ref readerInterface; + // Early exit if data is already read + if (m_activeCellInfoIsReadFromFile) return true; + cvf::ref readerInterface; if (caseFileName().contains("Result Mock Debug Model")) { readerInterface = this->createMockModel(this->caseFileName()); @@ -154,11 +159,11 @@ bool RimResultCase::openAndReadActiveCellData(RigCaseData* mainEclipseCase) reservoirData()->computeActiveCellBoundingBoxes(); + m_activeCellInfoIsReadFromFile = true; + return true; } - - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -236,7 +241,6 @@ cvf::ref RimResultCase::createMockModel(QString modelName) return mockFileInterface.p(); } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimResultCase.h b/ApplicationCode/ProjectDataModel/RimResultCase.h index b85dbde04e..d3db414e87 100644 --- a/ApplicationCode/ProjectDataModel/RimResultCase.h +++ b/ApplicationCode/ProjectDataModel/RimResultCase.h @@ -62,4 +62,6 @@ private: // Obsolete field caf::PdmField caseDirectory; + bool m_gridAndWellDataIsReadFromFile; + bool m_activeCellInfoIsReadFromFile; }; diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp index 95cccce438..a27c66c7d1 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp @@ -29,6 +29,8 @@ #include "cafPdmUiTextEditor.h" #include "cafPdmUiLineEditor.h" #include "cafPdmUiPushButtonEditor.h" +#include "RiuMainWindow.h" +#include "RimUiTreeModelPdm.h" namespace caf { template<> @@ -97,6 +99,8 @@ RimStatisticsCase::RimStatisticsCase() CAF_PDM_InitField(&m_lowPercentile, "LowPercentile", 10.0, "Low", "", "", ""); CAF_PDM_InitField(&m_midPercentile, "MidPercentile", 50.0, "Mid", "", "", ""); CAF_PDM_InitField(&m_highPercentile, "HighPercentile", 90.0, "High", "", "", ""); + + CAF_PDM_InitField(&m_wellDataSourceCase, "WellDataSourceCase", RimDefines::undefinedResultName(), "Well Data Source Case", "", "", "" ); } //-------------------------------------------------------------------------------------------------- @@ -405,6 +409,20 @@ QList RimStatisticsCase::calculateValueOptions(const caf return toOptionList(varList); } + else if (&m_wellDataSourceCase == fieldNeedingOptions) + { + QStringList sourceCaseNames; + sourceCaseNames += RimDefines::undefinedResultName(); + + for (size_t i = 0; i < caseGroup()->caseCollection()->reservoirs().size(); i++) + { + sourceCaseNames += caseGroup()->caseCollection()->reservoirs()[i]->caseUserDescription(); + } + + return toOptionList(sourceCaseNames); + } + + return options; } @@ -430,9 +448,56 @@ void RimStatisticsCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField m_calculateEditCommand = false; } - //updateSelectionSummaryLabel(); + if (&m_wellDataSourceCase == changedField) + { + RimUiTreeModelPdm* treeModel = RiuMainWindow::instance()->uiPdmModel(); + + // Find or load well data for given case + RimCase* sourceResultCase = caseGroup()->caseCollection()->findByDescription(m_wellDataSourceCase); + if (sourceResultCase) + { + sourceResultCase->openEclipseGridFile(); + + // Propagate well info to statistics case + if (sourceResultCase->reservoirData()) + { + const cvf::Collection& sourceCaseWellResults = sourceResultCase->reservoirData()->wellResults(); + setWellResultsAndUpdateViews(sourceCaseWellResults); + } + } + else + { + cvf::Collection sourceCaseWellResults; + setWellResultsAndUpdateViews(sourceCaseWellResults); + } + } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimStatisticsCase::setWellResultsAndUpdateViews(const cvf::Collection& sourceCaseWellResults) +{ + RimUiTreeModelPdm* treeModel = RiuMainWindow::instance()->uiPdmModel(); + + this->reservoirData()->setWellResults(sourceCaseWellResults); + + // Update views + for (size_t i = 0; i < reservoirViews().size(); i++) + { + RimReservoirView* reservoirView = reservoirViews()[i]; + CVF_ASSERT(reservoirView); + + reservoirView->wellCollection()->wells.deleteAllChildObjects(); + reservoirView->updateDisplayModelForWellResults(); + + treeModel->rebuildUiSubTree(reservoirView->wellCollection()); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- void addPropertySetToHtmlText(QString& html, const QString& heading, const std::vector& varNames) { if (varNames.size()) @@ -608,3 +673,4 @@ void RimStatisticsCase::populateWithDefaultsIfNeeded() if (varList.contains("PORO")) m_selectedFractureStaticProperties.v().push_back("PORO"); } } + diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCase.h b/ApplicationCode/ProjectDataModel/RimStatisticsCase.h index 48891dc982..e56235e24e 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCase.h +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCase.h @@ -29,6 +29,7 @@ class RimIdenticalGridCaseGroup; class RimResultDefinition; class RimStatisticsCaseCollection; class RigMainGrid; +class RigSingleWellResultsData; //================================================================================================== @@ -72,6 +73,8 @@ private: void updateSelectionSummaryLabel(); void updatePercentileUiVisibility(); + void setWellResultsAndUpdateViews(const cvf::Collection& sourceCaseWellResults); + // Pdm system overrides virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) ; virtual QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly ); @@ -104,4 +107,5 @@ private: caf::PdmField m_midPercentile; caf::PdmField m_highPercentile; + caf::PdmField m_wellDataSourceCase; }; diff --git a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp index 383b7d0262..076ef7df8d 100644 --- a/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp +++ b/ApplicationCode/ProjectDataModel/RimUiTreeModelPdm.cpp @@ -385,22 +385,7 @@ RimReservoirView* RimUiTreeModelPdm::addReservoirView(const QModelIndex& itemInd if (collectionItem) { RimCase* rimReservoir = dynamic_cast(collectionItem->dataObject().p()); - - // If the case is one of the source cases in a CaseGroup, but not the main case, we need to - // trigger a complete load of the case, if the new view is the first on the case. - - if (rimReservoir && rimReservoir->parentGridCaseGroup() - && rimReservoir->parentGridCaseGroup()->contains(rimReservoir) - && !(rimReservoir == rimReservoir->parentGridCaseGroup()->mainCase()) - && rimReservoir->reservoirViews().size() == 0) - { - if (rimReservoir->reservoirData()) - { - CVF_ASSERT(rimReservoir->reservoirData()->refCount() == 1); - } - - rimReservoir->removeReservoirData(); - } + rimReservoir->openEclipseGridFile(); RimReservoirView* insertedView = rimReservoir->createAndAddReservoirView(); diff --git a/ApplicationCode/ReservoirDataModel/RigCaseData.h b/ApplicationCode/ReservoirDataModel/RigCaseData.h index 866dec4819..ce4f72dac0 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseData.h +++ b/ApplicationCode/ReservoirDataModel/RigCaseData.h @@ -46,8 +46,8 @@ public: RigGridBase* grid(size_t index); size_t gridCount() const; - RigCaseCellResultsData* results(RifReaderInterface::PorosityModelResultType porosityModel); - const RigCaseCellResultsData* results(RifReaderInterface::PorosityModelResultType porosityModel) const; + RigCaseCellResultsData* results(RifReaderInterface::PorosityModelResultType porosityModel); + const RigCaseCellResultsData* results(RifReaderInterface::PorosityModelResultType porosityModel) const; RigActiveCellInfo* activeCellInfo(RifReaderInterface::PorosityModelResultType porosityModel); const RigActiveCellInfo* activeCellInfo(RifReaderInterface::PorosityModelResultType porosityModel) const; @@ -80,9 +80,9 @@ private: cvf::ref m_activeCellInfo; cvf::ref m_fractureActiveCellInfo; - cvf::ref m_matrixModelResults; - cvf::ref m_fractureModelResults; + cvf::ref m_matrixModelResults; + cvf::ref m_fractureModelResults; - cvf::Collection m_wellResults; //< A WellResults object for each well in the reservoir + cvf::Collection m_wellResults; //< A WellResults object for each well in the reservoir cvf::Collection m_wellCellsInGrid; //< A bool array pr grid with one bool pr cell telling wether the cell is a well cell or not }; From 337e0c32269a54840d2bbf170d1aaded59658f3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Fri, 12 Apr 2013 13:15:41 +0200 Subject: [PATCH 239/242] Added mesh color as preference, and resetting of preferences before doing regression tests p4#: 21263 --- .../Application/RiaApplication.cpp | 1 + .../Application/RiaPreferences.cpp | 20 +++++++++++++++ ApplicationCode/Application/RiaPreferences.h | 4 +++ .../ModelVisualization/RivGridPartMgr.cpp | 25 +++++++++++++++++-- cafProjectDataModel/cafPdmField.h | 3 +++ 5 files changed, 51 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index a06f9679dc..95accf3985 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -1278,6 +1278,7 @@ void RiaApplication::runRegressionTest(const QString& testRootPath) imageCompareReporter.generateHTMLReport(testDir.filePath(RegTestNames::reportFileName).toStdString()); // Generate diff images + this->preferences()->resetToDefaults(); for (int dirIdx = 0; dirIdx < folderList.size(); ++dirIdx) { diff --git a/ApplicationCode/Application/RiaPreferences.cpp b/ApplicationCode/Application/RiaPreferences.cpp index 2dcb049782..37014083a6 100644 --- a/ApplicationCode/Application/RiaPreferences.cpp +++ b/ApplicationCode/Application/RiaPreferences.cpp @@ -38,6 +38,9 @@ RiaPreferences::RiaPreferences(void) octaveExecutable.setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName()); CAF_PDM_InitField(&defaultGridLines, "defaultGridLines", true, "Gridlines", "", "", ""); + CAF_PDM_InitField(&defaultGridLineColors, "defaultGridLineColors", cvf::Color3f(0.92f, 0.92f, 0.92f), "Mesh color", "", "", ""); + CAF_PDM_InitField(&defaultFaultGridLineColors, "defaultFaultGridLineColors", cvf::Color3f(0.08f, 0.08f, 0.08f), "Mesh color along faults", "", "", ""); + CAF_PDM_InitField(&defaultScaleFactorZ, "defaultScaleFactorZ", 5, "Z scale factor", "", "", ""); CAF_PDM_InitField(&useShaders, "useShaders", true, "Use Shaders", "", "", ""); @@ -88,9 +91,26 @@ void RiaPreferences::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& caf::PdmUiGroup* defaultSettingsGroup = uiOrdering.addNewGroup("Default settings"); defaultSettingsGroup->add(&defaultScaleFactorZ); defaultSettingsGroup->add(&defaultGridLines); + defaultSettingsGroup->add(&defaultGridLineColors); + defaultSettingsGroup->add(&defaultFaultGridLineColors); + caf::PdmUiGroup* autoComputeGroup = uiOrdering.addNewGroup("Compute when loading new case"); autoComputeGroup->add(&autocomputeSOIL); autoComputeGroup->add(&autocomputeDepthRelatedProperties); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaPreferences::resetToDefaults() +{ + std::vector fields; + this->fields(fields); + + for (size_t i = 0; i < fields.size(); ++i) + { + fields[i]->resetToDefaultValue(); + } +} + diff --git a/ApplicationCode/Application/RiaPreferences.h b/ApplicationCode/Application/RiaPreferences.h index 528fc147b3..50cc1b3e09 100644 --- a/ApplicationCode/Application/RiaPreferences.h +++ b/ApplicationCode/Application/RiaPreferences.h @@ -29,6 +29,8 @@ public: RiaPreferences(void); virtual ~RiaPreferences(void); + void resetToDefaults(); + public: // Pdm Fields caf::PdmField > navigationPolicy; @@ -38,6 +40,8 @@ public: // Pdm Fields caf::PdmField defaultScaleFactorZ; caf::PdmField defaultGridLines; + caf::PdmField defaultGridLineColors; + caf::PdmField defaultFaultGridLineColors; caf::PdmField useShaders; caf::PdmField showHud; diff --git a/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp b/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp index 64e1f6437c..99a58f3382 100644 --- a/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp @@ -30,6 +30,8 @@ #include "RigGridScalarDataAccess.h" #include "RigCaseCellResultsData.h" #include "RigCaseData.h" +#include "RiaApplication.h" +#include "RiaPreferences.h" //-------------------------------------------------------------------------------------------------- @@ -144,10 +146,12 @@ void RivGridPartMgr::generatePartGeometry(cvf::StructGridGeometryGenerator& geoB part->setTransform(m_scaleTransform.p()); part->updateBoundingBox(); + RiaPreferences* prefs = RiaApplication::instance()->preferences(); + cvf::ref eff; if (faultGeometry) { - caf::MeshEffectGenerator effGen(cvf::Color3f::BLACK); + caf::MeshEffectGenerator effGen(prefs->defaultFaultGridLineColors()); eff = effGen.generateEffect(); part->setEnableMask(meshFaultBit); @@ -156,7 +160,7 @@ void RivGridPartMgr::generatePartGeometry(cvf::StructGridGeometryGenerator& geoB } else { - caf::MeshEffectGenerator effGen(cvf::Color3f::WHITE); + caf::MeshEffectGenerator effGen(prefs->defaultGridLineColors()); eff = effGen.generateEffect(); // Set priority to make sure fault lines are rendered first @@ -205,6 +209,23 @@ void RivGridPartMgr::updateCellColor(cvf::Color4f color) m_opacityLevel = color.a(); m_defaultColor = color.toColor3f(); + + // Update mesh colors as well, in case of change + RiaPreferences* prefs = RiaApplication::instance()->preferences(); + + cvf::ref eff; + if (m_faultFaces.notNull()) + { + caf::MeshEffectGenerator faultEffGen(prefs->defaultFaultGridLineColors()); + eff = faultEffGen.generateEffect(); + m_faultGridLines->setEffect(eff.p()); + } + if (m_surfaceFaces.notNull()) + { + caf::MeshEffectGenerator effGen(prefs->defaultGridLineColors()); + eff = effGen.generateEffect(); + m_surfaceGridLines->setEffect(eff.p()); + } } //-------------------------------------------------------------------------------------------------- diff --git a/cafProjectDataModel/cafPdmField.h b/cafProjectDataModel/cafPdmField.h index 35dfb51042..e3788c7120 100644 --- a/cafProjectDataModel/cafPdmField.h +++ b/cafProjectDataModel/cafPdmField.h @@ -46,6 +46,8 @@ public: PdmFieldHandle() : m_isIOReadable(true), m_isIOWritable(true) { m_ownerObject = NULL; m_keyword = "UNDEFINED"; } virtual ~PdmFieldHandle() { } + virtual void resetToDefaultValue() { }; + virtual void readFieldData(QXmlStreamReader& xmlStream) = 0; virtual void writeFieldData(QXmlStreamWriter& xmlStream) = 0; @@ -119,6 +121,7 @@ public: const DataType& defaultValue() const { return m_defaultFieldValue; } void setDefaultValue(const DataType& val) { m_defaultFieldValue = val; } + virtual void resetToDefaultValue() { m_fieldValue = m_defaultFieldValue; } // Gui generalized interface virtual QVariant uiValue() const; From 987af95391b9f2c1ce3274c1de29d12cafec1aa9 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 12 Apr 2013 15:27:18 +0200 Subject: [PATCH 240/242] Harmonize branches on basis of project external pull requests p4#: 21273 --- CMakeLists.txt | 1 + debian/rules | 0 2 files changed, 1 insertion(+) mode change 100755 => 100644 debian/rules diff --git a/CMakeLists.txt b/CMakeLists.txt index b082632ee5..d99ac20fb8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ project (ResInsight) set (VIZ_MODULES_FOLDER_NAME VisualizationModules) + # Setup the main platform defines #----------------------------------------------------- if (${CMAKE_SYSTEM_NAME} MATCHES "Linux") diff --git a/debian/rules b/debian/rules old mode 100755 new mode 100644 From e0654c98913bc798d6f1b00c24373d2bde2e56da Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 12 Apr 2013 15:53:37 +0200 Subject: [PATCH 241/242] Added progress info when reading well data for statistics case p4#: 21274 --- ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp index a27c66c7d1..5dfa809860 100644 --- a/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimStatisticsCase.cpp @@ -31,6 +31,7 @@ #include "cafPdmUiPushButtonEditor.h" #include "RiuMainWindow.h" #include "RimUiTreeModelPdm.h" +#include "cafProgressInfo.h" namespace caf { template<> @@ -481,6 +482,8 @@ void RimStatisticsCase::setWellResultsAndUpdateViews(const cvf::CollectionuiPdmModel(); this->reservoirData()->setWellResults(sourceCaseWellResults); + + caf::ProgressInfo progInfo(reservoirViews().size() + 1, "Updating Well Data for Views"); // Update views for (size_t i = 0; i < reservoirViews().size(); i++) @@ -492,6 +495,8 @@ void RimStatisticsCase::setWellResultsAndUpdateViews(const cvf::CollectionupdateDisplayModelForWellResults(); treeModel->rebuildUiSubTree(reservoirView->wellCollection()); + + progInfo.incrementProgress(); } } From 35fca6659f8432165940c64ca0cac460763aae64 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Fri, 12 Apr 2013 16:22:50 +0200 Subject: [PATCH 242/242] Updated to version 0.9.4 p4#: 21275 --- ResInsightVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 2570559524..496e427c4b 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -1,7 +1,7 @@ set(CMAKE_MAJOR_VERSION 0) set(CMAKE_MINOR_VERSION 9) -set(CMAKE_PATCH_VERSION 3) +set(CMAKE_PATCH_VERSION 4) set(PRODUCTVER ${CMAKE_MAJOR_VERSION},${CMAKE_MINOR_VERSION},0,${CMAKE_PATCH_VERSION}) set(STRPRODUCTVER ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION})