mirror of
https://github.com/OPM/ResInsight.git
synced 2025-01-07 06:33:05 -06:00
#1977 Curve Calculator : Get summary values from summary reader
This commit is contained in:
parent
5f39bc5c39
commit
9449bbff20
@ -18,6 +18,9 @@
|
||||
|
||||
#include "RiaSummaryCurveDefinition.h"
|
||||
|
||||
#include "RifSummaryReaderInterface.h"
|
||||
#include "RimSummaryCase.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -42,6 +45,22 @@ const RifEclipseSummaryAddress& RiaSummaryCurveDefinition::summaryAddress() cons
|
||||
return m_curveDefinition.second;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiaSummaryCurveDefinition::resultValues(const RiaSummaryCurveDefinition& curveDefinition, std::vector<double>* values)
|
||||
{
|
||||
CVF_ASSERT(values);
|
||||
|
||||
if (!curveDefinition.summaryAddress().isValid()) return;
|
||||
if (!curveDefinition.summaryCase()) return;
|
||||
|
||||
RifSummaryReaderInterface* reader = curveDefinition.summaryCase()->summaryReader();
|
||||
if (!reader) return;
|
||||
|
||||
reader->values(curveDefinition.summaryAddress(), values);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "RifEclipseSummaryAddress.h"
|
||||
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
class RimSummaryCase;
|
||||
|
||||
@ -37,6 +38,9 @@ public:
|
||||
|
||||
bool operator < (const RiaSummaryCurveDefinition& other) const;
|
||||
|
||||
// TODO: Consider moving to a separate tools class
|
||||
static void resultValues(const RiaSummaryCurveDefinition& curveDefinition, std::vector<double>* values);
|
||||
|
||||
private:
|
||||
std::pair<RimSummaryCase*, RifEclipseSummaryAddress> m_curveDefinition;
|
||||
};
|
||||
|
@ -21,12 +21,15 @@
|
||||
#include "expressionparser/ExpressionParser.h"
|
||||
|
||||
#include "RiaLogging.h"
|
||||
#include "RiaSummaryCurveDefinition.h"
|
||||
|
||||
#include "RimCalculationVariable.h"
|
||||
#include "RimSummaryCurve.h"
|
||||
|
||||
#include "cafPdmUiTextEditor.h"
|
||||
|
||||
#include <numeric>
|
||||
#include <algorithm>
|
||||
#include <numeric>
|
||||
|
||||
|
||||
CAF_PDM_SOURCE_INIT(RimCalculation, "RimCalculation");
|
||||
@ -173,15 +176,50 @@ bool RimCalculation::calculate()
|
||||
|
||||
ExpressionParser parser;
|
||||
|
||||
std::vector<double> a(10);
|
||||
std::iota(a.begin(), a.end(), 0);
|
||||
std::vector<std::vector<double>> variableValues;
|
||||
variableValues.resize(m_variables.size());
|
||||
|
||||
size_t itemCount = 0;
|
||||
|
||||
for (RimCalculationVariable* v : m_variables)
|
||||
for (size_t i = 0; i < m_variables.size(); i++)
|
||||
{
|
||||
itemCount = a.size();
|
||||
parser.assignVector(v->name(), a);
|
||||
RimCalculationVariable* v = m_variables[i];
|
||||
|
||||
if (!v->summaryCase())
|
||||
{
|
||||
RiaLogging::error("No summary case defined.");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!v->summaryAddress())
|
||||
{
|
||||
RiaLogging::error("No summary address defined.");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
RimSummaryAddress* sumAdr = v->summaryAddress();
|
||||
RiaSummaryCurveDefinition curveDef(v->summaryCase(), v->summaryAddress()->address());
|
||||
|
||||
std::vector<double>& curveValues = variableValues[i];
|
||||
RiaSummaryCurveDefinition::resultValues(curveDef, &curveValues);
|
||||
|
||||
if (itemCount == 0)
|
||||
{
|
||||
itemCount = curveValues.size();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (itemCount != curveValues.size())
|
||||
{
|
||||
RiaLogging::error("Not able to evaluate expression varying vector size.");
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
parser.assignVector(v->name(), curveValues);
|
||||
}
|
||||
|
||||
if (itemCount == 0)
|
||||
|
@ -145,6 +145,22 @@ QString RimCalculationVariable::summaryAddressDisplayString() const
|
||||
return txt;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryCase* RimCalculationVariable::summaryCase()
|
||||
{
|
||||
return m_case();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RimSummaryAddress* RimCalculationVariable::summaryAddress()
|
||||
{
|
||||
return m_summaryAddress();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -45,6 +45,9 @@ public:
|
||||
|
||||
QString summaryAddressDisplayString() const;
|
||||
|
||||
RimSummaryCase* summaryCase();
|
||||
RimSummaryAddress* summaryAddress();
|
||||
|
||||
private:
|
||||
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
|
Loading…
Reference in New Issue
Block a user