diff --git a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp index 6b920b773e..9532b64d89 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp @@ -133,7 +133,6 @@ void RimWellLogExtractionCurve::updatePlotData() std::vector filteredValues; std::vector filteredDepths; - bool hasData = false; if (eclExtractor.notNull()) { @@ -153,32 +152,28 @@ void RimWellLogExtractionCurve::updatePlotData() if (resAcc.notNull()) { eclExtractor->curveData(resAcc.p(), &values); - hasData = true; } - // 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; - } + filterPlotValues( depthValues, filteredDepths, + values, filteredValues ); - filteredDepths.push_back(depthValues[vIdx]); - filteredValues.push_back(values[vIdx]); - } } - else if (false) // geomExtractor + else if (geomExtractor.notNull()) // geomExtractor { - // Todo: do geomech log extraction + const std::vector& depthValues = geomExtractor->measuredDepth(); + m_geomResultDefinition->loadResult(); + std::vector values; + geomExtractor->curveData(m_geomResultDefinition->resultAddress() , m_timeStep, &values); + + + filterPlotValues( depthValues, filteredDepths, + values, filteredValues ); + } m_plotCurve->setSamples(filteredValues.data(), filteredDepths.data(), (int)filteredValues.size()); - if (hasData) + if (filteredValues.size()) { RimWellLogPlot* wellLogPlot; firstAnchestorOrThisOfType(wellLogPlot); @@ -319,4 +314,26 @@ void RimWellLogExtractionCurve::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiT uiTreeOrdering.setForgetRemainingFields(true); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogExtractionCurve::filterPlotValues(const std::vector& depthValues, std::vector &filteredDepths, + const std::vector &values, std::vector &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]); + } +} + diff --git a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.h b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.h index 0052a02997..9434a79f4a 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.h @@ -52,6 +52,9 @@ protected: virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = ""); + void filterPlotValues(const std::vector& depthValues, std::vector &filteredDepths, + const std::vector &values, std::vector &filteredValues ); + caf::PdmPtrField m_wellPath; caf::PdmPtrField m_case; caf::PdmChildField m_eclipseResultDefinition; diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlotCollection.cpp b/ApplicationCode/ProjectDataModel/RimWellLogPlotCollection.cpp index e01fb7184f..95a9556ab0 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlotCollection.cpp @@ -80,24 +80,24 @@ RigEclipseWellLogExtractor* RimWellLogPlotCollection::findOrCreateExtractor(RimW //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigGeoMechWellLogExtractor* RimWellLogPlotCollection::findOrCreateExtractor(RimWellPath* wellPath, RimGeoMechCase* eclCase) +RigGeoMechWellLogExtractor* RimWellLogPlotCollection::findOrCreateExtractor(RimWellPath* wellPath, RimGeoMechCase* geomCase) { - if (!(wellPath && eclCase && wellPath->wellPathGeometry() && eclCase->geoMechData())) + if (!(wellPath && geomCase && wellPath->wellPathGeometry() && geomCase->geoMechData())) { return NULL; } - RigGeoMechCaseData* eclCaseData = eclCase->geoMechData(); + RigGeoMechCaseData* geomCaseData = geomCase->geoMechData(); RigWellPath* wellPathGeom = wellPath->wellPathGeometry(); for (size_t exIdx = 0; exIdx < m_geomExtractors.size(); ++exIdx) { - if (m_geomExtractors[exIdx]->caseData() == eclCaseData && m_geomExtractors[exIdx]->wellPathData() == wellPathGeom) + if (m_geomExtractors[exIdx]->caseData() == geomCaseData && m_geomExtractors[exIdx]->wellPathData() == wellPathGeom) { return m_geomExtractors[exIdx].p(); } } - cvf::ref extractor = new RigGeoMechWellLogExtractor(eclCaseData, wellPathGeom); + cvf::ref extractor = new RigGeoMechWellLogExtractor(geomCaseData, wellPathGeom); m_geomExtractors.push_back(extractor.p()); return extractor.p(); diff --git a/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp b/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp index 2287ea22bf..7ab250700a 100644 --- a/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp @@ -43,12 +43,17 @@ RigGeoMechWellLogExtractor::RigGeoMechWellLogExtractor(RigGeoMechCaseData* aCase void RigGeoMechWellLogExtractor::curveData(const RigFemResultAddress& resAddr, int frameIndex, std::vector* values) { CVF_TIGHT_ASSERT(values); - values->resize(m_intersections.size());// + 1); // Plus one for the end of the wellpath stopping inside a cell + + if (!resAddr.isValid()) return ; const RigFemPart* femPart = m_caseData->femParts()->part(0); const std::vector& nodeCoords = femPart->nodes().coordinates; const std::vector& resultValues = m_caseData->femPartResults()->resultValues(resAddr, 0, frameIndex); + if (!resultValues.size()) return; + + values->resize(m_intersections.size());// + 1); // Plus one for the end of the wellpath stopping inside a cell + for (size_t cpIdx = 0; cpIdx < m_intersections.size(); ++cpIdx) { size_t elmIdx = m_intersectedCells[cpIdx]; @@ -127,11 +132,11 @@ void RigGeoMechWellLogExtractor::calculateIntersection() std::vector intersections; cvf::Vec3d hexCorners[8]; - for (size_t cIdx = 0; cIdx < closeCells.size(); ++cIdx) + for (size_t ccIdx = 0; ccIdx < closeCells.size(); ++ccIdx) { - if (femPart->elementType(cIdx) != HEX8) continue; + if (femPart->elementType(closeCells[ccIdx]) != HEX8) continue; - const int* cornerIndices = femPart->connectivities(cIdx); + const int* cornerIndices = femPart->connectivities(closeCells[ccIdx]); hexCorners[0] = cvf::Vec3d(nodeCoords[cornerIndices[0]]); hexCorners[1] = cvf::Vec3d(nodeCoords[cornerIndices[1]]); @@ -142,7 +147,7 @@ void RigGeoMechWellLogExtractor::calculateIntersection() hexCorners[6] = cvf::Vec3d(nodeCoords[cornerIndices[6]]); hexCorners[7] = cvf::Vec3d(nodeCoords[cornerIndices[7]]); - int intersectionCount = RigHexIntersector::lineHexCellIntersection(p1, p2, hexCorners, closeCells[cIdx], &intersections); + int intersectionCount = RigHexIntersector::lineHexCellIntersection(p1, p2, hexCorners, closeCells[ccIdx], &intersections); } // Now, with all the intersections of this piece of line, we need to @@ -193,14 +198,17 @@ std::vector RigGeoMechWellLogExtractor::findCloseCells(const cvf::Boundi for (size_t elmIdx = 0; elmIdx < elmCount; ++elmIdx) { const int* elmNodeIndices = femPart->connectivities(elmIdx); - int elmNodeCount = RigFemTypes::elmentNodeCount( femPart->elementType(elmIdx)); + int elmNodeCount = RigFemTypes::elmentNodeCount(femPart->elementType(elmIdx)); + cvf::BoundingBox cellBB; + for (int enIdx = 0; enIdx < elmNodeCount; ++enIdx) { - if (bb.contains(cvf::Vec3d(nodeCoords[elmNodeIndices[enIdx]]))) - { - closeCells.push_back(elmIdx); - break; - } + cellBB.add(cvf::Vec3d(nodeCoords[elmNodeIndices[enIdx]])); + } + + if (bb.intersects(cellBB)) + { + closeCells.push_back(elmIdx); } } } diff --git a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp index 9d6c271c62..630c787ea4 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp @@ -23,6 +23,7 @@ #include "cvfAssert.h" #include "RimDefines.h" #include "RigFault.h" +#include "cvfBoundingBoxTree.h" RigMainGrid::RigMainGrid(void) @@ -441,3 +442,38 @@ const RigFault* RigMainGrid::findFaultFromCellIndexAndCellFace(size_t reservoirC #endif return NULL; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigMainGrid::findIntersectingCells(const cvf::BoundingBox& inputBB, std::vector* cellIndices) +{ + if (m_cellSearchTree.isNull()) + { + // build tree + + size_t cellCount = m_cells.size(); + + std::vector cellBoundingBoxes; + cellBoundingBoxes.resize(cellCount); + + for (size_t cIdx = 0; cIdx < cellCount; ++cIdx) + { + const caf::SizeTArray8& cellIndices = m_cells[cIdx].cornerIndices(); + cvf::BoundingBox& cellBB = cellBoundingBoxes[cIdx]; + cellBB.add(m_nodes[cellIndices[0]]); + cellBB.add(m_nodes[cellIndices[1]]); + cellBB.add(m_nodes[cellIndices[2]]); + cellBB.add(m_nodes[cellIndices[3]]); + cellBB.add(m_nodes[cellIndices[4]]); + cellBB.add(m_nodes[cellIndices[5]]); + cellBB.add(m_nodes[cellIndices[6]]); + cellBB.add(m_nodes[cellIndices[7]]); + } + + m_cellSearchTree = new cvf::BoundingBoxTree; + m_cellSearchTree->buildTreeFromBoundingBoxes(cellBoundingBoxes, NULL); + } + + m_cellSearchTree->findIntersections(inputBB, cellIndices); +} diff --git a/ApplicationCode/ReservoirDataModel/RigMainGrid.h b/ApplicationCode/ReservoirDataModel/RigMainGrid.h index f208d3f5cb..e12148a817 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.h +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.h @@ -30,6 +30,11 @@ #include #include "RigNNCData.h" +namespace cvf +{ + class BoundingBoxTree; +} + class RigMainGrid : public RigGridBase { public: @@ -63,7 +68,8 @@ public: void setDisplayModelOffset(cvf::Vec3d offset); void setFlipAxis(bool flipXAxis, bool flipYAxis); - + void findIntersectingCells(const cvf::BoundingBox& inputBB, std::vector* cellIndices); + private: void initAllSubGridsParentGridPointer(); void initAllSubCellsMainGridCellIndex(); @@ -81,6 +87,7 @@ private: cvf::ref m_faultsPrCellAcc; cvf::Vec3d m_displayModelOffset; + cvf::ref m_cellSearchTree; bool m_flipXAxis; bool m_flipYAxis;