///////////////////////////////////////////////////////////////////////////////// // // 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 "RigFemPartResultCalculatorNormalSE.h" #include "RigFemPart.h" #include "RigFemPartCollection.h" #include "RigFemPartResultsCollection.h" #include "RigFemResultAddress.h" #include "RigFemScalarResultFrames.h" #include "cafProgressInfo.h" #include //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RigFemPartResultCalculatorNormalSE::RigFemPartResultCalculatorNormalSE( RigFemPartResultsCollection& collection ) : RigFemPartResultCalculator( collection ) { } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RigFemPartResultCalculatorNormalSE::~RigFemPartResultCalculatorNormalSE() { } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- bool RigFemPartResultCalculatorNormalSE::isMatching( const RigFemResultAddress& resVarAddr ) const { return ( ( resVarAddr.fieldName == "SE" ) && ( resVarAddr.componentName == "S11" || resVarAddr.componentName == "S22" || resVarAddr.componentName == "S33" ) ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RigFemScalarResultFrames* RigFemPartResultCalculatorNormalSE::calculate( int partIndex, const RigFemResultAddress& resVarAddr ) { caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 3, "" ); frameCountProgress.setProgressDescription( "Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) ); frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); RigFemScalarResultFrames* srcDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "S-Bar", resVarAddr.componentName ) ); frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() ); RigFemScalarResultFrames* srcPORDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( RIG_NODAL, "POR-Bar", "" ) ); RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr ); frameCountProgress.incrementProgress(); // Biot porelastic coeffisient (alpha) RigFemScalarResultFrames* biotCoefficient = nullptr; if ( !m_resultCollection->biotResultAddress().isEmpty() ) { biotCoefficient = m_resultCollection ->findOrLoadScalarResult( partIndex, RigFemResultAddress( RIG_ELEMENT, m_resultCollection->biotResultAddress().toStdString(), "" ) ); } const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex ); float inf = std::numeric_limits::infinity(); int frameCount = srcDataFrames->frameCount(); for ( int fIdx = 0; fIdx < frameCount; ++fIdx ) { const std::vector& srcSFrameData = srcDataFrames->frameData( fIdx ); std::vector& dstFrameData = dstDataFrames->frameData( fIdx ); size_t valCount = srcSFrameData.size(); dstFrameData.resize( valCount ); const std::vector& initialPORFrameData = srcPORDataFrames->frameData( 0 ); int elementCount = femPart->elementCount(); std::vector biotData; if ( biotCoefficient ) { biotData = biotCoefficient->frameData( fIdx ); if ( !m_resultCollection->isValidBiotData( biotData, elementCount ) ) { m_resultCollection->deleteResult( resVarAddr ); return nullptr; } } #pragma omp parallel for for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) { RigElementType elmType = femPart->elementType( elmIdx ); int elmNodeCount = RigFemTypes::elmentNodeCount( femPart->elementType( elmIdx ) ); if ( elmType == HEX8P ) { for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) { size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); if ( elmNodResIdx < srcSFrameData.size() ) { double SE_abacus = -srcSFrameData[elmNodResIdx]; if ( fIdx == 0 ) { // Geostatic step: biot coefficient == 1.0 dstFrameData[elmNodResIdx] = SE_abacus; } else { // Use biot coefficient for all other (not Geostatic) timesteps double biotCoefficient = 1.0; if ( biotData.empty() ) { biotCoefficient = m_resultCollection->biotFixedFactor(); } else { // Use coefficient from element property table biotCoefficient = biotData[elmIdx]; } // SE = St - alpha * porePressure - (1 - alpha) * initialPorePressure // ST = SE_abaqus + alpha * porePressure // Can be simplified: // SE = SE_abaqus - (1-alpha) * initialPorePressure // SE_abaqus is called S-Bar int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx( elmNodResIdx ); double initialPorePressure = initialPORFrameData[nodeIdx]; if ( initialPorePressure == inf ) initialPorePressure = 0.0f; dstFrameData[elmNodResIdx] = SE_abacus - ( 1.0 - biotCoefficient ) * initialPorePressure; } } } } else { for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) { size_t elmNodResIdx = femPart->elementNodeResultIdx( elmIdx, elmNodIdx ); if ( elmNodResIdx < dstFrameData.size() ) { dstFrameData[elmNodResIdx] = inf; } } } } frameCountProgress.incrementProgress(); } return dstDataFrames; }