From faddabadbadc624c0073b043e7ceee6b4be5de3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Tue, 11 Oct 2016 14:54:42 +0200 Subject: [PATCH] #912 Deviatoric Stress added --- .../RigFemPartResultsCollection.cpp | 49 +++++++++++++++++++ .../RigFemPartResultsCollection.h | 1 + .../ProjectDataModel/RimGeoMechView.cpp | 2 +- 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index 35bca99f82..d1b9be4151 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -186,6 +186,7 @@ std::map > RigFemPartResultsCollection::sc fieldCompNames["SM"]; fieldCompNames["SEM"]; + fieldCompNames["Q"]; fieldCompNames["SE"].push_back("S11"); fieldCompNames["SE"].push_back("S22"); @@ -227,6 +228,7 @@ std::map > RigFemPartResultsCollection::sc fieldCompNames = m_readerInterface->scalarIntegrationPointFieldAndComponentNames(); fieldCompNames["SM"]; fieldCompNames["SEM"]; + fieldCompNames["Q"]; fieldCompNames["SE"].push_back("S11"); fieldCompNames["SE"].push_back("S22"); @@ -418,6 +420,48 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateMeanStressSMSEM( return dstDataFrames; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDeviatoricStress(int partIndex, const RigFemResultAddress& resVarAddr) +{ + CVF_ASSERT(resVarAddr.fieldName == "Q"); + + RigFemScalarResultFrames * sa11 = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "S-Bar", "S11")); + RigFemScalarResultFrames * sa22 = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "S-Bar", "S22")); + RigFemScalarResultFrames * sa33 = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "S-Bar", "S33")); + + RigFemScalarResultFrames * sm = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "SM", "")); + + RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); + + int frameCount = sa11->frameCount(); + for(int fIdx = 0; fIdx < frameCount; ++fIdx) + { + const std::vector& sa11Data = sa11->frameData(fIdx); + const std::vector& sa22Data = sa22->frameData(fIdx); + const std::vector& sa33Data = sa33->frameData(fIdx); + + const std::vector& smData = sm->frameData(fIdx); + + std::vector& dstFrameData = dstDataFrames->frameData(fIdx); + size_t valCount = sa11Data.size(); + dstFrameData.resize(valCount); + + for(size_t vIdx = 0; vIdx < valCount; ++vIdx) + { + float smVal = smData[vIdx]; + float sa11Corr = sa11Data[vIdx] - smVal; + float sa22Corr = sa22Data[vIdx] - smVal; + float sa33Corr = sa33Data[vIdx] - smVal; + + dstFrameData[vIdx] = sqrt (1.5*(sa11Corr*sa11Corr + sa22Corr*sa22Corr + sa33Corr*sa33Corr)); + } + } + + return dstDataFrames; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -428,6 +472,11 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDerivedResult(in return calculateTimeLapseResult(partIndex, resVarAddr); } + if(resVarAddr.fieldName == "Q" ) + { + return calculateDeviatoricStress(partIndex, resVarAddr); + } + if(resVarAddr.fieldName == "SM" || resVarAddr.fieldName == "SEM") { return calculateMeanStressSMSEM(partIndex, resVarAddr); diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h index ceaadb78f3..97264e9408 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h @@ -74,6 +74,7 @@ private: RigFemScalarResultFrames* calculateEnIpPorBarResult(int partIndex, const RigFemResultAddress &convertedResultAddr); RigFemScalarResultFrames* calculateTimeLapseResult(int partIndex, const RigFemResultAddress& resVarAddr); RigFemScalarResultFrames* calculateMeanStressSMSEM(int partIndex, const RigFemResultAddress& resVarAddr); + RigFemScalarResultFrames* calculateDeviatoricStress(int partIndex, const RigFemResultAddress& resVarAddr); cvf::Collection m_femPartResults; cvf::ref m_readerInterface; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index fb709cd857..a5f93e4641 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -445,7 +445,7 @@ void RimGeoMechView::updateLegends() } if ( cellResult->resultFieldName() == "SE" || cellResult->resultFieldName() == "ST" || cellResult->resultFieldName() == "POR-Bar" - || cellResult->resultFieldName() == "SM" || cellResult->resultFieldName() == "SEM") + || cellResult->resultFieldName() == "SM" || cellResult->resultFieldName() == "SEM" || cellResult->resultFieldName() == "Q" ) { legendTitle += " [Bar]"; }