From 5e54c58c6d6a596b3b487e03247648692b7599fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Jensen?= Date: Tue, 6 Mar 2018 09:33:03 +0100 Subject: [PATCH] #2564 Compaction. Set default reference layer to topmost layer having valid POR --- .../GeoMechDataModel/RigFemPartGrid.cpp | 30 +++++++++++++++++++ .../GeoMech/GeoMechDataModel/RigFemPartGrid.h | 4 ++- .../RimGeoMechResultDefinition.cpp | 7 ++++- 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.cpp index 372b7f2078..3fd1977ba6 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.cpp @@ -182,6 +182,28 @@ void RigFemPartGrid::generateStructGridData() cvf::Vec3i ijk = m_ijkPrElement[elmIdx]; m_elmIdxPrIJK.at(ijk[0], ijk[1], ijk[2]) = elmIdx; } + + // IJK bounding box + m_reservoirIJKBoundingBox.first = cvf::Vec3st(INT_MAX, INT_MAX, INT_MAX); + m_reservoirIJKBoundingBox.second = cvf::Vec3st(0, 0, 0); + cvf::Vec3st& min = m_reservoirIJKBoundingBox.first; + cvf::Vec3st& max = m_reservoirIJKBoundingBox.second; + + for (int elmIdx = 0; elmIdx < m_femPart->elementCount(); ++elmIdx) + { + RigElementType elementType = m_femPart->elementType(elmIdx); + size_t i, j, k; + if (elementType == HEX8P && ijkFromCellIndex(elmIdx, &i, &j, &k)) + { + if (i < min.x()) min.x() = i; + if (j < min.y()) min.y() = j; + if (k < min.z()) min.z() = k; + if (i > max.x()) max.x() = i; + if (j > max.y()) max.y() = j; + if (k > max.z()) max.z() = k; + } + } + } //-------------------------------------------------------------------------------------------------- @@ -287,6 +309,14 @@ cvf::Vec3i RigFemPartGrid::findMainIJKFaces(int elementIndex) const return ijkMainFaceIndices; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair RigFemPartGrid::reservoirIJKBoundingBox() const +{ + return m_reservoirIJKBoundingBox; +} + //-------------------------------------------------------------------------------------------------- /// Find the face that is not perpFaceIdx or its opposite, and has normal closest to direction //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.h index 20e511c569..810f66015d 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.h @@ -38,6 +38,8 @@ public: virtual size_t gridPointCountK() const; cvf::Vec3i findMainIJKFaces(int elementIndex) const; + + std::pair reservoirIJKBoundingBox() const; private: void generateStructGridData(); @@ -93,7 +95,7 @@ private: // Unused, Not implemented }; IJKArray m_elmIdxPrIJK; - + std::pair m_reservoirIJKBoundingBox; }; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp index 26653e834d..ce0f48d30c 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp @@ -101,7 +101,7 @@ RimGeoMechResultDefinition::RimGeoMechResultDefinition(void) m_resultVariableUiField.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName()); m_resultVariableUiField.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP); - CAF_PDM_InitField(&m_compactionRefLayerUiField, "CompactionRefLayerUi", 0, "Compaction Ref Layer", "", "The compaction is calculated with reference to this layer. Default layer is the topmost layer with POR", ""); + CAF_PDM_InitField(&m_compactionRefLayerUiField, "CompactionRefLayerUi", RigFemResultAddress::NO_COMPACTION, "Compaction Ref Layer", "", "The compaction is calculated with reference to this layer. Default layer is the topmost layer with POR", ""); m_compactionRefLayerUiField.xmlCapability()->setIOWritable(false); m_compactionRefLayerUiField.xmlCapability()->setIOReadable(false); @@ -136,6 +136,11 @@ void RimGeoMechResultDefinition::defineUiOrdering(QString uiConfigName, caf::Pdm { caf::PdmUiGroup * compactionGroup = uiOrdering.addNewGroup("Compaction Options"); compactionGroup->add(&m_compactionRefLayerUiField); + + if (m_compactionRefLayerUiField == RigFemResultAddress::NO_COMPACTION) + { + m_compactionRefLayerUiField = (int)m_geomCase->geoMechData()->femParts()->part(0)->structGrid()->reservoirIJKBoundingBox().first.z(); + } } if (!m_isChangedByField)