GEOSX
Namespaces | Functions | Variables
ComputationalGeometry.hpp File Reference
#include "common/DataTypes.hpp"
#include "common/DataLayouts.hpp"
#include "LvArray/src/output.hpp"
#include "LvArray/src/tensorOps.hpp"

Go to the source code of this file.

Namespaces

 geosx
 

Functions

template<typename LINEDIR_TYPE , typename POINT_TYPE , typename NORMAL_TYPE , typename ORIGIN_TYPE , typename INTPOINT_TYPE >
void geosx::computationalGeometry::LinePlaneIntersection (LINEDIR_TYPE const &lineDir, POINT_TYPE const &linePoint, NORMAL_TYPE const &planeNormal, ORIGIN_TYPE const &planeOrigin, INTPOINT_TYPE &intersectionPoint)
 Calculate the intersection between a line and a plane. More...
 
template<typename NORMAL_TYPE >
void geosx::computationalGeometry::orderPointsCCW (arrayView2d< real64 > const &points, NORMAL_TYPE const &normal)
 Reorder a set of points counter-clockwise. More...
 
template<typename NORMAL_TYPE >
real64 geosx::computationalGeometry::ComputeSurfaceArea (arrayView2d< real64 const > const &points, NORMAL_TYPE const &&normal)
 Calculate the area of a polygon given the set of points in ccw order defining it. More...
 
template<typename CENTER_TYPE , typename NORMAL_TYPE >
GEOSX_HOST_DEVICE GEOSX_FORCE_INLINE real64 geosx::computationalGeometry::Centroid_3DPolygon (arraySlice1d< localIndex const > const pointsIndices, arrayView2d< real64 const, nodes::REFERENCE_POSITION_USD > const &points, CENTER_TYPE &&center, NORMAL_TYPE &&normal, real64 const areaTolerance=0.0)
 Calculate the centroid of a convex 3D polygon as well as the normal and the rotation matrix. More...
 
template<typename NORMAL_TYPE >
GEOSX_HOST_DEVICE void geosx::computationalGeometry::FixNormalOrientation_3D (NORMAL_TYPE &&normal)
 Change the orientation of the input vector to be consistent in a global sense. More...
 
template<typename NORMAL_TYPE , typename MATRIX_TYPE >
GEOSX_HOST_DEVICE void geosx::computationalGeometry::RotationMatrix_3D (NORMAL_TYPE const &normal, MATRIX_TYPE &&rotationMatrix)
 Calculate the rotation matrix for a face in the 3D space. More...
 
template<typename T >
GEOSX_HOST_DEVICE GEOSX_FORCE_INLINE int geosx::computationalGeometry::sign (T const val)
 Return the sign of a given value as an integer. More...
 
template<typename POINT_TYPE >
GEOSX_HOST_DEVICE bool geosx::computationalGeometry::IsPointInsidePolyhedron (arrayView2d< real64 const, nodes::REFERENCE_POSITION_USD > const &nodeCoordinates, array1d< array1d< localIndex > > const &faceNodeIndicies, POINT_TYPE const &point, real64 const areaTolerance=0.0)
 Check if a point is inside a convex polyhedron (3D polygon) More...
 
template<typename VEC_TYPE >
GEOSX_HOST_DEVICE void geosx::computationalGeometry::GetBoundingBox (localIndex const elemIndex, arrayView2d< localIndex const, cells::NODE_MAP_USD > const &pointIndices, arrayView2d< real64 const, nodes::REFERENCE_POSITION_USD > const &pointCoordinates, VEC_TYPE &&boxDims)
 Compute the dimensions of the bounding box containing the element defined here by the coordinates of its vertices. More...
 
GEOSX_HOST_DEVICE real64 geosx::computationalGeometry::HexVolume (real64 const X[][3])
 Compute the volume of an hexahedron. More...
 
GEOSX_HOST_DEVICE real64 geosx::computationalGeometry::TetVolume (real64 const X[][3])
 Compute the volume of an tetrahedron. More...
 
GEOSX_HOST_DEVICE real64 geosx::computationalGeometry::WedgeVolume (real64 const X[][3])
 Compute the volume of a wedge. More...
 
GEOSX_HOST_DEVICE real64 geosx::computationalGeometry::PyramidVolume (real64 const X[][3])
 Compute the volume of a pyramid. More...
 

Variables

constexpr real64 geosx::computationalGeometry::machinePrecision = std::numeric_limits< real64 >::epsilon()
 Machine epsilon for double-precision calculations.
 

Function Documentation

◆ Centroid_3DPolygon()

template<typename CENTER_TYPE , typename NORMAL_TYPE >
GEOSX_HOST_DEVICE GEOSX_FORCE_INLINE real64 geosx::computationalGeometry::Centroid_3DPolygon ( arraySlice1d< localIndex const > const  pointsIndices,
arrayView2d< real64 const, nodes::REFERENCE_POSITION_USD > const &  points,
CENTER_TYPE &&  center,
NORMAL_TYPE &&  normal,
real64 const  areaTolerance = 0.0 
)

Calculate the centroid of a convex 3D polygon as well as the normal and the rotation matrix.

Template Parameters
CENTER_TYPEThe type of center.
NORMAL_TYPEThe type of normal.
Parameters
[in]pointsIndiceslist of index references for the points array in order (CW or CCW) about the polygon loop
[in]points3D point list
[out]center3D center of the given ordered polygon point list
[out]normalnormal to the face
[in]areaTolerancetolerance used in the geometric computations
Returns
area of the convex 3D polygon

if area < - areaTolerance, this function will throw an error, and if (- areaTolerance <= area <= areaTolerance), the area is set to zero

Definition at line 193 of file ComputationalGeometry.hpp.

◆ ComputeSurfaceArea()

template<typename NORMAL_TYPE >
real64 geosx::computationalGeometry::ComputeSurfaceArea ( arrayView2d< real64 const > const &  points,
NORMAL_TYPE const &&  normal 
)

Calculate the area of a polygon given the set of points in ccw order defining it.

Template Parameters
NORMAL_TYPEthe type of normal
Parameters
[in]pointscoordinates of the points
[in]normalvector normal to the plane
Returns
the area of the polygon

Definition at line 146 of file ComputationalGeometry.hpp.

◆ FixNormalOrientation_3D()

template<typename NORMAL_TYPE >
GEOSX_HOST_DEVICE void geosx::computationalGeometry::FixNormalOrientation_3D ( NORMAL_TYPE &&  normal)

Change the orientation of the input vector to be consistent in a global sense.

Template Parameters
NORMAL_TYPEtype of normal
Parameters
[in,out]normalnormal to the face

Definition at line 256 of file ComputationalGeometry.hpp.

◆ GetBoundingBox()

template<typename VEC_TYPE >
GEOSX_HOST_DEVICE void geosx::computationalGeometry::GetBoundingBox ( localIndex const  elemIndex,
arrayView2d< localIndex const, cells::NODE_MAP_USD > const &  pointIndices,
arrayView2d< real64 const, nodes::REFERENCE_POSITION_USD > const &  pointCoordinates,
VEC_TYPE &&  boxDims 
)

Compute the dimensions of the bounding box containing the element defined here by the coordinates of its vertices.

Template Parameters
VEC_TYPEtype of boxDims
Parameters
[in]elemIndexindex of the element in pointIndices.
[in]pointIndicesthe indices of the vertices in pointCoordinates.
[in]pointCoordinatesthe vertices coordinates.
[out]boxDimsThe dimensions of the bounding box.

Definition at line 400 of file ComputationalGeometry.hpp.

◆ HexVolume()

GEOSX_HOST_DEVICE real64 geosx::computationalGeometry::HexVolume ( real64 const  X[][3])
inline

Compute the volume of an hexahedron.

Parameters
[in]Xvertices of the hexahedron
Returns
the volume of the hexahedron

Definition at line 434 of file ComputationalGeometry.hpp.

◆ IsPointInsidePolyhedron()

template<typename POINT_TYPE >
GEOSX_HOST_DEVICE bool geosx::computationalGeometry::IsPointInsidePolyhedron ( arrayView2d< real64 const, nodes::REFERENCE_POSITION_USD > const &  nodeCoordinates,
array1d< array1d< localIndex > > const &  faceNodeIndicies,
POINT_TYPE const &  point,
real64 const  areaTolerance = 0.0 
)

Check if a point is inside a convex polyhedron (3D polygon)

Template Parameters
POINT_TYPEtype of point
Parameters
[in]nodeCoordinatesa global array of nodal coordinates
[in]faceNodeIndiciesordered lists of node indices for each face of the polyhedron
[in]pointcoordinates of the query point
[in]areaTolerancesame as in Centroid_3DPolygon
Returns
whether the point is inside
Note
Face nodes must all be ordered the same way (i.e. CW or CCW), resulting in all face normals pointing either outside or inside the polyhendron
For faces with n>3 nodes that are non-planar, average normal is used

Definition at line 362 of file ComputationalGeometry.hpp.

◆ LinePlaneIntersection()

template<typename LINEDIR_TYPE , typename POINT_TYPE , typename NORMAL_TYPE , typename ORIGIN_TYPE , typename INTPOINT_TYPE >
void geosx::computationalGeometry::LinePlaneIntersection ( LINEDIR_TYPE const &  lineDir,
POINT_TYPE const &  linePoint,
NORMAL_TYPE const &  planeNormal,
ORIGIN_TYPE const &  planeOrigin,
INTPOINT_TYPE &  intersectionPoint 
)

Calculate the intersection between a line and a plane.

Template Parameters
LINEDIR_TYPEthe type of lineDir
POINT_TYPEthe type of linePoint
NORMAL_TYPEthe type of planeNormal
ORIGIN_TYPEthe type of planeOrigin
INTPOINT_TYPEthe type of instersectionPoint
Parameters
[in]lineDirvector defining direction of the line
[in]linePointone point of the line
[in]planeNormalnormal to plane
[in]planeOriginplane origin
[out]intersectionPointthe intersection point

Definition at line 53 of file ComputationalGeometry.hpp.

◆ orderPointsCCW()

template<typename NORMAL_TYPE >
void geosx::computationalGeometry::orderPointsCCW ( arrayView2d< real64 > const &  points,
NORMAL_TYPE const &  normal 
)

Reorder a set of points counter-clockwise.

Template Parameters
NORMAL_TYPEthe type of normal
Parameters
[in]pointscoordinates of the points
[in]normalvector normal to the plane

Definition at line 82 of file ComputationalGeometry.hpp.

◆ PyramidVolume()

GEOSX_HOST_DEVICE real64 geosx::computationalGeometry::PyramidVolume ( real64 const  X[][3])
inline

Compute the volume of a pyramid.

Parameters
[in]Xvertices of the pyramid
Returns
the volume of the pyramid

Definition at line 535 of file ComputationalGeometry.hpp.

◆ RotationMatrix_3D()

template<typename NORMAL_TYPE , typename MATRIX_TYPE >
GEOSX_HOST_DEVICE void geosx::computationalGeometry::RotationMatrix_3D ( NORMAL_TYPE const &  normal,
MATRIX_TYPE &&  rotationMatrix 
)

Calculate the rotation matrix for a face in the 3D space.

Template Parameters
NORMAL_TYPEtype of normal
MATRIX_TYPEtype of rotationMatrix
Parameters
[in]normalnormal to the face
[out]rotationMatrixrotation matrix for the face

Definition at line 293 of file ComputationalGeometry.hpp.

◆ sign()

template<typename T >
GEOSX_HOST_DEVICE GEOSX_FORCE_INLINE int geosx::computationalGeometry::sign ( T const  val)

Return the sign of a given value as an integer.

Template Parameters
Ttype of value
Parameters
valthe value in question
Returns
-1, 0 or 1 depending on whether the value is negative, zero or positive

Definition at line 341 of file ComputationalGeometry.hpp.

◆ TetVolume()

GEOSX_HOST_DEVICE real64 geosx::computationalGeometry::TetVolume ( real64 const  X[][3])
inline

Compute the volume of an tetrahedron.

Parameters
[in]Xvertices of the tetrahedron
Returns
the volume of the tetrahedron

Definition at line 484 of file ComputationalGeometry.hpp.

◆ WedgeVolume()

GEOSX_HOST_DEVICE real64 geosx::computationalGeometry::WedgeVolume ( real64 const  X[][3])
inline

Compute the volume of a wedge.

Parameters
[in]Xvertices of the wedge
Returns
the volume of the wedge

Definition at line 508 of file ComputationalGeometry.hpp.