///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2020- Equinor ASA // // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. // // See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// #include "RigFemPartResultCalculatorPrincipalStrain.h" #include "RigFemPart.h" #include "RigFemPartCollection.h" #include "RigFemPartResultsCollection.h" #include "RigFemResultAddress.h" #include "RigFemScalarResultFrames.h" #include "cafProgressInfo.h" #include //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RigFemPartResultCalculatorPrincipalStrain::RigFemPartResultCalculatorPrincipalStrain( RigFemPartResultsCollection& collection ) : RigFemPartResultCalculator( collection ) { } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RigFemPartResultCalculatorPrincipalStrain::~RigFemPartResultCalculatorPrincipalStrain() { } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- bool RigFemPartResultCalculatorPrincipalStrain::isMatching( const RigFemResultAddress& resVarAddr ) const { return ( ( resVarAddr.fieldName == "NE" ) && ( resVarAddr.componentName == "E1" || resVarAddr.componentName == "E2" || resVarAddr.componentName == "E3" ) ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RigFemScalarResultFrames* RigFemPartResultCalculatorPrincipalStrain::calculate( int partIndex, const RigFemResultAddress& resVarAddr ) { CVF_ASSERT( resVarAddr.componentName == "E1" || resVarAddr.componentName == "E2" || resVarAddr.componentName == "E3" ); caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 7, "" ); frameCountProgress.setProgressDescription( "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); RigFemScalarResultFrames* s11Frames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, "E11" ) ); frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); RigFemScalarResultFrames* s22Frames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, "E22" ) ); frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); RigFemScalarResultFrames* s33Frames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, "E33" ) ); frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); RigFemScalarResultFrames* s12Frames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, "E12" ) ); frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); RigFemScalarResultFrames* s13Frames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, "E13" ) ); frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); RigFemScalarResultFrames* s23Frames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, "E23" ) ); RigFemScalarResultFrames* s1Frames = m_resultCollection->createScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, "E1" ) ); RigFemScalarResultFrames* s2Frames = m_resultCollection->createScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, resVarAddr.fieldName, "E2" ) ); RigFemScalarResultFrames* s3Frames = m_resultCollection->createScalarResult( partIndex, 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 ); #pragma omp parallel for for ( long vIdx = 0; vIdx < static_cast( 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 = m_resultCollection->findOrLoadScalarResult( partIndex, resVarAddr ); return requestedPrincipal; }