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