#2127 Sim Well Branches : Major refactor of sim well branch computation

Remove local branch geometry caches
Add checkbox to control if branch detection should be used
Add RiaSimWllBranchTools and move helper functions from RimProject
This commit is contained in:
Magne Sjaastad 2017-12-07 14:51:58 +01:00
parent 94a4bfeea5
commit 1841379e64
23 changed files with 345 additions and 312 deletions

View File

@ -22,6 +22,7 @@ ${CEE_CURRENT_LIST_DIR}RiaSummaryTools.h
${CEE_CURRENT_LIST_DIR}RiaWellNameComparer.h
${CEE_CURRENT_LIST_DIR}RiaStdStringTools.h
${CEE_CURRENT_LIST_DIR}RiaSummaryCurveAnalyzer.h
${CEE_CURRENT_LIST_DIR}RiaSimWellBranchTools.h
)
set (SOURCE_GROUP_SOURCE_FILES
@ -41,6 +42,7 @@ ${CEE_CURRENT_LIST_DIR}RiaSummaryTools.cpp
${CEE_CURRENT_LIST_DIR}RiaWellNameComparer.cpp
${CEE_CURRENT_LIST_DIR}RiaStdStringTools.cpp
${CEE_CURRENT_LIST_DIR}RiaSummaryCurveAnalyzer.cpp
${CEE_CURRENT_LIST_DIR}RiaSimWellBranchTools.cpp
)
list(APPEND CODE_HEADER_FILES

View File

@ -0,0 +1,68 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RiaSimWellBranchTools.h"
#include "RiaApplication.h"
#include "RigEclipseCaseData.h"
#include "RimEclipseCase.h"
#include "RimProject.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<const RigWellPath*> RiaSimWellBranchTools::simulationWellBranches(const QString& simWellName, bool useAutoDetectionOfBranches)
{
RiaApplication* app = RiaApplication::instance();
RimProject* proj = app->project();
// Find first case containing the specified simulation well
auto simCases = proj->eclipseCases();
auto caseItr = std::find_if(simCases.begin(), simCases.end(), [&simWellName](const RimEclipseCase* eclCase) {
const auto& eclData = eclCase->eclipseCaseData();
return eclData != nullptr && eclData->hasSimulationWell(simWellName);
});
RimEclipseCase* eclipseCase = caseItr != simCases.end() ? *caseItr : nullptr;
RigEclipseCaseData* eclCaseData = eclipseCase != nullptr ? eclipseCase->eclipseCaseData() : nullptr;
return eclCaseData != nullptr ?
eclCaseData->simulationWellBranches(simWellName, false, useAutoDetectionOfBranches) :
std::vector<const RigWellPath*>();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RiaSimWellBranchTools::valueOptionsForBranchIndexField(const std::vector<const RigWellPath*>& simulationWellPaths)
{
QList<caf::PdmOptionItemInfo> options;
size_t branchCount = simulationWellPaths.size();
if (simulationWellPaths.size() == 0)
{
options.push_front(caf::PdmOptionItemInfo("None", -1));
}
else
{
for (int bIdx = 0; bIdx < static_cast<int>(branchCount); ++bIdx)
{
options.push_back(caf::PdmOptionItemInfo("Branch " + QString::number(bIdx + 1), QVariant::fromValue(bIdx)));
}
}
return options;
}

View File

@ -0,0 +1,42 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QList>
#include <QString>
#include <vector>
class RigWellPath;
namespace caf
{
class PdmOptionItemInfo;
}
//==================================================================================================
//
//==================================================================================================
class RiaSimWellBranchTools
{
public:
static std::vector<const RigWellPath*> simulationWellBranches(const QString& simWellName, bool useAutoDetectionOfBranches);
static QList<caf::PdmOptionItemInfo> valueOptionsForBranchIndexField(const std::vector<const RigWellPath*>& simulationWellPaths);
};

View File

@ -167,7 +167,7 @@ RimWellPath* RicWellLogTools::selectedWellPathWithLogFile()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellLogExtractionCurve* RicWellLogTools::addExtractionCurve(RimWellLogTrack* plotTrack, RimView* view, RimWellPath* wellPath, const RimSimWellInView* simWell, int branchIndex)
RimWellLogExtractionCurve* RicWellLogTools::addExtractionCurve(RimWellLogTrack* plotTrack, RimView* view, RimWellPath* wellPath, const RimSimWellInView* simWell, int branchIndex, bool useBranchDetection)
{
CVF_ASSERT(plotTrack);
RimWellLogExtractionCurve* curve = new RimWellLogExtractionCurve();
@ -182,7 +182,7 @@ RimWellLogExtractionCurve* RicWellLogTools::addExtractionCurve(RimWellLogTrack*
}
if (simWell)
{
curve->setFromSimulationWellName(simWell->name(), branchIndex);
curve->setFromSimulationWellName(simWell->name(), branchIndex, useBranchDetection);
plotTrack->setFormationSimWellName(simWell->name());
plotTrack->setFormationBranchIndex(branchIndex);
plotTrack->setFormationTrajectoryType(RimWellLogTrack::SIMULATION_WELL);

View File

@ -1,23 +1,27 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QString>
#include <vector>
class RimSimWellInView;
class RimView;
class RimWellLogExtractionCurve;
@ -27,24 +31,23 @@ class RimWellLogRftCurve;
class RimWellLogTrack;
class RimWellPath;
#include <QString>
#include <vector>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class RicWellLogTools
{
public:
static RimWellLogTrack* selectedWellLogPlotTrack();
static RimSimWellInView* selectedSimulationWell(int *branchIndex);
static RimWellPath* selectedWellPath();
static bool wellHasRftData(const QString& wellName);
static bool isWellPathOrSimWellSelectedInView();
static void addWellLogChannelsToPlotTrack(RimWellLogTrack* plotTrack, const std::vector<RimWellLogFileChannel*>& wellLogFileChannels);
static RimWellPath* selectedWellPathWithLogFile();
static RimWellLogExtractionCurve* addExtractionCurve(RimWellLogTrack* plotTrack, RimView* view, RimWellPath* wellPath, const RimSimWellInView* simWell, int branchIndex);
static RimWellLogRftCurve* addRftCurve(RimWellLogTrack* plotTrack, const RimSimWellInView* simWell);
static RimWellLogFileCurve* addFileCurve(RimWellLogTrack* plotTrack);
};
static RimWellLogTrack* selectedWellLogPlotTrack();
static RimSimWellInView* selectedSimulationWell(int* branchIndex);
static RimWellPath* selectedWellPath();
static bool wellHasRftData(const QString& wellName);
static bool isWellPathOrSimWellSelectedInView();
static void addWellLogChannelsToPlotTrack(RimWellLogTrack* plotTrack,
const std::vector<RimWellLogFileChannel*>& wellLogFileChannels);
static RimWellPath* selectedWellPathWithLogFile();
static RimWellLogExtractionCurve* addExtractionCurve(RimWellLogTrack* plotTrack, RimView* view, RimWellPath* wellPath,
const RimSimWellInView* simWell, int branchIndex,
bool useBranchDetection);
static RimWellLogRftCurve* addRftCurve(RimWellLogTrack* plotTrack, const RimSimWellInView* simWell);
static RimWellLogFileCurve* addFileCurve(RimWellLogTrack* plotTrack);
};

View File

@ -44,6 +44,7 @@
#include <QAction>
#include <vector>
#include "RimSimWellInViewCollection.h"
CAF_CMD_SOURCE_INIT(RicNewWellLogCurveExtractionFeature, "RicNewWellLogCurveExtractionFeature");
@ -69,17 +70,29 @@ void RicNewWellLogCurveExtractionFeature::onActionTriggered(bool isChecked)
RimWellLogTrack* wellLogPlotTrack = RicWellLogTools::selectedWellLogPlotTrack();
if (wellLogPlotTrack)
{
RicWellLogTools::addExtractionCurve(wellLogPlotTrack, nullptr, nullptr, nullptr, -1);
RicWellLogTools::addExtractionCurve(wellLogPlotTrack, nullptr, nullptr, nullptr, -1, true);
}
else
{
RimWellPath* wellPath = RicWellLogTools::selectedWellPath();
int branchIndex = -1;
RimSimWellInView* simWell = RicWellLogTools::selectedSimulationWell(&branchIndex);
bool useBranchDetection = true;
RimSimWellInViewCollection* simWellColl = nullptr;
if (simWell)
{
simWell->firstAncestorOrThisOfTypeAsserted(simWellColl);
useBranchDetection = simWellColl->isAutoDetectingBranches;
}
if (wellPath || simWell)
{
RimWellLogTrack* wellLogPlotTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack();
RimWellLogExtractionCurve* plotCurve = RicWellLogTools::addExtractionCurve(wellLogPlotTrack, RiaApplication::instance()->activeReservoirView(), wellPath, simWell, branchIndex);
RimWellLogExtractionCurve* plotCurve =
RicWellLogTools::addExtractionCurve(wellLogPlotTrack, RiaApplication::instance()->activeReservoirView(), wellPath,
simWell, branchIndex, useBranchDetection);
plotCurve->loadDataAndUpdate(true);

View File

@ -53,7 +53,7 @@ bool RicNewWellLogPlotFeature::isCommandEnabled()
void RicNewWellLogPlotFeature::onActionTriggered(bool isChecked)
{
RimWellLogTrack* plotTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack();
RicWellLogTools::addExtractionCurve(plotTrack, nullptr, nullptr, nullptr, -1);
RicWellLogTools::addExtractionCurve(plotTrack, nullptr, nullptr, nullptr, -1, true);
}
//--------------------------------------------------------------------------------------------------

View File

@ -62,7 +62,7 @@ void RicNewWellLogPlotTrackFeature::onActionTriggered(bool isChecked)
plotTrack->setDescription(QString("Track %1").arg(wellLogPlot->trackCount()));
wellLogPlot->updateConnectedEditors();
RicWellLogTools::addExtractionCurve(plotTrack, nullptr, nullptr, nullptr, -1);
RicWellLogTools::addExtractionCurve(plotTrack, nullptr, nullptr, nullptr, -1, true);
}
}

View File

@ -835,7 +835,7 @@ void RimWellAllocationPlot::updateFormationNamesData() const
for (size_t i = 0; i < m_accumulatedWellFlowPlot->trackCount(); ++i)
{
RimWellLogTrack* track = m_accumulatedWellFlowPlot->trackByIndex(i);
track->setAndUpdateSimWellFormationNamesData(m_case, m_wellName, track->formationBranchIndex());
track->setAndUpdateSimWellFormationNamesData(m_case, m_wellName);
}
}

View File

@ -21,6 +21,7 @@
#include "RiaApplication.h"
#include "RiaColorTables.h"
#include "RiaDateStringParser.h"
#include "RiaSimWellBranchTools.h"
#include "RifReaderEclipseRft.h"
@ -46,6 +47,7 @@
#include "RimWellLogTrack.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "RimWellPltPlot.h"
#include "RiuWellRftPlot.h"
@ -55,7 +57,6 @@
#include <algorithm>
#include <iterator>
#include <tuple>
#include "RimWellPltPlot.h"
CAF_PDM_SOURCE_INIT(RimWellRftPlot, "WellRftPlot");
@ -83,6 +84,8 @@ RimWellRftPlot::RimWellRftPlot()
CAF_PDM_InitFieldNoDefault(&m_wellPathNameOrSimWellName, "WellName", "Well Name", "", "", "");
CAF_PDM_InitField(&m_branchIndex, "BranchIndex", 0, "Branch Index", "", "", "");
CAF_PDM_InitField(&m_branchDetection, "BranchDetection", true, "Branch Detection", "",
"Compute branches based on how simulation well cells are organized", "");
CAF_PDM_InitFieldNoDefault(&m_selectedSources, "Sources", "Sources", "", "", "");
m_selectedSources.uiCapability()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName());
@ -102,7 +105,25 @@ RimWellRftPlot::RimWellRftPlot()
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
RimWellLogTrack::TrajectoryType trajectoryTypeFromWellName(const QString& wellPathOrSimWellName)
{
RimWellLogTrack::TrajectoryType trajectoryType = RimWellLogTrack::SIMULATION_WELL;
RimProject* proj = RiaApplication::instance()->project();
RimWellPath* wellPath = proj->wellPathByName(wellPathOrSimWellName);
if (wellPath)
{
trajectoryType = RimWellLogTrack::WELL_PATH;
}
return trajectoryType;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimWellRftPlot::~RimWellRftPlot()
{
@ -234,20 +255,11 @@ void RimWellRftPlot::updateFormationsOnPlot() const
{
if (m_wellLogPlot->trackCount() > 0)
{
RimWellLogTrack::TrajectoryType trajectoryType = trajectoryTypeFromWellName(m_wellPathNameOrSimWellName);
RimProject* proj = RiaApplication::instance()->project();
RimWellPath* wellPath = proj->wellPathByName(m_wellPathNameOrSimWellName);
RimWellLogTrack::TrajectoryType trajectoryType;
if ( wellPath )
{
trajectoryType = RimWellLogTrack::WELL_PATH;
}
else
{
trajectoryType = RimWellLogTrack::SIMULATION_WELL;
}
RimCase* formationNamesCase = m_wellLogPlot->trackByIndex(0)->formationNamesCase();
if ( !formationNamesCase )
@ -264,7 +276,7 @@ void RimWellRftPlot::updateFormationsOnPlot() const
if (trajectoryType == RimWellLogTrack::SIMULATION_WELL)
{
m_wellLogPlot->trackByIndex(0)->setAndUpdateSimWellFormationNamesData(formationNamesCase, associatedSimWellName(), m_branchIndex);
m_wellLogPlot->trackByIndex(0)->setAndUpdateSimWellFormationNamesAndBranchData(formationNamesCase, associatedSimWellName(), m_branchIndex, m_branchDetection);
}
else if (trajectoryType == RimWellLogTrack::WELL_PATH)
{
@ -487,7 +499,7 @@ void RimWellRftPlot::updateCurvesInPlot(const std::set<RiaRftPltCurveDefinition>
cvf::Color3f curveColor = RiaColorTables::wellLogPlotPaletteColors().cycledColor3f(plotTrack->curveCount());
curve->setColor(curveColor);
curve->setFromSimulationWellName(simWellName, m_branchIndex);
curve->setFromSimulationWellName(simWellName, m_branchIndex, m_branchDetection);
// Fetch cases and time steps
auto gridCase = curveDefToAdd.address().eclCase();
@ -676,19 +688,9 @@ QList<caf::PdmOptionItemInfo> RimWellRftPlot::calculateValueOptions(const caf::P
}
else if (fieldNeedingOptions == &m_branchIndex)
{
RimProject* proj = RiaApplication::instance()->project();
auto simulationWellBranches = RiaSimWellBranchTools::simulationWellBranches(simWellName, m_branchDetection);
size_t branchCount = proj->simulationWellBranches(simWellName).size();
for (int bIdx = 0; bIdx < static_cast<int>(branchCount); ++bIdx)
{
options.push_back(caf::PdmOptionItemInfo("Branch " + QString::number(bIdx + 1), QVariant::fromValue(bIdx)));
}
if (options.size() == 0)
{
options.push_front(caf::PdmOptionItemInfo("None", -1));
}
options = RiaSimWellBranchTools::valueOptionsForBranchIndexField(simulationWellBranches);
}
return options;
@ -706,7 +708,7 @@ void RimWellRftPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c
setDescription(QString(plotNameFormatString()).arg(m_wellPathNameOrSimWellName));
}
if (changedField == &m_wellPathNameOrSimWellName || changedField == &m_branchIndex)
if (changedField == &m_wellPathNameOrSimWellName)
{
if (changedField == &m_wellPathNameOrSimWellName)
{
@ -719,11 +721,14 @@ void RimWellRftPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c
updateEditorsFromCurves();
updateFormationsOnPlot();
}
else if (changedField == &m_selectedSources)
else if (changedField == &m_branchIndex ||
changedField == &m_branchDetection)
{
}
updateFormationsOnPlot();
syncCurvesFromUiSelection();
if (changedField == &m_selectedSources ||
}
else if (changedField == &m_selectedSources ||
changedField == &m_selectedTimeSteps)
{
updateFormationsOnPlot();
@ -773,11 +778,15 @@ void RimWellRftPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
uiOrdering.add(&m_userName);
uiOrdering.add(&m_wellPathNameOrSimWellName);
RimProject* proj = RiaApplication::instance()->project();
if (proj->simulationWellBranches(associatedSimWellName()).size() > 1)
if (trajectoryTypeFromWellName(m_wellPathNameOrSimWellName) == RimWellLogTrack::SIMULATION_WELL)
{
uiOrdering.add(&m_branchIndex);
uiOrdering.add(&m_branchDetection);
if (RiaSimWellBranchTools::simulationWellBranches(associatedSimWellName(), m_branchDetection).size() > 1)
{
uiOrdering.add(&m_branchIndex);
}
}
caf::PdmUiGroup* sourcesGroup = uiOrdering.addNewGroupWithKeyword("Sources", "Sources");

View File

@ -135,6 +135,8 @@ private:
caf::PdmField<QString> m_wellPathNameOrSimWellName;
caf::PdmField<int> m_branchIndex;
caf::PdmField<bool> m_branchDetection;
caf::PdmField<std::vector<RifDataSourceForRftPlt>> m_selectedSources;
caf::PdmField<std::vector<QDateTime>> m_selectedTimeSteps;

View File

@ -217,7 +217,6 @@ void RimProject::close()
plotWindowTreeViewState = "";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -813,24 +812,6 @@ std::vector<QString> RimProject::simulationWellNames() const
return std::vector<QString>(wellNames.begin(), wellNames.end());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<const RigWellPath*> RimProject::simulationWellBranches(const QString& simWellName)
{
// Find first case containing the specified simulation well
auto simCases = eclipseCases();
auto caseItr = std::find_if(simCases.begin(), simCases.end(), [&simWellName](const RimEclipseCase* eclCase) {
const auto& eclData = eclCase->eclipseCaseData();
return eclData != nullptr && eclData->hasSimulationWell(simWellName);
});
RimEclipseCase* eclipseCase = caseItr != simCases.end() ? *caseItr : nullptr;
RigEclipseCaseData* eclCaseData = eclipseCase != nullptr ? eclipseCase->eclipseCaseData() : nullptr;
return eclCaseData != nullptr ?
eclCaseData->simulationWellBranches(simWellName) :
std::vector<const RigWellPath*>();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -126,7 +126,7 @@ public:
std::vector<RimEclipseCase*> eclipseCases() const;
std::vector<QString> simulationWellNames() const;
std::vector<const RigWellPath*> simulationWellBranches(const QString& simWellName);
RimWellPath* wellPathFromSimWellName(const QString& simWellName, int branchIndex = -1);
RimWellPath* wellPathByName(const QString& wellPathName) const;
std::vector<RimWellPath*> allWellPaths() const;

View File

@ -20,6 +20,7 @@
#include "RimWellLogExtractionCurve.h"
#include "RiaApplication.h"
#include "RiaSimWellBranchTools.h"
#include "RigCaseCellResultsData.h"
#include "RigEclipseCaseData.h"
@ -93,7 +94,9 @@ RimWellLogExtractionCurve::RimWellLogExtractionCurve()
m_wellPath.uiCapability()->setUiTreeChildrenHidden(true);
CAF_PDM_InitField(&m_simWellName, "SimulationWellName", QString("None"), " ", "", "", "");
CAF_PDM_InitField(&m_branchIndex, "Branch", 0, " ", "", "", "");
CAF_PDM_InitField(&m_branchDetection, "BranchDetection", true, "Branch Detection", "",
"Compute branches based on how simulation well cells are organized", "");
CAF_PDM_InitField(&m_branchIndex, "Branch", 0, "Branch Index", "", "", "");
CAF_PDM_InitFieldNoDefault(&m_case, "CurveCase", "Case", "", "", "");
m_case.uiCapability()->setUiTreeChildrenHidden(true);
@ -150,11 +153,12 @@ RimWellPath* RimWellLogExtractionCurve::wellPath() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogExtractionCurve::setFromSimulationWellName(const QString& simWellName, int branchIndex)
void RimWellLogExtractionCurve::setFromSimulationWellName(const QString& simWellName, int branchIndex, bool branchDetection)
{
m_trajectoryType = SIMULATION_WELL;
m_simWellName = simWellName;
m_branchIndex = branchIndex;
m_branchDetection = branchDetection;
clearGeneratedSimWellPaths();
}
@ -225,7 +229,7 @@ void RimWellLogExtractionCurve::clampTimestep()
//--------------------------------------------------------------------------------------------------
void RimWellLogExtractionCurve::clampBranchIndex()
{
int branchCount = static_cast<int>(m_generatedSimulationWellPathBranches.size());
int branchCount = static_cast<int>(simulationWellBranches().size());
if ( branchCount > 0 )
{
if ( m_branchIndex >= branchCount ) m_branchIndex = branchCount - 1;
@ -265,9 +269,16 @@ void RimWellLogExtractionCurve::fieldChangedByUi(const caf::PdmFieldHandle* chan
this->loadDataAndUpdate(true);
}
else if (changedField == &m_trajectoryType ||
else if (changedField == &m_trajectoryType)
{
this->loadDataAndUpdate(true);
}
else if (changedField == &m_branchDetection ||
changedField == &m_branchIndex ||
changedField == &m_branchIndex)
{
clearGeneratedSimWellPaths();
this->loadDataAndUpdate(true);
}
else if (changedField == &m_timeStep)
@ -303,7 +314,6 @@ void RimWellLogExtractionCurve::onLoadDataAndUpdate(bool updateParentPlot)
m_eclipseResultDefinition->setEclipseCase(eclipseCase);
m_geomResultDefinition->setGeoMechCase(geomCase);
updateGeneratedSimulationWellpath();
clampBranchIndex();
RimMainPlotCollection* mainPlotCollection;
@ -321,12 +331,19 @@ void RimWellLogExtractionCurve::onLoadDataAndUpdate(bool updateParentPlot)
}
else
{
if (m_branchIndex >= 0 && m_branchIndex < static_cast<int>(m_generatedSimulationWellPathBranches.size()))
std::vector<const RigWellPath*> simWellBranches = simulationWellBranches();
if (m_branchIndex >= 0 && m_branchIndex < static_cast<int>(simWellBranches.size()))
{
auto wellBranch = simWellBranches[m_branchIndex];
eclExtractor = wellLogCollection->findOrCreateSimWellExtractor(m_simWellName,
eclipseCase->caseUserDescription(),
m_generatedSimulationWellPathBranches[m_branchIndex].p(),
wellBranch,
eclipseCase->eclipseCaseData());
if (eclExtractor.notNull())
{
m_wellPathsWithExtractors.push_back(wellBranch);
}
isUsingPseudoLength = true;
}
}
@ -451,51 +468,6 @@ std::set<QString> RimWellLogExtractionCurve::findSortedWellNames()
return sortedWellNames;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogExtractionCurve::updateGeneratedSimulationWellpath()
{
if (m_generatedSimulationWellPathBranches.size()) return; // Already created. Nothing to do
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(m_case.value());
if (!(!m_simWellName().isEmpty() && m_simWellName() != "None" && eclipseCase && eclipseCase->eclipseCaseData()))
{
return ;
}
RigEclipseCaseData* eclCaseData = eclipseCase->eclipseCaseData();
const RigSimWellData* simWellData = eclCaseData->findSimWellData(m_simWellName());
if (!simWellData) return;
std::vector< std::vector <cvf::Vec3d> > pipeBranchesCLCoords;
std::vector< std::vector <RigWellResultPoint> > pipeBranchesCellIds;
RigSimulationWellCenterLineCalculator::calculateWellPipeCenterlineFromWellFrame(eclCaseData,
simWellData,
-1,
true,
true,
pipeBranchesCLCoords,
pipeBranchesCellIds);
for ( size_t brIdx = 0; brIdx < pipeBranchesCLCoords.size(); ++brIdx )
{
auto wellMdCalculator = RigSimulationWellCoordsAndMD(pipeBranchesCLCoords[brIdx]); // Todo, branch index
cvf::ref<RigWellPath> newWellPath = new RigWellPath();
newWellPath->m_measuredDepths = wellMdCalculator.measuredDepths();
newWellPath->m_wellPathPoints = wellMdCalculator.wellPathPoints();
m_generatedSimulationWellPathBranches.push_back(newWellPath.p() );
}
}
//--------------------------------------------------------------------------------------------------
/// Clean up existing generated well paths
//--------------------------------------------------------------------------------------------------
@ -510,12 +482,20 @@ void RimWellLogExtractionCurve::clearGeneratedSimWellPaths()
if (!wellLogCollection) return;
for ( size_t wpIdx = 0; wpIdx < m_generatedSimulationWellPathBranches.size(); ++wpIdx )
for (auto wellPath : m_wellPathsWithExtractors)
{
wellLogCollection->removeExtractors(m_generatedSimulationWellPathBranches[wpIdx].p());
wellLogCollection->removeExtractors(wellPath);
}
m_generatedSimulationWellPathBranches.clear();
m_wellPathsWithExtractors.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<const RigWellPath*> RimWellLogExtractionCurve::simulationWellBranches() const
{
return RiaSimWellBranchTools::simulationWellBranches(m_simWellName, m_branchDetection);
}
//--------------------------------------------------------------------------------------------------
@ -571,24 +551,14 @@ QList<caf::PdmOptionItemInfo> RimWellLogExtractionCurve::calculateValueOptions(c
}
else if (fieldNeedingOptions == &m_branchIndex)
{
updateGeneratedSimulationWellpath();
auto branches = simulationWellBranches();
size_t branchCount = m_generatedSimulationWellPathBranches.size();
for ( int bIdx = 0; bIdx < static_cast<int>(branchCount); ++bIdx)
{
options.push_back(caf::PdmOptionItemInfo("Branch " + QString::number(bIdx + 1), QVariant::fromValue(bIdx) ));
}
if (options.size() == 0)
{
options.push_front(caf::PdmOptionItemInfo("None", -1));
}
options = RiaSimWellBranchTools::valueOptionsForBranchIndexField(branches);
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -611,7 +581,9 @@ void RimWellLogExtractionCurve::defineUiOrdering(QString uiConfigName, caf::PdmU
else
{
curveDataGroup->add(&m_simWellName);
if ( m_generatedSimulationWellPathBranches.size() > 1 )
curveDataGroup->add(&m_branchDetection);
if ( simulationWellBranches().size() > 1 )
{
curveDataGroup->add(&m_branchIndex);
}
@ -713,7 +685,7 @@ QString RimWellLogExtractionCurve::createCurveAutoName()
if (!wellName().isEmpty())
{
generatedCurveName += wellName();
if (m_trajectoryType == SIMULATION_WELL && m_generatedSimulationWellPathBranches.size() > 1)
if (m_trajectoryType == SIMULATION_WELL && simulationWellBranches().size() > 1)
{
generatedCurveName.push_back(" Br" + QString::number(m_branchIndex + 1));
}

View File

@ -23,14 +23,13 @@
#include "cafPdmPtrField.h"
#include "cafPdmChildField.h"
#include "cvfCollection.h"
class RigWellPath;
class RimCase;
class RimEclipseResultDefinition;
class RimGeoMechResultDefinition;
class RimView;
class RimWellPath;
class RigWellPath;
//==================================================================================================
///
@ -48,7 +47,7 @@ public:
void setWellPath(RimWellPath* wellPath);
RimWellPath* wellPath() const;
void setFromSimulationWellName(const QString& simWellName, int branchIndex);
void setFromSimulationWellName(const QString& simWellName, int branchIndex, bool branchDetection);
void setCase(RimCase* rimCase);
RimCase* rimCase() const;
@ -83,8 +82,8 @@ private:
void clampTimestep();
void clampBranchIndex();
std::set<QString> findSortedWellNames();
void updateGeneratedSimulationWellpath();
void clearGeneratedSimWellPaths();
std::vector<const RigWellPath*> simulationWellBranches() const;
private:
caf::PdmPtrField<RimCase*> m_case;
@ -92,6 +91,7 @@ private:
caf::PdmPtrField<RimWellPath*> m_wellPath;
caf::PdmField<QString> m_simWellName;
caf::PdmField<int> m_branchIndex;
caf::PdmField<bool> m_branchDetection;
caf::PdmChildField<RimEclipseResultDefinition*> m_eclipseResultDefinition;
caf::PdmChildField<RimGeoMechResultDefinition*> m_geomResultDefinition;
@ -103,6 +103,5 @@ private:
caf::PdmField<bool> m_addTimestepToCurveName;
caf::PdmField<bool> m_addDateToCurveName;
cvf::Collection<RigWellPath> m_generatedSimulationWellPathBranches;
std::vector<const RigWellPath*> m_wellPathsWithExtractors;
};

View File

@ -21,6 +21,7 @@
#include "RiaApplication.h"
#include "RiaEclipseUnitTools.h"
#include "RiaSimWellBranchTools.h"
#include "RimEclipseResultCase.h"
#include "RimMainPlotCollection.h"
@ -484,7 +485,7 @@ RigEclipseWellLogExtractor* RimWellLogRftCurve::extractor()
if (!eclExtractor)
{
std::vector<const RigWellPath*> wellPaths = proj->simulationWellBranches(m_wellName());
std::vector<const RigWellPath*> wellPaths = RiaSimWellBranchTools::simulationWellBranches(m_wellName(), true);
if (wellPaths.size() == 0) return nullptr;
eclExtractor = wellLogCollection->findOrCreateSimWellExtractor(m_wellName(), QString("Find or create sim well extractor"), wellPaths[0], m_eclipseResultCase->eclipseCaseData());

View File

@ -93,5 +93,3 @@ private:
bool m_isUsingPseudoLength;
};

View File

@ -58,6 +58,7 @@
#include "cvfAssert.h"
#include "qwt_scale_engine.h"
#include "RiaSimWellBranchTools.h"
#define RI_LOGPLOTTRACK_MINX_DEFAULT -10.0
#define RI_LOGPLOTTRACK_MAXX_DEFAULT 100.0
@ -119,10 +120,11 @@ RimWellLogTrack::RimWellLogTrack()
CAF_PDM_InitField(&m_formationSimWellName, "FormationSimulationWellName", QString("None"), "Simulation Well", "", "", "");
CAF_PDM_InitField(&m_formationBranchIndex, "FormationBranchIndex", 0, " ", "", "", "");
CAF_PDM_InitField(&m_formationBranchDetection, "FormationBranchDetection", true, "Branch Detection", "",
"Compute branches based on how simulation well cells are organized", "");
CAF_PDM_InitFieldNoDefault(&m_formationCase, "FormationCase", "Formation Case", "", "", "");
m_formationCase.uiCapability()->setUiTreeChildrenHidden(true);
}
//--------------------------------------------------------------------------------------------------
@ -137,8 +139,6 @@ RimWellLogTrack::~RimWellLogTrack()
m_wellLogTrackPlotWidget->deleteLater();
m_wellLogTrackPlotWidget = nullptr;
}
clearGeneratedSimWellPaths(&m_generatedSimulationWellPathBranches);
}
//--------------------------------------------------------------------------------------------------
@ -178,28 +178,6 @@ void RimWellLogTrack::simWellOptionItems(QList<caf::PdmOptionItemInfo>* options,
}
}
//--------------------------------------------------------------------------------------------------
/// Clean up existing generated well paths
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::clearGeneratedSimWellPaths(cvf::Collection<RigWellPath>* generatedSimulationWellPathBranches)
{
RimWellLogPlotCollection* wellLogCollection = nullptr;
// Need to use this approach, and not firstAnchestor because the curve might not be inside the hierarchy when deleted.
RimProject * proj = RiaApplication::instance()->project();
if (proj && proj->mainPlotCollection()) wellLogCollection = proj->mainPlotCollection()->wellLogPlotCollection();
if (!wellLogCollection) return;
for (size_t wpIdx = 0; wpIdx < generatedSimulationWellPathBranches->size(); ++wpIdx)
{
wellLogCollection->removeExtractors(generatedSimulationWellPathBranches->at(wpIdx));
}
generatedSimulationWellPathBranches->clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -286,8 +264,6 @@ void RimWellLogTrack::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
m_formationSimWellName = QString("None");
}
clearGeneratedSimWellPaths(&m_generatedSimulationWellPathBranches);
loadDataAndUpdate();
}
else if (changedField == &m_formationWellPath)
@ -296,17 +272,14 @@ void RimWellLogTrack::fieldChangedByUi(const caf::PdmFieldHandle* changedField,
}
else if (changedField == &m_formationSimWellName)
{
clearGeneratedSimWellPaths(&m_generatedSimulationWellPathBranches);
loadDataAndUpdate();
}
else if (changedField == &m_formationTrajectoryType)
{
clearGeneratedSimWellPaths(&m_generatedSimulationWellPathBranches);
loadDataAndUpdate();
}
else if (changedField == &m_formationBranchIndex)
else if (changedField == &m_formationBranchIndex ||
changedField == &m_formationBranchDetection)
{
loadDataAndUpdate();
}
@ -346,19 +319,8 @@ QList<caf::PdmOptionItemInfo> RimWellLogTrack::calculateValueOptions(const caf::
}
else if (fieldNeedingOptions == &m_formationBranchIndex)
{
updateGeneratedSimulationWellpath(&m_generatedSimulationWellPathBranches, m_formationSimWellName(), m_formationCase);
size_t branchCount = m_generatedSimulationWellPathBranches.size();
for (int bIdx = 0; bIdx < static_cast<int>(branchCount); ++bIdx)
{
options.push_back(caf::PdmOptionItemInfo("Branch " + QString::number(bIdx + 1), QVariant::fromValue(bIdx)));
}
if (options.size() == 0)
{
options.push_front(caf::PdmOptionItemInfo("None", -1));
}
auto simulationWellBranches = RiaSimWellBranchTools::simulationWellBranches(m_formationSimWellName(), m_formationBranchDetection);
options = RiaSimWellBranchTools::valueOptionsForBranchIndexField(simulationWellBranches);
}
return options;
@ -528,13 +490,23 @@ void RimWellLogTrack::setAndUpdateWellPathFormationNamesData(RimCase* rimCase, R
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setAndUpdateSimWellFormationNamesData(RimCase* rimCase, QString simWellName, int branchIndex)
void RimWellLogTrack::setAndUpdateSimWellFormationNamesAndBranchData(RimCase* rimCase, const QString& simWellName, int branchIndex, bool useBranchDetection)
{
m_formationBranchIndex = branchIndex;
m_formationBranchDetection = useBranchDetection;
setAndUpdateSimWellFormationNamesData(rimCase, simWellName);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::setAndUpdateSimWellFormationNamesData(RimCase* rimCase, const QString& simWellName)
{
m_formationCase = rimCase;
m_formationTrajectoryType = RimWellLogTrack::SIMULATION_WELL;
m_formationWellPath = nullptr;
m_formationSimWellName = simWellName;
m_formationBranchIndex = branchIndex;
updateConnectedEditors();
@ -592,14 +564,6 @@ void RimWellLogTrack::setFormationTrajectoryType(TrajectoryType trajectoryType)
m_formationTrajectoryType = trajectoryType;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RimWellLogTrack::formationBranchIndex() const
{
return m_formationBranchIndex;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -738,49 +702,6 @@ RimWellLogCurve* RimWellLogTrack::curveDefinitionFromCurve(const QwtPlotCurve* c
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellLogTrack::updateGeneratedSimulationWellpath(cvf::Collection<RigWellPath>* generatedSimulationWellPathBranches, const QString& simWellName, RimCase* rimCase)
{
if (generatedSimulationWellPathBranches->size()) return; // Already created. Nothing to do
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(rimCase);
if (!(!simWellName.isEmpty() && simWellName != QString("None") && eclipseCase && eclipseCase->eclipseCaseData()))
{
return;
}
RigEclipseCaseData* eclCaseData = eclipseCase->eclipseCaseData();
const RigSimWellData* simWellData = eclCaseData->findSimWellData(simWellName);
if (!simWellData) return;
std::vector< std::vector <cvf::Vec3d> > pipeBranchesCLCoords;
std::vector< std::vector <RigWellResultPoint> > pipeBranchesCellIds;
RigSimulationWellCenterLineCalculator::calculateWellPipeCenterlineFromWellFrame(eclCaseData,
simWellData,
-1,
true,
true,
pipeBranchesCLCoords,
pipeBranchesCellIds);
for (size_t brIdx = 0; brIdx < pipeBranchesCLCoords.size(); ++brIdx)
{
auto wellMdCalculator = RigSimulationWellCoordsAndMD(pipeBranchesCLCoords[brIdx]); // Todo, branch index
cvf::ref<RigWellPath> newWellPath = new RigWellPath();
newWellPath->m_measuredDepths = wellMdCalculator.measuredDepths();
newWellPath->m_wellPathPoints = wellMdCalculator.wellPathPoints();
generatedSimulationWellPathBranches->push_back(newWellPath.p());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -805,10 +726,11 @@ void RimWellLogTrack::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
}
else
{
updateGeneratedSimulationWellpath(&m_generatedSimulationWellPathBranches, m_formationSimWellName(), m_formationCase);
formationGroup->add(&m_formationSimWellName);
if (m_generatedSimulationWellPathBranches.size() > 1)
formationGroup->add(&m_formationBranchDetection);
auto simulationWellBranches = RiaSimWellBranchTools::simulationWellBranches(m_formationSimWellName(), m_formationBranchDetection);
if (simulationWellBranches.size() > 1)
{
formationGroup->add(&m_formationBranchIndex);
}
@ -819,7 +741,6 @@ void RimWellLogTrack::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering&
formationGroup->add(&m_formationWellPath);
}
uiOrderingForVisibleXRange(uiOrdering);
uiOrdering.skipRemainingFields(true);
@ -973,15 +894,14 @@ void RimWellLogTrack::uiOrderingForVisibleXRange(caf::PdmUiOrdering& uiOrdering)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigEclipseWellLogExtractor* RimWellLogTrack::createSimWellExtractor(RimWellLogPlotCollection* wellLogCollection, RimCase* rimCase, const QString& simWellName, int branchIndex)
RigEclipseWellLogExtractor* RimWellLogTrack::createSimWellExtractor(RimWellLogPlotCollection* wellLogCollection, RimCase* rimCase, const QString& simWellName, int branchIndex, bool useBranchDetection)
{
if (!wellLogCollection) return nullptr;
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(rimCase);
if (!eclipseCase) return nullptr;
RimProject* proj = RiaApplication::instance()->project();
std::vector<const RigWellPath*> wellPaths = proj->simulationWellBranches(simWellName);
std::vector<const RigWellPath*> wellPaths = RiaSimWellBranchTools::simulationWellBranches(simWellName, useBranchDetection);
if (wellPaths.size() == 0) return nullptr;
@ -1196,7 +1116,8 @@ void RimWellLogTrack::updateFormationNamesOnPlot()
eclWellLogExtractor = RimWellLogTrack::createSimWellExtractor(wellLogCollection,
m_formationCase,
m_formationSimWellName,
m_formationBranchIndex);
m_formationBranchIndex,
m_formationBranchDetection);
}
else
{

View File

@ -19,14 +19,13 @@
#pragma once
#include "RimWellLogPlot.h"
#include "cafPdmObject.h"
#include "cafPdmField.h"
#include "cafPdmChildArrayField.h"
#include "cvfCollection.h"
#include "cafPdmPtrField.h"
#include "RimWellLogPlot.h"
#include <QPointer>
#include <memory>
@ -86,15 +85,18 @@ public:
void setFormationBranchIndex(int branchIndex);
void setFormationCase(RimCase* rimCase);
void setFormationTrajectoryType(TrajectoryType trajectoryType);
int formationBranchIndex() const;
RimCase* formationNamesCase() const;
void recreateViewer();
void detachAllCurves();
void loadDataAndUpdate();
void setAndUpdateWellPathFormationNamesData(RimCase* rimCase, RimWellPath* wellPath);
void setAndUpdateSimWellFormationNamesData(RimCase* rimCase, QString simWellName, int branchIndex);
void setAndUpdateSimWellFormationNamesAndBranchData(RimCase* rimCase, const QString& simWellName, int branchIndex, bool useBranchDetection);
void setAndUpdateSimWellFormationNamesData(RimCase* rimCase, const QString& simWellName);
void availableDepthRange(double* minimumDepth, double* maximumDepth);
void updateXZoomAndParentPlotDepthZoom();
void updateXZoom();
@ -125,11 +127,9 @@ private:
void computeAndSetXRangeMinForLogarithmicScale();
static void updateGeneratedSimulationWellpath(cvf::Collection<RigWellPath>* generatedSimulationWellPathBranches, const QString& simWellName, RimCase* rimCase);
static void simWellOptionItems(QList<caf::PdmOptionItemInfo>* options, RimCase* eclCase);
static void clearGeneratedSimWellPaths(cvf::Collection<RigWellPath>* generatedSimulationWellPathBranches);
static RigEclipseWellLogExtractor* createSimWellExtractor(RimWellLogPlotCollection* wellLogCollection, RimCase* rimCase, const QString& simWellName, int branchIndex);
static RigEclipseWellLogExtractor* createSimWellExtractor(RimWellLogPlotCollection* wellLogCollection, RimCase* rimCase, const QString& simWellName, int branchIndex, bool useBranchDetection);
static RigEclipseWellLogExtractor* createWellPathExtractor(RimWellLogPlotCollection* wellLogCollection, RimCase* rimCase, RimWellPath* wellPath);
static RigGeoMechWellLogExtractor* createGeoMechExtractor(RimWellLogPlotCollection* wellLogCollection, RimCase* rimCase, RimWellPath* wellPath);
@ -168,10 +168,10 @@ private:
caf::PdmPtrField<RimCase*> m_formationCase;
caf::PdmField<caf::AppEnum<TrajectoryType> > m_formationTrajectoryType;
caf::PdmPtrField<RimWellPath*> m_formationWellPath;
caf::PdmField<QString> m_formationSimWellName;
caf::PdmField<int> m_formationBranchIndex;
cvf::Collection<RigWellPath> m_generatedSimulationWellPathBranches;
caf::PdmField<bool> m_formationBranchDetection;
QPointer<RiuWellLogTrack> m_wellLogTrackPlotWidget;

View File

@ -20,6 +20,10 @@
#include "RimWellPath.h"
#include "RiaApplication.h"
#include "RiaSimWellBranchTools.h"
#include "RiaWellNameComparer.h"
#include "RifWellPathFormationsImporter.h"
#include "RifWellPathImporter.h"
@ -40,9 +44,6 @@
#include "RivWellPathPartMgr.h"
#include "RiaApplication.h"
#include "RiaWellNameComparer.h"
#include "cafPdmUiTreeOrdering.h"
#include "cafUtils.h"
@ -345,9 +346,8 @@ QList<caf::PdmOptionItemInfo> RimWellPath::calculateValueOptions(const caf::PdmF
}
else if (fieldNeedingOptions == &m_branchIndex)
{
RimProject* proj = RiaApplication::instance()->project();
size_t branchCount = RimWellPath::simulationWellBranchCount(m_simWellName);
size_t branchCount = proj->simulationWellBranches(m_simWellName).size();
if (branchCount == 0)
branchCount = 1;
@ -471,9 +471,10 @@ void RimWellPath::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiO
caf::PdmUiGroup* simWellGroup = uiOrdering.addNewGroup("Simulation Well");
simWellGroup->add(&m_simWellName);
RimProject* proj = RiaApplication::instance()->project();
if(proj->simulationWellBranches(m_simWellName).size() > 1)
if (simulationWellBranchCount(m_simWellName) > 1)
{
simWellGroup->add(&m_branchIndex);
}
caf::PdmUiGroup* ssihubGroup = uiOrdering.addNewGroup("Well Info");
ssihubGroup->add(&id);
@ -581,6 +582,18 @@ void RimWellPath::setupBeforeSave()
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t RimWellPath::simulationWellBranchCount(const QString& simWellName)
{
bool detectBranches = true;
auto branches = RiaSimWellBranchTools::simulationWellBranches(simWellName, detectBranches);
return branches.size();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -151,6 +151,9 @@ private:
virtual void setupBeforeSave() override;
static size_t simulationWellBranchCount(const QString& simWellName);
private:
caf::PdmField<QString> id;
caf::PdmField<QString> sourceSystem;
caf::PdmField<QString> utmZone;

View File

@ -281,7 +281,10 @@ const RigSimWellData* RigEclipseCaseData::findSimWellData(QString wellName) cons
{
for (size_t wIdx = 0; wIdx < m_simWellData.size(); ++wIdx)
{
if (m_simWellData[wIdx]->m_wellName == wellName) return m_simWellData[wIdx].p();
if (m_simWellData[wIdx]->m_wellName == wellName)
{
return m_simWellData[wIdx].p();
}
}
return nullptr;
@ -467,52 +470,52 @@ bool RigEclipseCaseData::hasSimulationWell(const QString& simWellName) const
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
std::vector<const RigWellPath*> RigEclipseCaseData::simulationWellBranches(const QString& simWellName)
std::vector<const RigWellPath*> RigEclipseCaseData::simulationWellBranches(const QString& simWellName,
bool includeAllCellCenters,
bool useAutoDetectionOfBranches)
{
std::vector<const RigWellPath*> branches;
if (m_branchCache.find(simWellName) == m_branchCache.end())
if (simWellName.isEmpty() || simWellName.toUpper() == "NONE")
{
if (!(!simWellName.isEmpty() && simWellName != "None"))
{
return branches;
}
return branches;
}
const RigSimWellData* simWellData = findSimWellData(simWellName);
const RigSimWellData* simWellData = findSimWellData(simWellName);
if (!simWellData) return branches;
if (!simWellData) return branches;
std::tuple<QString, bool, bool> simWellSeachItem =
std::make_tuple(simWellName, includeAllCellCenters, useAutoDetectionOfBranches);
std::vector< std::vector <cvf::Vec3d> > pipeBranchesCLCoords;
std::vector< std::vector <RigWellResultPoint> > pipeBranchesCellIds;
if (m_simWellBranchCache.find(simWellSeachItem) == m_simWellBranchCache.end())
{
std::vector<std::vector<cvf::Vec3d>> pipeBranchesCLCoords;
std::vector<std::vector<RigWellResultPoint>> pipeBranchesCellIds;
RigSimulationWellCenterLineCalculator::calculateWellPipeCenterlineFromWellFrame(this,
simWellData,
-1,
true,
true,
pipeBranchesCLCoords,
pipeBranchesCellIds);
RigSimulationWellCenterLineCalculator::calculateWellPipeCenterlineFromWellFrame(
this, simWellData, -1, useAutoDetectionOfBranches, includeAllCellCenters, pipeBranchesCLCoords, pipeBranchesCellIds);
m_branchCache.insert(std::make_pair(simWellName, cvf::Collection<RigWellPath>()));
m_simWellBranchCache.insert(std::make_pair(simWellSeachItem, cvf::Collection<RigWellPath>()));
for (size_t brIdx = 0; brIdx < pipeBranchesCLCoords.size(); ++brIdx)
{
auto wellMdCalculator = RigSimulationWellCoordsAndMD(pipeBranchesCLCoords[brIdx]);
cvf::ref<RigWellPath> newWellPath = new RigWellPath();
newWellPath->m_measuredDepths = wellMdCalculator.measuredDepths();
newWellPath->m_wellPathPoints = wellMdCalculator.wellPathPoints();
newWellPath->m_measuredDepths = wellMdCalculator.measuredDepths();
newWellPath->m_wellPathPoints = wellMdCalculator.wellPathPoints();
m_branchCache[simWellName].push_back(newWellPath.p());
m_simWellBranchCache[simWellSeachItem].push_back(newWellPath.p());
}
}
for (const auto& branch : m_branchCache[simWellName])
for (const auto& branch : m_simWellBranchCache[simWellSeachItem])
{
branches.push_back(branch.p());
}
return branches;
}

View File

@ -99,7 +99,10 @@ public:
std::vector<QString> simulationWellNames() const;
bool hasSimulationWell(const QString& simWellName) const;
std::vector<const RigWellPath*> simulationWellBranches(const QString& simWellName);
std::vector<const RigWellPath*> simulationWellBranches(const QString& simWellName,
bool includeAllCellCenters,
bool useAutoDetectionOfBranches);
private:
void computeActiveCellIJKBBox();
@ -124,5 +127,5 @@ private:
RiaEclipseUnitTools::UnitSystem m_unitsType;
std::map<QString, cvf::Collection<RigWellPath>> m_branchCache;
std::map<std::tuple<QString, bool, bool>, cvf::Collection<RigWellPath>> m_simWellBranchCache;
};