2012-05-18 09:45:23 +02:00
/////////////////////////////////////////////////////////////////////////////////
//
2014-09-23 15:04:57 +02:00
// Copyright (C) 2011- Statoil ASA
// Copyright (C) 2013- Ceetron Solutions AS
// Copyright (C) 2011-2012 Ceetron AS
2012-05-18 09:45:23 +02:00
//
// 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
# pragma once
2014-08-18 12:03:21 +02:00
# include "RifReaderInterface.h"
2017-06-13 15:41:52 +02:00
# include "RiaDefines.h"
2014-08-18 12:03:21 +02:00
2017-01-17 15:11:02 +01:00
# include "cvfCollection.h"
2012-06-26 16:10:41 +02:00
# include <QDateTime>
2014-08-18 12:03:21 +02:00
2012-06-26 16:10:41 +02:00
# include <vector>
2012-09-11 09:22:36 +02:00
# include <cmath>
2012-05-18 09:45:23 +02:00
2012-06-26 16:10:41 +02:00
class RifReaderInterface ;
2014-08-22 08:07:00 +02:00
class RigActiveCellInfo ;
2017-08-11 07:57:55 +02:00
class RigMainGrid ;
2017-08-11 15:10:08 +02:00
class RigEclipseResultInfo ;
2017-01-09 20:51:37 +01:00
class RigStatisticsDataCache ;
2017-08-11 15:10:08 +02:00
class RigEclipseTimeStepInfo ;
2012-05-18 09:45:23 +02:00
//==================================================================================================
/// Class containing the results for the complete number of active cells. Both main grid and LGR's
//==================================================================================================
2013-03-22 15:43:42 +01:00
class RigCaseCellResultsData : public cvf : : Object
2012-05-18 09:45:23 +02:00
{
public :
2017-09-08 14:43:28 +02:00
explicit RigCaseCellResultsData ( RigEclipseCaseData * ownerCaseData ) ;
void setReaderInterface ( RifReaderInterface * readerInterface ) ;
2017-09-11 11:03:05 +02:00
void setHdf5Filename ( const QString & hdf5SourSimFilename ) ;
2012-05-18 09:45:23 +02:00
2013-03-21 15:31:47 +01:00
void setMainGrid ( RigMainGrid * ownerGrid ) ;
2014-08-22 08:07:00 +02:00
void setActiveCellInfo ( RigActiveCellInfo * activeCellInfo ) { m_activeCellInfo = activeCellInfo ; }
RigActiveCellInfo * activeCellInfo ( ) { return m_activeCellInfo ; }
const RigActiveCellInfo * activeCellInfo ( ) const { return m_activeCellInfo ; }
2013-03-19 08:28:25 +01:00
2012-06-26 16:10:41 +02:00
// Max and min values of the results
2014-08-18 12:03:21 +02:00
void recalculateStatistics ( size_t scalarResultIndex ) ;
2013-03-18 14:34:29 +01:00
void minMaxCellScalarValues ( size_t scalarResultIndex , double & min , double & max ) ;
void minMaxCellScalarValues ( size_t scalarResultIndex , size_t timeStepIndex , double & min , double & max ) ;
2013-06-03 13:08:11 +02:00
void posNegClosestToZero ( size_t scalarResultIndex , double & pos , double & neg ) ;
void posNegClosestToZero ( size_t scalarResultIndex , size_t timeStepIndex , double & pos , double & neg ) ;
2013-03-18 14:34:29 +01:00
const std : : vector < size_t > & cellScalarValuesHistogram ( size_t scalarResultIndex ) ;
2015-11-04 15:44:09 +01:00
const std : : vector < size_t > & cellScalarValuesHistogram ( size_t scalarResultIndex , size_t timeStepIndex ) ;
2013-03-18 14:34:29 +01:00
void p10p90CellScalarValues ( size_t scalarResultIndex , double & p10 , double & p90 ) ;
2015-11-04 15:44:09 +01:00
void p10p90CellScalarValues ( size_t scalarResultIndex , size_t timeStepIndex , double & p10 , double & p90 ) ;
2013-03-18 14:34:29 +01:00
void meanCellScalarValues ( size_t scalarResultIndex , double & meanValue ) ;
2015-11-04 15:44:09 +01:00
void meanCellScalarValues ( size_t scalarResultIndex , size_t timeStepIndex , double & meanValue ) ;
2016-09-07 10:28:57 +02:00
const std : : vector < int > & uniqueCellScalarValues ( size_t scalarResultIndex ) ;
2016-08-04 14:15:59 +02:00
void sumCellScalarValues ( size_t scalarResultIndex , double & sumValue ) ;
void sumCellScalarValues ( size_t scalarResultIndex , size_t timeStepIndex , double & sumValue ) ;
2017-11-20 09:24:19 +01:00
void mobileVolumeWeightedMean ( size_t scalarResultIndex , double & meanValue ) ;
2017-11-16 15:28:12 +01:00
void mobileVolumeWeightedMean ( size_t scalarResultIndex , size_t timeStepIndex , double & meanValue ) ;
2012-06-26 16:10:41 +02:00
// Access meta-information about the results
2013-03-18 14:34:29 +01:00
size_t resultCount ( ) const ;
size_t timeStepCount ( size_t scalarResultIndex ) const ;
2018-02-18 18:56:43 +01:00
size_t maxTimeStepCount ( size_t * scalarResultIndex = nullptr ) const ;
2017-06-13 15:41:52 +02:00
QStringList resultNames ( RiaDefines : : ResultCatType type ) const ;
2013-03-18 14:34:29 +01:00
bool isUsingGlobalActiveIndex ( size_t scalarResultIndex ) const ;
2017-01-12 14:16:39 +01:00
bool hasFlowDiagUsableFluxes ( ) const ;
2012-09-11 09:22:36 +02:00
2017-09-11 11:03:05 +02:00
std : : vector < QDateTime > allTimeStepDatesFromEclipseReader ( ) const ;
2017-03-23 13:58:32 +01:00
std : : vector < QDateTime > timeStepDates ( ) const ;
2013-03-18 14:34:29 +01:00
QDateTime timeStepDate ( size_t scalarResultIndex , size_t timeStepIndex ) const ;
std : : vector < QDateTime > timeStepDates ( size_t scalarResultIndex ) const ;
2017-04-26 09:39:17 +02:00
std : : vector < double > daysSinceSimulationStart ( ) const ;
std : : vector < double > daysSinceSimulationStart ( size_t scalarResultIndex ) const ;
2017-01-12 12:04:54 +01:00
int reportStepNumber ( size_t scalarResultIndex , size_t timeStepIndex ) const ;
std : : vector < int > reportStepNumbers ( size_t scalarResultIndex ) const ;
2017-08-11 09:21:32 +02:00
2017-11-16 10:50:48 +01:00
std : : vector < RigEclipseTimeStepInfo > timeStepInfos ( size_t scalarResultIndex ) const ;
2017-08-11 15:10:08 +02:00
void setTimeStepInfos ( size_t scalarResultIndex , const std : : vector < RigEclipseTimeStepInfo > & timeStepInfos ) ;
2012-05-18 09:45:23 +02:00
2017-09-08 14:43:28 +02:00
size_t findOrLoadScalarResultForTimeStep ( RiaDefines : : ResultCatType type , const QString & resultName , size_t timeStepIndex ) ;
size_t findOrLoadScalarResult ( RiaDefines : : ResultCatType type , const QString & resultName ) ;
size_t findOrLoadScalarResult ( const QString & resultName ) ; ///< Simplified search. Assumes unique names across types.
2012-06-26 16:10:41 +02:00
// Find or create a slot for the results
2012-05-18 09:45:23 +02:00
2017-08-25 06:58:47 +02:00
size_t findOrCreateScalarResultIndex ( RiaDefines : : ResultCatType type , const QString & resultName , bool needsToBeStored ) ;
2017-06-13 15:41:52 +02:00
size_t findScalarResultIndex ( RiaDefines : : ResultCatType type , const QString & resultName ) const ;
2013-03-18 14:34:29 +01:00
size_t findScalarResultIndex ( const QString & resultName ) const ;
QString makeResultNameUnique ( const QString & resultNameProposal ) const ;
2014-08-20 11:32:50 +02:00
void createPlaceholderResultEntries ( ) ;
2017-09-08 14:43:28 +02:00
void computeDepthRelatedResults ( ) ;
2013-12-16 20:26:52 +01:00
2017-09-11 11:03:05 +02:00
void clearScalarResult ( RiaDefines : : ResultCatType type , const QString & resultName ) ;
2018-06-19 13:20:15 +02:00
void clearScalarResult ( const RigEclipseResultInfo & resultInfo ) ;
2013-03-18 14:34:29 +01:00
void clearAllResults ( ) ;
2013-06-26 23:34:03 +02:00
void freeAllocatedResultsData ( ) ;
2018-06-19 15:28:35 +02:00
bool isResultLoaded ( const RigEclipseResultInfo & resultInfo ) const ;
2012-05-18 09:45:23 +02:00
2012-06-26 16:10:41 +02:00
// Access the results data
2013-03-21 15:31:47 +01:00
2013-03-18 14:34:29 +01:00
const std : : vector < std : : vector < double > > & cellScalarResults ( size_t scalarResultIndex ) const ;
std : : vector < std : : vector < double > > & cellScalarResults ( size_t scalarResultIndex ) ;
std : : vector < double > & cellScalarResults ( size_t scalarResultIndex , size_t timeStepIndex ) ;
2012-05-18 09:45:23 +02:00
2017-06-13 15:41:52 +02:00
bool updateResultName ( RiaDefines : : ResultCatType resultType , QString & oldName , const QString & newName ) ;
2016-10-21 13:57:15 +02:00
2017-11-16 10:22:55 +01:00
static const std : : vector < double > * getResultIndexableStaticResult ( RigActiveCellInfo * actCellInfo ,
2017-11-16 10:50:48 +01:00
RigCaseCellResultsData * gridCellResults ,
QString porvResultName ,
std : : vector < double > & activeCellsResultsTempContainer ) ;
2013-03-18 11:40:39 +01:00
public :
2017-11-16 10:50:48 +01:00
const std : : vector < RigEclipseResultInfo > & infoForEachResultIndex ( ) { return m_resultInfos ; }
2013-04-10 11:37:34 +02:00
2017-11-16 10:50:48 +01:00
bool mustBeCalculated ( size_t scalarResultIndex ) const ;
void setMustBeCalculated ( size_t scalarResultIndex ) ;
void eraseAllSourSimData ( ) ;
2013-04-10 11:37:34 +02:00
2013-03-18 11:40:39 +01:00
2013-03-18 14:34:29 +01:00
public :
2017-11-16 10:50:48 +01:00
size_t addStaticScalarResult ( RiaDefines : : ResultCatType type ,
const QString & resultName ,
bool needsToBeStored ,
size_t resultValueCount ) ;
2013-12-17 07:31:54 +01:00
2017-09-08 14:43:28 +02:00
bool
2017-11-16 10:50:48 +01:00
findTransmissibilityResults ( size_t & tranX , size_t & tranY , size_t & tranZ ) const ;
2017-09-08 14:43:28 +02:00
private : // from RimReservoirCellResultsStorage
void computeSOILForTimeStep ( size_t timeStepIndex ) ;
2017-11-10 10:36:43 +01:00
void testAndComputeSgasForTimeStep ( size_t timeStepIndex ) ;
2017-11-16 10:50:48 +01:00
2017-09-08 14:43:28 +02:00
void computeRiTransComponent ( const QString & riTransComponentResultName ) ;
void computeNncCombRiTrans ( ) ;
void computeRiMULTComponent ( const QString & riMultCompName ) ;
void computeNncCombRiMULT ( ) ;
void computeRiTRANSbyAreaComponent ( const QString & riTransByAreaCompResultName ) ;
void computeNncCombRiTRANSbyArea ( ) ;
void computeCompletionTypeForTimeStep ( size_t timeStep ) ;
double darchysValue ( ) ;
2017-11-16 10:50:48 +01:00
void computeMobilePV ( ) ;
2017-09-08 14:43:28 +02:00
bool isDataPresent ( size_t scalarResultIndex ) const ;
cvf : : ref < RifReaderInterface > m_readerInterface ;
2013-03-18 11:40:39 +01:00
private :
2017-11-16 10:50:48 +01:00
std : : vector < std : : vector < std : : vector < double > > > m_cellScalarResults ; ///< Scalar results on the complete reservoir for each Result index (ResultVariable) and timestep
cvf : : Collection < RigStatisticsDataCache > m_statisticsDataCache ;
2013-03-18 11:40:39 +01:00
private :
2017-11-16 10:50:48 +01:00
std : : vector < RigEclipseResultInfo > m_resultInfos ;
2013-03-18 14:34:29 +01:00
2017-11-16 10:50:48 +01:00
RigMainGrid * m_ownerMainGrid ;
RigEclipseCaseData * m_ownerCaseData ;
RigActiveCellInfo * m_activeCellInfo ;
2012-05-18 09:45:23 +02:00
} ;