mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-10 23:46:00 -06:00
115 lines
4.9 KiB
C++
115 lines
4.9 KiB
C++
/////////////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// 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 <http://www.gnu.org/licenses/gpl.html>
|
|
// for more details.
|
|
//
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
#include "RigFemPartResultCalculatorQ.h"
|
|
|
|
#include "RigFemPart.h"
|
|
#include "RigFemPartCollection.h"
|
|
#include "RigFemPartResultsCollection.h"
|
|
#include "RigFemResultAddress.h"
|
|
#include "RigFemScalarResultFrames.h"
|
|
|
|
#include "cafProgressInfo.h"
|
|
|
|
#include <QString>
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RigFemPartResultCalculatorQ::RigFemPartResultCalculatorQ( RigFemPartResultsCollection& collection )
|
|
: RigFemPartResultCalculator( collection )
|
|
{
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RigFemPartResultCalculatorQ::~RigFemPartResultCalculatorQ()
|
|
{
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
bool RigFemPartResultCalculatorQ::isMatching( const RigFemResultAddress& resVarAddr ) const
|
|
{
|
|
return ( resVarAddr.fieldName == "ST" && resVarAddr.componentName == "Q" );
|
|
}
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
///
|
|
//--------------------------------------------------------------------------------------------------
|
|
RigFemScalarResultFrames* RigFemPartResultCalculatorQ::calculate( int partIndex, const RigFemResultAddress& resVarAddr )
|
|
{
|
|
CVF_ASSERT( resVarAddr.fieldName == "ST" && resVarAddr.componentName == "Q" );
|
|
|
|
caf::ProgressInfo frameCountProgress( m_resultCollection->frameCount() * 5, "" );
|
|
frameCountProgress.setProgressDescription(
|
|
"Calculating " + QString::fromStdString( resVarAddr.fieldName + ": " + resVarAddr.componentName ) );
|
|
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() );
|
|
|
|
RigFemScalarResultFrames* st11 =
|
|
m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "ST", "S1" ) );
|
|
frameCountProgress.incrementProgress();
|
|
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() );
|
|
RigFemScalarResultFrames* st22 =
|
|
m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "ST", "S2" ) );
|
|
frameCountProgress.incrementProgress();
|
|
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() );
|
|
RigFemScalarResultFrames* st33 =
|
|
m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "ST", "S3" ) );
|
|
frameCountProgress.incrementProgress();
|
|
frameCountProgress.setNextProgressIncrement( m_resultCollection->frameCount() );
|
|
|
|
RigFemScalarResultFrames* stm =
|
|
m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "ST", "SM" ) );
|
|
|
|
RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr );
|
|
|
|
frameCountProgress.incrementProgress();
|
|
|
|
int frameCount = st11->frameCount();
|
|
for ( int fIdx = 0; fIdx < frameCount; ++fIdx )
|
|
{
|
|
const std::vector<float>& st11Data = st11->frameData( fIdx );
|
|
const std::vector<float>& st22Data = st22->frameData( fIdx );
|
|
const std::vector<float>& st33Data = st33->frameData( fIdx );
|
|
|
|
const std::vector<float>& stmData = stm->frameData( fIdx );
|
|
|
|
std::vector<float>& dstFrameData = dstDataFrames->frameData( fIdx );
|
|
size_t valCount = st11Data.size();
|
|
dstFrameData.resize( valCount );
|
|
|
|
#pragma omp parallel for
|
|
for ( long vIdx = 0; vIdx < static_cast<long>( valCount ); ++vIdx )
|
|
{
|
|
float stmVal = stmData[vIdx];
|
|
float st11Corr = st11Data[vIdx] - stmVal;
|
|
float st22Corr = st22Data[vIdx] - stmVal;
|
|
float st33Corr = st33Data[vIdx] - stmVal;
|
|
|
|
dstFrameData[vIdx] = sqrt( 1.5 * ( st11Corr * st11Corr + st22Corr * st22Corr + st33Corr * st33Corr ) );
|
|
}
|
|
|
|
frameCountProgress.incrementProgress();
|
|
}
|
|
|
|
return dstDataFrames;
|
|
}
|