diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index bedf9f93c2..30424acb75 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -259,6 +259,9 @@ std::map > RigFemPartResultsCollection::sc fieldCompNames["NE"].push_back("E12"); fieldCompNames["NE"].push_back("E13"); fieldCompNames["NE"].push_back("E23"); + fieldCompNames["NE"].push_back("E1"); + fieldCompNames["NE"].push_back("E2"); + fieldCompNames["NE"].push_back("E3"); } else if (resPos == RIG_INTEGRATION_POINT) @@ -319,6 +322,9 @@ std::map > RigFemPartResultsCollection::sc fieldCompNames["NE"].push_back("E12"); fieldCompNames["NE"].push_back("E13"); fieldCompNames["NE"].push_back("E23"); + fieldCompNames["NE"].push_back("E1"); + fieldCompNames["NE"].push_back("E2"); + fieldCompNames["NE"].push_back("E3"); } else if(resPos == RIG_ELEMENT_NODAL_FACE) @@ -882,6 +888,204 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateSurfaceAlignedSt return requestedSurfStress; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemScalarResultFrames* RigFemPartResultsCollection::calculatePrincipalStressValues(int partIndex, const RigFemResultAddress &resVarAddr ) +{ + CVF_ASSERT(resVarAddr.componentName == "S1" || resVarAddr.componentName == "S2" || resVarAddr.componentName == "S3" + || resVarAddr.componentName == "S1inc" + || resVarAddr.componentName == "S1azi" + || resVarAddr.componentName == "S2inc" + || resVarAddr.componentName == "S2azi" + || resVarAddr.componentName == "S3inc" + || resVarAddr.componentName == "S3azi"); + + caf::ProgressInfo frameCountProgress(this->frameCount() * 7, ""); + frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); + frameCountProgress.setNextProgressIncrement(this->frameCount()); + + + RigFemScalarResultFrames * s11Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S11")); + frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement(this->frameCount()); + RigFemScalarResultFrames * s22Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S22")); + frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement(this->frameCount()); + RigFemScalarResultFrames * s33Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S33")); + frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement(this->frameCount()); + RigFemScalarResultFrames * s12Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S12")); + frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement(this->frameCount()); + RigFemScalarResultFrames * s13Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S13")); + frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement(this->frameCount()); + RigFemScalarResultFrames * s23Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S23")); + + RigFemScalarResultFrames * s1Frames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S1")); + RigFemScalarResultFrames * s2Frames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S2")); + RigFemScalarResultFrames * s3Frames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S3")); + + RigFemScalarResultFrames * s1IncFrames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S1inc")); + RigFemScalarResultFrames * s1AziFrames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S1azi")); + RigFemScalarResultFrames * s2IncFrames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S2inc")); + RigFemScalarResultFrames * s2AziFrames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S2azi")); + RigFemScalarResultFrames * s3IncFrames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S3inc")); + RigFemScalarResultFrames * s3AziFrames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S3azi")); + + frameCountProgress.incrementProgress(); + + int frameCount = s11Frames->frameCount(); + for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + { + const std::vector& s11 = s11Frames->frameData(fIdx); + const std::vector& s22 = s22Frames->frameData(fIdx); + const std::vector& s33 = s33Frames->frameData(fIdx); + const std::vector& s12 = s12Frames->frameData(fIdx); + const std::vector& s13 = s13Frames->frameData(fIdx); + const std::vector& s23 = s23Frames->frameData(fIdx); + + std::vector& s1 = s1Frames->frameData(fIdx); + std::vector& s2 = s2Frames->frameData(fIdx); + std::vector& s3 = s3Frames->frameData(fIdx); + + std::vector& s1inc = s1IncFrames->frameData(fIdx); + std::vector& s1azi = s1AziFrames->frameData(fIdx); + std::vector& s2inc = s2IncFrames->frameData(fIdx); + std::vector& s2azi = s2AziFrames->frameData(fIdx); + std::vector& s3inc = s3IncFrames->frameData(fIdx); + std::vector& s3azi = s3AziFrames->frameData(fIdx); + + size_t valCount = s11.size(); + + s1.resize(valCount); + s2.resize(valCount); + s3.resize(valCount); + s1inc.resize(valCount); + s1azi.resize(valCount); + s2inc.resize(valCount); + s2azi.resize(valCount); + s3inc.resize(valCount); + s3azi.resize(valCount); + + for ( size_t vIdx = 0; vIdx < valCount; ++vIdx ) + { + caf::Ten3f T(s11[vIdx], s22[vIdx], s33[vIdx], s12[vIdx], s23[vIdx], s13[vIdx]); + cvf::Vec3f principalDirs[3]; + cvf::Vec3f principals = T.calculatePrincipals(principalDirs); + s1[vIdx] = principals[0]; + s2[vIdx] = principals[1]; + s3[vIdx] = principals[2]; + + if ( principals[0] != std::numeric_limits::infinity() ) + { + OffshoreSphericalCoords sphCoord1(principalDirs[0]); + s1inc[vIdx] = cvf::Math::toDegrees(sphCoord1.inc()); + s1azi[vIdx] = cvf::Math::toDegrees(sphCoord1.azi()); + } + else + { + s1inc[vIdx] = std::numeric_limits::infinity(); + s1azi[vIdx] = std::numeric_limits::infinity(); + } + + if ( principals[1] != std::numeric_limits::infinity() ) + { + OffshoreSphericalCoords sphCoord2(principalDirs[1]); + s2inc[vIdx] = cvf::Math::toDegrees(sphCoord2.inc()); + s2azi[vIdx] = cvf::Math::toDegrees(sphCoord2.azi()); + } + else + { + s2inc[vIdx] = std::numeric_limits::infinity(); + s2azi[vIdx] = std::numeric_limits::infinity(); + } + + if ( principals[2] != std::numeric_limits::infinity() ) + { + OffshoreSphericalCoords sphCoord3(principalDirs[2]); + s3inc[vIdx] = cvf::Math::toDegrees(sphCoord3.inc()); + s3azi[vIdx] = cvf::Math::toDegrees(sphCoord3.azi()); + } + else + { + s3inc[vIdx] = std::numeric_limits::infinity(); + s3azi[vIdx] = std::numeric_limits::infinity(); + } + } + + frameCountProgress.incrementProgress(); + } + + RigFemScalarResultFrames* requestedPrincipal = this->findOrLoadScalarResult(partIndex, resVarAddr); + + return requestedPrincipal; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemScalarResultFrames* RigFemPartResultsCollection::calculatePrincipalStrainValues(int partIndex, const RigFemResultAddress &resVarAddr) +{ + CVF_ASSERT(resVarAddr.componentName == "E1" || resVarAddr.componentName == "E2" || resVarAddr.componentName == "E3"); + + caf::ProgressInfo frameCountProgress(this->frameCount() * 7, ""); + frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); + frameCountProgress.setNextProgressIncrement(this->frameCount()); + + + RigFemScalarResultFrames * s11Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "E11")); + frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement(this->frameCount()); + RigFemScalarResultFrames * s22Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "E22")); + frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement(this->frameCount()); + RigFemScalarResultFrames * s33Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "E33")); + frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement(this->frameCount()); + RigFemScalarResultFrames * s12Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "E12")); + frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement(this->frameCount()); + RigFemScalarResultFrames * s13Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "E13")); + frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement(this->frameCount()); + RigFemScalarResultFrames * s23Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "E23")); + + RigFemScalarResultFrames * s1Frames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "E1")); + RigFemScalarResultFrames * s2Frames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "E2")); + RigFemScalarResultFrames * s3Frames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "E3")); + + frameCountProgress.incrementProgress(); + + int frameCount = s11Frames->frameCount(); + for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) + { + const std::vector& s11 = s11Frames->frameData(fIdx); + const std::vector& s22 = s22Frames->frameData(fIdx); + const std::vector& s33 = s33Frames->frameData(fIdx); + const std::vector& s12 = s12Frames->frameData(fIdx); + const std::vector& s13 = s13Frames->frameData(fIdx); + const std::vector& s23 = s23Frames->frameData(fIdx); + + std::vector& s1 = s1Frames->frameData(fIdx); + std::vector& s2 = s2Frames->frameData(fIdx); + std::vector& s3 = s3Frames->frameData(fIdx); + + size_t valCount = s11.size(); + + s1.resize(valCount); + s2.resize(valCount); + s3.resize(valCount); + + for ( size_t vIdx = 0; vIdx < valCount; ++vIdx ) + { + caf::Ten3f T(s11[vIdx], s22[vIdx], s33[vIdx], s12[vIdx], s23[vIdx], s13[vIdx]); + cvf::Vec3f principalDirs[3]; + cvf::Vec3f principals = T.calculatePrincipals(principalDirs); + s1[vIdx] = principals[0]; + s2[vIdx] = principals[1]; + s3[vIdx] = principals[2]; + } + + frameCountProgress.incrementProgress(); + } + + RigFemScalarResultFrames* requestedPrincipal = this->findOrLoadScalarResult(partIndex, resVarAddr); + + return requestedPrincipal; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -971,6 +1175,13 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDerivedResult(in return dstDataFrames; } + if ( (resVarAddr.fieldName == "NE") + && ( resVarAddr.componentName == "E1" + || resVarAddr.componentName == "E2" + || resVarAddr.componentName == "E3") ) + { + return calculatePrincipalStrainValues(partIndex, resVarAddr); + } if ((resVarAddr.fieldName == "SE") && ( resVarAddr.componentName == "S11" @@ -1048,121 +1259,7 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDerivedResult(in || resVarAddr.componentName == "S3azi" ) ) { - caf::ProgressInfo frameCountProgress(this->frameCount() * 7, ""); - frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); - frameCountProgress.setNextProgressIncrement(this->frameCount()); - - - RigFemScalarResultFrames * s11Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S11")); - frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement(this->frameCount()); - RigFemScalarResultFrames * s22Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S22")); - frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement(this->frameCount()); - RigFemScalarResultFrames * s33Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S33")); - frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement(this->frameCount()); - RigFemScalarResultFrames * s12Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S12")); - frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement(this->frameCount()); - RigFemScalarResultFrames * s13Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S13")); - frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement(this->frameCount()); - RigFemScalarResultFrames * s23Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S23")); - - RigFemScalarResultFrames * s1Frames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S1")); - RigFemScalarResultFrames * s2Frames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S2")); - RigFemScalarResultFrames * s3Frames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S3")); - - RigFemScalarResultFrames * s1IncFrames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S1inc")); - RigFemScalarResultFrames * s1AziFrames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S1azi")); - RigFemScalarResultFrames * s2IncFrames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S2inc")); - RigFemScalarResultFrames * s2AziFrames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S2azi")); - RigFemScalarResultFrames * s3IncFrames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S3inc")); - RigFemScalarResultFrames * s3AziFrames = m_femPartResults[partIndex]->createScalarResult(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "S3azi")); - - frameCountProgress.incrementProgress(); - - int frameCount = s11Frames->frameCount(); - for (int fIdx = 0; fIdx < frameCount; ++fIdx) - { - const std::vector& s11 = s11Frames->frameData(fIdx); - const std::vector& s22 = s22Frames->frameData(fIdx); - const std::vector& s33 = s33Frames->frameData(fIdx); - const std::vector& s12 = s12Frames->frameData(fIdx); - const std::vector& s13 = s13Frames->frameData(fIdx); - const std::vector& s23 = s23Frames->frameData(fIdx); - - std::vector& s1 = s1Frames->frameData(fIdx); - std::vector& s2 = s2Frames->frameData(fIdx); - std::vector& s3 = s3Frames->frameData(fIdx); - - std::vector& s1inc = s1IncFrames->frameData(fIdx); - std::vector& s1azi = s1AziFrames->frameData(fIdx); - std::vector& s2inc = s2IncFrames->frameData(fIdx); - std::vector& s2azi = s2AziFrames->frameData(fIdx); - std::vector& s3inc = s3IncFrames->frameData(fIdx); - std::vector& s3azi = s3AziFrames->frameData(fIdx); - - size_t valCount = s11.size(); - - s1.resize(valCount); - s2.resize(valCount); - s3.resize(valCount); - s1inc.resize(valCount); - s1azi.resize(valCount); - s2inc.resize(valCount); - s2azi.resize(valCount); - s3inc.resize(valCount); - s3azi.resize(valCount); - - for (size_t vIdx = 0; vIdx < valCount; ++vIdx) - { - caf::Ten3f T(s11[vIdx], s22[vIdx], s33[vIdx], s12[vIdx], s23[vIdx], s13[vIdx] ); - cvf::Vec3f principalDirs[3]; - cvf::Vec3f principals = T.calculatePrincipals(principalDirs); - s1[vIdx] = principals[0]; - s2[vIdx] = principals[1]; - s3[vIdx] = principals[2]; - - if(principals[0] != std::numeric_limits::infinity()) - { - OffshoreSphericalCoords sphCoord1(principalDirs[0]); - s1inc[vIdx] = cvf::Math::toDegrees(sphCoord1.inc()); - s1azi[vIdx] = cvf::Math::toDegrees(sphCoord1.azi()); - } - else - { - s1inc[vIdx] = std::numeric_limits::infinity(); - s1azi[vIdx] = std::numeric_limits::infinity(); - } - - if ( principals[1] != std::numeric_limits::infinity() ) - { - OffshoreSphericalCoords sphCoord2(principalDirs[1]); - s2inc[vIdx] = cvf::Math::toDegrees(sphCoord2.inc()); - s2azi[vIdx] = cvf::Math::toDegrees(sphCoord2.azi()); - } - else - { - s2inc[vIdx] = std::numeric_limits::infinity(); - s2azi[vIdx] = std::numeric_limits::infinity(); - } - - if(principals[2] != std::numeric_limits::infinity()) - { - OffshoreSphericalCoords sphCoord3(principalDirs[2]); - s3inc[vIdx] = cvf::Math::toDegrees(sphCoord3.inc()); - s3azi[vIdx] = cvf::Math::toDegrees(sphCoord3.azi()); - } - else - { - s3inc[vIdx] = std::numeric_limits::infinity(); - s3azi[vIdx] = std::numeric_limits::infinity(); - } - } - - frameCountProgress.incrementProgress(); - } - - RigFemScalarResultFrames* requestedPrincipal = this->findOrLoadScalarResult(partIndex,resVarAddr); - - return requestedPrincipal; + return calculatePrincipalStressValues(partIndex, resVarAddr); } if ( resVarAddr.fieldName == "ST" diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h index 2aa205eb30..4ca0145ad7 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h @@ -77,6 +77,7 @@ private: RigFemScalarResultFrames* calculateDerivedResult(int partIndex, const RigFemResultAddress& resVarAddr); + void calculateGammaFromFrames(int partIndex, const RigFemScalarResultFrames * totalStressComponentDataFrames, const RigFemScalarResultFrames * srcPORDataFrames, @@ -92,6 +93,8 @@ private: RigFemScalarResultFrames* calculateDeviatoricStress(int partIndex, const RigFemResultAddress& resVarAddr); RigFemScalarResultFrames* calculateVolumetricStrain(int partIndex, const RigFemResultAddress& resVarAddr); RigFemScalarResultFrames* calculateSurfaceAlignedStress(int partIndex, const RigFemResultAddress& resVarAddr); + RigFemScalarResultFrames* calculatePrincipalStressValues(int partIndex, const RigFemResultAddress &resVarAddr); + RigFemScalarResultFrames* calculatePrincipalStrainValues(int partIndex, const RigFemResultAddress &resVarAddr); cvf::Collection m_femPartResults; cvf::ref m_readerInterface;