From 1e6baed1dc59bf16d1a95a671846c3568b7de349 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Thu, 3 Sep 2015 20:13:08 +0200 Subject: [PATCH] Placed WellLogExtractors in the RimWellLogPlotCollection and cached them --- .../ProjectDataModel/RimProject.cpp | 2 +- .../RimWellLogExtractionCurve.cpp | 91 ++++++++++--------- .../RimWellLogPlotCollection.cpp | 31 +++++++ .../RimWellLogPlotCollection.h | 10 +- .../RigEclipseWellLogExtractor.h | 3 + 5 files changed, 90 insertions(+), 47 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 9545de115c..c263d05a8d 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -142,9 +142,9 @@ RimProject::~RimProject(void) //-------------------------------------------------------------------------------------------------- void RimProject::close() { + if (mainPlotCollection()) delete mainPlotCollection(); oilFields.deleteAllChildObjects(); oilFields.push_back(new RimOilField); - if (mainPlotCollection()) delete mainPlotCollection(); casesObsolete.deleteAllChildObjects(); caseGroupsObsolete.deleteAllChildObjects(); diff --git a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp index 9473f2abd8..42aefe7d0a 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp @@ -36,6 +36,7 @@ #include "RimWellLogPlot.h" #include "RiuWellLogTracePlot.h" #include "qwt_plot_curve.h" +#include "RimWellLogPlotCollection.h" //================================================================================================== /// @@ -112,61 +113,65 @@ void RimWellLogExtractionCurve::updatePlotData() if (m_showCurve) { - bool hasData = false; - - - - std::vector filteredValues; - std::vector filteredDepths; + // Make sure we have set correct case data into the result definitions. RimGeoMechCase* geomCase = dynamic_cast(m_case.value()); RimEclipseCase* eclipseCase = dynamic_cast(m_case.value()); m_eclipseResultDefinition->setEclipseCase(eclipseCase); m_geomResultDefinition->setGeoMechCase(geomCase); - if (m_wellPath) + RimWellLogPlotCollection* wellLogCollection = NULL; + this->firstAnchestorOrThisOfType(wellLogCollection); + + CVF_ASSERT(wellLogCollection); + + cvf::ref eclExtractor = wellLogCollection->findOrCreateExtractor(m_wellPath, eclipseCase); + //cvf::ref geomExtractor = wellLogCollection->findOrCreateExtractor(m_wellPath, geomCase); + + std::vector filteredValues; + std::vector filteredDepths; + bool hasData = false; + + if (eclExtractor.notNull()) { - if (eclipseCase) + const std::vector& depthValues = eclExtractor->measuredDepth(); + + RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(m_eclipseResultDefinition->porosityModel()); + m_eclipseResultDefinition->loadResult(); + + cvf::ref resAcc = RigResultAccessorFactory::createResultAccessor( + eclipseCase->reservoirData(), 0, + porosityModel, + m_timeStep, + m_eclipseResultDefinition->resultVariable()); + + std::vector values; + + if (resAcc.notNull()) { - RigEclipseWellLogExtractor extractor(eclipseCase->reservoirData(), m_wellPath->wellPathGeometry()); - const std::vector& depthValues = (extractor.measuredDepth()); - - RifReaderInterface::PorosityModelResultType porosityModel = RigCaseCellResultsData::convertFromProjectModelPorosityModel(m_eclipseResultDefinition->porosityModel()); - m_eclipseResultDefinition->loadResult(); - - cvf::ref resAcc = RigResultAccessorFactory::createResultAccessor( - eclipseCase->reservoirData(), 0, - porosityModel, - m_timeStep, - m_eclipseResultDefinition->resultVariable()); - - std::vector 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]); - } + eclExtractor->curveData(resAcc.p(), &values); + hasData = true; } - 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()); @@ -182,8 +187,6 @@ void RimWellLogExtractionCurve::updatePlotData() } updateCurveTitle(); - - m_plot->replot(); } diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlotCollection.cpp b/ApplicationCode/ProjectDataModel/RimWellLogPlotCollection.cpp index b992858268..e29a9cd369 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlotCollection.cpp @@ -22,6 +22,11 @@ #include "RimWellLogPlot.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"); @@ -43,3 +48,29 @@ RimWellLogPlotCollection::~RimWellLogPlotCollection() { 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 extractor = new RigEclipseWellLogExtractor(eclCaseData, wellPathGeom); + m_extractors.push_back(extractor.p()); + + return extractor.p(); +} diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlotCollection.h b/ApplicationCode/ProjectDataModel/RimWellLogPlotCollection.h index 2c605712fe..b0fdfa77e5 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlotCollection.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlotCollection.h @@ -22,10 +22,12 @@ #include "cafPdmObject.h" #include "cafPdmField.h" #include "cafPdmChildArrayField.h" +#include "cvfCollection.h" class RimWellLogPlot; - - +class RigEclipseWellLogExtractor; +class RimWellPath; +class RimEclipseCase; //================================================================================================== /// /// @@ -36,6 +38,10 @@ class RimWellLogPlotCollection : public caf::PdmObject public: RimWellLogPlotCollection(); virtual ~RimWellLogPlotCollection(); + + RigEclipseWellLogExtractor* findOrCreateExtractor(RimWellPath* wellPath, RimEclipseCase* eclCase); caf::PdmChildArrayField wellLogPlots; +private: + cvf::Collection m_extractors; }; diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.h b/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.h index a5b3ed310f..e02ee60f8c 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.h +++ b/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.h @@ -49,6 +49,9 @@ public: void curveData(const RigResultAccessor* resultAccessor, std::vector* values ); + const RigCaseData* caseData() { return m_caseData.p();} + const RigWellPath* wellPathData() { return m_wellPath.p();} + private: void calculateIntersection(); std::vector findCloseCells(const cvf::BoundingBox& bb);