Well branches. Simple well branch cache

This commit is contained in:
Bjørn Erik Jensen
2017-10-12 11:03:00 +02:00
parent 445048c24b
commit 389234715c
4 changed files with 44 additions and 32 deletions

View File

@@ -881,7 +881,7 @@ std::vector<QString> RimProject::simulationWellNames() const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RigWellPath*> RimProject::simulationWellBranches(const QString& simWellName)
std::vector<const RigWellPath*> RimProject::simulationWellBranches(const QString& simWellName)
{
// Find first case containing the specified simulation well
auto simCases = eclipseCases();
@@ -893,7 +893,7 @@ std::vector<RigWellPath*> RimProject::simulationWellBranches(const QString& simW
RigEclipseCaseData* eclCaseData = eclipseCase != nullptr ? eclipseCase->eclipseCaseData() : nullptr;
return eclCaseData != nullptr ?
eclCaseData->simulationWellBranches(simWellName) :
std::vector<RigWellPath*>();
std::vector<const RigWellPath*>();
}
//--------------------------------------------------------------------------------------------------

View File

@@ -124,7 +124,7 @@ public:
std::vector<RimEclipseCase*> eclipseCases() const;
std::vector<QString> simulationWellNames() const;
std::vector<RigWellPath*> simulationWellBranches(const QString& simWellName);
std::vector<const RigWellPath*> simulationWellBranches(const QString& simWellName);
RimWellPath* wellPathFromSimulationWell(const QString& simWellName, int branchIndex = -1);
protected:

View File

@@ -462,18 +462,20 @@ bool RigEclipseCaseData::hasSimulationWell(const QString& simWellName) const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RigWellPath*> RigEclipseCaseData::simulationWellBranches(const QString& simWellName)
std::vector<const RigWellPath*> RigEclipseCaseData::simulationWellBranches(const QString& simWellName)
{
std::vector<RigWellPath*> branches;
std::vector<const RigWellPath*> branches;
if (m_branchCache.find(simWellName) == m_branchCache.end())
{
if (!(!simWellName.isEmpty() && simWellName != "None"))
{
return std::vector<RigWellPath*>();
return branches;
}
const RigSingleWellResultsData* wellResults = findWellResult(simWellName);
if (!wellResults) return std::vector<RigWellPath*>();
if (!wellResults) return branches;
std::vector< std::vector <cvf::Vec3d> > pipeBranchesCLCoords;
std::vector< std::vector <RigWellResultPoint> > pipeBranchesCellIds;
@@ -486,6 +488,8 @@ std::vector<RigWellPath*> RigEclipseCaseData::simulationWellBranches(const QStri
pipeBranchesCLCoords,
pipeBranchesCellIds);
m_branchCache.insert(std::make_pair(simWellName, cvf::Collection<RigWellPath>()));
for (size_t brIdx = 0; brIdx < pipeBranchesCLCoords.size(); ++brIdx)
{
auto wellMdCalculator = RigSimulationWellCoordsAndMD(pipeBranchesCLCoords[brIdx]);
@@ -494,9 +498,14 @@ std::vector<RigWellPath*> RigEclipseCaseData::simulationWellBranches(const QStri
newWellPath->m_measuredDepths = wellMdCalculator.measuredDepths();
newWellPath->m_wellPathPoints = wellMdCalculator.wellPathPoints();
branches.push_back(newWellPath.p());
m_branchCache[simWellName].push_back(newWellPath.p());
}
}
for (const auto& branch : m_branchCache[simWellName])
{
branches.push_back(branch.p());
}
return branches;
}

View File

@@ -31,6 +31,7 @@
#include "cvfCollection.h"
#include "cvfStructGrid.h"
#include "cvfVector3.h"
#include "cvfCollection.h"
#include <vector>
@@ -95,7 +96,7 @@ public:
std::vector<QString> simulationWellNames() const;
bool hasSimulationWell(const QString& simWellName) const;
std::vector<RigWellPath*> simulationWellBranches(const QString& simWellName);
std::vector<const RigWellPath*> simulationWellBranches(const QString& simWellName);
private:
void computeActiveCellIJKBBox();
@@ -119,4 +120,6 @@ private:
cvf::Collection<cvf::UIntArray> m_gridCellToResultWellIndex; //< Array pr grid with index to well pr cell telling which well a cell is in
RiaEclipseUnitTools::UnitSystem m_unitsType;
std::map<QString, cvf::Collection<RigWellPath>> m_branchCache;
};