mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4404 Derived Ensemble: Fix stepping based on data source
This commit is contained in:
parent
74718c38fc
commit
8ce19c742e
@ -1,17 +1,17 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@ -21,22 +21,30 @@
|
||||
#include "RimDerivedEnsembleCase.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<time_t> RifDerivedEnsembleReader::EMPTY_TIME_STEPS_VECTOR;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifDerivedEnsembleReader::RifDerivedEnsembleReader(RimDerivedEnsembleCase* derivedCase)
|
||||
RifDerivedEnsembleReader::RifDerivedEnsembleReader(RimDerivedEnsembleCase* derivedCase,
|
||||
RifSummaryReaderInterface* sourceSummaryReader1)
|
||||
{
|
||||
CVF_ASSERT(derivedCase);
|
||||
|
||||
m_derivedCase = derivedCase;
|
||||
|
||||
if (sourceSummaryReader1)
|
||||
{
|
||||
// TODO: This is assuming that the addresses of both reader interfaces are equal
|
||||
m_allResultAddresses = sourceSummaryReader1->allResultAddresses();
|
||||
m_allErrorAddresses = sourceSummaryReader1->allErrorAddresses();
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<time_t>& RifDerivedEnsembleReader::timeSteps(const RifEclipseSummaryAddress& resultAddress) const
|
||||
{
|
||||
@ -49,7 +57,7 @@ const std::vector<time_t>& RifDerivedEnsembleReader::timeSteps(const RifEclipseS
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifDerivedEnsembleReader::values(const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values) const
|
||||
{
|
||||
@ -62,12 +70,13 @@ bool RifDerivedEnsembleReader::values(const RifEclipseSummaryAddress& resultAddr
|
||||
auto dataValues = m_derivedCase->values(resultAddress);
|
||||
values->clear();
|
||||
values->reserve(dataValues.size());
|
||||
for (auto val : dataValues) values->push_back(val);
|
||||
for (auto val : dataValues)
|
||||
values->push_back(val);
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::string RifDerivedEnsembleReader::unitName(const RifEclipseSummaryAddress& resultAddress) const
|
||||
{
|
||||
|
@ -33,7 +33,7 @@ class RifDerivedEnsembleReader : public RifSummaryReaderInterface
|
||||
static const std::vector<time_t> EMPTY_TIME_STEPS_VECTOR;
|
||||
|
||||
public:
|
||||
RifDerivedEnsembleReader(RimDerivedEnsembleCase* derivedCase);
|
||||
RifDerivedEnsembleReader(RimDerivedEnsembleCase* derivedCase, RifSummaryReaderInterface* sourceSummaryReader1);
|
||||
|
||||
const std::vector<time_t>& timeSteps(const RifEclipseSummaryAddress& resultAddress) const override;
|
||||
bool values(const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values) const override;
|
||||
|
@ -1,17 +1,17 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@ -22,9 +22,8 @@
|
||||
|
||||
#include <QDateTime>
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::set<RifEclipseSummaryAddress>& RifSummaryReaderInterface::allResultAddresses() const
|
||||
{
|
||||
@ -32,7 +31,15 @@ const std::set<RifEclipseSummaryAddress>& RifSummaryReaderInterface::allResultAd
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::set<RifEclipseSummaryAddress>& RifSummaryReaderInterface::allErrorAddresses() const
|
||||
{
|
||||
return m_allErrorAddresses;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifEclipseSummaryAddress RifSummaryReaderInterface::errorAddress(const RifEclipseSummaryAddress& resultAddress) const
|
||||
{
|
||||
@ -43,7 +50,7 @@ RifEclipseSummaryAddress RifSummaryReaderInterface::errorAddress(const RifEclips
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifSummaryReaderInterface::hasAddress(const RifEclipseSummaryAddress& resultAddress) const
|
||||
{
|
||||
|
@ -38,7 +38,10 @@ class RifSummaryReaderInterface : public cvf::Object
|
||||
{
|
||||
public:
|
||||
bool hasAddress(const RifEclipseSummaryAddress& resultAddress) const;
|
||||
|
||||
const std::set<RifEclipseSummaryAddress>& allResultAddresses() const;
|
||||
const std::set<RifEclipseSummaryAddress>& allErrorAddresses() const;
|
||||
|
||||
RifEclipseSummaryAddress errorAddress(const RifEclipseSummaryAddress& resultAddress) const;
|
||||
|
||||
virtual const std::vector<time_t>& timeSteps(const RifEclipseSummaryAddress& resultAddress) const = 0;
|
||||
|
@ -1,17 +1,17 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2016- 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>
|
||||
//
|
||||
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
// for more details.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
@ -28,9 +28,9 @@
|
||||
#include "RimMainPlotCollection.h"
|
||||
#include "RimOilField.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSummaryCaseCollection.h"
|
||||
#include "RimSummaryCaseMainCollection.h"
|
||||
#include "RimSummaryPlotCollection.h"
|
||||
#include "RimSummaryCaseCollection.h"
|
||||
|
||||
#include "cvfAssert.h"
|
||||
|
||||
@ -39,17 +39,19 @@
|
||||
CAF_PDM_ABSTRACT_SOURCE_INIT(RimDerivedEnsembleCase, "RimDerivedEnsembleCase");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<time_t> RimDerivedEnsembleCase::EMPTY_TIME_STEPS_VECTOR;
|
||||
const std::vector<double> RimDerivedEnsembleCase::EMPTY_VALUES_VECTOR;
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimDerivedEnsembleCase::RimDerivedEnsembleCase() : m_summaryCase1(nullptr), m_summaryCase2(nullptr)
|
||||
RimDerivedEnsembleCase::RimDerivedEnsembleCase()
|
||||
: m_summaryCase1(nullptr)
|
||||
, m_summaryCase2(nullptr)
|
||||
{
|
||||
CAF_PDM_InitObject("Summary Case",":/SummaryCase16x16.png","","");
|
||||
CAF_PDM_InitObject("Summary Case", ":/SummaryCase16x16.png", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_summaryCase1, "SummaryCase1", "SummaryCase1", "", "", "");
|
||||
CAF_PDM_InitFieldNoDefault(&m_summaryCase2, "SummaryCase2", "SummaryCase2", "", "", "");
|
||||
|
||||
@ -57,15 +59,12 @@ RimDerivedEnsembleCase::RimDerivedEnsembleCase() : m_summaryCase1(nullptr), m_su
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimDerivedEnsembleCase::~RimDerivedEnsembleCase()
|
||||
{
|
||||
|
||||
}
|
||||
RimDerivedEnsembleCase::~RimDerivedEnsembleCase() {}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimDerivedEnsembleCase::setInUse(bool inUse)
|
||||
{
|
||||
@ -80,7 +79,7 @@ void RimDerivedEnsembleCase::setInUse(bool inUse)
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimDerivedEnsembleCase::isInUse() const
|
||||
{
|
||||
@ -88,7 +87,7 @@ bool RimDerivedEnsembleCase::isInUse() const
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimDerivedEnsembleCase::setSummaryCases(RimSummaryCase* sumCase1, RimSummaryCase* sumCase2)
|
||||
{
|
||||
@ -98,7 +97,7 @@ void RimDerivedEnsembleCase::setSummaryCases(RimSummaryCase* sumCase1, RimSummar
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RimDerivedEnsembleCase::needsCalculation(const RifEclipseSummaryAddress& address) const
|
||||
{
|
||||
@ -106,7 +105,7 @@ bool RimDerivedEnsembleCase::needsCalculation(const RifEclipseSummaryAddress& ad
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<time_t>& RimDerivedEnsembleCase::timeSteps(const RifEclipseSummaryAddress& address) const
|
||||
{
|
||||
@ -115,7 +114,7 @@ const std::vector<time_t>& RimDerivedEnsembleCase::timeSteps(const RifEclipseSum
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<double>& RimDerivedEnsembleCase::values(const RifEclipseSummaryAddress& address) const
|
||||
{
|
||||
@ -124,14 +123,14 @@ const std::vector<double>& RimDerivedEnsembleCase::values(const RifEclipseSummar
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimDerivedEnsembleCase::calculate(const RifEclipseSummaryAddress& address)
|
||||
{
|
||||
clearData(address);
|
||||
|
||||
RifSummaryReaderInterface* reader1 = m_summaryCase1 ? m_summaryCase1->summaryReader() : nullptr;
|
||||
RifSummaryReaderInterface* reader2 = m_summaryCase2 ? m_summaryCase2->summaryReader() : nullptr;
|
||||
RifSummaryReaderInterface* reader1 = m_summaryCase1 ? m_summaryCase1->summaryReader() : nullptr;
|
||||
RifSummaryReaderInterface* reader2 = m_summaryCase2 ? m_summaryCase2->summaryReader() : nullptr;
|
||||
if (!reader1 || !reader2 || !parentEnsemble()) return;
|
||||
|
||||
if (!reader1->hasAddress(address) || !reader2->hasAddress(address))
|
||||
@ -144,10 +143,10 @@ void RimDerivedEnsembleCase::calculate(const RifEclipseSummaryAddress& address)
|
||||
return;
|
||||
}
|
||||
|
||||
RiaTimeHistoryCurveMerger merger;
|
||||
std::vector<double> values1;
|
||||
std::vector<double> values2;
|
||||
DerivedEnsembleOperator op = parentEnsemble()->op();
|
||||
RiaTimeHistoryCurveMerger merger;
|
||||
std::vector<double> values1;
|
||||
std::vector<double> values2;
|
||||
DerivedEnsembleOperator op = parentEnsemble()->op();
|
||||
|
||||
reader1->values(address, &values1);
|
||||
reader2->values(address, &values2);
|
||||
@ -159,7 +158,7 @@ void RimDerivedEnsembleCase::calculate(const RifEclipseSummaryAddress& address)
|
||||
std::vector<double>& allValues1 = merger.interpolatedCurveValuesForAllTimeSteps(0);
|
||||
std::vector<double>& allValues2 = merger.interpolatedCurveValuesForAllTimeSteps(1);
|
||||
|
||||
size_t sampleCount = merger.allTimeSteps().size();
|
||||
size_t sampleCount = merger.allTimeSteps().size();
|
||||
std::vector<double> calculatedValues;
|
||||
calculatedValues.reserve(sampleCount);
|
||||
for (size_t i = 0; i < sampleCount; i++)
|
||||
@ -174,33 +173,46 @@ void RimDerivedEnsembleCase::calculate(const RifEclipseSummaryAddress& address)
|
||||
}
|
||||
}
|
||||
|
||||
auto& dataItem = m_data[address];
|
||||
dataItem.first = merger.allTimeSteps();
|
||||
auto& dataItem = m_data[address];
|
||||
dataItem.first = merger.allTimeSteps();
|
||||
dataItem.second = calculatedValues;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RimDerivedEnsembleCase::caseName() const
|
||||
{
|
||||
auto case1Name = m_summaryCase1->caseName();
|
||||
auto case2Name = m_summaryCase2->caseName();
|
||||
|
||||
if (case1Name == case2Name) return case1Name;
|
||||
else return QString("%1/%2").arg(case1Name).arg(case2Name);
|
||||
if (case1Name == case2Name)
|
||||
return case1Name;
|
||||
else
|
||||
return QString("%1/%2").arg(case1Name).arg(case2Name);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimDerivedEnsembleCase::createSummaryReaderInterface()
|
||||
{
|
||||
m_reader.reset(new RifDerivedEnsembleReader(this));
|
||||
RifSummaryReaderInterface* summaryCase1Reader = nullptr;
|
||||
if (m_summaryCase1)
|
||||
{
|
||||
if (!m_summaryCase1->summaryReader())
|
||||
{
|
||||
m_summaryCase1->createSummaryReaderInterface();
|
||||
}
|
||||
|
||||
summaryCase1Reader = m_summaryCase1->summaryReader();
|
||||
}
|
||||
|
||||
m_reader.reset(new RifDerivedEnsembleReader(this, summaryCase1Reader));
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RifSummaryReaderInterface* RimDerivedEnsembleCase::summaryReader()
|
||||
{
|
||||
@ -208,7 +220,7 @@ RifSummaryReaderInterface* RimDerivedEnsembleCase::summaryReader()
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimDerivedEnsembleCase::updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath)
|
||||
{
|
||||
@ -216,9 +228,9 @@ void RimDerivedEnsembleCase::updateFilePathsFromProjectPath(const QString& newPr
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimDerivedEnsembleCaseCollection * RimDerivedEnsembleCase::parentEnsemble() const
|
||||
RimDerivedEnsembleCaseCollection* RimDerivedEnsembleCase::parentEnsemble() const
|
||||
{
|
||||
RimDerivedEnsembleCaseCollection* ensemble;
|
||||
firstAncestorOrThisOfType(ensemble);
|
||||
@ -226,7 +238,7 @@ RimDerivedEnsembleCaseCollection * RimDerivedEnsembleCase::parentEnsemble() cons
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimDerivedEnsembleCase::clearData(const RifEclipseSummaryAddress& address)
|
||||
{
|
||||
|
@ -152,8 +152,8 @@ void RimDerivedEnsembleCaseCollection::updateDerivedEnsembleCases()
|
||||
if (!sumCase2) continue;
|
||||
|
||||
auto derivedCase = firstCaseNotInUse();
|
||||
derivedCase->createSummaryReaderInterface();
|
||||
derivedCase->setSummaryCases(sumCase1, sumCase2);
|
||||
derivedCase->createSummaryReaderInterface();
|
||||
derivedCase->setCaseRealizationParameters(crp);
|
||||
derivedCase->setInUse(true);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user