Placed WellLogExtractors in the RimWellLogPlotCollection and cached them

This commit is contained in:
Jacob Støren
2015-09-03 20:13:08 +02:00
parent e15a95f8b4
commit 1e6baed1dc
5 changed files with 90 additions and 47 deletions

View File

@@ -142,9 +142,9 @@ RimProject::~RimProject(void)
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RimProject::close() void RimProject::close()
{ {
if (mainPlotCollection()) delete mainPlotCollection();
oilFields.deleteAllChildObjects(); oilFields.deleteAllChildObjects();
oilFields.push_back(new RimOilField); oilFields.push_back(new RimOilField);
if (mainPlotCollection()) delete mainPlotCollection();
casesObsolete.deleteAllChildObjects(); casesObsolete.deleteAllChildObjects();
caseGroupsObsolete.deleteAllChildObjects(); caseGroupsObsolete.deleteAllChildObjects();

View File

@@ -36,6 +36,7 @@
#include "RimWellLogPlot.h" #include "RimWellLogPlot.h"
#include "RiuWellLogTracePlot.h" #include "RiuWellLogTracePlot.h"
#include "qwt_plot_curve.h" #include "qwt_plot_curve.h"
#include "RimWellLogPlotCollection.h"
//================================================================================================== //==================================================================================================
/// ///
@@ -112,61 +113,65 @@ void RimWellLogExtractionCurve::updatePlotData()
if (m_showCurve) if (m_showCurve)
{ {
bool hasData = false; // Make sure we have set correct case data into the result definitions.
std::vector<double> filteredValues;
std::vector<double> filteredDepths;
RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>(m_case.value()); RimGeoMechCase* geomCase = dynamic_cast<RimGeoMechCase*>(m_case.value());
RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(m_case.value()); RimEclipseCase* eclipseCase = dynamic_cast<RimEclipseCase*>(m_case.value());
m_eclipseResultDefinition->setEclipseCase(eclipseCase); m_eclipseResultDefinition->setEclipseCase(eclipseCase);
m_geomResultDefinition->setGeoMechCase(geomCase); m_geomResultDefinition->setGeoMechCase(geomCase);
if (m_wellPath) RimWellLogPlotCollection* wellLogCollection = NULL;
this->firstAnchestorOrThisOfType(wellLogCollection);
CVF_ASSERT(wellLogCollection);
cvf::ref<RigEclipseWellLogExtractor> eclExtractor = wellLogCollection->findOrCreateExtractor(m_wellPath, eclipseCase);
//cvf::ref<RigGeoMechWellLogExtractor> geomExtractor = wellLogCollection->findOrCreateExtractor(m_wellPath, geomCase);
std::vector<double> filteredValues;
std::vector<double> filteredDepths;
bool hasData = false;
if (eclExtractor.notNull())
{ {
if (eclipseCase) const std::vector<double>& depthValues = eclExtractor->measuredDepth();
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())
{ {
RigEclipseWellLogExtractor extractor(eclipseCase->reservoirData(), m_wellPath->wellPathGeometry()); eclExtractor->curveData(resAcc.p(), &values);
const std::vector<double>& depthValues = (extractor.measuredDepth()); hasData = true;
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())
{
extractor.curveData(resAcc.p(), &values);
hasData = true;
}
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]);
}
} }
else if (geomCase)
// 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]);
} }
} }
else if (false) // geomExtractor
{
// Todo: do geomech log extraction
}
m_plotCurve->setSamples(filteredValues.data(), filteredDepths.data(), (int)filteredValues.size()); m_plotCurve->setSamples(filteredValues.data(), filteredDepths.data(), (int)filteredValues.size());
@@ -182,8 +187,6 @@ void RimWellLogExtractionCurve::updatePlotData()
} }
updateCurveTitle(); updateCurveTitle();
m_plot->replot(); m_plot->replot();
} }

View File

@@ -22,6 +22,11 @@
#include "RimWellLogPlot.h" #include "RimWellLogPlot.h"
#include "cafPdmUiTreeView.h" #include "cafPdmUiTreeView.h"
#include "RigCaseData.h"
#include "RimWellPath.h"
#include "RimEclipseCase.h"
#include "RigEclipseWellLogExtractor.h"
#include "RimWellPathCollection.h"
CAF_PDM_SOURCE_INIT(RimWellLogPlotCollection, "WellLogPlotCollection"); CAF_PDM_SOURCE_INIT(RimWellLogPlotCollection, "WellLogPlotCollection");
@@ -43,3 +48,29 @@ RimWellLogPlotCollection::~RimWellLogPlotCollection()
{ {
wellLogPlots.deleteAllChildObjects(); wellLogPlots.deleteAllChildObjects();
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigEclipseWellLogExtractor* RimWellLogPlotCollection::findOrCreateExtractor(RimWellPath* wellPath, RimEclipseCase* eclCase)
{
if (!(wellPath && eclCase && wellPath->wellPathGeometry() && eclCase->reservoirData()))
{
return NULL;
}
RigCaseData* eclCaseData = eclCase->reservoirData();
RigWellPath* wellPathGeom = wellPath->wellPathGeometry();
for (size_t exIdx = 0; exIdx < m_extractors.size(); ++exIdx)
{
if (m_extractors[exIdx]->caseData() == eclCaseData && m_extractors[exIdx]->wellPathData() == wellPathGeom)
{
return m_extractors[exIdx].p();
}
}
cvf::ref<RigEclipseWellLogExtractor> extractor = new RigEclipseWellLogExtractor(eclCaseData, wellPathGeom);
m_extractors.push_back(extractor.p());
return extractor.p();
}

View File

@@ -22,10 +22,12 @@
#include "cafPdmObject.h" #include "cafPdmObject.h"
#include "cafPdmField.h" #include "cafPdmField.h"
#include "cafPdmChildArrayField.h" #include "cafPdmChildArrayField.h"
#include "cvfCollection.h"
class RimWellLogPlot; class RimWellLogPlot;
class RigEclipseWellLogExtractor;
class RimWellPath;
class RimEclipseCase;
//================================================================================================== //==================================================================================================
/// ///
/// ///
@@ -36,6 +38,10 @@ class RimWellLogPlotCollection : public caf::PdmObject
public: public:
RimWellLogPlotCollection(); RimWellLogPlotCollection();
virtual ~RimWellLogPlotCollection(); virtual ~RimWellLogPlotCollection();
RigEclipseWellLogExtractor* findOrCreateExtractor(RimWellPath* wellPath, RimEclipseCase* eclCase);
caf::PdmChildArrayField<RimWellLogPlot*> wellLogPlots; caf::PdmChildArrayField<RimWellLogPlot*> wellLogPlots;
private:
cvf::Collection<RigEclipseWellLogExtractor> m_extractors;
}; };

View File

@@ -49,6 +49,9 @@ public:
void curveData(const RigResultAccessor* resultAccessor, std::vector<double>* values ); void curveData(const RigResultAccessor* resultAccessor, std::vector<double>* values );
const RigCaseData* caseData() { return m_caseData.p();}
const RigWellPath* wellPathData() { return m_wellPath.p();}
private: private:
void calculateIntersection(); void calculateIntersection();
std::vector<size_t> findCloseCells(const cvf::BoundingBox& bb); std::vector<size_t> findCloseCells(const cvf::BoundingBox& bb);