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
2017-06-13 08:41:52 -05:00
# include "RiaDefines.h"
2019-01-22 03:02:30 -06:00
# include "RiaPorosityModel.h"
2014-08-18 05:03:21 -05:00
2019-03-07 13:38:42 -06:00
# include "RigEclipseResultAddress.h"
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
2019-01-22 03:02:30 -06: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 ;
2018-10-25 07:16:45 -05:00
class RigEclipseCaseData ;
2019-01-22 16:32:30 -06:00
class RigFormationNames ;
2012-05-18 02:45:23 -05:00
2019-01-22 03:02:30 -06:00
class RimEclipseCase ;
2019-01-22 01:54:00 -06:00
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 :
2019-03-07 13:38:42 -06:00
explicit RigCaseCellResultsData ( RigEclipseCaseData * ownerCaseData , RiaDefines : : PorosityModelType porosityModel ) ;
2017-09-08 07:43:28 -05:00
2019-01-28 09:31:57 -06:00
// Initialization
2017-09-08 07:43:28 -05:00
void setReaderInterface ( RifReaderInterface * readerInterface ) ;
2017-09-11 04:03:05 -05:00
void setHdf5Filename ( const QString & hdf5SourSimFilename ) ;
2019-01-22 16:32:30 -06:00
void setActiveFormationNames ( RigFormationNames * activeFormationNames ) ;
RigFormationNames * activeFormationNames ( ) ;
2012-05-18 02:45:23 -05:00
2013-03-21 09:31:47 -05:00
void setMainGrid ( RigMainGrid * ownerGrid ) ;
2018-10-23 14:33:54 -05:00
void setActiveCellInfo ( RigActiveCellInfo * activeCellInfo ) ;
RigActiveCellInfo * activeCellInfo ( ) ;
const RigActiveCellInfo * activeCellInfo ( ) const ;
2013-03-19 02:28:25 -05:00
2019-01-28 09:31:57 -06:00
// Access the results data
const std : : vector < std : : vector < double > > & cellScalarResults ( const RigEclipseResultAddress & resVarAddr ) const ;
const std : : vector < double > & cellScalarResults ( const RigEclipseResultAddress & resVarAddr , size_t timeStepIndex ) const ;
2019-01-28 10:04:50 -06:00
std : : vector < std : : vector < double > > & modifiableCellScalarResultTimesteps ( const RigEclipseResultAddress & resVarAddr ) ;
std : : vector < double > & modifiableCellScalarResult ( const RigEclipseResultAddress & resVarAddr , size_t timeStepIndex ) ;
2019-01-28 09:31:57 -06:00
bool isUsingGlobalActiveIndex ( const RigEclipseResultAddress & resVarAddr ) const ;
static const std : : vector < double > * getResultIndexableStaticResult ( RigActiveCellInfo * actCellInfo ,
RigCaseCellResultsData * gridCellResults ,
QString porvResultName ,
std : : vector < double > & activeCellsResultsTempContainer ) ;
// Statistic values of the results
2019-01-22 01:54:00 -06:00
void recalculateStatistics ( const RigEclipseResultAddress & resVarAddr ) ;
void minMaxCellScalarValues ( const RigEclipseResultAddress & resVarAddr , double & min , double & max ) ;
void minMaxCellScalarValues ( const RigEclipseResultAddress & resVarAddr , size_t timeStepIndex , double & min , double & max ) ;
void posNegClosestToZero ( const RigEclipseResultAddress & resVarAddr , double & pos , double & neg ) ;
void posNegClosestToZero ( const RigEclipseResultAddress & resVarAddr , size_t timeStepIndex , double & pos , double & neg ) ;
const std : : vector < size_t > & cellScalarValuesHistogram ( const RigEclipseResultAddress & resVarAddr ) ;
const std : : vector < size_t > & cellScalarValuesHistogram ( const RigEclipseResultAddress & resVarAddr , size_t timeStepIndex ) ;
void p10p90CellScalarValues ( const RigEclipseResultAddress & resVarAddr , double & p10 , double & p90 ) ;
void p10p90CellScalarValues ( const RigEclipseResultAddress & resVarAddr , size_t timeStepIndex , double & p10 , double & p90 ) ;
void meanCellScalarValues ( const RigEclipseResultAddress & resVarAddr , double & meanValue ) ;
void meanCellScalarValues ( const RigEclipseResultAddress & resVarAddr , size_t timeStepIndex , double & meanValue ) ;
const std : : vector < int > & uniqueCellScalarValues ( const RigEclipseResultAddress & resVarAddr ) ;
void sumCellScalarValues ( const RigEclipseResultAddress & resVarAddr , double & sumValue ) ;
void sumCellScalarValues ( const RigEclipseResultAddress & resVarAddr , size_t timeStepIndex , double & sumValue ) ;
void mobileVolumeWeightedMean ( const RigEclipseResultAddress & resVarAddr , double & meanValue ) ;
void mobileVolumeWeightedMean ( const RigEclipseResultAddress & resVarAddr , size_t timeStepIndex , double & meanValue ) ;
2019-01-22 08:54:54 -06:00
2012-06-26 09:10:41 -05:00
// Access meta-information about the results
2019-01-22 05:49:44 -06:00
2019-01-22 01:54:00 -06:00
size_t timeStepCount ( const RigEclipseResultAddress & resVarAddr ) const ;
2019-01-22 05:32:14 -06:00
size_t maxTimeStepCount ( RigEclipseResultAddress * resultAddressWithMostTimeSteps = nullptr ) 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 ;
2019-01-22 01:54:00 -06:00
std : : vector < QDateTime > timeStepDates ( const RigEclipseResultAddress & resVarAddr ) const ;
2017-04-26 02:39:17 -05:00
std : : vector < double > daysSinceSimulationStart ( ) const ;
2019-01-22 01:54:00 -06:00
std : : vector < double > daysSinceSimulationStart ( const RigEclipseResultAddress & resVarAddr ) const ;
int reportStepNumber ( const RigEclipseResultAddress & resVarAddr , size_t timeStepIndex ) const ;
2017-08-11 02:21:32 -05:00
2019-01-22 01:54:00 -06:00
std : : vector < RigEclipseTimeStepInfo > timeStepInfos ( const RigEclipseResultAddress & resVarAddr ) const ;
void setTimeStepInfos ( const RigEclipseResultAddress & resVarAddr , const std : : vector < RigEclipseTimeStepInfo > & timeStepInfos ) ;
2012-05-18 02:45:23 -05:00
2017-09-11 04:03:05 -05:00
void clearScalarResult ( RiaDefines : : ResultCatType type , const QString & resultName ) ;
2019-01-22 08:22:45 -06:00
void clearScalarResult ( const RigEclipseResultAddress & resultAddress ) ;
2013-03-18 08:34:29 -05:00
void clearAllResults ( ) ;
2013-06-26 16:34:03 -05:00
void freeAllocatedResultsData ( ) ;
2019-01-22 05:49:44 -06:00
void eraseAllSourSimData ( ) ;
2018-06-19 08:28:35 -05:00
2019-01-28 09:31:57 -06:00
QStringList resultNames ( RiaDefines : : ResultCatType type ) const ;
std : : vector < RigEclipseResultAddress > existingResults ( ) const ;
const RigEclipseResultInfo * resultInfo ( const RigEclipseResultAddress & resVarAddr ) const ;
2019-01-30 09:46:16 -06:00
bool updateResultName ( RiaDefines : : ResultCatType resultType , QString & oldName , const QString & newName ) ;
QString makeResultNameUnique ( const QString & resultNameProposal ) const ;
2019-01-22 05:49:44 -06:00
2019-01-28 09:18:28 -06:00
void ensureKnownResultLoadedForTimeStep ( const RigEclipseResultAddress & resultAddress , size_t timeStepIndex ) ;
bool ensureKnownResultLoaded ( const RigEclipseResultAddress & resultAddress ) ;
bool hasResultEntry ( const RigEclipseResultAddress & resultAddress ) const ;
2019-01-28 09:31:57 -06:00
bool isResultLoaded ( const RigEclipseResultAddress & resultAddress ) const ;
2019-01-28 09:18:28 -06:00
void createResultEntry ( const RigEclipseResultAddress & resultAddress , bool needsToBeStored ) ;
2019-01-28 09:31:57 -06:00
void createPlaceholderResultEntries ( ) ;
void computeDepthRelatedResults ( ) ;
void computeCellVolumes ( ) ;
bool hasFlowDiagUsableFluxes ( ) const ;
2019-01-22 08:54:54 -06:00
2019-01-22 03:02:30 -06:00
static void copyResultsMetaDataFromMainCase ( RigEclipseCaseData * mainCaseResultsData ,
RiaDefines : : PorosityModelType poroModel ,
std : : vector < RimEclipseCase * > destinationCases ) ;
2019-01-22 05:49:44 -06:00
private :
2019-01-29 05:44:23 -06:00
size_t findOrLoadKnownScalarResult ( const RigEclipseResultAddress & resVarAddr ) ;
size_t findOrLoadKnownScalarResultForTimeStep ( const RigEclipseResultAddress & resVarAddr ,
2019-01-28 09:18:28 -06:00
size_t timeStepIndex ) ;
2019-01-29 05:44:23 -06:00
size_t findOrCreateScalarResultIndex ( const RigEclipseResultAddress & resVarAddr , bool needsToBeStored ) ;
size_t findScalarResultIndexFromAddress ( const RigEclipseResultAddress & resVarAddr ) const ;
2019-01-28 09:18:28 -06:00
2019-01-22 16:32:30 -06:00
size_t addStaticScalarResult ( RiaDefines : : ResultCatType type ,
const QString & resultName ,
bool needsToBeStored ,
size_t resultValueCount ) ;
2019-01-22 08:22:45 -06:00
const std : : vector < RigEclipseResultInfo > & infoForEachResultIndex ( ) ;
size_t resultCount ( ) const ;
2019-01-22 05:49:44 -06:00
bool mustBeCalculated ( size_t scalarResultIndex ) const ;
void setMustBeCalculated ( size_t scalarResultIndex ) ;
2017-09-08 07:43:28 -05:00
void computeSOILForTimeStep ( size_t timeStepIndex ) ;
2017-11-10 03:36:43 -06:00
void testAndComputeSgasForTimeStep ( size_t timeStepIndex ) ;
2017-11-16 03:50:48 -06:00
2019-01-22 08:54:54 -06:00
bool hasCompleteTransmissibilityResults ( ) const ;
2017-09-08 07:43:28 -05: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 ( ) ;
2018-11-06 06:23:24 -06:00
void computeOilVolumes ( ) ;
2017-11-16 03:50:48 -06:00
void computeMobilePV ( ) ;
2017-09-08 07:43:28 -05:00
bool isDataPresent ( size_t scalarResultIndex ) const ;
2018-10-25 14:08:19 -05:00
void assignValuesToTemporaryLgrs ( const QString & resultName , std : : vector < double > & values ) ;
2018-10-23 14:27:26 -05:00
2019-01-22 05:49:44 -06:00
RigStatisticsDataCache * statistics ( const RigEclipseResultAddress & resVarAddr ) ;
2017-09-08 07:43:28 -05:00
2013-03-18 05:40:39 -05:00
private :
2019-01-22 05:49:44 -06:00
cvf : : ref < RifReaderInterface > m_readerInterface ;
2019-01-22 16:32:30 -06:00
cvf : : ref < RigFormationNames > m_activeFormationNamesData ;
2019-01-22 05:49:44 -06:00
2017-11-16 03:50:48 -06: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 ;
std : : vector < RigEclipseResultInfo > m_resultInfos ;
2013-03-18 08:34:29 -05:00
2017-11-16 03:50:48 -06:00
RigMainGrid * m_ownerMainGrid ;
RigEclipseCaseData * m_ownerCaseData ;
2018-11-06 06:23:24 -06:00
RigActiveCellInfo * m_activeCellInfo ;
2019-03-07 13:38:42 -06:00
RiaDefines : : PorosityModelType m_porosityModel ;
2012-05-18 02:45:23 -05:00
} ;