mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2141 Use accumulators to compute min/max used to configure legend
This commit is contained in:
parent
b4b1dfa0f9
commit
2da5f8cf54
@ -24,6 +24,7 @@
|
||||
#include "RigCellGeometryTools.h"
|
||||
#include "RigFractureCell.h"
|
||||
#include "RigFractureGrid.h"
|
||||
#include "RigStatisticsMath.h"
|
||||
#include "RigTesselatorTools.h"
|
||||
|
||||
#include "RimFracture.h"
|
||||
@ -307,6 +308,18 @@ double RimEllipseFractureTemplate::conductivity() const
|
||||
return cond;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimEllipseFractureTemplate::appendDataToResultStatistics(const QString& resultName, const QString& unit, MinMaxAccumulator& minMaxAccumulator, PosNegAccumulator& posNegAccumulator) const
|
||||
{
|
||||
if (resultName.startsWith("CONDUCTIVITY", Qt::CaseInsensitive))
|
||||
{
|
||||
minMaxAccumulator.addValue(conductivity());
|
||||
posNegAccumulator.addValue(conductivity());
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -59,6 +59,10 @@ public:
|
||||
void setDefaultValuesFromUnit();
|
||||
double conductivity() const;
|
||||
|
||||
virtual void appendDataToResultStatistics(const QString& resultName, const QString& unit,
|
||||
MinMaxAccumulator& minMaxAccumulator,
|
||||
PosNegAccumulator& posNegAccumulator) const override;
|
||||
|
||||
protected:
|
||||
virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering);
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
|
@ -35,6 +35,8 @@
|
||||
class RigEclipseCaseData;
|
||||
class RigFractureGrid;
|
||||
class RimFractureContainment;
|
||||
class MinMaxAccumulator;
|
||||
class PosNegAccumulator;
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
@ -86,6 +88,10 @@ public:
|
||||
|
||||
const RimFractureContainment * fractureContainment();
|
||||
|
||||
virtual void appendDataToResultStatistics(const QString& resultName, const QString& unit,
|
||||
MinMaxAccumulator& minMaxAccumulator,
|
||||
PosNegAccumulator& posNegAccumulator) const = 0;
|
||||
|
||||
protected:
|
||||
caf::PdmChildField<RimFractureContainment*> m_fractureContainment;
|
||||
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
#include "RimFractureTemplateCollection.h"
|
||||
|
||||
#include "RigStatisticsMath.h"
|
||||
|
||||
#include "RimEllipseFractureTemplate.h"
|
||||
#include "RimFractureTemplate.h"
|
||||
#include "RimStimPlanFractureTemplate.h"
|
||||
@ -95,16 +97,24 @@ std::vector<QString> RimFractureTemplateCollection::stimPlanResultNames() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimFractureTemplateCollection::computeMinMax(const QString& resultName, const QString& unit, double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const
|
||||
void RimFractureTemplateCollection::computeMinMax(const QString& resultName, const QString& unit, double* minValue,
|
||||
double* maxValue, double* posClosestToZero, double* negClosestToZero) const
|
||||
{
|
||||
MinMaxAccumulator minMaxAccumulator;
|
||||
PosNegAccumulator posNegAccumulator;
|
||||
|
||||
for (const RimFractureTemplate* f : fractureDefinitions())
|
||||
{
|
||||
auto stimPlanFracture = dynamic_cast<const RimStimPlanFractureTemplate*>(f);
|
||||
if (stimPlanFracture)
|
||||
if (f)
|
||||
{
|
||||
stimPlanFracture->computeMinMax(resultName, unit, minValue, maxValue, posClosestToZero, negClosestToZero);
|
||||
f->appendDataToResultStatistics(resultName, unit, minMaxAccumulator, posNegAccumulator);
|
||||
}
|
||||
}
|
||||
|
||||
if (*minValue) *minValue = minMaxAccumulator.min;
|
||||
if (*maxValue) *maxValue = minMaxAccumulator.max;
|
||||
if (*posClosestToZero) *posClosestToZero = posNegAccumulator.pos;
|
||||
if (*negClosestToZero) *negClosestToZero = posNegAccumulator.neg;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -357,17 +357,6 @@ std::vector<std::pair<QString, QString> > RimStimPlanFractureTemplate::resultNam
|
||||
return propertyNamesUnits;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimStimPlanFractureTemplate::computeMinMax(const QString& resultName, const QString& unitName, double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const
|
||||
{
|
||||
if (m_stimPlanFractureDefinitionData.notNull())
|
||||
{
|
||||
m_stimPlanFractureDefinitionData->computeMinMax(resultName, unitName, minValue, maxValue, posClosestToZero, negClosestToZero);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -409,7 +398,20 @@ bool RimStimPlanFractureTemplate::hasConductivity() const
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RimStimPlanFractureTemplate::appendDataToResultStatistics(const QString& resultName, const QString& unit,
|
||||
MinMaxAccumulator& minMaxAccumulator,
|
||||
PosNegAccumulator& posNegAccumulator) const
|
||||
{
|
||||
if (m_stimPlanFractureDefinitionData.notNull())
|
||||
{
|
||||
m_stimPlanFractureDefinitionData->appendDataToResultStatistics(resultName, unit, minMaxAccumulator, posNegAccumulator);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const RigFractureGrid* RimStimPlanFractureTemplate::fractureGrid() const
|
||||
{
|
||||
|
@ -78,11 +78,14 @@ public:
|
||||
|
||||
std::vector<double> timeSteps();
|
||||
std::vector<std::pair<QString, QString> > resultNamesWithUnit() const;
|
||||
void computeMinMax(const QString& resultName, const QString& unitName, double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const;
|
||||
std::vector<std::vector<double>> resultValues(const QString& resultName, const QString& unitName, size_t timeStepIndex) const;
|
||||
std::vector<double> fractureGridResults(const QString& resultName, const QString& unitName, size_t timeStepIndex) const;
|
||||
bool hasConductivity() const;
|
||||
|
||||
virtual void appendDataToResultStatistics(const QString& resultName, const QString& unit,
|
||||
MinMaxAccumulator& minMaxAccumulator,
|
||||
PosNegAccumulator& posNegAccumulator) const override;
|
||||
|
||||
protected:
|
||||
virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override;
|
||||
virtual QList<caf::PdmOptionItemInfo> calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override;
|
||||
|
@ -18,13 +18,16 @@
|
||||
|
||||
#include "RigStimPlanFractureDefinition.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include "RiaLogging.h"
|
||||
#include "RigFractureCell.h"
|
||||
#include "RigFractureGrid.h"
|
||||
#include "RigStatisticsMath.h"
|
||||
|
||||
#include "RivWellFracturePartMgr.h"
|
||||
|
||||
#include "cvfMath.h"
|
||||
#include "RivWellFracturePartMgr.h"
|
||||
#include "RigFractureCell.h"
|
||||
#include "RiaLogging.h"
|
||||
#include "RigFractureGrid.h"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -574,7 +577,8 @@ const std::vector<std::vector<double>>& RigStimPlanFractureDefinition::getDataAt
|
||||
}
|
||||
}
|
||||
|
||||
qDebug() << "ERROR: Requested parameter does not exists in stimPlan data";
|
||||
RiaLogging::error("Requested parameter does not exists in stimPlan data");
|
||||
|
||||
static std::vector<std::vector<double>> emptyVector;
|
||||
return emptyVector;
|
||||
}
|
||||
@ -582,12 +586,10 @@ const std::vector<std::vector<double>>& RigStimPlanFractureDefinition::getDataAt
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigStimPlanFractureDefinition::computeMinMax(const QString& resultName, const QString& unit,
|
||||
double* minValue, double* maxValue,
|
||||
double* posClosestToZero, double* negClosestToZero) const
|
||||
void RigStimPlanFractureDefinition::appendDataToResultStatistics(const QString& resultName, const QString& unit,
|
||||
MinMaxAccumulator& minMaxAccumulator,
|
||||
PosNegAccumulator& posNegAccumulator) const
|
||||
{
|
||||
CVF_ASSERT(minValue && maxValue && posClosestToZero && negClosestToZero);
|
||||
|
||||
size_t resIndex = resultIndex(resultName, unit);
|
||||
if (resIndex == cvf::UNDEFINED_SIZE_T) return;
|
||||
|
||||
@ -595,28 +597,8 @@ void RigStimPlanFractureDefinition::computeMinMax(const QString& resultName, con
|
||||
{
|
||||
for (const auto& values : timeValues)
|
||||
{
|
||||
for (double resultValue : values)
|
||||
{
|
||||
if (resultValue < *minValue)
|
||||
{
|
||||
*minValue = resultValue;
|
||||
}
|
||||
|
||||
if (resultValue > *maxValue)
|
||||
{
|
||||
*maxValue = resultValue;
|
||||
}
|
||||
|
||||
if (resultValue > 0 && resultValue < *posClosestToZero)
|
||||
{
|
||||
*posClosestToZero = resultValue;
|
||||
}
|
||||
|
||||
if (resultValue < 0 && resultValue > *negClosestToZero)
|
||||
{
|
||||
*posClosestToZero = resultValue;
|
||||
}
|
||||
}
|
||||
minMaxAccumulator.addData(values);
|
||||
posNegAccumulator.addData(values);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,8 @@
|
||||
#include "cvfVector3.h"
|
||||
|
||||
class RigFractureGrid;
|
||||
class MinMaxAccumulator;
|
||||
class PosNegAccumulator;
|
||||
|
||||
class RigStimPlanResultFrames
|
||||
{
|
||||
@ -102,7 +104,10 @@ public:
|
||||
std::vector<double> fractureGridResults(const QString& resultName,
|
||||
const QString& unitName,
|
||||
size_t timeStepIndex) const;
|
||||
void computeMinMax(const QString& resultName, const QString& unit, double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const;
|
||||
|
||||
void appendDataToResultStatistics(const QString& resultName, const QString& unit,
|
||||
MinMaxAccumulator& minMaxAccumulator,
|
||||
PosNegAccumulator& posNegAccumulator) const;
|
||||
|
||||
QString conductivityResultName() const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user