triFace Class Reference

A triangular face using a FixedList of labels corresponding to mesh vertices. More...

Inheritance diagram for triFace:
[legend]
Collaboration diagram for triFace:
[legend]

Classes

struct  Hash
 Hashing function class for triFace (commutative) More...
 

Public Member Functions

 triFace ()
 Default construct, with invalid point labels (-1) More...
 
 triFace (const label a, const label b, const label c)
 Construct from three point labels. More...
 
 triFace (std::initializer_list< label > list)
 Construct from an initializer list of three point labels. More...
 
 triFace (const labelUList &list)
 Copy construct from a list of three point labels. More...
 
 triFace (const labelUList &list, const FixedList< label, 3 > &indices)
 Copy construct from a subset of point labels. More...
 
 triFace (Istream &is)
 Construct from Istream. More...
 
label collapse ()
 'Collapse' face by marking duplicate point labels. More...
 
void flip ()
 Flip the face in-place. More...
 
pointField points (const UList< point > &points) const
 Return the points corresponding to this face. More...
 
face triFaceFace () const
 Return triangle as a face. More...
 
triPointRef tri (const UList< point > &points) const
 Return the triangle. More...
 
point centre (const UList< point > &points) const
 Return centre (centroid) More...
 
template<class Type >
Type average (const UList< point > &unused, const Field< Type > &fld) const
 Calculate average value at centroid of face. More...
 
vector areaNormal (const UList< point > &points) const
 The area normal - with magnitude equal to area of face. More...
 
vector unitNormal (const UList< point > &points) const
 The unit normal. More...
 
 FOAM_DEPRECATED_FOR (2018-12, "areaNormal() or unitNormal()") vector normal(const UList< point > &points) const
 Legacy name for areaNormal() More...
 
scalar mag (const UList< point > &points) const
 Magnitude of face area. More...
 
label nTriangles () const
 Number of triangles after splitting. More...
 
triFace reverseFace () const
 Return face with reverse direction. More...
 
bool found (const label pointLabel) const
 Return true if the point label is found in face. More...
 
label which (const label pointLabel) const
 Find local index on face for the point label. More...
 
scalar sweptVol (const UList< point > &opts, const UList< point > &npts) const
 Return swept-volume from old-points to new-points. More...
 
tensor inertia (const UList< point > &points, const point &refPt=vector::zero, scalar density=1.0) const
 Return the inertia tensor, with optional reference. More...
 
pointHit ray (const point &p, const vector &q, const UList< point > &points, const intersection::algorithm=intersection::FULL_RAY, const intersection::direction dir=intersection::VECTOR) const
 Return point intersection with a ray starting at p, in direction q. More...
 
pointHit intersection (const point &p, const vector &q, const UList< point > &points, const intersection::algorithm alg, const scalar tol=0.0) const
 Fast intersection with a ray. More...
 
pointHit intersection (const point &p, const vector &q, const point &ctr, const UList< point > &points, const intersection::algorithm alg, const scalar tol=0.0) const
 
pointHit nearestPoint (const point &p, const UList< point > &points) const
 Return nearest point to face. More...
 
pointHit nearestPointClassify (const point &p, const UList< point > &points, label &nearType, label &nearLabel) const
 Return nearest point to face and classify it: More...
 
int sign (const point &p, const UList< point > &points, const scalar tol=SMALL) const
 The sign for which side of the face plane the point is on. More...
 
label nEdges () const
 Return number of edges. More...
 
edgeList edges () const
 Return edges in face point ordering,. More...
 
edge faceEdge (const label n) const
 Return n-th face edge. More...
 
int edgeDirection (const edge &e) const
 Return the edge direction on the face. More...
 
unsigned hashval (unsigned seed=0) const
 The (commutative) hash-value for triFace. More...
 
- Public Member Functions inherited from FixedList< label, 3 >
void writeEntry (const word &keyword, Ostream &os) const
 Write the list as a dictionary entry with keyword. More...
 
 FixedList ()=default
 Default construct. More...
 
 FixedList (const label &val)
 Construct and initialize all entries to given value. More...
 
 FixedList (const Foam::zero)
 Construct and initialize all entries to zero. More...
 
 FixedList (const label list[N])
 Copy construct from C-array. More...
 
 FixedList (const FixedList< label, N > &list)
 Copy construct. More...
 
 FixedList (FixedList< label, N > &&list)
 
 FixedList (InputIterator begIter, InputIterator endIter)
 Construct given begin/end iterators. More...
 
 FixedList (std::initializer_list< label > list)
 Construct from an initializer list. More...
 
 FixedList (const UList< label > &list)
 Construct from UList. More...
 
 FixedList (const UList< label > &list, const FixedList< label, N > &indices)
 Copy construct from a subset of the input. More...
 
 FixedList (const SLList< label > &list)
 Construct from SLList. More...
 
 FixedList (Istream &is)
 Construct from Istream. More...
 
autoPtr< FixedList< label, N > > clone () const
 Clone. More...
 
const label * cdata () const noexcept
 Return a const pointer to the first data element. More...
 
label * data () noexcept
 Return a pointer to the first data element. More...
 
label & first () noexcept
 The first element of the list, position [0]. More...
 
const label & first () const noexcept
 The first element of the list, position [0]. More...
 
label & last () noexcept
 The last element of the list, position [N-1]. More...
 
const label & last () const noexcept
 The last element of the list, position [N-1]. More...
 
label fcIndex (const label i) const
 
const label & fcValue (const label i) const
 Return forward circular value (ie, next value in the list) More...
 
label & fcValue (const label i)
 Return forward circular value (ie, next value in the list) More...
 
label rcIndex (const label i) const
 
const label & rcValue (const label i) const
 Return reverse circular value (ie, previous value in the list) More...
 
label & rcValue (const label i)
 Return reverse circular value (ie, previous value in the list) More...
 
void checkStart (const label start) const
 Check start is within valid range [0,size) More...
 
void checkSize (const label size) const
 Check size is identical to template parameter N. More...
 
void checkIndex (const label i) const
 Check index is within valid range [0,N) More...
 
bool uniform () const
 True if all entries have identical values, and list is non-empty. More...
 
label find (const label &val, label pos=0) const
 Find index of the first occurrence of the value. More...
 
label rfind (const label &val, label pos=-1) const
 Find index of the last occurrence of the value. More...
 
bool found (const label &val, label pos=0) const
 True if the value if found in the list. More...
 
void resize (const label n)
 Dummy function, to make FixedList consistent with List. More...
 
void setSize (const label n)
 Dummy function, to make FixedList consistent with List. More...
 
void fill (const label &val)
 Assign all entries to the given value. More...
 
void fill (const Foam::zero)
 Assign all entries to zero. More...
 
void moveFirst (const label i)
 Move element to the first position. More...
 
void moveLast (const label i)
 Move element to the last position. More...
 
void swapFirst (const label i)
 Swap element with the first element. More...
 
void swapLast (const label i)
 Swap element with the last element. More...
 
void transfer (FixedList< label, N > &list)
 
label & operator[] (const label i)
 Return element of FixedList. More...
 
const label & operator[] (const label i) const
 Return element of constant FixedList. More...
 
void operator= (const label list[N])
 Assignment to array operator. Takes linear time. More...
 
void operator= (const UList< label > &list)
 Assignment to UList operator. Takes linear time. More...
 
void operator= (const SLList< label > &list)
 Assignment to SLList operator. Takes linear time. More...
 
void operator= (std::initializer_list< label > list)
 Assignment to an initializer list. Takes linear time. More...
 
void operator= (const label &val)
 Assign all entries to the given value. fill() More...
 
void operator= (const Foam::zero)
 Assign all entries to zero. fill() More...
 
void operator= (const FixedList< label, N > &list)
 Copy assignment. More...
 
void operator= (FixedList< label, N > &&list)
 Move assignment. More...
 
iterator begin ()
 Return an iterator to begin traversing the FixedList. More...
 
const_iterator begin () const
 Return const_iterator to begin traversing the constant FixedList. More...
 
iterator end ()
 Return an iterator to end traversing the FixedList. More...
 
const_iterator end () const
 Return const_iterator to end traversing the constant FixedList. More...
 
const_iterator cbegin () const
 Return const_iterator to begin traversing the constant FixedList. More...
 
const_iterator cend () const
 Return const_iterator to end traversing the constant FixedList. More...
 
reverse_iterator rbegin ()
 Return reverse_iterator to begin reverse traversing the FixedList. More...
 
const_reverse_iterator rbegin () const
 Return const_reverse_iterator to begin reverse traversing FixedList. More...
 
reverse_iterator rend ()
 Return reverse_iterator to end reverse traversing the FixedList. More...
 
const_reverse_iterator rend () const
 Return const_reverse_iterator to end reverse traversing FixedList. More...
 
const_reverse_iterator crbegin () const
 Return const_reverse_iterator to begin reverse traversing FixedList. More...
 
const_reverse_iterator crend () const
 Return const_reverse_iterator to end reverse traversing FixedList. More...
 
void swap (FixedList< label, N > &list)
 Swap lists by swapping the content of the individual list elements. More...
 
bool operator== (const FixedList< label, N > &list) const
 Equality operation on FixedLists of the same type. More...
 
bool operator!= (const FixedList< label, N > &list) const
 The opposite of the equality operation. Takes linear time. More...
 
bool operator< (const FixedList< label, N > &list) const
 Compare two FixedLists lexicographically. Takes linear time. More...
 
bool operator> (const FixedList< label, N > &list) const
 Compare two FixedLists lexicographically. Takes linear time. More...
 
bool operator<= (const FixedList< label, N > &list) const
 Return true if !(a > b). Takes linear time. More...
 
bool operator>= (const FixedList< label, N > &list) const
 Return true if !(a < b). Takes linear time. More...
 
OstreamwriteList (Ostream &os, const label shortLen=0) const
 Write List, with line-breaks in ASCII when length exceeds shortLen. More...
 

Static Public Member Functions

static int compare (const triFace &a, const triFace &b)
 Compare triFaces. More...
 
- Static Public Member Functions inherited from FixedList< label, 3 >
static const FixedList< label, N > & null ()
 Return a null FixedList. More...
 
static constexpr bool empty () noexcept
 Always false since zero-sized FixedList is compile-time disabled. More...
 
static constexpr label size () noexcept
 Return the number of elements in the FixedList. More...
 
static constexpr unsigned max_size () noexcept
 The dimensioned size (template parameter N) of the FixedList. More...
 

Additional Inherited Members

- Public Types inherited from FixedList< label, 3 >
typedef label value_type
 The value type the FixedList contains. More...
 
typedef label * pointer
 The pointer type for non-const access to value_type items. More...
 
typedef label & reference
 The type used for storing into value_type objects. More...
 
typedef label * iterator
 Random access iterator for traversing FixedList. More...
 
typedef label size_type
 The type to represent the size of a FixedList. More...
 
typedef label difference_type
 The difference between iterator objects. More...
 
typedef std::reverse_iterator< iteratorreverse_iterator
 Reverse iterator (non-const access) More...
 
typedef std::reverse_iterator< const_iteratorconst_reverse_iterator
 Reverse iterator (const access) More...
 
- Public Attributes inherited from FixedList< label, 3 >
const typedef label * const_pointer
 The pointer type for const access to value_type items. More...
 
const typedef label & const_reference
 The type used for reading from constant value_type objects. More...
 
const typedef label * const_iterator
 Random access iterator for traversing FixedList. More...
 
- Protected Member Functions inherited from FixedList< label, 3 >
void writeEntry (Ostream &os) const
 Write the FixedList with its compound type. More...
 

Detailed Description

A triangular face using a FixedList of labels corresponding to mesh vertices.

See also
Foam::face, Foam::triangle
Source files

Definition at line 69 of file triFace.H.

Constructor & Destructor Documentation

◆ triFace() [1/6]

triFace ( )
inline

Default construct, with invalid point labels (-1)

Definition at line 65 of file triFaceI.H.

◆ triFace() [2/6]

triFace ( const label  a,
const label  b,
const label  c 
)
inline

Construct from three point labels.

Definition at line 72 of file triFaceI.H.

References Foam::constant::physicoChemical::b, and Foam::constant::universal::c.

◆ triFace() [3/6]

triFace ( std::initializer_list< label >  list)
inlineexplicit

Construct from an initializer list of three point labels.

Definition at line 84 of file triFaceI.H.

◆ triFace() [4/6]

triFace ( const labelUList list)
inlineexplicit

Copy construct from a list of three point labels.

Definition at line 90 of file triFaceI.H.

◆ triFace() [5/6]

triFace ( const labelUList list,
const FixedList< label, 3 > &  indices 
)
inline

Copy construct from a subset of point labels.

Definition at line 97 of file triFaceI.H.

◆ triFace() [6/6]

triFace ( Istream is)
inline

Construct from Istream.

Definition at line 106 of file triFaceI.H.

Member Function Documentation

◆ collapse()

Foam::label collapse ( )
inline

'Collapse' face by marking duplicate point labels.

Duplicates point labels are marked with '-1' (the lower vertex is retained). Return the collapsed size.

Definition at line 114 of file triFaceI.H.

References n.

◆ flip()

void flip ( )
inline

Flip the face in-place.

The starting points of the original and flipped face are identical.

Definition at line 141 of file triFaceI.H.

References Foam::Swap().

Here is the call graph for this function:

◆ points()

Foam::pointField points ( const UList< point > &  points) const
inline

Return the points corresponding to this face.

Definition at line 147 of file triFaceI.H.

References p, and points.

◆ triFaceFace()

Foam::face triFaceFace ( ) const
inline

Return triangle as a face.

Definition at line 159 of file triFaceI.H.

◆ tri()

Foam::triPointRef tri ( const UList< point > &  points) const
inline

Return the triangle.

Definition at line 165 of file triFaceI.H.

References points.

Referenced by lumpedPointMovement::setInterpolator().

Here is the caller graph for this function:

◆ centre()

Foam::point centre ( const UList< point > &  points) const
inline

Return centre (centroid)

Definition at line 176 of file triFaceI.H.

References points.

◆ average()

Type average ( const UList< point > &  unused,
const Field< Type > &  fld 
) const

Calculate average value at centroid of face.

Definition at line 34 of file triFaceTemplates.C.

References fld.

◆ areaNormal()

Foam::vector areaNormal ( const UList< point > &  points) const
inline

The area normal - with magnitude equal to area of face.

Definition at line 187 of file triFaceI.H.

References points.

◆ unitNormal()

Foam::vector unitNormal ( const UList< point > &  points) const
inline

The unit normal.

Definition at line 198 of file triFaceI.H.

References Foam::mag(), n, points, s, and Foam::Zero.

Referenced by wallBoundedParticle::trackToEdge().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FOAM_DEPRECATED_FOR()

FOAM_DEPRECATED_FOR ( 2018-  12,
"areaNormal() or unitNormal()"   
) const &
inline

Legacy name for areaNormal()

Deprecated:
(2018-06) Deprecated for new use

Definition at line 141 of file triFace.H.

◆ mag()

Foam::scalar mag ( const UList< point > &  points) const
inline

Magnitude of face area.

Definition at line 206 of file triFaceI.H.

References Foam::mag(), and points.

Here is the call graph for this function:

◆ nTriangles()

Foam::label nTriangles ( ) const
inline

Number of triangles after splitting.

Definition at line 212 of file triFaceI.H.

◆ reverseFace()

Foam::triFace reverseFace ( ) const
inline

Return face with reverse direction.

The starting points of the original and reverse face are identical.

Definition at line 218 of file triFaceI.H.

References triFace().

Here is the call graph for this function:

◆ found()

bool found ( const label  pointLabel) const
inline

Return true if the point label is found in face.

Definition at line 225 of file triFaceI.H.

References FixedList< T, N >::found().

Referenced by wallBoundedParticle::isTriAlongTrack().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ which()

Foam::label which ( const label  pointLabel) const
inline

Find local index on face for the point label.

Returns
position in face (0,1,2) or -1 if not found.

Definition at line 231 of file triFaceI.H.

References FixedList< T, N >::find().

Here is the call graph for this function:

◆ sweptVol()

Foam::scalar sweptVol ( const UList< point > &  opts,
const UList< point > &  npts 
) const
inline

Return swept-volume from old-points to new-points.

Definition at line 238 of file triFaceI.H.

◆ inertia()

Foam::tensor inertia ( const UList< point > &  points,
const point refPt = vector::zero,
scalar  density = 1.0 
) const
inline

Return the inertia tensor, with optional reference.

point and density specification

Definition at line 271 of file triFaceI.H.

References points.

◆ ray()

Foam::pointHit ray ( const point p,
const vector q,
const UList< point > &  points,
const intersection::algorithm  alg = intersection::FULL_RAY,
const intersection::direction  dir = intersection::VECTOR 
) const
inline

Return point intersection with a ray starting at p, in direction q.

Definition at line 283 of file triFaceI.H.

References p, and points.

◆ intersection() [1/2]

Foam::pointHit intersection ( const point p,
const vector q,
const UList< point > &  points,
const intersection::algorithm  alg,
const scalar  tol = 0.0 
) const
inline

Fast intersection with a ray.

Definition at line 297 of file triFaceI.H.

References p, and points.

◆ intersection() [2/2]

Foam::pointHit intersection ( const point p,
const vector q,
const point ctr,
const UList< point > &  points,
const intersection::algorithm  alg,
const scalar  tol = 0.0 
) const
inline

Definition at line 310 of file triFaceI.H.

References p, and points.

◆ nearestPoint()

Foam::pointHit nearestPoint ( const point p,
const UList< point > &  points 
) const
inline

Return nearest point to face.

Definition at line 324 of file triFaceI.H.

References p, and points.

◆ nearestPointClassify()

Foam::pointHit nearestPointClassify ( const point p,
const UList< point > &  points,
label &  nearType,
label &  nearLabel 
) const
inline

Return nearest point to face and classify it:

+ near point (nearType=POINT, nearLabel=0, 1, 2) + near edge (nearType=EDGE, nearLabel=0, 1, 2) Note: edges are counted from starting vertex so e.g. edge n is from f[n] to f[0], where the face has n + 1 points

Definition at line 334 of file triFaceI.H.

References p, and points.

◆ sign()

int sign ( const point p,
const UList< point > &  points,
const scalar  tol = SMALL 
) const
inline

The sign for which side of the face plane the point is on.

Uses the supplied tolerance for rounding around zero.

Returns
  • 0: on plane
  • +1: front-side
  • -1: back-side

Definition at line 346 of file triFaceI.H.

References p, and points.

◆ nEdges()

Foam::label nEdges ( ) const
inline

Return number of edges.

Definition at line 356 of file triFaceI.H.

◆ edges()

Foam::edgeList edges ( ) const
inline

Return edges in face point ordering,.

i.e. edges()[0] is edge between [0] and [1]

Definition at line 362 of file triFaceI.H.

References Foam::constant::electromagnetic::e.

◆ faceEdge()

Foam::edge faceEdge ( const label  n) const
inline

Return n-th face edge.

Definition at line 379 of file triFaceI.H.

References n.

◆ edgeDirection()

int edgeDirection ( const edge e) const
inline

Return the edge direction on the face.

Returns
  • +1: forward (counter-clockwise) on the face
  • -1: reverse (clockwise) on the face
  • 0: edge not found on the face

Definition at line 389 of file triFaceI.H.

References Foam::constant::electromagnetic::e.

◆ compare()

int compare ( const triFace a,
const triFace b 
)
inlinestatic

Compare triFaces.

Returns
:
  • 0: different
  • +1: identical
  • -1: same face, but different orientation

Definition at line 36 of file triFaceI.H.

References Foam::constant::physicoChemical::b.

Referenced by Foam::operator!=(), and Foam::operator==().

Here is the caller graph for this function:

◆ hashval()

unsigned hashval ( unsigned  seed = 0) const
inline

The (commutative) hash-value for triFace.

Definition at line 273 of file triFace.H.

Referenced by triFace::Hash< HashT >::operator()(), and Hash< triFace >::operator()().

Here is the caller graph for this function:

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