ResInsight/ApplicationCode/FileInterface/RifEnsembleStatisticsReader.cpp

93 lines
4.0 KiB
C++
Raw Normal View History

/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017- Statoil ASA
2019-03-11 05:45:35 -05: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-03-11 05:45:35 -05: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-03-11 05:45:35 -05:00
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RifEnsembleStatisticsReader.h"
#include "RimEnsembleStatisticsCase.h"
2018-06-13 06:35:33 -05:00
static const std::vector<time_t> EMPTY_TIME_STEPS_VECTOR;
//--------------------------------------------------------------------------------------------------
2019-03-11 05:45:35 -05:00
///
//--------------------------------------------------------------------------------------------------
RifEnsembleStatisticsReader::RifEnsembleStatisticsReader(RimEnsembleStatisticsCase* ensStatCase)
{
CVF_ASSERT(ensStatCase);
m_ensembleStatCase = ensStatCase;
2018-06-25 08:14:47 -05:00
m_allResultAddresses = std::set<RifEclipseSummaryAddress>(
2019-03-11 05:45:35 -05:00
{RifEclipseSummaryAddress::ensembleStatisticsAddress(ENSEMBLE_STAT_P10_QUANTITY_NAME, ""),
RifEclipseSummaryAddress::ensembleStatisticsAddress(ENSEMBLE_STAT_P50_QUANTITY_NAME, ""),
RifEclipseSummaryAddress::ensembleStatisticsAddress(ENSEMBLE_STAT_P90_QUANTITY_NAME, ""),
RifEclipseSummaryAddress::ensembleStatisticsAddress(ENSEMBLE_STAT_MEAN_QUANTITY_NAME, "")});
}
//--------------------------------------------------------------------------------------------------
2019-03-11 05:45:35 -05:00
///
//--------------------------------------------------------------------------------------------------
const std::vector<time_t>& RifEnsembleStatisticsReader::timeSteps(const RifEclipseSummaryAddress& resultAddress) const
{
2018-06-25 08:14:47 -05:00
if (!validateAddress(resultAddress)) return EMPTY_TIME_STEPS_VECTOR;
return m_ensembleStatCase->timeSteps();
}
//--------------------------------------------------------------------------------------------------
2019-03-11 05:45:35 -05:00
///
//--------------------------------------------------------------------------------------------------
bool RifEnsembleStatisticsReader::values(const RifEclipseSummaryAddress& resultAddress, std::vector<double>* values) const
{
if (!validateAddress(resultAddress)) return false;
2019-03-11 05:45:35 -05:00
const std::vector<double>* sourceData = nullptr;
auto quantityName = resultAddress.ensembleStatisticsQuantityName();
2019-03-11 05:45:35 -05:00
if (quantityName == ENSEMBLE_STAT_P10_QUANTITY_NAME)
sourceData = &m_ensembleStatCase->p10();
else if (quantityName == ENSEMBLE_STAT_P50_QUANTITY_NAME)
sourceData = &m_ensembleStatCase->p50();
else if (quantityName == ENSEMBLE_STAT_P90_QUANTITY_NAME)
sourceData = &m_ensembleStatCase->p90();
else if (quantityName == ENSEMBLE_STAT_MEAN_QUANTITY_NAME)
sourceData = &m_ensembleStatCase->mean();
if (!sourceData) return false;
values->clear();
values->reserve(sourceData->size());
2019-03-11 05:45:35 -05:00
for (auto val : *sourceData)
values->push_back(val);
return true;
}
//--------------------------------------------------------------------------------------------------
2019-03-11 05:45:35 -05:00
///
//--------------------------------------------------------------------------------------------------
std::string RifEnsembleStatisticsReader::unitName(const RifEclipseSummaryAddress& resultAddress) const
{
2018-06-25 08:14:47 -05:00
return "";
}
//--------------------------------------------------------------------------------------------------
2019-03-11 05:45:35 -05:00
///
//--------------------------------------------------------------------------------------------------
bool RifEnsembleStatisticsReader::validateAddress(const RifEclipseSummaryAddress& address) const
{
2019-03-11 05:45:35 -05:00
return address.category() == RifEclipseSummaryAddress::SUMMARY_ENSEMBLE_STATISTICS && !address.quantityName().empty();
}