From 33614b30bcd45c4bfba8970ee223b812213739ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 15 Jun 2015 12:15:00 +0200 Subject: [PATCH] Added calculation of Total Stress (ST) Seems to work ok, but the nubers are not yet verified. --- .../GeoMech/GeoMechDataModel/RigFemPart.h | 2 + .../RigFemPartResultsCollection.cpp | 121 ++++++++++++------ .../RigFemPartResultsCollection.h | 4 +- .../GeoMechDataModel/RigGeoMechCaseData.cpp | 2 +- 4 files changed, 87 insertions(+), 42 deletions(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.h index d9ef327045..1e2763765f 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.h @@ -56,7 +56,9 @@ public: int elmId(size_t elementIdx) const { return m_elementId[elementIdx]; } RigElementType elementType(size_t elementIdx) const { return m_elementTypes[elementIdx]; } const int* connectivities(size_t elementIdx) const { return &m_allAlementConnectivities[m_elementConnectivityStartIndices[elementIdx]];} + size_t elementNodeResultIdx(int elementIdx, int elmLocalNodeIdx) const { return m_elementConnectivityStartIndices[elementIdx] + elmLocalNodeIdx;} + int nodeIdxFromElementNodeResultIdx(size_t elmNodeResultIdx) const { return m_allAlementConnectivities[elmNodeResultIdx]; } RigFemPartNodes& nodes() {return m_nodes;} const RigFemPartNodes& nodes() const {return m_nodes;} diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index 3dd85920c6..696b6433be 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -27,6 +27,7 @@ #include "RigFemScalarResultFrames.h" #include "RigStatisticsDataCache.h" #include "RigFemPartResults.h" +#include "RigFemPartCollection.h" #include "cafProgressInfo.h" #include "cvfBoundingBox.h" @@ -40,11 +41,13 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigFemPartResultsCollection::RigFemPartResultsCollection(RifGeoMechReaderInterface* readerInterface, int partCount) +RigFemPartResultsCollection::RigFemPartResultsCollection(RifGeoMechReaderInterface* readerInterface, const RigFemPartCollection * femPartCollection) { CVF_ASSERT(readerInterface); m_readerInterface = readerInterface; - m_femPartResults.resize(partCount); + m_femParts = femPartCollection; + + m_femPartResults.resize(m_femParts->partCount()); std::vector stepNames = m_readerInterface->stepNames(); for (int pIdx = 0; pIdx < static_cast(m_femPartResults.size()); ++pIdx) { @@ -62,44 +65,6 @@ RigFemPartResultsCollection::~RigFemPartResultsCollection() } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::map > RigFemPartResultsCollection::scalarFieldAndComponentNames(RigFemResultPosEnum resPos) -{ - std::map > fieldCompNames; - - if (m_readerInterface.notNull()) - { - if (resPos == RIG_NODAL) - { - fieldCompNames = m_readerInterface->scalarNodeFieldAndComponentNames(); - } - else if (resPos == RIG_ELEMENT_NODAL) - { - fieldCompNames = m_readerInterface->scalarElementNodeFieldAndComponentNames(); - fieldCompNames["NS"].push_back("S11"); - fieldCompNames["NS"].push_back("S22"); - fieldCompNames["NS"].push_back("S33"); - fieldCompNames["NS"].push_back("S12"); - fieldCompNames["NS"].push_back("S13"); - fieldCompNames["NS"].push_back("S23"); - } - else if (resPos == RIG_INTEGRATION_POINT) - { - fieldCompNames = m_readerInterface->scalarIntegrationPointFieldAndComponentNames(); - fieldCompNames["NS"].push_back("S11"); - fieldCompNames["NS"].push_back("S22"); - fieldCompNames["NS"].push_back("S33"); - fieldCompNames["NS"].push_back("S12"); - fieldCompNames["NS"].push_back("S13"); - fieldCompNames["NS"].push_back("S23"); - } - } - - return fieldCompNames; -} - //-------------------------------------------------------------------------------------------------- /// Will always return a valid object, but it can be empty //-------------------------------------------------------------------------------------------------- @@ -170,6 +135,52 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::findOrLoadScalarResult(in } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::map > RigFemPartResultsCollection::scalarFieldAndComponentNames(RigFemResultPosEnum resPos) +{ + std::map > fieldCompNames; + + if (m_readerInterface.notNull()) + { + if (resPos == RIG_NODAL) + { + fieldCompNames = m_readerInterface->scalarNodeFieldAndComponentNames(); + } + else if (resPos == RIG_ELEMENT_NODAL) + { + fieldCompNames = m_readerInterface->scalarElementNodeFieldAndComponentNames(); + fieldCompNames["NS"].push_back("S11"); + fieldCompNames["NS"].push_back("S22"); + fieldCompNames["NS"].push_back("S33"); + fieldCompNames["NS"].push_back("S12"); + fieldCompNames["NS"].push_back("S13"); + fieldCompNames["NS"].push_back("S23"); + + fieldCompNames["ST"].push_back("S11"); + fieldCompNames["ST"].push_back("S22"); + fieldCompNames["ST"].push_back("S33"); + } + else if (resPos == RIG_INTEGRATION_POINT) + { + fieldCompNames = m_readerInterface->scalarIntegrationPointFieldAndComponentNames(); + fieldCompNames["NS"].push_back("S11"); + fieldCompNames["NS"].push_back("S22"); + fieldCompNames["NS"].push_back("S33"); + fieldCompNames["NS"].push_back("S12"); + fieldCompNames["NS"].push_back("S13"); + fieldCompNames["NS"].push_back("S23"); + + fieldCompNames["ST"].push_back("S11"); + fieldCompNames["ST"].push_back("S22"); + fieldCompNames["ST"].push_back("S33"); + } + } + + return fieldCompNames; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -196,6 +207,36 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDerivedResult(in return dstDataFrames; } + if ( resVarAddr.fieldName == "ST" + && (resVarAddr.componentName == "S11" + || resVarAddr.componentName == "S22" + || resVarAddr.componentName == "S33" )) + { + RigFemScalarResultFrames * srcNSDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "NS", resVarAddr.componentName)); + RigFemScalarResultFrames * srcPORDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(RIG_NODAL, "POR", "")); + + RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); + const RigFemPart * femPart = m_femParts->part(partIndex); + int frameCount = srcNSDataFrames->frameCount(); + for (int fIdx = 0; fIdx < frameCount; ++fIdx) + { + const std::vector& srcNSFrameData = srcNSDataFrames->frameData(fIdx); + const std::vector& srcPORFrameData = srcPORDataFrames->frameData(fIdx); + + std::vector& dstFrameData = dstDataFrames->frameData(fIdx); + + size_t valCount = srcNSFrameData.size(); + dstFrameData.resize(valCount); + int nodeIdx = 0; + for (size_t vIdx = 0; vIdx < valCount; ++vIdx) + { + nodeIdx = femPart->nodeIdxFromElementNodeResultIdx(vIdx); + dstFrameData[vIdx] = srcNSFrameData[vIdx] + srcPORFrameData[nodeIdx]; + } + } + return dstDataFrames; + } + return NULL; } diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h index 04b46983a7..a3daf3db0e 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h @@ -31,11 +31,12 @@ class RigFemScalarResultFrames; class RigFemPartResultsCollection; class RigFemPartResults; class RigStatisticsDataCache; +class RigFemPartCollection; class RigFemPartResultsCollection: public cvf::Object { public: - RigFemPartResultsCollection(RifGeoMechReaderInterface* readerInterface, int partCount); + RigFemPartResultsCollection(RifGeoMechReaderInterface* readerInterface, const RigFemPartCollection * femPartCollection); ~RigFemPartResultsCollection(); std::map > scalarFieldAndComponentNames(RigFemResultPosEnum resPos); @@ -63,6 +64,7 @@ private: friend class RigFemNativeStatCalc; cvf::Collection m_femPartResults; cvf::ref m_readerInterface; + cvf::cref m_femParts; RigStatisticsDataCache* statistics(const RigFemResultAddress& resVarAddr); std::vector< RigFemResultAddress> getResAddrToComponentsToRead(const RigFemResultAddress& resVarAddr); diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp index adf16c2deb..67e2f1d59c 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp @@ -104,7 +104,7 @@ bool RigGeoMechCaseData::openAndReadFemParts(std::string* errorMessage) progress.setProgressDescription("Calculating element neighbors"); // Initialize results containers - m_femPartResultsColl = new RigFemPartResultsCollection(m_readerInterface.p(), m_femParts->partCount()); + m_femPartResultsColl = new RigFemPartResultsCollection(m_readerInterface.p(), m_femParts.p()); // Calculate derived Fem data for (int pIdx = 0; pIdx < m_femParts->partCount(); ++pIdx)