mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4669 Round small values to avoid ugly coloring for near-zero gradients.
This commit is contained in:
parent
235dd1a2c0
commit
22ccf6003d
@ -1181,9 +1181,13 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateNodalGradient( i
|
||||
|
||||
if ( nValidElements > 0 )
|
||||
{
|
||||
dstFrameDataX[nodeIdx] = result.x() / static_cast<double>( nValidElements );
|
||||
dstFrameDataY[nodeIdx] = result.y() / static_cast<double>( nValidElements );
|
||||
dstFrameDataZ[nodeIdx] = result.z() / static_cast<double>( nValidElements );
|
||||
// Round very small values to zero to avoid ugly coloring when gradients
|
||||
// are dominated by floating point math artifacts.
|
||||
double epsilon = 1.0e-6;
|
||||
result /= static_cast<double>( nValidElements );
|
||||
dstFrameDataX[nodeIdx] = std::abs( result.x() ) > epsilon ? result.x() : 0.0;
|
||||
dstFrameDataY[nodeIdx] = std::abs( result.y() ) > epsilon ? result.y() : 0.0;
|
||||
dstFrameDataZ[nodeIdx] = std::abs( result.z() ) > epsilon ? result.z() : 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user