Fixed Problem regarding negative riTrans values

The reason was a bit sloppy detection of whether the surface normals was
pointing outwards or inwards in a cell.
The cells can be turned inside out due to depth/Z or mapaxis conditions.
This commit is contained in:
Jacob Støren
2014-09-23 12:24:48 +02:00
parent b58862ad93
commit 6e55ca82e2
8 changed files with 45 additions and 15 deletions

View File

@@ -363,9 +363,39 @@ void RigMainGrid::calculateFaults()
/// The cell is normally inverted due to Depth becoming -Z at import,
/// but if (only) one of the flipX/Y is done, the cell is back to normal
//--------------------------------------------------------------------------------------------------
bool RigMainGrid::faceNormalsIsOutwards() const
bool RigMainGrid::isFaceNormalsOutwards() const
{
return m_flipXAxis ^ m_flipYAxis;
for (int gcIdx = 0 ; gcIdx < static_cast<int>(m_cells.size()); ++gcIdx)
{
if (!m_cells[gcIdx].isInvalid())
{
cvf::Vec3d cellCenter = m_cells[gcIdx].center();
cvf::Vec3d faceCenter = m_cells[gcIdx].faceCenter(StructGridInterface::POS_I);
cvf::Vec3d faceNormal = m_cells[gcIdx].faceNormalWithAreaLenght(StructGridInterface::POS_I);
double typicalIJCellSize = characteristicIJCellSize();
double dummy, dummy2, typicalKSize;
characteristicCellSizes(&dummy, &dummy2, &typicalKSize);
if ( (faceCenter - cellCenter).length() > 0.2 * typicalIJCellSize
&& (faceNormal.length() > (0.2 * typicalIJCellSize * 0.2* typicalKSize)))
{
// Cell is assumed ok to use, so calculate whether the normals are outwards or inwards
if ((faceCenter - cellCenter) * faceNormal >= 0)
{
return true;
}
else
{
return false;
}
}
}
}
return false;
}
//--------------------------------------------------------------------------------------------------