AXOM
Axom provides a robust, flexible software infrastructure for the development of multi-physics applications and computational tools.
axom::primal::Hexahedron< T, NDIMS > Class Template Reference

Represents an hexahedral geometric shape defined by eight points. More...

#include </home/docs/checkouts/readthedocs.org/user_builds/axom/checkouts/develop/src/axom/primal/geometry/Hexahedron.hpp>

Public Types

enum  { NUM_HEX_VERTS = 8 , NUM_TRIANGULATE = 24 }
 
using PointType = Point< T, NDIMS >
 
using VectorType = Vector< T, NDIMS >
 
using TetrahedronType = Tetrahedron< T, NDIMS >
 
using NumArrayType = NumericArray< T, NDIMS >
 

Public Member Functions

 Hexahedron ()=default
 Default constructor. Creates a degenerate hexahedron. More...
 
AXOM_HOST_DEVICE Hexahedron (const PointType &p, const PointType &q, const PointType &r, const PointType &s, const PointType &t, const PointType &u, const PointType &v, const PointType &w)
 Creates an hexahedron from the 8 points p,q,r,s,t,u,v,w. More...
 
AXOM_HOST_DEVICE Hexahedron (const PointType *pts)
 Hexahedron constructor from an array of Points. More...
 
AXOM_HOST_DEVICE Hexahedron (const axom::ArrayView< PointType > pts)
 Hexahedron constructor from an Array of Points. More...
 
AXOM_HOST_DEVICE Hexahedron (std::initializer_list< PointType > pts)
 Hexahedron constructor from an initializer list of Points. More...
 
AXOM_HOST_DEVICE PointTypeoperator[] (int idx)
 Index operator to get the i^th vertex. More...
 
AXOM_HOST_DEVICE const PointTypeoperator[] (int idx) const
 Index operator to get the i^th vertex. More...
 
AXOM_HOST_DEVICE PointType vertexMean () const
 Computes the average of the hexahedron's vertex positions. More...
 
AXOM_HOST_DEVICE double signedVolume () const
 Finds the signed volume of the hexahedron. More...
 
AXOM_HOST_DEVICE double volume () const
 Returns the absolute (unsigned) volume of the hexahedron. More...
 
AXOM_HOST_DEVICE void triangulate (axom::StackArray< TetrahedronType, NUM_TRIANGULATE > &tets)
 Method to decompose a Hexahedron into 24 Tetrahedrons. Each Tetrahedron consists of 4 points: (1) The mean of all Hexahedron points (2,3) Two adjacent vertices on a Hexahedron face (4) The mean of the current Hexahedron face. More...
 
AXOM_HOST_DEVICE bool equals (const Hexahedron &other, double eps=1.e-24) const
 Test if this Hexahedron is equal to another, within a tolerance. More...
 
std::ostream & print (std::ostream &os) const
 Simple formatted print of an hexahedron instance. More...
 

Detailed Description

template<typename T, int NDIMS = 3>
class axom::primal::Hexahedron< T, NDIMS >

Represents an hexahedral geometric shape defined by eight points.

Template Parameters
Tthe coordinate type, e.g., double, float, etc.
NDIMSthe number of spatial dimensions

There are eight vertices in the hexahedron, labelled P through W as the constructor's arguments. They are accessible using the square-brackets operator, with P being index 0, Q index 1, through W as index 7.

Here's a diagram showing a cube with the labeled vertices.

*
* S +---------+ R              +y
*   |\        |\
*   |  \      |  \              ^
*   | W + --------+ V           |
* P +---|-----+ Q |             |
*   \   |     \   |             -----> +x
*    \  |      \  |              \
*     \ |       \ |               \
*   T  +----------+ U              >
*                                   +z
* 

Member Typedef Documentation

◆ PointType

template<typename T , int NDIMS = 3>
using axom::primal::Hexahedron< T, NDIMS >::PointType = Point<T, NDIMS>

◆ VectorType

template<typename T , int NDIMS = 3>
using axom::primal::Hexahedron< T, NDIMS >::VectorType = Vector<T, NDIMS>

◆ TetrahedronType

template<typename T , int NDIMS = 3>
using axom::primal::Hexahedron< T, NDIMS >::TetrahedronType = Tetrahedron<T, NDIMS>

◆ NumArrayType

template<typename T , int NDIMS = 3>
using axom::primal::Hexahedron< T, NDIMS >::NumArrayType = NumericArray<T, NDIMS>

Member Enumeration Documentation

◆ anonymous enum

template<typename T , int NDIMS = 3>
anonymous enum
Enumerator
NUM_HEX_VERTS 
NUM_TRIANGULATE 

Constructor & Destructor Documentation

◆ Hexahedron() [1/5]

template<typename T , int NDIMS = 3>
axom::primal::Hexahedron< T, NDIMS >::Hexahedron ( )
default

Default constructor. Creates a degenerate hexahedron.

◆ Hexahedron() [2/5]

template<typename T , int NDIMS = 3>
AXOM_HOST_DEVICE axom::primal::Hexahedron< T, NDIMS >::Hexahedron ( const PointType p,
const PointType q,
const PointType r,
const PointType s,
const PointType t,
const PointType u,
const PointType v,
const PointType w 
)
inline

Creates an hexahedron from the 8 points p,q,r,s,t,u,v,w.

Parameters
[in]Pointcorresponding to vertex p of the hexahedron.
[in]Pointcorresponding to vertex q of the hexahedron.
[in]Pointcorresponding to vertex r of the hexahedron.
[in]Pointcorresponding to vertex s of the hexahedron.
[in]Pointcorresponding to vertex t of the hexahedron.
[in]Pointcorresponding to vertex u of the hexahedron.
[in]Pointcorresponding to vertex v of the hexahedron.
[in]Pointcorresponding to vertex w of the hexahedron.

◆ Hexahedron() [3/5]

template<typename T , int NDIMS = 3>
AXOM_HOST_DEVICE axom::primal::Hexahedron< T, NDIMS >::Hexahedron ( const PointType pts)
inlineexplicit

Hexahedron constructor from an array of Points.

Parameters
[in]ptsAn array containing at least 8 Points.
Note
It is the responsiblity of the caller to pass an array with at least 8 Points

References axom::primal::Hexahedron< T, NDIMS >::NUM_HEX_VERTS.

◆ Hexahedron() [4/5]

template<typename T , int NDIMS = 3>
AXOM_HOST_DEVICE axom::primal::Hexahedron< T, NDIMS >::Hexahedron ( const axom::ArrayView< PointType pts)
inlineexplicit

Hexahedron constructor from an Array of Points.

Parameters
[in]ptsAn ArrayView containing 8 Points.

References axom::primal::Hexahedron< T, NDIMS >::NUM_HEX_VERTS, axom::ArrayView< T, DIM, SPACE >::size(), and SLIC_ASSERT.

◆ Hexahedron() [5/5]

template<typename T , int NDIMS = 3>
AXOM_HOST_DEVICE axom::primal::Hexahedron< T, NDIMS >::Hexahedron ( std::initializer_list< PointType pts)
inlineexplicit

Hexahedron constructor from an initializer list of Points.

Parameters
[in]ptsan initializer list containing 8 Points

References axom::primal::Hexahedron< T, NDIMS >::NUM_HEX_VERTS, and SLIC_ASSERT.

Member Function Documentation

◆ operator[]() [1/2]

template<typename T , int NDIMS = 3>
AXOM_HOST_DEVICE PointType& axom::primal::Hexahedron< T, NDIMS >::operator[] ( int  idx)
inline

Index operator to get the i^th vertex.

Parameters
idxThe index of the desired vertex
Precondition
idx is 0, 1, 2, 3, 4, 5, 6, or 7

References axom::primal::Hexahedron< T, NDIMS >::NUM_HEX_VERTS, and SLIC_ASSERT.

◆ operator[]() [2/2]

template<typename T , int NDIMS = 3>
AXOM_HOST_DEVICE const PointType& axom::primal::Hexahedron< T, NDIMS >::operator[] ( int  idx) const
inline

Index operator to get the i^th vertex.

Parameters
idxThe index of the desired vertex
Precondition
idx is 0, 1, 2, 3, 4, 5, 6, or 7

References axom::primal::Hexahedron< T, NDIMS >::NUM_HEX_VERTS, and SLIC_ASSERT.

◆ vertexMean()

template<typename T , int NDIMS = 3>
AXOM_HOST_DEVICE PointType axom::primal::Hexahedron< T, NDIMS >::vertexMean ( ) const
inline

Computes the average of the hexahedron's vertex positions.

Returns
A point at the mean of the hexahedron's vertices

References axom::primal::Point< T, NDIMS >::array(), and axom::primal::Hexahedron< T, NDIMS >::NUM_HEX_VERTS.

◆ signedVolume()

template<typename T , int NDIMS = 3>
AXOM_HOST_DEVICE double axom::primal::Hexahedron< T, NDIMS >::signedVolume ( ) const
inline

Finds the signed volume of the hexahedron.

Uses algorithm in Grandy, J. Efficient computation of volume of hexahedral cells. United States: N. p., 1997. Web. doi:10.2172/632793.

Returns
The volume of the hexahedron
Note
Indices are different from the original paper

References axom::primal::Vector< T, NDIMS >::scalar_triple_product().

◆ volume()

template<typename T , int NDIMS = 3>
AXOM_HOST_DEVICE double axom::primal::Hexahedron< T, NDIMS >::volume ( ) const
inline

Returns the absolute (unsigned) volume of the hexahedron.

See also
signedVolume()

References axom::utilities::abs(), and axom::primal::Hexahedron< T, NDIMS >::signedVolume().

◆ triangulate()

template<typename T , int NDIMS = 3>
AXOM_HOST_DEVICE void axom::primal::Hexahedron< T, NDIMS >::triangulate ( axom::StackArray< TetrahedronType, NUM_TRIANGULATE > &  tets)
inline

Method to decompose a Hexahedron into 24 Tetrahedrons. Each Tetrahedron consists of 4 points: (1) The mean of all Hexahedron points (2,3) Two adjacent vertices on a Hexahedron face (4) The mean of the current Hexahedron face.

Parameters
tets[out] The tetrahedrons
Note
Assumes tets is pre-allocated

References axom::primal::Point< T, NDIMS >::midpoint(), and axom::primal::Hexahedron< T, NDIMS >::vertexMean().

◆ equals()

template<typename T , int NDIMS = 3>
AXOM_HOST_DEVICE bool axom::primal::Hexahedron< T, NDIMS >::equals ( const Hexahedron< T, NDIMS > &  other,
double  eps = 1.e-24 
) const
inline

Test if this Hexahedron is equal to another, within a tolerance.

Note
This function can be an expensive operation

References axom::primal::Hexahedron< T, NDIMS >::NUM_HEX_VERTS, and axom::primal::squared_distance().

◆ print()

template<typename T , int NDIMS = 3>
std::ostream& axom::primal::Hexahedron< T, NDIMS >::print ( std::ostream &  os) const
inline

Simple formatted print of an hexahedron instance.

Parameters
osThe output stream to write to
Returns
A reference to the modified ostream

The documentation for this class was generated from the following file: