Skip to content

Commit

Permalink
levelset: check cell intersection by interecting its interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantinos committed May 31, 2024
1 parent a841ab0 commit 3902e37
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/levelset/levelSetCommon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ enum class LevelSetIntersectionMode{
FAST_FUZZY=0, /**< Compares levelset value to tangent and bounding radius of a cell */
FAST_GUARANTEE_TRUE=1, /**< All LevelSetIntersectionStatus::TRUE are accurate but LevelSetIntersectionStatus::FALSE may be wrong */
FAST_GUARANTEE_FALSE=2, /**< All LevelSetIntersectionStatus::FALSE are accurate but LevelSetIntersectionStatus::TRUE may be wrong */
ACCURATE=3 /**< Accurate but more costly checks */
ACCURATE_LOW_ORDER=3, /**< Accurate but more costly checks. Handles the zero level set as planar. */
ACCURATE_HIGH_ORDER=4, /**< Accurate but more costly checks. Takes into consideration the curvature of the zero level set surface */
ACCURATE=ACCURATE_LOW_ORDER
};

/*!
Expand Down
32 changes: 30 additions & 2 deletions src/levelset/levelSetObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1406,12 +1406,17 @@ LevelSetIntersectionStatus LevelSetObject::_intersectInterfaceSurface(long id, i
* larger than the bounding radius LevelSetIntersectionStatus::FALSE is returned,
* otherwise LevelSetIntersectionStatus::TRUE.
*
* If mode==LevelSetIntersectionMode::ACCURATE, the same checks of fuzzy mode are
* If mode==LevelSetIntersectionMode::ACCURATE_LOW_ORDER, the same checks of fuzzy mode are
* performed, however, in the cases where fuzzy mode would return CLOSE, an additional
* check on the intersection between the tangent plane at the projection point and the
* cell is performed. Errors of the method are related to the ratio of surface curvature
* over cell size.
*
* If mode==LevelSetIntersectionMode::ACCURATE_HIGH_ORDER, the same checks of the low order
* accurate mode, but the curvature of the zero level set is accounted as well. Each interface
* evaluates its own distance from it. Also, this is the only mode taking into consideration
* possible high order smoothing of the surface.
*
* The bounding sphere is the sphere with the minimum radius that contains all the
* cell vertices and has the center in the cell centroid.
*
Expand Down Expand Up @@ -1470,7 +1475,7 @@ LevelSetIntersectionStatus LevelSetObject::_intersectCellSurface(long id, double
break;
}

case LevelSetIntersectionMode::ACCURATE:
case LevelSetIntersectionMode::ACCURATE_LOW_ORDER:
{
double boundingSphere = m_kernel->computeCellBoundingRadius(id) ;
if(utils::DoubleFloatingGreater()(distance, boundingSphere, distanceTolerance, distanceTolerance)){
Expand All @@ -1492,6 +1497,29 @@ LevelSetIntersectionStatus LevelSetObject::_intersectCellSurface(long id, double

break;
}

case LevelSetIntersectionMode::ACCURATE_HIGH_ORDER:
{
double boundingSphere = m_kernel->computeCellBoundingRadius(id) ;
if(utils::DoubleFloatingGreater()(distance, boundingSphere, distanceTolerance, distanceTolerance)){
return LevelSetIntersectionStatus::FALSE;
}

double tangentSphere = m_kernel->computeCellTangentRadius(id) ;
if(utils::DoubleFloatingLessEqual()(distance, tangentSphere, distanceTolerance, distanceTolerance)){
return LevelSetIntersectionStatus::TRUE;
}

int nInterfaces = m_kernel->getMesh()->getCell(id).getInterfaceCount();
for (int i = 0; i < nInterfaces; ++i) {
if (_intersectInterfaceSurface(id, i, distanceTolerance) == LevelSetIntersectionStatus::TRUE) {
return LevelSetIntersectionStatus::TRUE;
}
}
return LevelSetIntersectionStatus::FALSE;

break;
}
}

BITPIT_UNREACHABLE("cannot reach");
Expand Down
8 changes: 7 additions & 1 deletion src/levelset/levelSetSegmentationObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1881,12 +1881,18 @@ LevelSetIntersectionStatus LevelSetSegmentationBaseObject::evalIntersectedInterf
* larger than the bounding radius LevelSetIntersectionStatus::FALSE is returned,
* otherwise LevelSetIntersectionStatus::TRUE.
*
* If mode==LevelSetIntersectionMode::ACCURATE, the same checks of fuzzy mode are
* If mode==LevelSetIntersectionMode::ACCURATE_LOW_ORDER, the same checks of fuzzy mode are
* performed, however, in the cases where fuzzy mode would return CLOSE, an additional
* check on the intersection between the tangent plane at the projection point and the
* cell is performed. Errors of the method are related to the ratio of surface curvature
* over cell size.
*
* If mode==LevelSetIntersectionMode::ACCURATE_HIGH_ORDER, the same checks of the low order
* accurate mode, but the curvature of the zero level set is accounted as well. Each interface
* evaluates its own distance from it. Also, this is the only mode taking into consideration
* possible high order smoothing of the surface.
*
*
* The bounding sphere is the sphere with the minimum radius that contains all the
* cell vertices and has the center in the cell centroid.
*
Expand Down

0 comments on commit 3902e37

Please sign in to comment.