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