#1813 Observed data: Make summary reader interface and make observed data reader object

This commit is contained in:
Rebecca Cox
2017-09-15 14:26:06 +02:00
parent 1a6e3447a7
commit 1ac50e178e
7 changed files with 306 additions and 71 deletions

View File

@@ -15,6 +15,8 @@ ${CEE_CURRENT_LIST_DIR}RifEclipseUnifiedRestartFileAccess.h
${CEE_CURRENT_LIST_DIR}RifPerforationIntervalReader.h
${CEE_CURRENT_LIST_DIR}RifReaderEclipseInput.h
${CEE_CURRENT_LIST_DIR}RifReaderEclipseOutput.h
${CEE_CURRENT_LIST_DIR}RifSummaryReaderInterface.h
${CEE_CURRENT_LIST_DIR}RifReaderObservedData.h
${CEE_CURRENT_LIST_DIR}RifReaderEclipseSummary.h
${CEE_CURRENT_LIST_DIR}RifJsonEncodeDecode.h
${CEE_CURRENT_LIST_DIR}RifReaderInterface.h
@@ -45,6 +47,8 @@ ${CEE_CURRENT_LIST_DIR}RifEclipseSummaryTools.cpp
${CEE_CURRENT_LIST_DIR}RifPerforationIntervalReader.cpp
${CEE_CURRENT_LIST_DIR}RifReaderEclipseInput.cpp
${CEE_CURRENT_LIST_DIR}RifReaderEclipseOutput.cpp
${CEE_CURRENT_LIST_DIR}RifSummaryReaderInterface.cpp
${CEE_CURRENT_LIST_DIR}RifReaderObservedData.cpp
${CEE_CURRENT_LIST_DIR}RifReaderEclipseSummary.cpp
${CEE_CURRENT_LIST_DIR}RifJsonEncodeDecode.cpp
${CEE_CURRENT_LIST_DIR}RifReaderInterface.cpp

View File

@@ -231,16 +231,6 @@ RifEclipseSummaryAddress addressFromErtSmSpecNode(const smspec_node_type * ertSu
cellI, cellJ, cellK);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<RifEclipseSummaryAddress>& RifReaderEclipseSummary::allResultAddresses()
{
buildMetaData();
return m_allResultAddresses;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -293,38 +283,6 @@ const std::vector<time_t>& RifReaderEclipseSummary::timeSteps() const
return m_timeSteps;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<QDateTime> RifReaderEclipseSummary::fromTimeT(const std::vector<time_t>& timeSteps)
{
std::vector<QDateTime> a;
for (size_t i = 0; i < timeSteps.size(); i++)
{
QDateTime dt = QDateTime::fromTime_t(timeSteps[i]);
a.push_back(dt);
}
return a;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RifReaderEclipseSummary::indexFromAddress(const RifEclipseSummaryAddress& resultAddress)
{
this->buildMetaData();
auto it = m_resultAddressToErtNodeIdx.find(resultAddress);
if (it != m_resultAddressToErtNodeIdx.end())
{
return it->second;
}
return -1;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -343,17 +301,6 @@ void RifReaderEclipseSummary::buildMetaData()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifReaderEclipseSummary::hasAddress(const RifEclipseSummaryAddress& resultAddress)
{
this->buildMetaData();
auto it = m_resultAddressToErtNodeIdx.find(resultAddress);
return (it != m_resultAddressToErtNodeIdx.end());
}
//--------------------------------------------------------------------------------------------------
///

View File

@@ -19,6 +19,7 @@
#pragma once
#include "RifEclipseSummaryAddress.h"
#include "RifSummaryReaderInterface.h"
#include <string>
#include <vector>
@@ -34,30 +35,23 @@ class QDateTime;
//
//
//==================================================================================================
class RifReaderEclipseSummary : public cvf::Object
class RifReaderEclipseSummary : public RifSummaryReaderInterface
{
public:
RifReaderEclipseSummary();
~RifReaderEclipseSummary();
bool open(const std::string& headerFileName, const std::vector<std::string>& dataFileNames);
virtual bool open(const std::string& headerFileName, const std::vector<std::string>& dataFileNames) override;
bool hasAddress(const RifEclipseSummaryAddress& resultAddress);
const std::vector<RifEclipseSummaryAddress>& allResultAddresses();
const std::vector<time_t>& timeSteps() const;
virtual const std::vector<time_t>& timeSteps() const override;
bool values(const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values);
std::string unitName(const RifEclipseSummaryAddress& resultAddress);
virtual bool values(const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values) override;
std::string unitName(const RifEclipseSummaryAddress& resultAddress) override;
// TODO: Move this to a tools class with static members
static std::vector<QDateTime> fromTimeT(const std::vector<time_t>& timeSteps);
private:
virtual int timeStepCount() const override;
int timeStepCount() const;
int indexFromAddress(const RifEclipseSummaryAddress& resultAddress);
void buildMetaData();
virtual void buildMetaData() override;
private:
// Taken from ecl_sum.h
typedef struct ecl_sum_struct ecl_sum_type;
@@ -66,9 +60,5 @@ private:
ecl_sum_type* m_ecl_sum;
const ecl_smspec_type * m_ecl_SmSpec;
std::vector<time_t> m_timeSteps;
std::vector<RifEclipseSummaryAddress> m_allResultAddresses;
std::map<RifEclipseSummaryAddress, int> m_resultAddressToErtNodeIdx;
};

View File

@@ -0,0 +1,94 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- Statoil ASA
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RifReaderObservedData.h"
#include "ert/ecl/ecl_sum.h"
#include <string>
#include <assert.h>
#include <QDateTime>
#include "ert/ecl/smspec_node.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifReaderObservedData::RifReaderObservedData()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RifReaderObservedData::~RifReaderObservedData()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifReaderObservedData::open(const std::string& headerFileName, const std::vector<std::string>& dataFileNames)
{
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifReaderObservedData::values(const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values)
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RifReaderObservedData::timeStepCount() const
{
return 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<time_t>& RifReaderObservedData::timeSteps() const
{
std::vector<time_t> steps;
return steps;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifReaderObservedData::buildMetaData()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string RifReaderObservedData::unitName(const RifEclipseSummaryAddress& resultAddress)
{
std::string str = "";
return str;
}

View File

@@ -0,0 +1,59 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- Statoil ASA
//
// 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 "RifEclipseSummaryAddress.h"
#include "RifSummaryReaderInterface.h"
#include <string>
#include <vector>
#include <map>
#include "cvfObject.h"
class QDateTime;
//==================================================================================================
//
//
//==================================================================================================
class RifReaderObservedData : public RifSummaryReaderInterface
{
public:
RifReaderObservedData();
~RifReaderObservedData();
virtual bool open(const std::string& headerFileName, const std::vector<std::string>& dataFileNames) override;
virtual const std::vector<time_t>& timeSteps() const override;
virtual bool values(const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values) override;
std::string unitName(const RifEclipseSummaryAddress& resultAddress) override;
private:
virtual int timeStepCount() const override;
virtual void buildMetaData() override;
private:
};

View File

@@ -0,0 +1,78 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- Statoil ASA
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RifSummaryReaderInterface.h"
#include <string>
#include <QDateTime>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<RifEclipseSummaryAddress>& RifSummaryReaderInterface::allResultAddresses()
{
this->buildMetaData();
return m_allResultAddresses;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<QDateTime> RifSummaryReaderInterface::fromTimeT(const std::vector<time_t>& timeSteps)
{
std::vector<QDateTime> a;
for (size_t i = 0; i < timeSteps.size(); i++)
{
QDateTime dt = QDateTime::fromTime_t(timeSteps[i]);
a.push_back(dt);
}
return a;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RifSummaryReaderInterface::indexFromAddress(const RifEclipseSummaryAddress& resultAddress)
{
this->buildMetaData();
auto it = m_resultAddressToErtNodeIdx.find(resultAddress);
if (it != m_resultAddressToErtNodeIdx.end())
{
return it->second;
}
return -1;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RifSummaryReaderInterface::hasAddress(const RifEclipseSummaryAddress& resultAddress)
{
this->buildMetaData();
auto it = m_resultAddressToErtNodeIdx.find(resultAddress);
return (it != m_resultAddressToErtNodeIdx.end());
}

View File

@@ -0,0 +1,63 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- Statoil ASA
//
// 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 "RifEclipseSummaryAddress.h"
#include <string>
#include <vector>
#include <map>
#include "cvfObject.h"
class QDateTime;
//==================================================================================================
//
//
//==================================================================================================
class RifSummaryReaderInterface : public cvf::Object
{
public:
virtual bool open(const std::string& headerFileName, const std::vector<std::string>& dataFileNames) = 0;
bool hasAddress(const RifEclipseSummaryAddress& resultAddress);
const std::vector<RifEclipseSummaryAddress>& allResultAddresses();
virtual const std::vector<time_t>& timeSteps() const = 0;
virtual bool values(const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values) = 0;
virtual std::string unitName(const RifEclipseSummaryAddress& resultAddress) = 0;
// TODO: Move this to a tools class with static members
static std::vector<QDateTime> fromTimeT(const std::vector<time_t>& timeSteps);
protected:
virtual int timeStepCount() const = 0;
int indexFromAddress(const RifEclipseSummaryAddress& resultAddress);
virtual void buildMetaData() = 0;
protected:
std::vector<RifEclipseSummaryAddress> m_allResultAddresses;
std::map<RifEclipseSummaryAddress, int> m_resultAddressToErtNodeIdx;
};