Merge branch '2018.01.01-patch' into dev

This commit is contained in:
Rebecca Cox 2018-01-24 08:33:47 +01:00
commit e68f0e2be8
11 changed files with 488 additions and 176 deletions

View File

@ -49,6 +49,9 @@ CAF_CMD_SOURCE_INIT(RicNewSimWellFractureAtPosFeature, "RicNewSimWellFractureAtP
//--------------------------------------------------------------------------------------------------
void RicNewSimWellFractureAtPosFeature::onActionTriggered(bool isChecked)
{
RimProject* proj = RiaApplication::instance()->project();
if (proj->allFractureTemplates().empty()) return;
Rim3dView* activeView = RiaApplication::instance()->activeReservoirView();
if (!activeView) return;
@ -120,6 +123,9 @@ void RicNewSimWellFractureAtPosFeature::setupActionLook(QAction* actionToSetup)
//--------------------------------------------------------------------------------------------------
bool RicNewSimWellFractureAtPosFeature::isCommandEnabled()
{
RimProject* proj = RiaApplication::instance()->project();
if (proj->allFractureTemplates().empty()) return false;
caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem();
if (!pdmUiItem) return false;

View File

@ -50,6 +50,9 @@ CAF_CMD_SOURCE_INIT(RicNewSimWellFractureFeature, "RicNewSimWellFractureFeature"
//--------------------------------------------------------------------------------------------------
void RicNewSimWellFractureFeature::onActionTriggered(bool isChecked)
{
RimProject* proj = RiaApplication::instance()->project();
if (proj->allFractureTemplates().empty()) return;
caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem();
if (!pdmUiItem) return;
@ -109,6 +112,9 @@ void RicNewSimWellFractureFeature::setupActionLook(QAction* actionToSetup)
//--------------------------------------------------------------------------------------------------
bool RicNewSimWellFractureFeature::isCommandEnabled()
{
RimProject* proj = RiaApplication::instance()->project();
if (proj->allFractureTemplates().empty()) return false;
caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem();
if (!pdmUiItem) return false;

View File

@ -22,6 +22,8 @@
#include "RicNewWellPathFractureFeature.h"
#include "RimProject.h"
#include "RiuSelectionManager.h"
#include <QAction>
@ -35,6 +37,9 @@ CAF_CMD_SOURCE_INIT(RicNewWellPathFractureAtPosFeature, "RicNewWellPathFractureA
//--------------------------------------------------------------------------------------------------
void RicNewWellPathFractureAtPosFeature::onActionTriggered(bool isChecked)
{
RimProject* proj = RiaApplication::instance()->project();
if (proj->allFractureTemplates().empty()) return;
RiuSelectionManager* riuSelManager = RiuSelectionManager::instance();
RiuSelectionItem* selItem = riuSelManager->selectedItem(RiuSelectionManager::RUI_TEMPORARY);
@ -61,5 +66,8 @@ void RicNewWellPathFractureAtPosFeature::setupActionLook(QAction* actionToSetup)
//--------------------------------------------------------------------------------------------------
bool RicNewWellPathFractureAtPosFeature::isCommandEnabled()
{
RimProject* proj = RiaApplication::instance()->project();
if (proj->allFractureTemplates().empty()) return false;
return true;
}

View File

@ -96,6 +96,9 @@ void RicNewWellPathFractureFeature::addFracture(RimWellPath* wellPath, double me
//--------------------------------------------------------------------------------------------------
void RicNewWellPathFractureFeature::onActionTriggered(bool isChecked)
{
RimProject* proj = RiaApplication::instance()->project();
if (proj->allFractureTemplates().empty()) return;
RimWellPathFractureCollection* fractureColl = RicNewWellPathFractureFeature::selectedWellPathFractureCollection();
if (!fractureColl) return;
@ -120,6 +123,9 @@ void RicNewWellPathFractureFeature::setupActionLook(QAction* actionToSetup)
//--------------------------------------------------------------------------------------------------
bool RicNewWellPathFractureFeature::isCommandEnabled()
{
RimProject* proj = RiaApplication::instance()->project();
if (proj->allFractureTemplates().empty()) return false;
if (selectedWellPathFractureCollection())
{
return true;

View File

@ -39,11 +39,29 @@ std::map<QString, cvf::ref<RigWellPathFormations>>
std::vector<QString> wellNames;
std::vector<QString> formationNames;
std::vector<double> mdTop;
std::vector<double> mdBase;
readFile(filePath, &wellNames, &formationNames, &mdTop, &mdBase);
if (wellNames.empty() || formationNames.empty() || mdTop.empty() || mdBase.empty())
std::vector<double> tvdTop;
std::vector<double> tvdBase;
readFile(filePath, &wellNames, &formationNames, &mdTop, &mdBase, &tvdTop, &tvdBase);
bool mdIsPresent = true;
bool tvdIsPresent = true;
if (mdTop.empty() || mdBase.empty())
{
mdIsPresent = false;
}
if (tvdTop.empty() || tvdBase.empty())
{
tvdIsPresent = false;
}
if (wellNames.empty() || formationNames.empty())
{
QMessageBox::warning(RiuMainWindow::instance(), "Import failure",
QString("Failed to parse %1 as a well pick file").arg(filePath));
@ -51,10 +69,16 @@ std::map<QString, cvf::ref<RigWellPathFormations>>
return result;
}
else if (!(mdIsPresent || tvdIsPresent))
{
QMessageBox::warning(RiuMainWindow::instance(), "Import failure",
QString("Failed to parse %1 as a well pick file. Neither MD or TVD is present.").arg(filePath));
RiaLogging::error(QString("Failed to parse %1 as a well pick file. Neither MD or TVD is present.").arg(filePath));
return result;
}
CVF_ASSERT(wellNames.size() == formationNames.size());
CVF_ASSERT(mdTop.size() == formationNames.size());
CVF_ASSERT(mdBase.size() == formationNames.size());
std::map<QString, std::vector<RigWellPathFormation>> formations;
@ -62,8 +86,18 @@ std::map<QString, cvf::ref<RigWellPathFormations>>
{
RigWellPathFormation formation;
formation.formationName = formationNames[i];
formation.mdTop = mdTop[i];
formation.mdBase = mdBase[i];
if (mdIsPresent)
{
formation.mdTop = mdTop[i];
formation.mdBase = mdBase[i];
}
if (tvdIsPresent)
{
formation.tvdTop = tvdTop[i];
formation.tvdBase = tvdBase[i];
}
if (!formations.count(wellNames[i]))
{
@ -73,10 +107,10 @@ std::map<QString, cvf::ref<RigWellPathFormations>>
formations[wellNames[i]].push_back(formation);
}
for (auto it = formations.begin(); it != formations.end(); it++)
for (const std::pair<QString, std::vector<RigWellPathFormation>>& formation : formations)
{
cvf::ref<RigWellPathFormations> wellPathFormations = new RigWellPathFormations(it->second, filePath, it->first);
result[it->first] = wellPathFormations;
cvf::ref<RigWellPathFormations> wellPathFormations = new RigWellPathFormations(formation.second, filePath, formation.first);
result[formation.first] = wellPathFormations;
}
return result;
@ -95,7 +129,8 @@ void removeWhiteSpaces(QString* word)
//--------------------------------------------------------------------------------------------------
void RifWellPathFormationReader::readFile(const QString& filePath, std::vector<QString>* wellNames,
std::vector<QString>* formationNames, std::vector<double>* mdTop,
std::vector<double>* mdBase)
std::vector<double>* mdBase, std::vector<double>* tvdTop,
std::vector<double>* tvdBase)
{
QFile data(filePath);
@ -151,12 +186,31 @@ void RifWellPathFormationReader::readFile(const QString& filePath, std::vector<Q
static const QString unitNameText = "unitname";
static const QString measuredDepthToptext = "topmd";
static const QString measuredDepthBasetext = "basemd";
static const QString trueVerticalDepthToptext = "toptvdss";
static const QString trueVerticalDepthBasetext = "basetvdss";
int unitNameIndex = header.indexOf(unitNameText);
int measuredDepthTopIndex = header.indexOf(measuredDepthToptext);
int measuredDepthBaseIndex = header.indexOf(measuredDepthBasetext);
if (unitNameIndex != -1 && measuredDepthTopIndex != -1 && measuredDepthBaseIndex != -1)
int trueVerticalDepthTopIndex = header.indexOf(trueVerticalDepthToptext);
int trueVerticalDepthBaseIndex = header.indexOf(trueVerticalDepthBasetext);
bool mdIsPresent = true;
bool tvdIsPresent = true;
if (measuredDepthTopIndex == -1 || measuredDepthBaseIndex == -1)
{
mdIsPresent = false;
}
if (trueVerticalDepthTopIndex == -1 || trueVerticalDepthBaseIndex == -1)
{
tvdIsPresent = false;
}
if (unitNameIndex != -1 && (mdIsPresent || tvdIsPresent))
{
do
{
@ -168,13 +222,27 @@ void RifWellPathFormationReader::readFile(const QString& filePath, std::vector<Q
QString wellName = dataLine[wellNameIndex];
QString unitName = dataLine[unitNameIndex];
unitName = unitName.trimmed();
double measuredDepthTop = dataLine[measuredDepthTopIndex].toDouble();
double measuredDepthBase = dataLine[measuredDepthBaseIndex].toDouble();
if (mdIsPresent)
{
double mdTopValue = dataLine[measuredDepthTopIndex].toDouble();
double mdBaseValue = dataLine[measuredDepthBaseIndex].toDouble();
mdTop->push_back(mdTopValue);
mdBase->push_back(mdBaseValue);
}
if (tvdIsPresent)
{
double tvdTopValue = dataLine[trueVerticalDepthTopIndex].toDouble();
double tvdBaseValue = dataLine[trueVerticalDepthBaseIndex].toDouble();
tvdTop->push_back(-tvdTopValue);
tvdBase->push_back(-tvdBaseValue);
}
wellNames->push_back(wellName);
formationNames->push_back(unitName);
mdTop->push_back(measuredDepthTop);
mdBase->push_back(measuredDepthBase);
} while (!data.atEnd());
}

View File

@ -39,5 +39,6 @@ public:
private:
static void readFile(const QString& filePath, std::vector<QString>* wellNames, std::vector<QString>* formationNames,
std::vector<double>* mdTop, std::vector<double>* mdBase);
std::vector<double>* mdTop, std::vector<double>* mdBase, std::vector<double>* tvdTop,
std::vector<double>* tvdBase);
};

View File

@ -1269,14 +1269,19 @@ void RimWellLogTrack::updateFormationNamesOnPlot()
else if (m_formationSource() == WELL_PICK_FILTER)
{
if (m_formationWellPathForSourceWellPath == nullptr) return;
if (plot->depthType() != RimWellLogPlot::MEASURED_DEPTH) return;
if (!(plot->depthType() == RimWellLogPlot::MEASURED_DEPTH || plot->depthType() == RimWellLogPlot::TRUE_VERTICAL_DEPTH))
{
return;
}
std::vector<double> yValues;
const RigWellPathFormations* formations = m_formationWellPathForSourceWellPath->formationsGeometry();
if (!formations) return;
formations->measuredDepthAndFormationNamesUpToLevel(m_formationLevel(), &formationNamesToPlot, &yValues, m_showformationFluids());
formations->depthAndFormationNamesUpToLevel(m_formationLevel(), &formationNamesToPlot, &yValues, m_showformationFluids(), plot->depthType());
m_annotationTool->attachWellPicks(this->viewer(), formationNamesToPlot, yValues);
}

View File

@ -185,7 +185,9 @@ public:
///
//--------------------------------------------------------------------------------------------------
RigFlowDiagSolverInterface::RigFlowDiagSolverInterface(RimEclipseResultCase * eclipseCase)
: m_eclipseCase(eclipseCase)
: m_eclipseCase(eclipseCase),
m_pvtCurveErrorCount(0),
m_relpermCurveErrorCount(0)
{
}
@ -237,6 +239,7 @@ RigFlowDiagTimeStepResult RigFlowDiagSolverInterface::calculate(size_t timeStepI
caf::ProgressInfo progressInfo(8, "Calculating Flow Diagnostics");
try
{
progressInfo.setProgressDescription("Grid access");
@ -294,6 +297,11 @@ RigFlowDiagTimeStepResult RigFlowDiagSolverInterface::calculate(size_t timeStepI
}
}
}
catch ( const std::exception& e )
{
QMessageBox::critical(nullptr, "ResInsight", "Flow Diagnostics Exception: " + QString(e.what()));
return result;
}
progressInfo.setProgress(3);
progressInfo.setProgressDescription("Assigning Flux Field");
@ -328,6 +336,7 @@ RigFlowDiagTimeStepResult RigFlowDiagSolverInterface::calculate(size_t timeStepI
// Set up flow Toolbox with timestep data
std::map<Opm::FlowDiagnostics::CellSetID, Opm::FlowDiagnostics::CellSetValues> WellInFluxPrCell;
try
{
if (m_eclipseCase->eclipseCaseData()->results(RiaDefines::MATRIX_MODEL)->hasFlowDiagUsableFluxes())
{
@ -338,12 +347,12 @@ RigFlowDiagTimeStepResult RigFlowDiagSolverInterface::calculate(size_t timeStepI
}
else
{
Opm::ECLInitFileData init(getInitFileName());
Opm::FlowDiagnostics::ConnectionValues connectionVals = RigFlowDiagInterfaceTools::calculateFluxField((*m_opmFlowDiagStaticData->m_eclGraph),
init,
*currentRestartData,
phaseSelection);
m_opmFlowDiagStaticData->m_fldToolbox->assignConnectionFlux(connectionVals);
Opm::ECLInitFileData init(getInitFileName());
Opm::FlowDiagnostics::ConnectionValues connectionVals = RigFlowDiagInterfaceTools::calculateFluxField((*m_opmFlowDiagStaticData->m_eclGraph),
init,
*currentRestartData,
phaseSelection);
m_opmFlowDiagStaticData->m_fldToolbox->assignConnectionFlux(connectionVals);
}
@ -360,10 +369,16 @@ RigFlowDiagTimeStepResult RigFlowDiagSolverInterface::calculate(size_t timeStepI
m_opmFlowDiagStaticData->m_fldToolbox->assignInflowFlux(WellInFluxPrCell);
}
catch ( const std::exception& e )
{
QMessageBox::critical(nullptr, "ResInsight", "Flow Diagnostics Exception: " + QString(e.what()));
return result;
}
progressInfo.incrementProgress();
progressInfo.setProgressDescription("Injector Solution");
try
{
// Injection Solution
std::set<std::string> injectorCrossFlowTracers;
@ -380,16 +395,8 @@ RigFlowDiagTimeStepResult RigFlowDiagSolverInterface::calculate(size_t timeStepI
}
injectorCellSets.push_back(CellSet(CellSetID(tracerName), tIt.second));
}
try
{
injectorSolution.reset(new Toolbox::Forward(m_opmFlowDiagStaticData->m_fldToolbox->computeInjectionDiagnostics(injectorCellSets)));
}
catch ( const std::exception& e )
{
QMessageBox::critical(nullptr, "ResInsight", "Flow Diagnostics: " + QString(e.what()));
return result;
}
injectorSolution.reset(new Toolbox::Forward(m_opmFlowDiagStaticData->m_fldToolbox->computeInjectionDiagnostics(injectorCellSets)));
for ( const CellSetID& tracerId: injectorSolution->fd.startPoints() )
{
@ -422,15 +429,7 @@ RigFlowDiagTimeStepResult RigFlowDiagSolverInterface::calculate(size_t timeStepI
prodjCellSets.push_back(CellSet(CellSetID(tracerName), tIt.second));
}
try
{
producerSolution.reset(new Toolbox::Reverse(m_opmFlowDiagStaticData->m_fldToolbox->computeProductionDiagnostics(prodjCellSets)));
}
catch ( const std::exception& e )
{
QMessageBox::critical(nullptr, "ResInsight", "Flow Diagnostics: " + QString(e.what()));
return result;
}
producerSolution.reset(new Toolbox::Reverse(m_opmFlowDiagStaticData->m_fldToolbox->computeProductionDiagnostics(prodjCellSets)));
for ( const CellSetID& tracerId: producerSolution->fd.startPoints() )
{
@ -490,6 +489,11 @@ RigFlowDiagTimeStepResult RigFlowDiagSolverInterface::calculate(size_t timeStepI
}
}
}
catch ( const std::exception& e )
{
QMessageBox::critical(nullptr, "ResInsight", "Flow Diagnostics Exception: " + QString(e.what()));
return result;
}
return result; // Relying on implicit move constructor
}
@ -559,6 +563,30 @@ void RigFlowDiagSolverInterface::assignPhaseCorrecedPORV(RigFlowDiagResultAddres
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFlowDiagSolverInterface::reportRelPermCurveError(const QString& message)
{
if (m_relpermCurveErrorCount == 0)
{
QMessageBox::critical(nullptr, "ResInsight", "RelPerm curve problems: \n" + message);
}
m_relpermCurveErrorCount++;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFlowDiagSolverInterface::reportPvtCurveError(const QString& message)
{
if (m_pvtCurveErrorCount == 0)
{
QMessageBox::critical(nullptr, "ResInsight", "PVT curve problems: \n" + message);
}
m_pvtCurveErrorCount++;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -634,6 +662,8 @@ std::vector<RigFlowDiagSolverInterface::RelPermCurve> RigFlowDiagSolverInterface
curveIdentNameArr.push_back(std::make_pair(RelPermCurve::PCOG, "PCOG")); satFuncRequests.push_back(pcgo);
curveIdentNameArr.push_back(std::make_pair(RelPermCurve::PCOW, "PCOW")); satFuncRequests.push_back(pcow);
try {
// Calculate and return curves both with and without endpoint scaling and tag them accordingly
// Must use two calls to achieve this
const std::array<RelPermCurve::EpsMode, 2> epsModeArr = { RelPermCurve::EPS_ON , RelPermCurve::EPS_OFF };
@ -655,6 +685,13 @@ std::vector<RigFlowDiagSolverInterface::RelPermCurve> RigFlowDiagSolverInterface
}
}
}
catch ( const std::exception& e )
{
reportRelPermCurveError( QString(e.what()));
return retCurveArr;
}
return retCurveArr;
}
@ -665,6 +702,8 @@ std::vector<RigFlowDiagSolverInterface::PvtCurve> RigFlowDiagSolverInterface::ca
{
std::vector<PvtCurve> retCurveArr;
try {
if (!ensureStaticDataObjectInstanceCreated())
{
return retCurveArr;
@ -732,6 +771,13 @@ std::vector<RigFlowDiagSolverInterface::PvtCurve> RigFlowDiagSolverInterface::ca
}
}
}
catch ( const std::exception& e )
{
reportPvtCurveError( QString(e.what()));
return retCurveArr;
}
return retCurveArr;
}
@ -754,6 +800,7 @@ bool RigFlowDiagSolverInterface::calculatePvtDynamicPropertiesFvf(size_t activeC
return false;
}
try {
// Bo
{
std::vector<double> phasePress = { pressure };
@ -776,6 +823,13 @@ bool RigFlowDiagSolverInterface::calculatePvtDynamicPropertiesFvf(size_t activeC
}
}
}
catch ( const std::exception& e )
{
reportPvtCurveError( QString(e.what()));
return false;
}
return true;
}
@ -798,6 +852,7 @@ bool RigFlowDiagSolverInterface::calculatePvtDynamicPropertiesViscosity(size_t a
return false;
}
try {
// mu_o
{
std::vector<double> phasePress = { pressure };
@ -820,6 +875,13 @@ bool RigFlowDiagSolverInterface::calculatePvtDynamicPropertiesViscosity(size_t a
}
}
}
catch ( const std::exception& e )
{
reportPvtCurveError( QString(e.what()));
return false;
}
return true;
}

View File

@ -129,9 +129,16 @@ private:
bool ensureStaticDataObjectInstanceCreated();
void assignPhaseCorrecedPORV(RigFlowDiagResultAddress::PhaseSelection phaseSelection,
size_t timeStepIdx);
void reportRelPermCurveError(const QString &message);
void reportPvtCurveError(const QString &message);
RimEclipseResultCase * m_eclipseCase;
cvf::ref<RigOpmFlowDiagStaticData> m_opmFlowDiagStaticData;
int m_pvtCurveErrorCount;
int m_relpermCurveErrorCount;
};

View File

@ -20,16 +20,14 @@
#include "QStringList"
#include "cvfMath.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigWellPathFormations::RigWellPathFormations(const std::vector<RigWellPathFormation>& formations, const QString& filePath,
const QString& key)
{
m_filePath = filePath;
m_keyInFile = key;
m_filePath = filePath;
m_keyInFile = key;
for (const RigWellPathFormation& formation : formations)
{
@ -39,7 +37,7 @@ RigWellPathFormations::RigWellPathFormations(const std::vector<RigWellPathFormat
}
else
{
FormationLevel level = detectLevel(formation.formationName);
FormationLevel level = detectLevel(formation.formationName);
m_formationsLevelsPresent[level] = true;
m_formations.push_back(std::pair<RigWellPathFormation, FormationLevel>(formation, level));
@ -47,74 +45,114 @@ RigWellPathFormations::RigWellPathFormations(const std::vector<RigWellPathFormat
}
}
struct MeasuredDepthComp
{
bool operator()(const double& md1, const double& md2) const
{
if (cvf::Math::abs(md1 - md2) < 0.1)
{
return false;
}
return md1 < md2;
}
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigWellPathFormations::measuredDepthAndFormationNamesWithoutDuplicatesOnDepth(std::vector<QString>* names,
std::vector<double>* measuredDepths) const
void RigWellPathFormations::depthAndFormationNamesWithoutDuplicatesOnDepth(std::vector<QString>* names,
std::vector<double>* measuredDepths,
RimWellLogPlot::DepthTypeEnum depthType) const
{
std::map<double, bool, MeasuredDepthComp> tempMakeVectorUniqueOnMeasuredDepth;
std::map<double, bool, DepthComp> tempMakeVectorUniqueOnMeasuredDepth;
if (depthType == RimWellLogPlot::MEASURED_DEPTH)
{
for (const std::pair<RigWellPathFormation, FormationLevel>& formation : m_formations)
{
if (!tempMakeVectorUniqueOnMeasuredDepth.count(formation.first.mdTop))
{
measuredDepths->push_back(formation.first.mdTop);
names->push_back(formation.first.formationName + " Top");
tempMakeVectorUniqueOnMeasuredDepth[formation.first.mdTop] = true;
}
}
for (const std::pair<RigWellPathFormation, FormationLevel>& formation : m_formations)
{
if (!tempMakeVectorUniqueOnMeasuredDepth.count(formation.first.mdBase))
{
measuredDepths->push_back(formation.first.mdBase);
names->push_back(formation.first.formationName + " Base");
tempMakeVectorUniqueOnMeasuredDepth[formation.first.mdBase] = true;
}
}
}
else if (depthType == RimWellLogPlot::TRUE_VERTICAL_DEPTH)
{
for (const std::pair<RigWellPathFormation, FormationLevel>& formation : m_formations)
{
if (!tempMakeVectorUniqueOnMeasuredDepth.count(formation.first.tvdTop))
{
measuredDepths->push_back(formation.first.tvdTop);
names->push_back(formation.first.formationName + " Top");
tempMakeVectorUniqueOnMeasuredDepth[formation.first.tvdTop] = true;
}
}
for (const std::pair<RigWellPathFormation, FormationLevel>& formation : m_formations)
{
if (!tempMakeVectorUniqueOnMeasuredDepth.count(formation.first.tvdBase))
{
measuredDepths->push_back(formation.first.tvdBase);
names->push_back(formation.first.formationName + " Base");
tempMakeVectorUniqueOnMeasuredDepth[formation.first.tvdBase] = true;
}
}
}
/*
for (const std::pair<RigWellPathFormation, FormationLevel>& formation : m_formations)
{
if (!tempMakeVectorUniqueOnMeasuredDepth.count(formation.first.mdTop))
{
measuredDepths->push_back(formation.first.mdTop);
double depth;
if (depthType == RimWellLogPlot::MEASURED_DEPTH)
{
depth = formation.first.mdTop;
}
else if (depthType == RimWellLogPlot::TRUE_VERTICAL_DEPTH)
{
depth = formation.first.tvdTop;
}
else return;
measuredDepths->push_back(depth);
names->push_back(formation.first.formationName + " Top");
tempMakeVectorUniqueOnMeasuredDepth[formation.first.mdTop] = true;
tempMakeVectorUniqueOnMeasuredDepth[depth] = true;
}
}
for (const std::pair<RigWellPathFormation, FormationLevel>& formation : m_formations)
{
double depth;
if (depthType == RimWellLogPlot::MEASURED_DEPTH)
{
depth = formation.first.mdBase;
}
else if (depthType == RimWellLogPlot::TRUE_VERTICAL_DEPTH)
{
depth = formation.first.tvdBase;
}
else return;
if (!tempMakeVectorUniqueOnMeasuredDepth.count(formation.first.mdBase))
{
measuredDepths->push_back(formation.first.mdBase);
measuredDepths->push_back(depth);
names->push_back(formation.first.formationName + " Base");
tempMakeVectorUniqueOnMeasuredDepth[formation.first.mdBase] = true;
tempMakeVectorUniqueOnMeasuredDepth[depth] = true;
}
}
}*/
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
struct LevelAndName
{
LevelAndName() {}
LevelAndName(RigWellPathFormations::FormationLevel level, QString name) : level(level), name(name) {}
RigWellPathFormations::FormationLevel level;
QString name;
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
enum PICK_POSITION
{
TOP,
BASE
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void evaluateFormationsForOnePosition(const std::vector<std::pair<RigWellPathFormation, RigWellPathFormations::FormationLevel>>& formations,
const RigWellPathFormations::FormationLevel& maxLevel, const PICK_POSITION& position,
std::map<double, LevelAndName, MeasuredDepthComp>* uniqueListMaker)
void RigWellPathFormations::evaluateFormationsForOnePosition(
const std::vector<std::pair<RigWellPathFormation, FormationLevel>>& formations,
const FormationLevel& maxLevel, const PickPosition& position,
std::map<double, LevelAndName, DepthComp>* uniqueListMaker, RimWellLogPlot::DepthTypeEnum depthType) const
{
QString postFix;
@ -127,92 +165,134 @@ void evaluateFormationsForOnePosition(const std::vector<std::pair<RigWellPathFor
postFix = " Base";
}
for (const std::pair<RigWellPathFormation, RigWellPathFormations::FormationLevel>& formation : formations)
for (const std::pair<RigWellPathFormation, FormationLevel>& formation : formations)
{
double md;
if (position == TOP)
double depth;
if (depthType == RimWellLogPlot::MEASURED_DEPTH)
{
md = formation.first.mdTop;
if (position == TOP)
{
depth = formation.first.mdTop;
}
else
{
depth = formation.first.mdBase;
}
}
else
else if (depthType == RimWellLogPlot::TRUE_VERTICAL_DEPTH)
{
md = formation.first.mdBase;
if (position == TOP)
{
depth = formation.first.tvdTop;
}
else
{
depth = formation.first.tvdBase;
}
}
else return;
if (formation.second > maxLevel) continue;
if (!uniqueListMaker->count(md) || uniqueListMaker->at(md).level < formation.second)
if (!uniqueListMaker->count(depth) || uniqueListMaker->at(depth).level < formation.second)
{
(*uniqueListMaker)[md] = LevelAndName(formation.second, formation.first.formationName + postFix);
(*uniqueListMaker)[depth] = LevelAndName(formation.second, formation.first.formationName + postFix);
}
}
}
void evaluateFormations(const std::vector<std::pair<RigWellPathFormation, RigWellPathFormations::FormationLevel>>& formations,
const RigWellPathFormations::FormationLevel& maxLevel,
std::vector<QString>* names, std::vector<double>* measuredDepths)
{
std::map<double, LevelAndName, MeasuredDepthComp> tempMakeVectorUniqueOnMeasuredDepth;
evaluateFormationsForOnePosition(formations, maxLevel, PICK_POSITION::TOP, &tempMakeVectorUniqueOnMeasuredDepth);
evaluateFormationsForOnePosition(formations, maxLevel, PICK_POSITION::BASE, &tempMakeVectorUniqueOnMeasuredDepth);
for (auto it = tempMakeVectorUniqueOnMeasuredDepth.begin(); it != tempMakeVectorUniqueOnMeasuredDepth.end(); it++)
{
measuredDepths->push_back(it->first);
names->push_back(it->second.name);
}
}
void evaluateFluids(const std::vector<RigWellPathFormation>& fluidFormations,
std::vector<QString>* names, std::vector<double>* measuredDepths)
{
std::map<double, QString, MeasuredDepthComp> uniqueListMaker;
for (const RigWellPathFormation& formation : fluidFormations)
{
uniqueListMaker[formation.mdBase] = formation.formationName + " Base";
}
for (const RigWellPathFormation& formation : fluidFormations)
{
uniqueListMaker[formation.mdTop] = formation.formationName + " Top";
}
for (auto it = uniqueListMaker.begin(); it != uniqueListMaker.end(); it++)
{
measuredDepths->push_back(it->first);
names->push_back(it->second);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigWellPathFormations::measuredDepthAndFormationNamesUpToLevel(FormationLevel maxLevel,
std::vector<QString>* names,
std::vector<double>* measuredDepths, bool includeFluids) const
void RigWellPathFormations::evaluateFormations(const std::vector<std::pair<RigWellPathFormation, FormationLevel>>& formations,
const FormationLevel& maxLevel, std::vector<QString>* names,
std::vector<double>* depths, RimWellLogPlot::DepthTypeEnum depthType) const
{
std::map<double, LevelAndName, DepthComp> tempMakeVectorUniqueOnDepth;
evaluateFormationsForOnePosition(formations, maxLevel, PickPosition::TOP, &tempMakeVectorUniqueOnDepth, depthType);
evaluateFormationsForOnePosition(formations, maxLevel, PickPosition::BASE, &tempMakeVectorUniqueOnDepth, depthType);
for (const std::pair<double, LevelAndName>& uniqueDepth : tempMakeVectorUniqueOnDepth)
{
depths->push_back(uniqueDepth.first);
names->push_back(uniqueDepth.second.name);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigWellPathFormations::evaluateFluids(const std::vector<RigWellPathFormation>& fluidFormations, std::vector<QString>* names,
std::vector<double>* depths, RimWellLogPlot::DepthTypeEnum depthType) const
{
std::map<double, QString, DepthComp> uniqueListMaker;
for (const RigWellPathFormation& formation : fluidFormations)
{
double depthBase;
if (depthType == RimWellLogPlot::MEASURED_DEPTH)
{
depthBase = formation.mdBase;
}
else if (depthType == RimWellLogPlot::TRUE_VERTICAL_DEPTH)
{
depthBase = formation.tvdBase;
}
else return;
uniqueListMaker[depthBase] = formation.formationName + " Base";
}
for (const RigWellPathFormation& formation : fluidFormations)
{
double depthTop;
if (depthType == RimWellLogPlot::MEASURED_DEPTH)
{
depthTop = formation.mdTop;
}
else if (depthType == RimWellLogPlot::TRUE_VERTICAL_DEPTH)
{
depthTop = formation.tvdTop;
}
else return;
uniqueListMaker[depthTop] = formation.formationName + " Top";
}
for (const std::pair<double, QString>& depthAndFormation : uniqueListMaker)
{
depths->push_back(depthAndFormation.first);
names->push_back(depthAndFormation.second);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigWellPathFormations::depthAndFormationNamesUpToLevel(FormationLevel level, std::vector<QString>* names, std::vector<double>* depths,
bool includeFluids, RimWellLogPlot::DepthTypeEnum depthType) const
{
names->clear();
measuredDepths->clear();
depths->clear();
if (includeFluids)
{
evaluateFluids(m_fluids, names, measuredDepths);
evaluateFluids(m_fluids, names, depths, depthType);
}
if (maxLevel == RigWellPathFormations::NONE)
if (level == RigWellPathFormations::NONE)
{
return;
}
else if (maxLevel == RigWellPathFormations::ALL)
else if (level == RigWellPathFormations::ALL)
{
measuredDepthAndFormationNamesWithoutDuplicatesOnDepth(names, measuredDepths);
depthAndFormationNamesWithoutDuplicatesOnDepth(names, depths, depthType);
}
else
{
evaluateFormations(m_formations, maxLevel, names, measuredDepths);
evaluateFormations(m_formations, level, names, depths, depthType);
}
}
@ -223,9 +303,9 @@ std::vector<RigWellPathFormations::FormationLevel> RigWellPathFormations::format
{
std::vector<RigWellPathFormations::FormationLevel> formationLevels;
for (auto it = m_formationsLevelsPresent.begin(); it != m_formationsLevelsPresent.end(); it++)
for (const std::pair<RigWellPathFormations::FormationLevel, bool>& formationLevel : m_formationsLevelsPresent)
{
formationLevels.push_back(it->first);
formationLevels.push_back(formationLevel.first);
}
return formationLevels;
}
@ -255,7 +335,7 @@ size_t RigWellPathFormations::formationNamesCount() const
}
//--------------------------------------------------------------------------------------------------
///
///
//--------------------------------------------------------------------------------------------------
bool RigWellPathFormations::isFluid(QString formationName)
{
@ -327,7 +407,7 @@ RigWellPathFormations::FormationLevel RigWellPathFormations::detectLevel(QString
QString levelDescriptor = levelDesctiptorCandidates[0];
QStringList joinedLevel = levelDescriptor.split('+');
if ( joinedLevel.size() > 1 )
if (joinedLevel.size() > 1)
{
levelDescriptor = joinedLevel[0];
}
@ -338,16 +418,16 @@ RigWellPathFormations::FormationLevel RigWellPathFormations::detectLevel(QString
switch (dotCount)
{
case 0: return RigWellPathFormations::LEVEL1;
case 1: return RigWellPathFormations::LEVEL2;
case 2: return RigWellPathFormations::LEVEL3;
case 3: return RigWellPathFormations::LEVEL4;
case 4: return RigWellPathFormations::LEVEL5;
case 5: return RigWellPathFormations::LEVEL6;
case 6: return RigWellPathFormations::LEVEL7;
case 7: return RigWellPathFormations::LEVEL8;
case 8: return RigWellPathFormations::LEVEL9;
case 9: return RigWellPathFormations::LEVEL10;
case 0: return RigWellPathFormations::LEVEL1;
case 1: return RigWellPathFormations::LEVEL2;
case 2: return RigWellPathFormations::LEVEL3;
case 3: return RigWellPathFormations::LEVEL4;
case 4: return RigWellPathFormations::LEVEL5;
case 5: return RigWellPathFormations::LEVEL6;
case 6: return RigWellPathFormations::LEVEL7;
case 7: return RigWellPathFormations::LEVEL8;
case 8: return RigWellPathFormations::LEVEL9;
case 9: return RigWellPathFormations::LEVEL10;
default: break;
}
return RigWellPathFormations::UNKNOWN;

View File

@ -1,17 +1,17 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
@ -19,8 +19,11 @@
#pragma once
#include "cvfBase.h"
#include "cvfMath.h"
#include "cvfObject.h"
#include "RimWellLogPlot.h"
#include <map>
#include <utility>
#include <vector>
@ -31,32 +34,92 @@ struct RigWellPathFormation
{
double mdTop;
double mdBase;
double tvdTop;
double tvdBase;
QString formationName;
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class RigWellPathFormations : public cvf::Object
{
public:
RigWellPathFormations(const std::vector<RigWellPathFormation>& formations, const QString& filePath, const QString& key);
enum FormationLevel
{
GROUP, LEVEL0, LEVEL1, LEVEL2, LEVEL3, LEVEL4, LEVEL5, LEVEL6, LEVEL7, LEVEL8, LEVEL9, LEVEL10, ALL, UNKNOWN, NONE
GROUP,
LEVEL0,
LEVEL1,
LEVEL2,
LEVEL3,
LEVEL4,
LEVEL5,
LEVEL6,
LEVEL7,
LEVEL8,
LEVEL9,
LEVEL10,
ALL,
UNKNOWN,
NONE
};
void measuredDepthAndFormationNamesUpToLevel(FormationLevel level, std::vector<QString>* names,
std::vector<double>* measuredDepths, bool includeFluids) const;
public:
RigWellPathFormations(const std::vector<RigWellPathFormation>& formations, const QString& filePath, const QString& key);
void depthAndFormationNamesUpToLevel(FormationLevel level, std::vector<QString>* names, std::vector<double>* depths,
bool includeFluids, RimWellLogPlot::DepthTypeEnum depthType) const;
std::vector<FormationLevel> formationsLevelsPresent() const;
QString filePath() const;
QString keyInFile() const;
size_t formationNamesCount() const;
size_t formationNamesCount() const;
private:
void measuredDepthAndFormationNamesWithoutDuplicatesOnDepth(std::vector<QString>* names,
std::vector<double>* measuredDepths) const;
struct DepthComp
{
bool operator()(const double& depth1, const double& depth2) const
{
if (cvf::Math::abs(depth1 - depth2) < 0.1)
{
return false;
}
return depth1 < depth2;
}
};
struct LevelAndName
{
LevelAndName() = default;
LevelAndName(RigWellPathFormations::FormationLevel level, QString name) : level(level), name(name) {}
RigWellPathFormations::FormationLevel level;
QString name;
};
enum PickPosition
{
TOP,
BASE
};
private:
void evaluateFormations(const std::vector<std::pair<RigWellPathFormation, FormationLevel>>& formations,
const FormationLevel& maxLevel, std::vector<QString>* names, std::vector<double>* depths,
RimWellLogPlot::DepthTypeEnum depthType) const;
void evaluateFluids(const std::vector<RigWellPathFormation>& fluidFormations, std::vector<QString>* names,
std::vector<double>* depths, RimWellLogPlot::DepthTypeEnum depthType) const;
void evaluateFormationsForOnePosition(const std::vector<std::pair<RigWellPathFormation, FormationLevel>>& formations,
const FormationLevel& maxLevel, const PickPosition& position,
std::map<double, LevelAndName, DepthComp>* uniqueListMaker,
RimWellLogPlot::DepthTypeEnum depthType) const;
void depthAndFormationNamesWithoutDuplicatesOnDepth(std::vector<QString>* names, std::vector<double>* measuredDepths,
RimWellLogPlot::DepthTypeEnum depthType) const;
bool isFluid(QString formationName);
FormationLevel detectLevel(QString formationName);
@ -68,5 +131,5 @@ private:
std::map<FormationLevel, bool> m_formationsLevelsPresent;
std::vector<std::pair<RigWellPathFormation, FormationLevel>> m_formations;
std::vector<RigWellPathFormation> m_fluids;
std::vector<RigWellPathFormation> m_fluids;
};