2015-11-05 04:45:18 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) Statoil ASA
|
|
|
|
// Copyright (C) Ceetron Solutions AS
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2015-11-05 04:45:18 -06:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2015-11-05 04:45:18 -06:00
|
|
|
// 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2015-11-05 04:45:18 -06:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2016-10-26 10:14:11 -05:00
|
|
|
#include "RiuFemTimeHistoryResultAccessor.h"
|
2015-11-05 04:45:18 -06:00
|
|
|
|
2022-03-11 06:24:01 -06:00
|
|
|
#include "RiaNumberFormat.h"
|
|
|
|
|
Split fem part results collection 5785 (#5871)
* #5785 Extract RigFemClosestResultIndexCalculator class to separate file.
* #5785 Move method implementation of RigFemClosestResutIndexCalculator to cpp file.
Also improve const correctness.
* #5785 Extract method for calculating normal SE, ie. SE:11/22/33.
* #5785 Extract method for calculating shear SE, ie. SE:12/13/23.
* #5785 Create a list of result calculators.
* #5785 Extract method for calculating timelapse, normalized, and gamma results.
* #5785 Extract method for calculating normal ST, ie. ST:11/22/33.
* #5785 Extract method for calculating shear ST, ie. ST:12/13/23.
* #5785 Extract method for calculating surface angles and aligned stress.
* #5785 Extract method for calculating principal strain and stress.
* #5785 Extract method for calculating FOS, SFI and DSM for SE.
* #5785 Extract method for calculating NE.EV, NE.ED, ST.Q and ST.STM.
* #5785 Extract method for calculating compaction.
* #5785 Extract method for calculating stress gradients.
* #5785 Extract method for calculating SE.SEM.
* #5785 Extract method for calculating NE.
* #5785 Extract method for calculating formation indices.
* #5785 Extract method for calculating nodal graidents, bar conversions, and EnIpPorBar.
* #5785 Use std::unique_ptr to calculators.
* Use std::vector<unique_ptr>
Co-authored-by: Magne Sjaastad <magne.sjaastad@ceetronsolutions.com>
2020-05-09 01:57:07 -05:00
|
|
|
#include "RigFemClosestResultIndexCalculator.h"
|
2015-11-05 04:45:18 -06:00
|
|
|
#include "RigFemPart.h"
|
|
|
|
#include "RigFemPartCollection.h"
|
|
|
|
#include "RigFemPartGrid.h"
|
|
|
|
#include "RigFemPartResultsCollection.h"
|
|
|
|
#include "RigFemTypes.h"
|
|
|
|
#include "RigGeoMechCaseData.h"
|
2022-03-11 06:24:01 -06:00
|
|
|
|
2016-10-26 10:05:39 -05:00
|
|
|
#include "RiuGeoMechXfTensorResultAccessor.h"
|
2015-11-05 04:45:18 -06:00
|
|
|
|
|
|
|
#include <cmath> // Needed for HUGE_VAL on Linux
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-11-05 04:45:18 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
RiuFemTimeHistoryResultAccessor::RiuFemTimeHistoryResultAccessor( RigGeoMechCaseData* geomData,
|
|
|
|
RigFemResultAddress femResultAddress,
|
|
|
|
size_t gridIndex,
|
|
|
|
int elementIndex,
|
|
|
|
int face,
|
|
|
|
const cvf::Vec3d& intersectionPointInDomain )
|
|
|
|
: m_geoMechCaseData( geomData )
|
|
|
|
, m_femResultAddress( new RigFemResultAddress( femResultAddress ) )
|
|
|
|
, m_gridIndex( gridIndex )
|
|
|
|
, m_elementIndex( elementIndex )
|
|
|
|
, m_face( face )
|
|
|
|
, m_intersectionPointInDomain( intersectionPointInDomain )
|
|
|
|
, m_hasIntersectionTriangle( false )
|
2016-10-26 10:05:39 -05:00
|
|
|
{
|
|
|
|
computeTimeHistoryData();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2016-10-26 10:05:39 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
RiuFemTimeHistoryResultAccessor::RiuFemTimeHistoryResultAccessor( RigGeoMechCaseData* geomData,
|
|
|
|
RigFemResultAddress femResultAddress,
|
|
|
|
size_t gridIndex,
|
|
|
|
int elementIndex,
|
|
|
|
int face,
|
|
|
|
const cvf::Vec3d& intersectionPointInDomain,
|
|
|
|
const std::array<cvf::Vec3f, 3>& intersectionTriangle )
|
|
|
|
: m_geoMechCaseData( geomData )
|
|
|
|
, m_femResultAddress( new RigFemResultAddress( femResultAddress ) )
|
|
|
|
, m_gridIndex( gridIndex )
|
|
|
|
, m_elementIndex( elementIndex )
|
|
|
|
, m_face( face )
|
|
|
|
, m_intersectionPointInDomain( intersectionPointInDomain )
|
|
|
|
, m_hasIntersectionTriangle( true )
|
|
|
|
, m_intersectionTriangle( intersectionTriangle )
|
2015-11-05 04:45:18 -06:00
|
|
|
{
|
|
|
|
computeTimeHistoryData();
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-11-05 04:45:18 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2017-04-04 09:08:42 -05:00
|
|
|
QString RiuFemTimeHistoryResultAccessor::geometrySelectionText() const
|
2015-11-05 04:45:18 -06:00
|
|
|
{
|
|
|
|
QString text;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_geoMechCaseData )
|
2015-11-05 04:45:18 -06:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
RigFemPart* femPart = m_geoMechCaseData->femParts()->part( m_gridIndex );
|
|
|
|
int elementId = femPart->elmId( m_elementIndex );
|
|
|
|
text += QString( "Element : Id[%1]" ).arg( elementId );
|
2015-11-05 04:45:18 -06:00
|
|
|
|
|
|
|
size_t i = 0;
|
|
|
|
size_t j = 0;
|
|
|
|
size_t k = 0;
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_geoMechCaseData->femParts()
|
|
|
|
->part( m_gridIndex )
|
|
|
|
->getOrCreateStructGrid()
|
|
|
|
->ijkFromCellIndex( m_elementIndex, &i, &j, &k ) )
|
2015-11-05 04:45:18 -06:00
|
|
|
{
|
|
|
|
// Adjust to 1-based Eclipse indexing
|
|
|
|
i++;
|
|
|
|
j++;
|
|
|
|
k++;
|
|
|
|
|
2018-09-27 07:47:15 -05:00
|
|
|
cvf::Vec3d domainCoord = m_intersectionPointInDomain;
|
2019-09-06 03:40:57 -05:00
|
|
|
text += QString( ", ijk[%1, %2, %3] " ).arg( i ).arg( j ).arg( k );
|
2015-11-05 04:45:18 -06:00
|
|
|
|
2022-03-11 06:24:01 -06:00
|
|
|
auto xTxt = RiaNumberFormat::valueToText( domainCoord.x(), RiaNumberFormat::NumberFormatType::FIXED, 2 );
|
|
|
|
auto yTxt = RiaNumberFormat::valueToText( domainCoord.y(), RiaNumberFormat::NumberFormatType::FIXED, 2 );
|
|
|
|
auto zTxt = RiaNumberFormat::valueToText( -domainCoord.z(), RiaNumberFormat::NumberFormatType::FIXED, 2 );
|
|
|
|
|
|
|
|
QString formattedText =
|
|
|
|
QString( "Intersection point : [E: %1, N: %2, Depth: %3]" ).arg( xTxt ).arg( yTxt ).arg( zTxt );
|
2015-11-05 04:45:18 -06:00
|
|
|
|
|
|
|
text += formattedText;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return text;
|
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-11-05 04:45:18 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2016-10-26 10:14:11 -05:00
|
|
|
std::vector<double> RiuFemTimeHistoryResultAccessor::timeHistoryValues() const
|
2015-11-05 04:45:18 -06:00
|
|
|
{
|
|
|
|
return m_timeHistoryValues;
|
|
|
|
}
|
|
|
|
|
2019-02-11 07:07:05 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2019-02-11 07:07:05 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
int RiuFemTimeHistoryResultAccessor::closestNodeId() const
|
|
|
|
{
|
|
|
|
return m_closestNodeId;
|
|
|
|
}
|
|
|
|
|
2015-11-05 04:45:18 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2015-11-05 04:45:18 -06:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2016-10-26 10:14:11 -05:00
|
|
|
void RiuFemTimeHistoryResultAccessor::computeTimeHistoryData()
|
2015-11-05 04:45:18 -06:00
|
|
|
{
|
|
|
|
m_timeHistoryValues.clear();
|
2019-09-06 03:40:57 -05:00
|
|
|
|
|
|
|
RigFemClosestResultIndexCalculator closestCalc( m_geoMechCaseData->femParts()->part( m_gridIndex ),
|
|
|
|
m_femResultAddress->resultPosType,
|
|
|
|
m_elementIndex,
|
|
|
|
m_face,
|
|
|
|
m_intersectionPointInDomain );
|
|
|
|
|
2016-10-25 06:42:40 -05:00
|
|
|
int scalarResultIndex = closestCalc.resultIndexToClosestResult();
|
2019-09-06 03:40:57 -05:00
|
|
|
m_closestNodeId = closestCalc.closestNodeId();
|
2015-11-05 04:45:18 -06:00
|
|
|
|
|
|
|
RigFemPartResultsCollection* femPartResultsColl = m_geoMechCaseData->femPartResults();
|
2016-10-26 10:05:39 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_femResultAddress->resultPosType == RIG_ELEMENT_NODAL_FACE && m_hasIntersectionTriangle )
|
2015-11-05 04:45:18 -06:00
|
|
|
{
|
2016-10-26 10:05:39 -05:00
|
|
|
int closestElmNodeResIndex = closestCalc.closestElementNodeResIdx();
|
2015-11-05 04:45:18 -06:00
|
|
|
|
2016-10-26 10:05:39 -05:00
|
|
|
for ( int frameIdx = 0; frameIdx < femPartResultsColl->frameCount(); frameIdx++ )
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
RiuGeoMechXfTensorResultAccessor stressXfAccessor( femPartResultsColl, *m_femResultAddress, frameIdx );
|
|
|
|
float scalarValue = stressXfAccessor.calculateElmNodeValue( m_intersectionTriangle, closestElmNodeResIndex );
|
|
|
|
m_timeHistoryValues.push_back( scalarValue );
|
2015-11-05 04:45:18 -06:00
|
|
|
}
|
|
|
|
}
|
2016-10-26 10:05:39 -05:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( scalarResultIndex < 0 ) return;
|
|
|
|
|
|
|
|
for ( int frameIdx = 0; frameIdx < femPartResultsColl->frameCount(); frameIdx++ )
|
|
|
|
{
|
2019-11-04 08:08:09 -06:00
|
|
|
const std::vector<float>& scalarResults =
|
|
|
|
m_geoMechCaseData->femPartResults()->resultValues( *m_femResultAddress,
|
|
|
|
static_cast<int>( m_gridIndex ),
|
|
|
|
frameIdx );
|
2016-10-26 10:05:39 -05:00
|
|
|
if ( scalarResults.size() )
|
|
|
|
{
|
|
|
|
float scalarValue = scalarResults[scalarResultIndex];
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
m_timeHistoryValues.push_back( scalarValue );
|
2016-10-26 10:05:39 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-11-05 04:45:18 -06:00
|
|
|
}
|