2016-04-12 11:32:28 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) Statoil ASA
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
2016-04-12 11:32:28 +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.
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
2016-04-12 11:32:28 +02:00
|
|
|
// 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.
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2016-04-12 11:32:28 +02:00
|
|
|
// for more details.
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2019-07-25 07:38:46 +02:00
|
|
|
#include "RiaEclipseUnitTools.h"
|
2016-05-04 14:11:04 +02:00
|
|
|
#include "RifEclipseSummaryAddress.h"
|
2017-09-15 14:26:06 +02:00
|
|
|
#include "RifSummaryReaderInterface.h"
|
2016-05-04 14:11:04 +02:00
|
|
|
|
2018-03-15 14:23:48 +01:00
|
|
|
#include <QString>
|
2018-04-17 11:01:24 +02:00
|
|
|
#include <QStringList>
|
2018-03-15 14:23:48 +01:00
|
|
|
|
2016-06-21 15:56:09 +02:00
|
|
|
#include <map>
|
2018-09-13 12:38:17 +02:00
|
|
|
#include <memory>
|
2019-09-06 10:40:57 +02:00
|
|
|
#include <set>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
2018-03-15 14:23:48 +01:00
|
|
|
|
|
|
|
|
//==================================================================================================
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//==================================================================================================
|
|
|
|
|
class RifRestartFileInfo
|
|
|
|
|
{
|
|
|
|
|
public:
|
2019-09-06 10:40:57 +02:00
|
|
|
RifRestartFileInfo()
|
|
|
|
|
: startDate( 0 )
|
|
|
|
|
, endDate( 0 )
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
RifRestartFileInfo( const QString& _fileName, time_t _startDate, time_t _endDate )
|
|
|
|
|
: fileName( _fileName )
|
|
|
|
|
, startDate( _startDate )
|
|
|
|
|
, endDate( _endDate )
|
|
|
|
|
{
|
|
|
|
|
}
|
2020-02-12 11:13:38 +01:00
|
|
|
bool valid() { return !fileName.isEmpty(); }
|
2019-09-06 10:40:57 +02:00
|
|
|
|
|
|
|
|
QString fileName;
|
|
|
|
|
time_t startDate;
|
|
|
|
|
time_t endDate;
|
2018-03-15 14:23:48 +01:00
|
|
|
};
|
|
|
|
|
|
2016-04-12 11:32:28 +02:00
|
|
|
//==================================================================================================
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
//==================================================================================================
|
2017-09-15 14:26:06 +02:00
|
|
|
class RifReaderEclipseSummary : public RifSummaryReaderInterface
|
2016-04-12 11:32:28 +02:00
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
RifReaderEclipseSummary();
|
2018-10-18 19:45:57 +02:00
|
|
|
~RifReaderEclipseSummary() override;
|
2016-04-12 11:32:28 +02:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
bool open( const QString& headerFileName, bool includeRestartFiles );
|
2018-03-15 14:23:48 +01:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
std::vector<RifRestartFileInfo> getRestartFiles( const QString& headerFileName, bool* hasWarnings );
|
|
|
|
|
RifRestartFileInfo getFileInfo( const QString& headerFileName );
|
2016-04-12 11:32:28 +02:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
const std::vector<time_t>& timeSteps( const RifEclipseSummaryAddress& resultAddress ) const override;
|
2016-04-12 11:32:28 +02:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
bool values( const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values ) const override;
|
|
|
|
|
std::string unitName( const RifEclipseSummaryAddress& resultAddress ) const override;
|
|
|
|
|
RiaEclipseUnitTools::UnitSystem unitSystem() const override;
|
2020-02-12 11:13:38 +01:00
|
|
|
QStringList warnings() const { return m_warnings; }
|
2018-04-17 11:01:24 +02:00
|
|
|
|
2019-11-12 17:47:41 +01:00
|
|
|
void markForCachePurge( const RifEclipseSummaryAddress& address ) override;
|
2018-09-13 12:38:17 +02:00
|
|
|
|
2016-04-12 11:32:28 +02:00
|
|
|
private:
|
2019-09-06 10:40:57 +02:00
|
|
|
int timeStepCount() const;
|
|
|
|
|
int indexFromAddress( const RifEclipseSummaryAddress& resultAddress ) const;
|
|
|
|
|
void buildMetaData();
|
|
|
|
|
RifRestartFileInfo getRestartFile( const QString& headerFileName );
|
2016-04-12 11:32:28 +02:00
|
|
|
|
2020-03-18 07:46:18 +01:00
|
|
|
static std::string differenceIdentifier() { return "_DIFF"; }
|
|
|
|
|
|
2016-04-12 11:32:28 +02:00
|
|
|
private:
|
2016-05-31 13:37:50 +02:00
|
|
|
// Taken from ecl_sum.h
|
2016-06-09 10:55:48 +02:00
|
|
|
typedef struct ecl_sum_struct ecl_sum_type;
|
|
|
|
|
typedef struct ecl_smspec_struct ecl_smspec_type;
|
|
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
ecl_sum_type* m_ecl_sum;
|
|
|
|
|
const ecl_smspec_type* m_ecl_SmSpec;
|
|
|
|
|
std::vector<time_t> m_timeSteps;
|
2017-09-21 12:20:09 +02:00
|
|
|
|
2019-07-25 07:38:46 +02:00
|
|
|
RiaEclipseUnitTools::UnitSystem m_unitSystem;
|
|
|
|
|
|
2017-09-21 12:20:09 +02:00
|
|
|
std::map<RifEclipseSummaryAddress, int> m_resultAddressToErtNodeIdx;
|
2018-04-17 11:01:24 +02:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
QStringList m_warnings;
|
2018-09-13 12:38:17 +02:00
|
|
|
|
2020-03-18 07:46:18 +01:00
|
|
|
std::set<RifEclipseSummaryAddress> m_differenceAddresses;
|
|
|
|
|
|
2018-09-13 12:38:17 +02:00
|
|
|
//==================================================================================================
|
|
|
|
|
//
|
|
|
|
|
//==================================================================================================
|
|
|
|
|
class ValuesCache
|
|
|
|
|
{
|
|
|
|
|
static const std::vector<double> EMPTY_VECTOR;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
ValuesCache();
|
|
|
|
|
~ValuesCache();
|
|
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
void insertValues( const RifEclipseSummaryAddress& address, const std::vector<double>& values );
|
|
|
|
|
const std::vector<double>& getValues( const RifEclipseSummaryAddress& address ) const;
|
|
|
|
|
void markAddressForPurge( const RifEclipseSummaryAddress& address );
|
2018-09-13 12:38:17 +02:00
|
|
|
|
|
|
|
|
private:
|
2019-09-06 10:40:57 +02:00
|
|
|
void purgeData();
|
2018-09-13 12:38:17 +02:00
|
|
|
|
|
|
|
|
std::map<const RifEclipseSummaryAddress, std::vector<double>> m_cachedValues;
|
2019-09-06 10:40:57 +02:00
|
|
|
std::set<RifEclipseSummaryAddress> m_purgeList;
|
2018-09-13 12:38:17 +02:00
|
|
|
};
|
|
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
std::unique_ptr<ValuesCache> m_valuesCache;
|
2016-04-12 11:32:28 +02:00
|
|
|
};
|