2012-05-18 02:45:23 -05:00
/////////////////////////////////////////////////////////////////////////////////
//
// 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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
# pragma once
# include "RimDefines.h"
2012-06-26 09:10:41 -05:00
# include <QDateTime>
# include <vector>
2012-09-11 02:22:36 -05:00
# include <cmath>
2013-02-01 07:39:32 -06:00
# include "RifReaderInterface.h"
2012-05-18 02:45:23 -05:00
2012-06-26 09:10:41 -05:00
class RifReaderInterface ;
class RigMainGrid ;
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 :
2013-03-22 09:43:42 -05:00
RigCaseCellResultsData ( RigMainGrid * ownerGrid ) ;
2012-05-18 02:45:23 -05:00
2013-03-21 09:31:47 -05:00
void setMainGrid ( RigMainGrid * ownerGrid ) ;
2013-03-19 02:28:25 -05:00
2012-06-26 09:10:41 -05:00
// Max and min values of the results
2013-03-18 08:34:29 -05:00
void recalculateMinMax ( size_t scalarResultIndex ) ;
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 ) ;
void p10p90CellScalarValues ( size_t scalarResultIndex , double & p10 , double & p90 ) ;
void meanCellScalarValues ( size_t scalarResultIndex , double & meanValue ) ;
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 ;
2013-03-18 08:34:29 -05:00
QStringList resultNames ( RimDefines : : ResultCatType type ) const ;
bool isUsingGlobalActiveIndex ( size_t scalarResultIndex ) const ;
2012-09-11 02:22:36 -05:00
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 ;
void setTimeStepDates ( size_t scalarResultIndex , const std : : vector < QDateTime > & dates ) ;
2012-05-18 02:45:23 -05:00
2012-06-26 09:10:41 -05:00
// Find or create a slot for the results
2012-05-18 02:45:23 -05:00
2013-03-18 08:34:29 -05:00
size_t findScalarResultIndex ( RimDefines : : ResultCatType type , const QString & resultName ) const ;
size_t findScalarResultIndex ( const QString & resultName ) const ;
2013-03-21 09:31:47 -05:00
size_t addEmptyScalarResult ( RimDefines : : ResultCatType type , const QString & resultName , bool needsToBeStored ) ;
2013-03-18 08:34:29 -05:00
QString makeResultNameUnique ( const QString & resultNameProposal ) const ;
void removeResult ( const QString & resultName ) ;
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 ) ;
double cellScalarResult ( size_t scalarResultIndex , size_t timeStepIndex , size_t resultValueIndex ) ;
2012-05-18 02:45:23 -05:00
2013-02-01 07:39:32 -06:00
static RifReaderInterface : : PorosityModelResultType convertFromProjectModelPorosityModel ( RimDefines : : PorosityModelType porosityModel ) ;
2012-05-18 02:45:23 -05:00
2013-03-18 05:40:39 -05:00
public :
2012-06-26 09:10:41 -05:00
class ResultInfo
{
public :
2013-04-10 04:37:34 -05:00
ResultInfo ( RimDefines : : ResultCatType resultType , bool needsToBeStored , bool mustBeCalculated , QString resultName , size_t gridScalarResultIndex )
: m_resultType ( resultType ) , m_needsToBeStored ( needsToBeStored ) , m_resultName ( resultName ) , m_gridScalarResultIndex ( gridScalarResultIndex ) , m_mustBeCalculated ( mustBeCalculated ) { }
2012-06-26 09:10:41 -05:00
public :
RimDefines : : ResultCatType m_resultType ;
2013-03-21 09:31:47 -05:00
bool m_needsToBeStored ;
2013-04-10 04:37:34 -05:00
bool m_mustBeCalculated ;
2012-06-26 09:10:41 -05:00
QString m_resultName ;
size_t m_gridScalarResultIndex ;
2013-03-21 09:31:47 -05:00
std : : vector < QDateTime > m_timeStepDates ;
2012-06-26 09:10:41 -05:00
} ;
2013-03-18 05:40:39 -05:00
const std : : vector < ResultInfo > & infoForEachResultIndex ( ) { return m_resultInfos ; }
2013-04-10 04:37:34 -05:00
bool mustBeCalculated ( size_t scalarResultIndex ) const ;
void setMustBeCalculated ( size_t scalarResultIndex ) ;
2013-03-18 05:40:39 -05:00
2013-03-18 08:34:29 -05:00
public :
size_t addStaticScalarResult ( RimDefines : : ResultCatType type ,
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-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
std : : vector < std : : pair < double , double > > m_maxMinValues ; ///< Max min values for each Result index
2013-06-03 06:08:11 -05:00
std : : vector < std : : pair < double , double > > m_posNegClosestToZero ;
2013-03-18 05:40:39 -05:00
std : : vector < std : : vector < size_t > > m_histograms ; ///< Histogram for each Result Index
std : : vector < std : : pair < double , double > > m_p10p90 ; ///< P10 and p90 values for each Result Index
std : : vector < double > m_meanValues ; ///< Mean value for each Result Index
std : : vector < std : : vector < std : : pair < double , double > > > m_maxMinValuesPrTs ; ///< Max min values for each Result index and timestep
2013-06-03 06:08:11 -05:00
std : : vector < std : : vector < std : : pair < double , double > > > m_posNegClosestToZeroPrTs ;
2013-03-18 05:40:39 -05:00
private :
2012-06-26 09:10:41 -05:00
std : : vector < ResultInfo > m_resultInfos ;
2013-03-18 08:34:29 -05:00
2012-06-26 09:10:41 -05:00
RigMainGrid * m_ownerMainGrid ;
2012-05-18 02:45:23 -05:00
} ;