Merge branch 'dev' into dev-deeper

This commit is contained in:
Gaute Lindkvist 2018-11-26 09:21:33 +01:00
commit 8b7b110440
12 changed files with 243 additions and 102 deletions

View File

@ -22,6 +22,8 @@
#include "RifEclipseSummaryAddress.h"
#include <QString>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -20,9 +20,9 @@
#pragma once
#include <QString>
#include <QByteArray>
#include <string>
#include <cmath>
class QString;
//==================================================================================================
//
@ -33,4 +33,19 @@ class RiaStatisticsTools
{
public:
static const QString replacePercentileByPValueText(const QString& percentile);
template<class NumberType> static bool isInvalidNumber(NumberType value)
{
return !isValidNumber<NumberType>(value);
}
template<class NumberType> static bool isValidNumber(NumberType value)
{
if (std::isinf(value)) return false;
if (std::isnan(value)) return false;
return true;
}
};

View File

@ -325,23 +325,32 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve
{
for (auto wellPath : usedWellPaths)
{
std::vector<RigCompletionData> wellCompletions;
std::vector<RigCompletionData> completionsForWell;
for (const auto& completion : completions)
{
if (completion.wellName() == wellPath->completions()->wellNameForExport())
{
wellCompletions.push_back(completion);
completionsForWell.push_back(completion);
}
}
if (wellCompletions.empty()) continue;
if (completionsForWell.empty()) continue;
std::vector<RicWellPathFractureReportItem> reportItemsForWell;
for (const auto& fracItem : fractureDataReportItems)
{
if (fracItem.wellPathNameForExport() == wellPath->completions()->wellNameForExport())
{
reportItemsForWell.push_back(fracItem);
}
}
QString fileName = QString("%1_unifiedCompletions_%2").arg(wellPath->name()).arg(eclipseCaseName);
sortAndExportCompletionsToFile(exportSettings.caseToApply,
exportSettings.folder,
fileName,
wellCompletions,
fractureDataReportItems,
completionsForWell,
reportItemsForWell,
exportSettings.compdatExport);
progress.incrementProgress();
}
@ -357,17 +366,17 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve
{
for (auto wellPath : usedWellPaths)
{
std::vector<RigCompletionData> wellCompletions;
std::vector<RigCompletionData> completionsForWell;
for (const auto& completion : completions)
{
if (completion.wellName() == wellPath->completions()->wellNameForExport() &&
completionType == completion.completionType())
{
wellCompletions.push_back(completion);
completionsForWell.push_back(completion);
}
}
if (wellCompletions.empty()) continue;
if (completionsForWell.empty()) continue;
{
QString completionTypeText;
@ -378,11 +387,20 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve
QString fileName = QString("%1_%2_%3").arg(wellPath->name()).arg(completionTypeText).arg(eclipseCaseName);
if (completionType == RigCompletionData::FRACTURE)
{
std::vector<RicWellPathFractureReportItem> reportItemsForWell;
for (const auto& fracItem : fractureDataReportItems)
{
if (fracItem.wellPathNameForExport() == wellPath->completions()->wellNameForExport())
{
reportItemsForWell.push_back(fracItem);
}
}
sortAndExportCompletionsToFile(exportSettings.caseToApply,
exportSettings.folder,
fileName,
wellCompletions,
fractureDataReportItems,
completionsForWell,
reportItemsForWell,
exportSettings.compdatExport);
}
else
@ -391,7 +409,7 @@ void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::ve
sortAndExportCompletionsToFile(exportSettings.caseToApply,
exportSettings.folder,
fileName,
wellCompletions,
completionsForWell,
emptyReportItemVector,
exportSettings.compdatExport);
}

View File

@ -25,11 +25,11 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicWellPathFractureReportItem::RicWellPathFractureReportItem(const QString& wellPathName,
RicWellPathFractureReportItem::RicWellPathFractureReportItem(const QString& wellPathNameForExport,
const QString& fractureName,
const QString& fractureTemplateName,
double measuredDepth)
: m_wellPathNameForExport(wellPathName)
: m_wellPathNameForExport(wellPathNameForExport)
, m_wellPathFracture(fractureName)
, m_wellPathFractureTemplate(fractureTemplateName)
, m_mesuredDepth(measuredDepth)

View File

@ -80,24 +80,39 @@ QString RicWellPathFractureTextReportFeatureImpl::wellPathFractureReport(
textStream << lineStart << "\n";
auto proj = RiaApplication::instance()->project();
auto fractureTemplates = proj->activeOilField()->fractureDefinitionCollection()->fractureTemplates();
std::vector<RimStimPlanFractureTemplate*> stimPlanTemplates;
std::vector<RimEllipseFractureTemplate*> ellipseTemplates;
for (const auto fracTemplate : fractureTemplates)
{
auto stimPlanTemplate = dynamic_cast<RimStimPlanFractureTemplate*>(fracTemplate);
if (stimPlanTemplate)
auto proj = RiaApplication::instance()->project();
auto fractureTemplates = proj->activeOilField()->fractureDefinitionCollection()->fractureTemplates();
std::set<QString> usedFractureTemplateNames;
for (const auto& item : wellPathFractureReportItems)
{
stimPlanTemplates.push_back(stimPlanTemplate);
usedFractureTemplateNames.insert(item.fractureTemplateName());
}
auto ellipseTemplate = dynamic_cast<RimEllipseFractureTemplate*>(fracTemplate);
if (ellipseTemplate)
for (const auto fracTemplate : fractureTemplates)
{
ellipseTemplates.push_back(ellipseTemplate);
if (usedFractureTemplateNames.find(fracTemplate->name()) == usedFractureTemplateNames.end())
{
continue;
}
auto stimPlanTemplate = dynamic_cast<RimStimPlanFractureTemplate*>(fracTemplate);
if (stimPlanTemplate)
{
stimPlanTemplates.push_back(stimPlanTemplate);
}
auto ellipseTemplate = dynamic_cast<RimEllipseFractureTemplate*>(fracTemplate);
if (ellipseTemplate)
{
ellipseTemplates.push_back(ellipseTemplate);
}
}
}
@ -136,7 +151,11 @@ QString RicWellPathFractureTextReportFeatureImpl::wellPathFractureReport(
}
{
QString tableText = createFractureText(fractureTemplates);
std::vector<RimFractureTemplate*> fracTemplates;
fracTemplates.insert(fracTemplates.end(), ellipseTemplates.begin(), ellipseTemplates.end());
fracTemplates.insert(fracTemplates.end(), stimPlanTemplates.begin(), stimPlanTemplates.end());
QString tableText = createFractureText(fracTemplates);
textStream << tableText;
textStream << lineStart << "\n";
}
@ -623,7 +642,7 @@ QString RicWellPathFractureTextReportFeatureImpl::createFractureCompletionSummar
RifEclipseOutputTableColumn(meanText, RifEclipseOutputTableDoubleFormatting(RIF_FLOAT, 1), RIGHT), // KfWf
RifEclipseOutputTableColumn(meanText, RifEclipseOutputTableDoubleFormatting(RIF_FLOAT, 1), RIGHT), // Kf
floatNumberColumn(meanText), // wf
RifEclipseOutputTableColumn(meanText, RifEclipseOutputTableDoubleFormatting(RIF_FLOAT, 1), RIGHT), //xf
RifEclipseOutputTableColumn(meanText, RifEclipseOutputTableDoubleFormatting(RIF_FLOAT, 1), RIGHT), // xf
RifEclipseOutputTableColumn(meanText, RifEclipseOutputTableDoubleFormatting(RIF_FLOAT, 1), RIGHT), // H
floatNumberColumn(meanText), // Km
};
@ -698,7 +717,8 @@ QString RicWellPathFractureTextReportFeatureImpl::createFractureCompletionSummar
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RicWellPathFractureTextReportFeatureImpl::createFracturePressureDepletionSummaryText(const std::vector<RicWellPathFractureReportItem>& wellPathFractureReportItems) const
QString RicWellPathFractureTextReportFeatureImpl::createFracturePressureDepletionSummaryText(
const std::vector<RicWellPathFractureReportItem>& wellPathFractureReportItems) const
{
QString tableText;
@ -706,13 +726,11 @@ QString RicWellPathFractureTextReportFeatureImpl::createFracturePressureDepletio
RifEclipseDataTableFormatter formatter(stream);
configureFormatter(&formatter);
std::vector<RifEclipseOutputTableColumn> header = {
RifEclipseOutputTableColumn("Well"),
RifEclipseOutputTableColumn("Fracture"),
RifEclipseOutputTableColumn("Actual WBHP"),
RifEclipseOutputTableColumn("Min Pressure Drop"),
RifEclipseOutputTableColumn("Max Pressure Drop")
};
std::vector<RifEclipseOutputTableColumn> header = {RifEclipseOutputTableColumn("Well"),
RifEclipseOutputTableColumn("Fracture"),
RifEclipseOutputTableColumn("Actual WBHP"),
RifEclipseOutputTableColumn("Min Pressure Drop"),
RifEclipseOutputTableColumn("Max Pressure Drop")};
bool createdTable = false;

View File

@ -29,6 +29,7 @@
#include "RimEclipseCase.h"
#include "RimEclipseView.h"
#include "RimFracture.h"
#include "RimRegularLegendConfig.h"
#include "RimSimWellInViewCollection.h"
#include "RimVirtualPerforationResults.h"
@ -121,16 +122,30 @@ void RivWellConnectionFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::Mode
}
}
bool showConnectionFactorOnWellPath = true;
{
for (const auto& completion : completionsForCell.second)
{
auto fracture = dynamic_cast<const RimFracture*>(completion.sourcePdmObject());
if (fracture)
{
showConnectionFactorOnWellPath = false;
}
}
}
size_t reservoirCellIndex = completionsForCell.first;
const RigCell& rigCell = mainGrid->cell(reservoirCellIndex);
cvf::Vec3d locationInDomainCoord = rigCell.center();
cvf::Vec3d direction = cvf::Vec3d::X_AXIS;
bool foundLocation = false;
if (showConnectionFactorOnWellPath)
{
size_t i = 0;
size_t i = 0;
bool foundLocation = false;
while (!foundLocation && (i < wellPathCellIntersections.size()))
{
const WellPathCellIntersectionInfo& intersectionInfo = wellPathCellIntersections[i];

View File

@ -42,7 +42,7 @@ void RigStatisticsMath::calculateBasicStatistics(const std::vector<double>& valu
for (size_t i = 0; i < values.size(); i++)
{
double val = values[i];
if (val == HUGE_VAL) continue;
if (RiaStatisticsTools::isInvalidNumber<double>(val)) continue;
validValueCount++;
@ -57,7 +57,6 @@ void RigStatisticsMath::calculateBasicStatistics(const std::vector<double>& valu
{
m_mean = m_sum / validValueCount;
// http://en.wikipedia.org/wiki/Standard_deviation#Rapid_calculation_methods
// Running standard deviation
@ -91,7 +90,7 @@ std::vector<double> RigStatisticsMath::calculateNearestRankPercentiles(const std
for (size_t i = 0; i < inputValues.size(); ++i)
{
if (inputValues[i] != HUGE_VAL)
if (RiaStatisticsTools::isValidNumber<double>(inputValues[i]))
{
sortedValues.push_back(inputValues[i]);
}
@ -130,7 +129,7 @@ std::vector<double> RigStatisticsMath::calculateInterpolatedPercentiles(const st
for (size_t i = 0; i < inputValues.size(); ++i)
{
if (inputValues[i] != HUGE_VAL)
if (RiaStatisticsTools::isValidNumber<double>(inputValues[i]))
{
sortedValues.push_back(inputValues[i]);
}
@ -195,10 +194,7 @@ RigHistogramCalculator::RigHistogramCalculator(double min, double max, size_t nB
//--------------------------------------------------------------------------------------------------
void RigHistogramCalculator::addValue(double value)
{
if (value == HUGE_VAL || value != value)
{
return;
}
if (RiaStatisticsTools::isInvalidNumber<double>(value)) return;
size_t index = 0;
@ -262,5 +258,6 @@ double RigHistogramCalculator::calculatePercentil(double pVal)
}
}
assert(false);
return HUGE_VAL;
}

View File

@ -17,6 +17,8 @@
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "RiaStatisticsTools.h"
#include <vector>
#include <set>
#include <cmath>
@ -82,19 +84,17 @@ public:
void addValue(double value)
{
if (value == HUGE_VAL) // TODO
if (RiaStatisticsTools::isValidNumber<double>(value))
{
return;
}
if (value < min)
{
min = value;
}
if (value < min)
{
min = value;
}
if (value > max)
{
max = value;
if (value > max)
{
max = value;
}
}
}
@ -126,19 +126,17 @@ public:
void addValue(double value)
{
if (value == HUGE_VAL)
if (RiaStatisticsTools::isValidNumber<double>(value))
{
return;
}
if (value < pos && value > 0)
{
pos = value;
}
if (value < pos && value > 0)
{
pos = value;
}
if (value > neg && value < 0)
{
neg = value;
if (value > neg && value < 0)
{
neg = value;
}
}
}
@ -170,13 +168,11 @@ public:
void addValue(double value)
{
if (value == HUGE_VAL || value != value)
if (RiaStatisticsTools::isValidNumber<double>(value))
{
return;
valueSum += value;
++sampleCount;
}
valueSum += value;
++sampleCount;
}
double valueSum;
@ -208,7 +204,10 @@ public:
void addValue(double value)
{
uniqueValues.insert(static_cast<int>(value));
if (RiaStatisticsTools::isValidNumber<double>(value))
{
uniqueValues.insert(static_cast<int>(value));
}
}
std::set<int> uniqueValues;

View File

@ -44,7 +44,7 @@ TEST(RigStatisticsMath, BasicTest)
values.push_back(80720.4378655615000);
values.push_back(-98649.8109937874000);
values.push_back(99372.9362079615000);
values.push_back(HUGE_VAL);
values.push_back(-HUGE_VAL);
values.push_back(-57020.4389966513000);
double min, max, sum, range, mean, stdev;
@ -65,7 +65,7 @@ TEST(RigStatisticsMath, BasicTest)
TEST(RigStatisticsMath, RankPercentiles)
{
std::vector<double> values;
values.push_back(HUGE_VAL);
values.push_back(-HUGE_VAL);
values.push_back(2788.2723335651900);
values.push_back(-22481.0927881701000);
values.push_back(68778.6851686236000);
@ -113,8 +113,8 @@ TEST(RigStatisticsMath, HistogramPercentiles)
values.push_back(6391.97999909729003);
values.push_back(65930.1200169780000);
values.push_back(-27696.2320267235000);
values.push_back(HUGE_VAL);
values.push_back(HUGE_VAL);
values.push_back(-HUGE_VAL);
values.push_back(-HUGE_VAL);
values.push_back(96161.7546348456000);
values.push_back(73875.6716288563000);
values.push_back(80720.4378655615000);
@ -179,3 +179,52 @@ TEST(RigStatisticsMath, InterpolatedPercentiles)
EXPECT_DOUBLE_EQ( 6391.9799990972897, pVals[2]);
EXPECT_DOUBLE_EQ( 93073.49128098879, pVals[3]);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TEST(RigStatisticsMath, Accumulators)
{
std::vector<double> values;
const double v1 = 2788.2723335651900;
const double v2 = 68778.6851686236000;
const double v3 = -98649.8109937874000;
const double v4 = -57020.4389966513000;
values.push_back(HUGE_VAL);
values.push_back(v1);
values.push_back(v2);
values.push_back(-HUGE_VAL);
values.push_back(v3);
values.push_back(HUGE_VAL);
values.push_back(v4);
{
MinMaxAccumulator acc;
acc.addData(values);
EXPECT_DOUBLE_EQ(v3, acc.min);
EXPECT_DOUBLE_EQ(v2, acc.max);
}
{
PosNegAccumulator acc;
acc.addData(values);
EXPECT_DOUBLE_EQ(v1, acc.pos);
EXPECT_DOUBLE_EQ(v4, acc.neg);
}
{
SumCountAccumulator acc;
acc.addData(values);
const double sum = v1 + v2 + v3 + v4;
EXPECT_FALSE(std::isinf(acc.valueSum));
EXPECT_DOUBLE_EQ(sum, acc.valueSum);
EXPECT_EQ(4u, acc.sampleCount);
}
}

View File

@ -43,6 +43,7 @@
#include <QBoxLayout>
#include <QCheckBox>
#include <QKeyEvent>
#include <QLabel>
#include <QLineEdit>
#include <QMenu>
@ -89,6 +90,21 @@ public:
m_heightHint = heightHint;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void keyPressEvent(QKeyEvent *event)
{
QTreeView::keyPressEvent(event);
if (event->key() == Qt::Key_Down || event->key() == Qt::Key_Up ||
event->key() == Qt::Key_Home || event->key() == Qt::Key_End ||
event->key() == Qt::Key_PageDown || event->key() == Qt::Key_PageUp)
{
emit clicked(currentIndex());
}
}
private:
int m_heightHint;
};
@ -244,8 +260,8 @@ void PdmUiTreeSelectionEditor::configureAndUpdateUi(const QString& uiConfigName)
m_treeView->setModel(m_proxyModel);
connect(m_treeView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)),
this, SLOT(slotCurrentChanged(QModelIndex, QModelIndex)));
connect(m_treeView->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), this, SLOT(slotCurrentChanged(QModelIndex, QModelIndex)), Qt::UniqueConnection);
}
bool optionsOnly = true;
@ -291,7 +307,7 @@ void PdmUiTreeSelectionEditor::configureAndUpdateUi(const QString& uiConfigName)
m_treeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
}
connect(m_treeView, SIGNAL(clicked(QModelIndex)), this, SLOT(slotClicked(QModelIndex)));
connect(m_treeView, SIGNAL(clicked(QModelIndex)), this, SLOT(slotClicked(QModelIndex)), Qt::UniqueConnection);
if (!m_attributes.showTextFilter)
{
@ -471,6 +487,14 @@ void PdmUiTreeSelectionEditor::customMenuRequested(const QPoint& pos)
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiTreeSelectionEditor::slotCurrentChanged(const QModelIndex& current, const QModelIndex& previous)
{
currentChanged(current);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -574,7 +598,27 @@ void PdmUiTreeSelectionEditor::slotTextFilterChanged()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiTreeSelectionEditor::slotCurrentChanged(const QModelIndex& current, const QModelIndex& previous)
void PdmUiTreeSelectionEditor::slotClicked(const QModelIndex& index)
{
if (m_attributes.setCurrentIndexWhenItemIsChecked && index.isValid())
{
QModelIndexList selectedIndexes = m_treeView->selectionModel()->selectedIndexes();
if (selectedIndexes.size() < 2)
{
QVariant v = m_proxyModel->data(index, Qt::CheckStateRole);
if (v == Qt::Checked)
{
m_treeView->setCurrentIndex(index);
}
}
}
currentChanged(index);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiTreeSelectionEditor::currentChanged(const QModelIndex& current)
{
if (m_attributes.singleSelectionMode)
{
@ -593,25 +637,6 @@ void PdmUiTreeSelectionEditor::slotCurrentChanged(const QModelIndex& current, co
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PdmUiTreeSelectionEditor::slotClicked(const QModelIndex& index)
{
if (m_attributes.setCurrentIndexWhenItemIsChecked && index.isValid())
{
QModelIndexList selectedIndexes = m_treeView->selectionModel()->selectedIndexes();
if (selectedIndexes.size() < 2)
{
QVariant v = m_proxyModel->data(index, Qt::CheckStateRole);
if (v == Qt::Checked)
{
m_treeView->setCurrentIndex(index);
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -103,6 +103,7 @@ protected:
private slots:
void customMenuRequested(const QPoint& pos);
void slotCurrentChanged(const QModelIndex& current, const QModelIndex& previous);
void slotSetSelectedOn();
void slotSetSelectedOff();
void slotSetSubItemsOn();
@ -112,10 +113,11 @@ private slots:
void slotTextFilterChanged();
void slotCurrentChanged(const QModelIndex& current, const QModelIndex& previous);
void slotClicked(const QModelIndex& index);
private:
void currentChanged(const QModelIndex& current);
void setCheckedStateOfSelected(bool checked);
void setCheckedStateForSubItemsOfSelected(bool checked);
void checkAllItems();

View File

@ -46,6 +46,7 @@
#include <algorithm>
#include <QDebug>
//--------------------------------------------------------------------------------------------------
///
@ -485,7 +486,7 @@ bool caf::PdmUiTreeSelectionQModel::setData(const QModelIndex &index, const QVar
}
PdmUiCommandSystemProxy::instance()->setUiValueToField(m_uiFieldHandle->uiField(), fieldValueSelection);
emit dataChanged(index, index);
return true;
}
}