Additional refactoring for POR-Bar result handling

* Always use element-nodal for POR calculations
* Add RigFemAddressDefines
Add special handling for "POR-Bar" result, always use element_nodal

* 9362 Show unit text "sg" when normalized by hydrostatic pressure
This commit is contained in:
Magne Sjaastad
2023-08-23 13:29:54 +02:00
committed by GitHub
parent 4b12f82583
commit bb293539d5
25 changed files with 203 additions and 88 deletions

View File

@@ -106,6 +106,8 @@ add_library(
RimGeoMechGeometrySelectionItem.cpp
RigFemPartResultCalculatorNodalDisplacement.h
RigFemPartResultCalculatorNodalDisplacement.cpp
RigFemAddressDefines.h
RigFemAddressDefines.cpp
)
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

View File

@@ -0,0 +1,66 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2023- 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 "RigFemAddressDefines.h"
#include "RigFemResultAddress.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::string RigFemAddressDefines::porBar()
{
return "POR-Bar";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemResultAddress RigFemAddressDefines::getResultLookupAddress( const RigFemResultAddress& sourceAddress )
{
if ( sourceAddress.resultPosType == RIG_NODAL && sourceAddress.fieldName == RigFemAddressDefines::porBar() )
{
// Use element nodal results when using POR-Bar. If nodal results are used, the resulting display will bleed into neighboring
// cells.
//
// https://github.com/OPM/ResInsight/issues/331
// https://github.com/OPM/ResInsight/issues/10488
RigFemResultAddress lookupAddressForPOR = sourceAddress;
lookupAddressForPOR.resultPosType = RIG_ELEMENT_NODAL;
return lookupAddressForPOR;
}
return sourceAddress;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemResultAddress RigFemAddressDefines::elementNodalPorBarAddress()
{
return RigFemResultAddress( RIG_ELEMENT_NODAL, RigFemAddressDefines::porBar(), "" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigFemResultAddress RigFemAddressDefines::nodalPorBarAddress()
{
return RigFemResultAddress( RIG_NODAL, RigFemAddressDefines::porBar(), "" );
}

View File

@@ -0,0 +1,33 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2023- 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <string>
class RigFemResultAddress;
namespace RigFemAddressDefines
{
const std::string porBar();
RigFemResultAddress getResultLookupAddress( const RigFemResultAddress& sourceAddress );
RigFemResultAddress elementNodalPorBarAddress();
RigFemResultAddress nodalPorBarAddress();
}; // namespace RigFemAddressDefines

View File

@@ -18,6 +18,7 @@
#include "RigFemPartResultCalculatorBarConverted.h"
#include "RigFemAddressDefines.h"
#include "RigFemPart.h"
#include "RigFemPartCollection.h"
#include "RigFemPartResultsCollection.h"
@@ -63,9 +64,9 @@ bool RigFemPartResultCalculatorBarConverted::isMatching( const RigFemResultAddre
}
// TODO: split in multiple classes??
if ( m_fieldName == "POR-Bar" )
if ( m_fieldName == RigFemAddressDefines::porBar() )
{
return ( ( resVarAddr.fieldName == "POR-Bar" ) && ( resVarAddr.resultPosType == RIG_NODAL ) &&
return ( ( resVarAddr.fieldName == RigFemAddressDefines::porBar() ) && ( resVarAddr.resultPosType == RIG_NODAL ) &&
!( resVarAddr.componentName == "X" || resVarAddr.componentName == "Y" || resVarAddr.componentName == "Z" ) );
}
else

View File

@@ -18,6 +18,7 @@
#include "RigFemPartResultCalculatorEnIpPorBar.h"
#include "RigFemAddressDefines.h"
#include "RigFemPart.h"
#include "RigFemPartCollection.h"
#include "RigFemPartResultsCollection.h"
@@ -48,7 +49,7 @@ RigFemPartResultCalculatorEnIpPorBar::~RigFemPartResultCalculatorEnIpPorBar()
//--------------------------------------------------------------------------------------------------
bool RigFemPartResultCalculatorEnIpPorBar::isMatching( const RigFemResultAddress& resVarAddr ) const
{
return ( resVarAddr.fieldName == "POR-Bar" && resVarAddr.resultPosType != RIG_NODAL );
return ( resVarAddr.fieldName == RigFemAddressDefines::porBar() && resVarAddr.resultPosType != RIG_NODAL );
}
//--------------------------------------------------------------------------------------------------

View File

@@ -18,6 +18,7 @@
#include "RigFemPartResultCalculatorGamma.h"
#include "RigFemAddressDefines.h"
#include "RigFemPart.h"
#include "RigFemPartCollection.h"
#include "RigFemPartResultsCollection.h"
@@ -88,7 +89,7 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorGamma::calculate( int partIn
stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* srcPORDataFrames =
m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( RIG_NODAL, "POR-Bar", "" ) );
m_resultCollection->findOrLoadScalarResult( partIndex, RigFemAddressDefines::nodalPorBarAddress() );
RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr );
stepCountProgress.incrementProgress();

View File

@@ -18,6 +18,7 @@
#include "RigFemPartResultCalculatorMudWeightWindow.h"
#include "RigFemAddressDefines.h"
#include "RigFemPart.h"
#include "RigFemPartCollection.h"
#include "RigFemPartGrid.h"
@@ -99,9 +100,8 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorMudWeightWindow::calculate(
// Pore pressure
RigFemScalarResultFrames* porePressureDataFrames = nullptr;
{
auto task = stepCountProgress.task( "Loading POR-Bar.", m_resultCollection->timeStepCount() );
porePressureDataFrames =
m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( RIG_ELEMENT_NODAL, "POR-Bar", "" ) );
auto task = stepCountProgress.task( "Loading POR-Bar.", m_resultCollection->timeStepCount() );
porePressureDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemAddressDefines::elementNodalPorBarAddress() );
}
// Stress (ST.S3)

View File

@@ -18,6 +18,7 @@
#include "RigFemPartResultCalculatorNodalGradients.h"
#include "RigFemAddressDefines.h"
#include "RigFemPart.h"
#include "RigFemPartCollection.h"
#include "RigFemPartResultsCollection.h"
@@ -49,7 +50,7 @@ RigFemPartResultCalculatorNodalGradients::~RigFemPartResultCalculatorNodalGradie
//--------------------------------------------------------------------------------------------------
bool RigFemPartResultCalculatorNodalGradients::isMatching( const RigFemResultAddress& resVarAddr ) const
{
return ( ( resVarAddr.fieldName == "POR-Bar" ) && ( resVarAddr.resultPosType == RIG_NODAL ) &&
return ( ( resVarAddr.fieldName == RigFemAddressDefines::porBar() ) && ( resVarAddr.resultPosType == RIG_NODAL ) &&
( resVarAddr.componentName == "X" || resVarAddr.componentName == "Y" || resVarAddr.componentName == "Z" ) );
}
@@ -58,7 +59,7 @@ bool RigFemPartResultCalculatorNodalGradients::isMatching( const RigFemResultAdd
//--------------------------------------------------------------------------------------------------
RigFemScalarResultFrames* RigFemPartResultCalculatorNodalGradients::calculate( int partIndex, const RigFemResultAddress& resVarAddr )
{
CVF_ASSERT( resVarAddr.fieldName == "POR-Bar" );
CVF_ASSERT( resVarAddr.fieldName == RigFemAddressDefines::porBar() );
CVF_ASSERT( resVarAddr.componentName == "X" || resVarAddr.componentName == "Y" || resVarAddr.componentName == "Z" );
caf::ProgressInfo stepCountProgress( m_resultCollection->timeStepCount() * 5, "" );
@@ -81,8 +82,8 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorNodalGradients::calculate( i
stepCountProgress.incrementProgress();
stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemResultAddress porResultAddr( RIG_NODAL, "POR-Bar", "" );
RigFemScalarResultFrames* srcDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, porResultAddr );
RigFemScalarResultFrames* srcDataFrames =
m_resultCollection->findOrLoadScalarResult( partIndex, RigFemAddressDefines::nodalPorBarAddress() );
stepCountProgress.incrementProgress();

View File

@@ -18,6 +18,7 @@
#include "RigFemPartResultCalculatorNormalST.h"
#include "RigFemAddressDefines.h"
#include "RigFemPart.h"
#include "RigFemPartCollection.h"
#include "RigFemPartResultsCollection.h"
@@ -69,7 +70,7 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorNormalST::calculate( int par
stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* srcPORDataFrames =
m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( RIG_NODAL, "POR-Bar", "" ) );
m_resultCollection->findOrLoadScalarResult( partIndex, RigFemAddressDefines::nodalPorBarAddress() );
RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr );
const RigFemPart* femPart = m_resultCollection->parts()->part( partIndex );

View File

@@ -18,6 +18,7 @@
#include "RigFemPartResultCalculatorNormalized.h"
#include "RigFemAddressDefines.h"
#include "RigFemPart.h"
#include "RigFemPartCollection.h"
#include "RigFemPartGrid.h"
@@ -61,9 +62,7 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorNormalized::calculate( int p
{
CVF_ASSERT( resVarAddr.normalizeByHydrostaticPressure() && isNormalizableResult( resVarAddr ) );
RigFemResultAddress unscaledResult = resVarAddr;
if ( unscaledResult.resultPosType == RIG_NODAL && unscaledResult.fieldName == "POR-Bar" )
unscaledResult.resultPosType = RIG_ELEMENT_NODAL;
RigFemResultAddress unscaledResult = RigFemAddressDefines::getResultLookupAddress( resVarAddr );
unscaledResult.normalizedByHydrostaticPressure = false;
CAF_ASSERT( unscaledResult.resultPosType == RIG_ELEMENT_NODAL );
@@ -76,7 +75,7 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorNormalized::calculate( int p
{
auto task = stepCountProgress.task( "Loading POR Result", m_resultCollection->timeStepCount() );
porDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( RIG_ELEMENT_NODAL, "POR-Bar", "" ) );
porDataFrames = m_resultCollection->findOrLoadScalarResult( partIndex, RigFemAddressDefines::elementNodalPorBarAddress() );
if ( !porDataFrames ) return nullptr;
}
@@ -86,8 +85,11 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorNormalized::calculate( int p
if ( !srcDataFrames ) return nullptr;
}
{
auto task = stepCountProgress.task( "Creating Space for Normalized Result", m_resultCollection->timeStepCount() );
dstDataFrames = m_resultCollection->createScalarResult( partIndex, RigFemResultAddress( resVarAddr ) );
auto task = stepCountProgress.task( "Creating Space for Normalized Result", m_resultCollection->timeStepCount() );
RigFemResultAddress destResultAddr = RigFemAddressDefines::getResultLookupAddress( resVarAddr );
dstDataFrames = m_resultCollection->createScalarResult( partIndex, destResultAddr );
if ( !dstDataFrames ) return nullptr;
}

View File

@@ -20,6 +20,7 @@
#include "RiaEclipseUnitTools.h"
#include "RigFemAddressDefines.h"
#include "RigFemPart.h"
#include "RigFemPartCollection.h"
#include "RigFemPartResultsCollection.h"
@@ -78,7 +79,7 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorPoreCompressibility::calcula
return result;
};
RigFemScalarResultFrames* srcPORDataFrames = loadFrameLambda( RigFemResultAddress( RIG_NODAL, "POR-Bar", "" ) );
RigFemScalarResultFrames* srcPORDataFrames = loadFrameLambda( RigFemAddressDefines::nodalPorBarAddress() );
// Volumetric Strain
RigFemScalarResultFrames* srcEVDataFrames = loadFrameLambda( RigFemResultAddress( resAddr.resultPosType, "NE", "EV" ) );

View File

@@ -20,6 +20,7 @@
#include "RiaEclipseUnitTools.h"
#include "RigFemAddressDefines.h"
#include "RigFemPart.h"
#include "RigFemPartCollection.h"
#include "RigFemPartResultsCollection.h"
@@ -67,7 +68,7 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorPorosityPermeability::calcul
stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* srcPorePressureDataFrames =
m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( RIG_NODAL, "POR-Bar", "" ) );
m_resultCollection->findOrLoadScalarResult( partIndex, RigFemAddressDefines::nodalPorBarAddress() );
stepCountProgress.incrementProgress();
// Volumetric Strain

View File

@@ -18,6 +18,7 @@
#include "RigFemPartResultCalculatorShearSlipIndicator.h"
#include "RigFemAddressDefines.h"
#include "RigFemPart.h"
#include "RigFemPartCollection.h"
#include "RigFemPartGrid.h"
@@ -66,7 +67,8 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorShearSlipIndicator::calculat
// Pore pressure
stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* porePressureDataFrames =
m_resultCollection->findOrLoadScalarResult( partIndex, RigFemResultAddress( resVarAddr.resultPosType, "POR-Bar", "" ) );
m_resultCollection->findOrLoadScalarResult( partIndex,
RigFemResultAddress( resVarAddr.resultPosType, RigFemAddressDefines::porBar(), "" ) );
stepCountProgress.incrementProgress();
// Total vertical stress (ST.S33)

View File

@@ -18,6 +18,7 @@
#include "RigFemPartResultCalculatorTimeLapse.h"
#include "RigFemAddressDefines.h"
#include "RigFemPart.h"
#include "RigFemPartCollection.h"
#include "RigFemPartResultCalculatorGamma.h"
@@ -178,7 +179,10 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorTimeLapse::calculateGammaTim
stepCountProgress.setNextProgressIncrement( m_resultCollection->timeStepCount() );
RigFemScalarResultFrames* srcPORDataFrames =
m_resultCollection->findOrLoadScalarResult( partIndex,
RigFemResultAddress( RIG_NODAL, "POR-Bar", "", resVarAddr.timeLapseBaseStepIdx ) );
RigFemResultAddress( RIG_NODAL,
RigFemAddressDefines::porBar(),
"",
resVarAddr.timeLapseBaseStepIdx ) );
RigFemScalarResultFrames* dstDataFrames = m_resultCollection->createScalarResult( partIndex, resVarAddr );
stepCountProgress.incrementProgress();

View File

@@ -26,6 +26,7 @@
#include "RifElementPropertyReader.h"
#include "RifGeoMechReaderInterface.h"
#include "RigFemAddressDefines.h"
#include "RigFemNativeStatCalc.h"
#include "RigFemPartCollection.h"
#include "RigFemPartResultCalculatorBarConverted.h"
@@ -163,8 +164,8 @@ RigFemPartResultsCollection::RigFemPartResultsCollection( RifGeoMechReaderInterf
m_resultCalculators.push_back( std::unique_ptr<RigFemPartResultCalculator>( new RigFemPartResultCalculatorSurfaceAlignedStress( *this ) ) );
m_resultCalculators.push_back(
std::unique_ptr<RigFemPartResultCalculator>( new RigFemPartResultCalculatorBarConverted( *this, "S-Bar", "S" ) ) );
m_resultCalculators.push_back(
std::unique_ptr<RigFemPartResultCalculator>( new RigFemPartResultCalculatorBarConverted( *this, "POR-Bar", "POR" ) ) );
m_resultCalculators.push_back( std::unique_ptr<RigFemPartResultCalculator>(
new RigFemPartResultCalculatorBarConverted( *this, RigFemAddressDefines::porBar(), "POR" ) ) );
m_resultCalculators.push_back( std::unique_ptr<RigFemPartResultCalculator>( new RigFemPartResultCalculatorEnIpPorBar( *this ) ) );
m_resultCalculators.push_back( std::unique_ptr<RigFemPartResultCalculator>( new RigFemPartResultCalculatorNodalGradients( *this ) ) );
m_resultCalculators.push_back( std::unique_ptr<RigFemPartResultCalculator>( new RigFemPartResultCalculatorCompaction( *this ) ) );
@@ -573,7 +574,7 @@ std::map<std::string, std::vector<std::string>> RigFemPartResultsCollection::sca
{
fieldCompNames = m_readerInterface->scalarNodeFieldAndComponentNames();
if ( fieldCompNames.contains( "U" ) ) fieldCompNames["U"].push_back( "U_LENGTH" );
fieldCompNames["POR-Bar"];
fieldCompNames[RigFemAddressDefines::porBar()];
fieldCompNames[FIELD_NAME_COMPACTION];
}
else if ( resPos == RIG_ELEMENT_NODAL )
@@ -823,10 +824,10 @@ std::map<std::string, std::vector<std::string>> RigFemPartResultsCollection::sca
}
else if ( resPos == RIG_DIFFERENTIALS )
{
fieldCompNames["POR-Bar"];
fieldCompNames["POR-Bar"].push_back( "X" );
fieldCompNames["POR-Bar"].push_back( "Y" );
fieldCompNames["POR-Bar"].push_back( "Z" );
fieldCompNames[RigFemAddressDefines::porBar()];
fieldCompNames[RigFemAddressDefines::porBar()].push_back( "X" );
fieldCompNames[RigFemAddressDefines::porBar()].push_back( "Y" );
fieldCompNames[RigFemAddressDefines::porBar()].push_back( "Z" );
for ( auto& s : stressGradientComponentNames )
{
@@ -1367,8 +1368,9 @@ std::set<RigFemResultAddress> RigFemPartResultsCollection::normalizedResults()
}
results.insert( RigFemResultAddress( RIG_ELEMENT_NODAL, "ST", "Q", RigFemResultAddress::allTimeLapsesValue(), -1, true ) );
results.insert( RigFemResultAddress( RIG_NODAL, "POR-Bar", "", RigFemResultAddress::allTimeLapsesValue(), -1, true ) );
results.insert( RigFemResultAddress( RIG_ELEMENT_NODAL, "POR-Bar", "", RigFemResultAddress::allTimeLapsesValue(), -1, true ) );
results.insert( RigFemResultAddress( RIG_NODAL, RigFemAddressDefines::porBar(), "", RigFemResultAddress::allTimeLapsesValue(), -1, true ) );
results.insert(
RigFemResultAddress( RIG_ELEMENT_NODAL, RigFemAddressDefines::porBar(), "", RigFemResultAddress::allTimeLapsesValue(), -1, true ) );
return results;
}

View File

@@ -20,6 +20,7 @@
#include "RivFemElmVisibilityCalculator.h"
#include "RigCaseToCaseCellMapper.h"
#include "RigFemAddressDefines.h"
#include "RigFemPart.h"
#include "RigFemPartGrid.h"
#include "RigFemPartResultsCollection.h"
@@ -118,11 +119,7 @@ void RivFemElmVisibilityCalculator::computePropertyVisibility( cvf::UByteArray*
RigGeoMechCaseData* caseData = propFilterColl->reservoirView()->geoMechCase()->geoMechData();
RigFemResultAddress resVarAddress = propertyFilter->resultDefinition->resultAddress();
// Do a "Hack" to use elm nodal and not nodal POR results
if ( resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar" )
resVarAddress.resultPosType = RIG_ELEMENT_NODAL;
RigFemResultAddress resVarAddress = RigFemAddressDefines::getResultLookupAddress( propertyFilter->resultDefinition->resultAddress() );
const std::vector<float>& resVals =
caseData->femPartResults()->resultValues( resVarAddress, part->elementPartId(), timeStepIndex, frameIndex );

View File

@@ -17,16 +17,13 @@
//
/////////////////////////////////////////////////////////////////////////////////
#include <cstdlib>
#include "RivFemPartPartMgr.h"
#include "RivGeoMechPartMgr.h"
#include "RiaPreferences.h"
#include "RifGeoMechReaderInterface.h"
#include "RigFemAddressDefines.h"
#include "RigFemPart.h"
#include "RigFemPartResultsCollection.h"
#include "RigFemScalarResultFrames.h"
@@ -38,6 +35,7 @@
#include "RimRegularLegendConfig.h"
#include "RivFemPickSourceInfo.h"
#include "RivGeoMechPartMgr.h"
#include "RivMeshLinesSourceInfo.h"
#include "RivPartPriority.h"
#include "RivResultToTextureMapper.h"
@@ -61,6 +59,8 @@
#include "cvfTransform.h"
#include "cvfUniform.h"
#include <cstdlib>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -286,13 +286,7 @@ void RivFemPartPartMgr::updateCellResultColor( int timeStepIndex, int frameIndex
if ( !caseData ) return;
RigFemResultAddress resVarAddress = cellResultColors->resultAddress();
// Do a "Hack" to show elm nodal and not nodal POR results
if ( resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar" )
{
resVarAddress.resultPosType = RIG_ELEMENT_NODAL;
}
RigFemResultAddress resVarAddress = RigFemAddressDefines::getResultLookupAddress( cellResultColors->resultAddress() );
const std::vector<float>& resultValues =
caseData->femPartResults()->resultValues( resVarAddress, m_partIdx, timeStepIndex, frameIndex );