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; + };