mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Result Divided by Area: Establish concept used to compute flow velocity and normalized trans (#7349)
* Geometry Tools : Add convenience functions for polygon area * #7232 Result Divided by Area: Add cell face result and show in GUI Native support for flow rate is given by mass rate (mass per time) over a cell face. Add a derived result that takes flow rate divided by cell face area to get velocity (distance per time). Add support for this concept on relevant native results, and indicate this result type in UI using a "/A" postfix * Speed up divided-by-area calculations by using openmp * Some refactoring of result data access. * Make sure NNC data is scaled correctly in vector flow viz. Co-authored-by: jonjenssen <jon@soundsoft.no>
This commit is contained in:
@@ -188,7 +188,7 @@ size_t RigNNCData::connectionsWithNoCommonArea( QStringList& connectionTextFirst
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigNNCData::ensureConnectionDataIsProcecced()
|
||||
bool RigNNCData::ensureConnectionDataIsProcessed()
|
||||
{
|
||||
if ( m_connectionsAreProcessed ) return false;
|
||||
|
||||
@@ -258,7 +258,7 @@ size_t RigNNCData::nativeConnectionCount() const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigConnectionContainer& RigNNCData::connections()
|
||||
{
|
||||
ensureConnectionDataIsProcecced();
|
||||
ensureConnectionDataIsProcessed();
|
||||
|
||||
return m_connections;
|
||||
}
|
||||
@@ -268,7 +268,7 @@ RigConnectionContainer& RigNNCData::connections()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double>& RigNNCData::makeStaticConnectionScalarResult( QString nncDataType )
|
||||
{
|
||||
ensureConnectionDataIsProcecced();
|
||||
ensureConnectionDataIsProcessed();
|
||||
|
||||
std::vector<std::vector<double>>& results = m_connectionResults[nncDataType];
|
||||
results.resize( 1 );
|
||||
@@ -566,15 +566,17 @@ std::vector<QString> RigNNCData::availableProperties( NNCResultType resultType )
|
||||
|
||||
for ( auto it : m_connectionResults )
|
||||
{
|
||||
if ( resultType == NNC_STATIC && it.second.size() == 1 && it.second[0].size() > 0 && isNative( it.first ) )
|
||||
if ( resultType == NNCResultType::NNC_STATIC && it.second.size() == 1 && it.second[0].size() > 0 &&
|
||||
isNative( it.first ) )
|
||||
{
|
||||
properties.push_back( it.first );
|
||||
}
|
||||
else if ( resultType == NNC_DYNAMIC && it.second.size() > 1 && it.second[0].size() > 0 && isNative( it.first ) )
|
||||
else if ( resultType == NNCResultType::NNC_DYNAMIC && it.second.size() > 1 && it.second[0].size() > 0 &&
|
||||
isNative( it.first ) )
|
||||
{
|
||||
properties.push_back( it.first );
|
||||
}
|
||||
else if ( resultType == NNC_GENERATED && !isNative( it.first ) )
|
||||
else if ( resultType == NNCResultType::NNC_GENERATED && !isNative( it.first ) )
|
||||
{
|
||||
properties.push_back( it.first );
|
||||
}
|
||||
@@ -603,6 +605,62 @@ bool RigNNCData::hasScalarValues( const RigEclipseResultAddress& resVarAddr )
|
||||
return ( it != m_connectionResults.end() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigNNCData::generateScalarValues( const RigEclipseResultAddress& resVarAddr )
|
||||
{
|
||||
if ( hasScalarValues( resVarAddr ) ) return true;
|
||||
|
||||
if ( resVarAddr.isDivideByCellFaceAreaActive() && resVarAddr.resultCatType() == RiaDefines::ResultCatType::DYNAMIC_NATIVE )
|
||||
{
|
||||
RigEclipseResultAddress tmpAddr = resVarAddr;
|
||||
tmpAddr.enableDivideByCellFaceArea( false );
|
||||
|
||||
auto nameit = m_resultAddrToNNCDataType.find( tmpAddr );
|
||||
if ( nameit == m_resultAddrToNNCDataType.end() ) return false;
|
||||
|
||||
auto it = m_connectionResults.find( nameit->second );
|
||||
if ( it == m_connectionResults.end() ) return false;
|
||||
|
||||
auto& srcdata = it->second;
|
||||
|
||||
auto& dstdata = makeDynamicConnectionScalarResult( resVarAddr.resultName(), srcdata.size() );
|
||||
|
||||
const double epsilon = 1.0e-3;
|
||||
|
||||
std::vector<double> areas( m_connections.size() );
|
||||
|
||||
for ( size_t dataIdx = 0; dataIdx < m_connections.size(); dataIdx++ )
|
||||
{
|
||||
double area = 0.0;
|
||||
if ( m_connections[dataIdx].hasCommonArea() )
|
||||
area = cvf::GeometryTools::polygonArea( m_connections[dataIdx].polygon() );
|
||||
areas[dataIdx] = area;
|
||||
}
|
||||
|
||||
#pragma omp parallel for
|
||||
for ( int i = 0; i < static_cast<int>( srcdata.size() ); i++ )
|
||||
{
|
||||
size_t timeIdx = i;
|
||||
dstdata[timeIdx].resize( srcdata[timeIdx].size() );
|
||||
|
||||
for ( size_t dataIdx = 0; dataIdx < srcdata[timeIdx].size(); dataIdx++ )
|
||||
{
|
||||
double scaledVal = 0.0;
|
||||
if ( areas[dataIdx] > epsilon ) scaledVal = srcdata[timeIdx][dataIdx] / areas[dataIdx];
|
||||
dstdata[timeIdx][dataIdx] = scaledVal;
|
||||
}
|
||||
}
|
||||
|
||||
m_resultAddrToNNCDataType[resVarAddr] = resVarAddr.resultName();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -613,6 +671,7 @@ const QString RigNNCData::getNNCDataTypeFromScalarResultIndex( const RigEclipseR
|
||||
{
|
||||
return it->second;
|
||||
}
|
||||
|
||||
return QString();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user