2015-09-02 05:34:12 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2015- Statoil ASA
|
|
|
|
// Copyright (C) 2015- Ceetron Solutions AS
|
|
|
|
//
|
|
|
|
// 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 "RimWellLogExtractionCurve.h"
|
|
|
|
#include "RimProject.h"
|
|
|
|
#include "RiaApplication.h"
|
|
|
|
#include "RimOilField.h"
|
|
|
|
#include "RimWellPathCollection.h"
|
|
|
|
#include "RimWellPath.h"
|
|
|
|
#include "RimEclipseCase.h"
|
|
|
|
#include "RimEclipseResultDefinition.h"
|
|
|
|
#include "RimGeoMechResultDefinition.h"
|
|
|
|
#include "RimGeoMechCase.h"
|
|
|
|
#include "RigEclipseWellLogExtractor.h"
|
|
|
|
#include "RigResultAccessorFactory.h"
|
|
|
|
#include "RigCaseCellResultsData.h"
|
|
|
|
#include "RigCaseData.h"
|
|
|
|
#include "RimWellLogPlotCurve.h"
|
|
|
|
#include "RimWellLogPlot.h"
|
2015-09-04 05:21:41 -05:00
|
|
|
#include "RimWellLogPlotTrace.h"
|
2015-09-11 03:44:10 -05:00
|
|
|
|
2015-09-02 05:34:12 -05:00
|
|
|
#include "RiuWellLogTracePlot.h"
|
|
|
|
#include "qwt_plot_curve.h"
|
2015-09-03 13:13:08 -05:00
|
|
|
#include "RimWellLogPlotCollection.h"
|
2015-09-03 13:54:15 -05:00
|
|
|
#include "cafPdmUiTreeOrdering.h"
|
2015-09-04 08:30:04 -05:00
|
|
|
#include "RigGeoMechWellLogExtractor.h"
|
2015-09-02 05:34:12 -05:00
|
|
|
|
|
|
|
//==================================================================================================
|
|
|
|
///
|
|
|
|
///
|
|
|
|
//==================================================================================================
|
|
|
|
|
|
|
|
CAF_PDM_SOURCE_INIT(RimWellLogExtractionCurve, "WellLogEclipseCurve");
|
2015-09-03 03:55:54 -05:00
|
|
|
|
2015-09-02 05:34:12 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimWellLogExtractionCurve::RimWellLogExtractionCurve()
|
|
|
|
{
|
|
|
|
CAF_PDM_InitObject("Well Log Curve", "", "", "");
|
|
|
|
|
|
|
|
CAF_PDM_InitFieldNoDefault(&m_wellPath, "CurveWellPath", "Well Path", "", "", "");
|
|
|
|
m_wellPath.uiCapability()->setUiChildrenHidden(true);
|
2015-09-03 01:09:06 -05:00
|
|
|
//m_wellPath.uiCapability()->setUiHidden(true);
|
|
|
|
|
2015-09-02 05:34:12 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault(&m_case, "CurveCase", "Case", "", "", "");
|
|
|
|
m_case.uiCapability()->setUiChildrenHidden(true);
|
2015-09-03 01:09:06 -05:00
|
|
|
//m_case.uiCapability()->setUiHidden(true);
|
2015-09-02 05:34:12 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault(&m_eclipseResultDefinition, "CurveEclipseResult", "", "", "", "");
|
2015-09-03 01:09:06 -05:00
|
|
|
m_eclipseResultDefinition.uiCapability()->setUiHidden(true);
|
2015-09-02 05:34:12 -05:00
|
|
|
m_eclipseResultDefinition.uiCapability()->setUiChildrenHidden(true);
|
|
|
|
m_eclipseResultDefinition = new RimEclipseResultDefinition;
|
2015-09-03 01:09:06 -05:00
|
|
|
|
2015-09-02 05:34:12 -05:00
|
|
|
CAF_PDM_InitFieldNoDefault(&m_geomResultDefinition, "CurveGeomechResult", "", "", "", "");
|
2015-09-03 01:09:06 -05:00
|
|
|
m_geomResultDefinition.uiCapability()->setUiHidden(true);
|
2015-09-02 05:34:12 -05:00
|
|
|
m_geomResultDefinition.uiCapability()->setUiChildrenHidden(true);
|
|
|
|
m_geomResultDefinition = new RimGeoMechResultDefinition;
|
|
|
|
|
|
|
|
CAF_PDM_InitField(&m_timeStep, "CurveTimeStep", 0,"Time Step", "", "", "");
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RimWellLogExtractionCurve::~RimWellLogExtractionCurve()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellLogExtractionCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
|
|
|
|
{
|
2015-09-03 02:49:36 -05:00
|
|
|
RimWellLogPlotCurve::fieldChangedByUi(changedField, oldValue, newValue);
|
|
|
|
|
2015-09-11 03:44:10 -05:00
|
|
|
if (changedField == &m_case)
|
2015-09-02 05:34:12 -05:00
|
|
|
{
|
2015-09-03 02:49:36 -05:00
|
|
|
this->updatePlotData();
|
2015-09-03 01:09:06 -05:00
|
|
|
}
|
|
|
|
|
2015-09-03 02:49:36 -05:00
|
|
|
if (changedField == &m_wellPath)
|
|
|
|
{
|
|
|
|
this->updatePlotData();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (changedField == &m_timeStep)
|
|
|
|
{
|
|
|
|
this->updatePlotData();
|
|
|
|
}
|
2015-09-02 05:34:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellLogExtractionCurve::updatePlotData()
|
|
|
|
{
|
2015-09-03 02:49:36 -05:00
|
|
|
RimWellLogPlotCurve::updatePlotData();
|
2015-09-02 05:34:12 -05:00
|
|
|
|
2015-09-03 02:49:36 -05:00
|
|
|
if (m_showCurve)
|
2015-09-02 05:34:12 -05:00
|
|
|
{
|
2015-09-03 13:13:08 -05:00
|
|
|
// Make sure we have set correct case data into the result definitions.
|
2015-09-03 02:49:36 -05:00
|
|
|
|
|
|
|
RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>(m_case.value());
|
|
|
|
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(m_case.value());
|
|
|
|
m_eclipseResultDefinition->setEclipseCase(eclipseCase);
|
|
|
|
m_geomResultDefinition->setGeoMechCase(geomCase);
|
|
|
|
|
2015-09-03 13:13:08 -05:00
|
|
|
RimWellLogPlotCollection* wellLogCollection = NULL;
|
|
|
|
this->firstAnchestorOrThisOfType(wellLogCollection);
|
2015-09-03 02:49:36 -05:00
|
|
|
|
2015-09-03 13:13:08 -05:00
|
|
|
CVF_ASSERT(wellLogCollection);
|
2015-09-03 02:49:36 -05:00
|
|
|
|
2015-09-03 13:13:08 -05:00
|
|
|
cvf::ref<RigEclipseWellLogExtractor> eclExtractor = wellLogCollection->findOrCreateExtractor(m_wellPath, eclipseCase);
|
2015-09-04 08:30:04 -05:00
|
|
|
cvf::ref<RigGeoMechWellLogExtractor> geomExtractor = wellLogCollection->findOrCreateExtractor(m_wellPath, geomCase);
|
2015-09-03 12:07:26 -05:00
|
|
|
|
2015-09-03 13:13:08 -05:00
|
|
|
std::vector<double> filteredValues;
|
|
|
|
std::vector<double> filteredDepths;
|
2015-09-03 12:07:26 -05:00
|
|
|
|
2015-09-03 13:13:08 -05:00
|
|
|
if (eclExtractor.notNull())
|
|
|
|
{
|
2015-09-11 03:44:10 -05:00
|
|
|
RimWellLogPlot* wellLogPlot;
|
|
|
|
firstAnchestorOrThisOfType(wellLogPlot);
|
|
|
|
CVF_ASSERT(wellLogPlot);
|
|
|
|
|
|
|
|
const std::vector<double>& depthValues = wellLogPlot->depthType() == RimWellLogPlot::MEASURED_DEPTH ? eclExtractor->measuredDepth() : eclExtractor->trueVerticalDepth();
|
2015-09-03 12:07:26 -05:00
|
|
|
|
2015-09-03 13:13:08 -05:00
|
|
|
RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(m_eclipseResultDefinition->porosityModel());
|
|
|
|
m_eclipseResultDefinition->loadResult();
|
|
|
|
|
|
|
|
cvf::ref<RigResultAccessor> resAcc = RigResultAccessorFactory::createResultAccessor(
|
|
|
|
eclipseCase->reservoirData(), 0,
|
|
|
|
porosityModel,
|
|
|
|
m_timeStep,
|
|
|
|
m_eclipseResultDefinition->resultVariable());
|
|
|
|
|
|
|
|
std::vector<double> values;
|
|
|
|
|
|
|
|
if (resAcc.notNull())
|
2015-09-03 02:49:36 -05:00
|
|
|
{
|
2015-09-03 13:13:08 -05:00
|
|
|
eclExtractor->curveData(resAcc.p(), &values);
|
|
|
|
}
|
2015-09-02 05:34:12 -05:00
|
|
|
|
2015-09-07 03:32:54 -05:00
|
|
|
filterPlotValues( depthValues, filteredDepths,
|
|
|
|
values, filteredValues );
|
2015-09-02 05:34:12 -05:00
|
|
|
|
2015-09-03 02:49:36 -05:00
|
|
|
}
|
2015-09-07 03:32:54 -05:00
|
|
|
else if (geomExtractor.notNull()) // geomExtractor
|
2015-09-03 13:13:08 -05:00
|
|
|
{
|
2015-09-07 03:32:54 -05:00
|
|
|
const std::vector<double>& depthValues = geomExtractor->measuredDepth();
|
|
|
|
m_geomResultDefinition->loadResult();
|
|
|
|
std::vector<double> values;
|
|
|
|
geomExtractor->curveData(m_geomResultDefinition->resultAddress() , m_timeStep, &values);
|
|
|
|
|
|
|
|
|
|
|
|
filterPlotValues( depthValues, filteredDepths,
|
|
|
|
values, filteredValues );
|
|
|
|
|
2015-09-03 13:13:08 -05:00
|
|
|
}
|
2015-09-03 02:49:36 -05:00
|
|
|
|
2015-09-03 12:07:26 -05:00
|
|
|
m_plotCurve->setSamples(filteredValues.data(), filteredDepths.data(), (int)filteredValues.size());
|
2015-09-02 05:34:12 -05:00
|
|
|
|
2015-09-07 03:32:54 -05:00
|
|
|
if (filteredValues.size())
|
2015-09-02 05:34:12 -05:00
|
|
|
{
|
2015-09-07 11:00:04 -05:00
|
|
|
RimWellLogPlotTrace* plotTrace;
|
|
|
|
firstAnchestorOrThisOfType(plotTrace);
|
|
|
|
|
2015-09-03 02:49:36 -05:00
|
|
|
RimWellLogPlot* wellLogPlot;
|
|
|
|
firstAnchestorOrThisOfType(wellLogPlot);
|
|
|
|
|
2015-09-07 11:00:04 -05:00
|
|
|
if (wellLogPlot && plotTrace)
|
2015-09-03 02:49:36 -05:00
|
|
|
{
|
2015-09-04 07:14:56 -05:00
|
|
|
bool setDepthRange = !wellLogPlot->hasAvailableDepthRange();
|
2015-09-03 02:49:36 -05:00
|
|
|
wellLogPlot->updateAvailableDepthRange();
|
2015-09-04 05:21:41 -05:00
|
|
|
|
2015-09-07 11:00:04 -05:00
|
|
|
if (setDepthRange)
|
|
|
|
{
|
|
|
|
wellLogPlot->setVisibleDepthRangeFromContents();
|
|
|
|
}
|
|
|
|
else if (plotTrace->curveCount() == 1)
|
2015-09-04 05:21:41 -05:00
|
|
|
{
|
2015-09-11 03:44:10 -05:00
|
|
|
plotTrace->updateAxisRangesAndReplot();
|
2015-09-04 05:21:41 -05:00
|
|
|
}
|
2015-09-03 02:49:36 -05:00
|
|
|
}
|
2015-09-02 05:34:12 -05:00
|
|
|
}
|
|
|
|
|
2015-09-03 02:49:36 -05:00
|
|
|
updateCurveTitle();
|
2015-09-02 05:34:12 -05:00
|
|
|
m_plot->replot();
|
|
|
|
}
|
2015-09-03 02:49:36 -05:00
|
|
|
|
2015-09-02 05:34:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
QList<caf::PdmOptionItemInfo> RimWellLogExtractionCurve::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly)
|
|
|
|
{
|
|
|
|
QList<caf::PdmOptionItemInfo> optionList;
|
|
|
|
|
|
|
|
if (fieldNeedingOptions == &m_wellPath)
|
|
|
|
{
|
|
|
|
RimProject* proj = RiaApplication::instance()->project();
|
2015-09-03 01:09:06 -05:00
|
|
|
if (proj->activeOilField()->wellPathCollection())
|
2015-09-02 05:34:12 -05:00
|
|
|
{
|
2015-09-03 01:09:06 -05:00
|
|
|
caf::PdmChildArrayField<RimWellPath*>& wellPaths = proj->activeOilField()->wellPathCollection()->wellPaths;
|
2015-09-02 05:34:12 -05:00
|
|
|
|
2015-09-03 01:09:06 -05:00
|
|
|
for (size_t i = 0; i< wellPaths.size(); i++)
|
|
|
|
{
|
|
|
|
optionList.push_back(caf::PdmOptionItemInfo(wellPaths[i]->name(), QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(wellPaths[i]))));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (optionList.size() > 0)
|
|
|
|
{
|
|
|
|
optionList.push_front(caf::PdmOptionItemInfo("None", QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(NULL))));
|
|
|
|
}
|
2015-09-02 05:34:12 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (fieldNeedingOptions == &m_case)
|
|
|
|
{
|
|
|
|
RimProject* proj = RiaApplication::instance()->project();
|
|
|
|
std::vector<RimCase*> cases;
|
|
|
|
|
|
|
|
proj->allCases(cases);
|
|
|
|
|
|
|
|
for (size_t i = 0; i< cases.size(); i++)
|
|
|
|
{
|
|
|
|
optionList.push_back(caf::PdmOptionItemInfo(cases[i]->caseUserDescription(), QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(cases[i]))));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (optionList.size() > 0)
|
|
|
|
{
|
|
|
|
optionList.push_front(caf::PdmOptionItemInfo("None", QVariant::fromValue(caf::PdmPointer<caf::PdmObjectHandle>(NULL))));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return optionList;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellLogExtractionCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering)
|
|
|
|
{
|
|
|
|
RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>(m_case.value());
|
|
|
|
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(m_case.value());
|
|
|
|
uiOrdering.add(&m_userName);
|
|
|
|
uiOrdering.add(&m_wellPath);
|
|
|
|
|
|
|
|
caf::PdmUiGroup* group1 = uiOrdering.addNewGroup("Result");
|
|
|
|
group1->add(&m_case);
|
|
|
|
if (eclipseCase)
|
|
|
|
{
|
|
|
|
|
|
|
|
group1->add(&(m_eclipseResultDefinition->m_resultTypeUiField));
|
|
|
|
group1->add(&(m_eclipseResultDefinition->m_porosityModelUiField));
|
|
|
|
group1->add(&(m_eclipseResultDefinition->m_resultVariableUiField));
|
|
|
|
}
|
|
|
|
if (geomCase)
|
|
|
|
{
|
|
|
|
group1->add(&(m_geomResultDefinition->m_resultPositionTypeUiField));
|
|
|
|
group1->add(&(m_geomResultDefinition->m_resultVariableUiField));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-03 01:09:06 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellLogExtractionCurve::initAfterRead()
|
|
|
|
{
|
|
|
|
RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>(m_case.value());
|
|
|
|
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(m_case.value());
|
|
|
|
|
|
|
|
m_eclipseResultDefinition->setEclipseCase(eclipseCase);
|
|
|
|
m_geomResultDefinition->setGeoMechCase(geomCase);
|
|
|
|
}
|
|
|
|
|
2015-09-03 02:49:36 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellLogExtractionCurve::updateCurveTitle()
|
|
|
|
{
|
|
|
|
RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>(m_case.value());
|
|
|
|
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(m_case.value());
|
|
|
|
QString resVar;
|
|
|
|
if (eclipseCase)
|
|
|
|
{
|
|
|
|
resVar = m_eclipseResultDefinition->resultVariable();
|
|
|
|
}
|
|
|
|
|
2015-09-08 02:54:55 -05:00
|
|
|
if (geomCase)
|
|
|
|
{
|
|
|
|
QString resCompName = m_geomResultDefinition->resultComponentUiName();
|
|
|
|
if (resCompName.isEmpty())
|
|
|
|
resVar = m_geomResultDefinition->resultFieldUiName();
|
|
|
|
else
|
|
|
|
resVar = m_geomResultDefinition->resultFieldUiName() + "." + resCompName ;
|
|
|
|
}
|
|
|
|
|
2015-09-03 02:49:36 -05:00
|
|
|
m_userName = resVar;
|
|
|
|
|
|
|
|
m_plotCurve->setTitle(m_userName);
|
|
|
|
}
|
|
|
|
|
2015-09-03 13:54:15 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellLogExtractionCurve::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/)
|
|
|
|
{
|
|
|
|
uiTreeOrdering.setForgetRemainingFields(true);
|
|
|
|
}
|
|
|
|
|
2015-09-07 03:32:54 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
///
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
void RimWellLogExtractionCurve::filterPlotValues(const std::vector<double>& depthValues, std::vector<double> &filteredDepths,
|
|
|
|
const std::vector<double> &values, std::vector<double> &filteredValues )
|
|
|
|
{
|
|
|
|
// Remove values that are too difficult for Qwt to handle
|
|
|
|
|
|
|
|
filteredValues.reserve(values.size());
|
|
|
|
filteredDepths.reserve(values.size());
|
|
|
|
for (size_t vIdx = 0; vIdx < values.size(); ++vIdx)
|
|
|
|
{
|
|
|
|
if (values[vIdx] == HUGE_VAL || values[vIdx] == -HUGE_VAL || (values[vIdx] != values[vIdx]))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
filteredDepths.push_back(depthValues[vIdx]);
|
|
|
|
filteredValues.push_back(values[vIdx]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-02 05:34:12 -05:00
|
|
|
|