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"
2012-05-18 09:45:23 +02:00
#include "RimDefines.h"
2014-12-01 10:03:08 +01:00
#include "RigStatisticsDataCache.h"
2014-08-18 12:03:21 +02:00
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 ;
class RigMainGrid ;
2014-08-22 08:07:00 +02:00
class RigActiveCellInfo ;
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 :
2013-03-22 15:43:42 +01:00
RigCaseCellResultsData ( RigMainGrid * ownerGrid );
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 );
void p10p90CellScalarValues ( size_t scalarResultIndex , double & p10 , double & p90 );
void meanCellScalarValues ( size_t scalarResultIndex , double & meanValue );
2012-05-18 09:45:23 +02:00
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 ;
2013-03-19 08:14:35 +01:00
size_t maxTimeStepCount ( size_t * scalarResultIndex = NULL ) const ;
2013-03-18 14:34:29 +01:00
QStringList resultNames ( RimDefines :: ResultCatType type ) const ;
bool isUsingGlobalActiveIndex ( size_t scalarResultIndex ) const ;
2012-09-11 09:22:36 +02:00
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 ;
void setTimeStepDates ( size_t scalarResultIndex , const std :: vector < QDateTime >& dates );
2012-05-18 09:45:23 +02:00
2012-06-26 16:10:41 +02:00
// Find or create a slot for the results
2012-05-18 09:45:23 +02:00
2013-03-18 14:34:29 +01:00
size_t findScalarResultIndex ( RimDefines :: ResultCatType type , const QString & resultName ) const ;
size_t findScalarResultIndex ( const QString & resultName ) const ;
2013-03-21 15:31:47 +01:00
size_t addEmptyScalarResult ( RimDefines :: ResultCatType type , const QString & resultName , bool needsToBeStored );
2013-03-18 14:34:29 +01:00
QString makeResultNameUnique ( const QString & resultNameProposal ) const ;
2014-08-20 11:32:50 +02:00
void createPlaceholderResultEntries ();
2013-12-16 20:26:52 +01:00
2013-03-18 14:34:29 +01:00
void removeResult ( const QString & resultName );
void clearAllResults ();
2013-06-26 23:34:03 +02:00
void freeAllocatedResultsData ();
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 );
double cellScalarResult ( size_t scalarResultIndex , size_t timeStepIndex , size_t resultValueIndex );
2012-05-18 09:45:23 +02:00
2013-02-01 14:39:32 +01:00
static RifReaderInterface :: PorosityModelResultType convertFromProjectModelPorosityModel ( RimDefines :: PorosityModelType porosityModel );
2012-05-18 09:45:23 +02:00
2013-03-18 11:40:39 +01:00
public :
2012-06-26 16:10:41 +02:00
class ResultInfo
{
public :
2013-04-10 11:37:34 +02: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 16:10:41 +02:00
public :
RimDefines :: ResultCatType m_resultType ;
2013-03-21 15:31:47 +01:00
bool m_needsToBeStored ;
2013-04-10 11:37:34 +02:00
bool m_mustBeCalculated ;
2012-06-26 16:10:41 +02:00
QString m_resultName ;
size_t m_gridScalarResultIndex ;
2013-03-21 15:31:47 +01:00
std :: vector < QDateTime > m_timeStepDates ;
2012-06-26 16:10:41 +02:00
};
2013-03-18 11:40:39 +01:00
const std :: vector < ResultInfo >& infoForEachResultIndex () { return m_resultInfos ;}
2013-04-10 11:37:34 +02:00
bool mustBeCalculated ( size_t scalarResultIndex ) const ;
void setMustBeCalculated ( size_t scalarResultIndex );
2013-03-18 11:40:39 +01:00
2013-03-18 14:34:29 +01:00
public :
size_t addStaticScalarResult ( RimDefines :: ResultCatType type ,
const QString & resultName ,
2013-03-21 15:31:47 +01:00
bool needsToBeStored ,
2013-03-18 14:34:29 +01:00
size_t resultValueCount );
2013-12-17 07:31:54 +01:00
2013-12-16 20:26:52 +01:00
bool findTransmissibilityResults ( size_t & tranX , size_t & tranY , size_t & tranZ ) const ;
2013-03-18 11:40:39 +01: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 12:03:21 +02:00
cvf :: Collection < RigStatisticsDataCache > m_statisticsDataCache ;
2013-03-18 11:40:39 +01:00
private :
2012-06-26 16:10:41 +02:00
std :: vector < ResultInfo > m_resultInfos ;
2013-03-18 14:34:29 +01:00
2012-06-26 16:10:41 +02:00
RigMainGrid * m_ownerMainGrid ;
2014-08-22 08:07:00 +02:00
RigActiveCellInfo * m_activeCellInfo ;
2012-06-26 16:10:41 +02:00
2012-05-18 09:45:23 +02:00
};