chombo-discharge
Loading...
Searching...
No Matches
Functions | Variables
PolyhedralEB::detail Namespace Reference

Cell topology and polygon geometry the cut cell classes are assembled from. More...

Functions

int edgeDirection (const int a_edge) noexcept
 Direction a cell edge runs along.
 
void edgeOrigin (const int a_edge, int a_offset[SpaceDim]) noexcept
 Corner offsets of a cell edge's low end.
 
void edgeCorners (const int a_edge, int &a_lo, int &a_hi) noexcept
 The corners a cell edge joins, low end first.
 
RealVect cornerPosition (const int a_corner) noexcept
 Position of a cell corner in the cell's own frame.
 
void faceCorners (const int a_dir, const int a_side, int a_corner[1<<(SpaceDim - 1)]) noexcept
 The corners of a cell face, in circuit order around the face.
 
int edgeIndex (const int a_dir, const int a_offset[SpaceDim]) noexcept
 Index of the edge running along a_dir whose low corner has the given offsets.
 
RealVect crossingPosition (const CutCellSurface &a_surface, const int a_edge, const Real a_tolerance) noexcept
 Position of an edge crossing in the cell's own frame.
 
void faceEdges (const int a_dir, const int a_side, int a_edge[4]) noexcept
 The edges of a cell face, edge i joining face corners i and i+1.
 
void polygonMoments (const RealVect *a_vertex, const int a_num, Real &a_area, RealVect &a_vector, RealVect &a_centroid) noexcept
 Area vector, area and centroid of a planar polygon given in circuit order.
 
int facePairs (const int a_dir, const int a_side, const CutCellSurface &a_surface, int a_pair[2][2]) noexcept
 The chords on a cell face, each an unordered pair of edge indices.
 
int crossingLoops (const CutCellSurface &a_surface, int a_loop[CutCellSurface::s_numEdges], int a_start[CutCellSurface::s_numEdges+1]) noexcept
 Order the crossings into closed loops, or fail if they do not form clean cycles.
 
bool sameVertex (const RealVect &a_a, const RealVect &a_b) noexcept
 Whether two positions are the same vertex.
 

Variables

constexpr int s_transverse [3][2] = {{1, 2}, {0, 2}, {0, 1}}
 The two directions transverse to each coordinate direction, in increasing order.
 
constexpr Real s_weldTolerance = 1.0E-10
 Distance within which two vertices are taken to be the same one.
 

Detailed Description

Cell topology and polygon geometry the cut cell classes are assembled from.

Corners, edges and faces are indexed in the cell's own [-1/2, 1/2]^SpaceDim frame. Corner c has offset ((c >> d) & 1) in direction d. Edges are numbered direction-major, with s_numEdges / SpaceDim edges running along each direction: edge e runs along direction e / (s_numEdges / SpaceDim), and the remainder holds the offsets of the edge's low corner in the transverse directions, one bit per direction in increasing order. An edge is parameterised from its low corner. Faces are indexed as 2 * dir + side with side 0 the low face and side 1 the high face. Two neighbouring cells therefore address a shared corner, edge or face identically.

Function Documentation

◆ cornerPosition()

RealVect PolyhedralEB::detail::cornerPosition ( const int  a_corner)
inlinenoexcept

Position of a cell corner in the cell's own frame.

Parameters
[in]a_cornerCorner index in [0, CutCellSurface::s_numCorners).
Returns
Corner position, each component -1/2 or 1/2.

◆ crossingLoops()

int PolyhedralEB::detail::crossingLoops ( const CutCellSurface &  a_surface,
int  a_loop[CutCellSurface::s_numEdges],
int  a_start[CutCellSurface::s_numEdges+1] 
)
inlinenoexcept

Order the crossings into closed loops, or fail if they do not form clean cycles.

Every crossing lies on exactly two faces and every face pairs its crossings up, so each node has degree two and the graph is a disjoint union of cycles. Several cycles is legal: the interface simply enters the cell as several sheets. Every loop returned has at least three crossings.

Parameters
[in]a_surfaceCorner values and edge crossings of the cell.
[out]a_loopEdge indices of every loop, one loop after the other.
[out]a_startWhere each loop begins in a_loop, with the total length last.
Returns
Number of loops, or -1 if some face carries an odd number of crossings, some crossing is paired with other than two, the cell has fewer than three crossings in all, or a loop closes on fewer than three.

◆ crossingPosition()

RealVect PolyhedralEB::detail::crossingPosition ( const CutCellSurface &  a_surface,
const int  a_edge,
const Real  a_tolerance 
)
inlinenoexcept

Position of an edge crossing in the cell's own frame.

The crossing is held at least a_tolerance away from either endpoint of the edge, except a crossing recorded exactly at an endpoint: that one sits on a corner the interface passes through and is left where it is, since displacing it would open a sliver of the displacement's own width.

Parameters
[in]a_surfaceCorner values and edge crossings of the cell.
[in]a_edgeEdge index in [0, CutCellSurface::s_numEdges). The edge must carry a crossing.
[in]a_toleranceDistance by which the crossing is held off the edge's endpoints, in [0, 1/2).
Returns
Crossing position.

◆ edgeCorners()

void PolyhedralEB::detail::edgeCorners ( const int  a_edge,
int &  a_lo,
int &  a_hi 
)
inlinenoexcept

The corners a cell edge joins, low end first.

Parameters
[in]a_edgeEdge index in [0, CutCellSurface::s_numEdges).
[out]a_loCorner at the edge's low end.
[out]a_hiCorner at the edge's high end.

◆ edgeDirection()

int PolyhedralEB::detail::edgeDirection ( const int  a_edge)
inlinenoexcept

Direction a cell edge runs along.

Parameters
[in]a_edgeEdge index in [0, CutCellSurface::s_numEdges).
Returns
Coordinate direction of the edge.

◆ edgeIndex()

int PolyhedralEB::detail::edgeIndex ( const int  a_dir,
const int  a_offset[SpaceDim] 
)
inlinenoexcept

Index of the edge running along a_dir whose low corner has the given offsets.

Only the offsets in the transverse directions take part; the offset along a_dir is ignored, since the edge's low corner has offset zero there by definition.

Parameters
[in]a_dirCoordinate direction the edge runs along.
[in]a_offsetCorner offsets of the edge's low end, each 0 or 1.
Returns
Edge index in [0, CutCellSurface::s_numEdges).

◆ edgeOrigin()

void PolyhedralEB::detail::edgeOrigin ( const int  a_edge,
int  a_offset[SpaceDim] 
)
inlinenoexcept

Corner offsets of a cell edge's low end.

Parameters
[in]a_edgeEdge index in [0, CutCellSurface::s_numEdges).
[out]a_offsetCorner offsets, zero in the direction the edge runs along.

◆ faceCorners()

void PolyhedralEB::detail::faceCorners ( const int  a_dir,
const int  a_side,
int  a_corner[1<<(SpaceDim - 1)] 
)
inlinenoexcept

The corners of a cell face, in circuit order around the face.

The circuit runs through the transverse offsets (0,0), (1,0), (1,1), (0,1). Its handedness relative to the face's outward normal depends on the direction, so a polygon assembled along it has to be oriented afterwards.

Parameters
[in]a_dirCoordinate direction of the face normal.
[in]a_side0 for the low face in that direction, 1 for the high face.
[out]a_cornerFace corners in circuit order.

◆ faceEdges()

void PolyhedralEB::detail::faceEdges ( const int  a_dir,
const int  a_side,
int  a_edge[4] 
)
inlinenoexcept

The edges of a cell face, edge i joining face corners i and i+1.

Parameters
[in]a_dirCoordinate direction of the face normal.
[in]a_side0 for the low face in that direction, 1 for the high face.
[out]a_edgeFace edges in the circuit order of faceCorners.

◆ facePairs()

int PolyhedralEB::detail::facePairs ( const int  a_dir,
const int  a_side,
const CutCellSurface &  a_surface,
int  a_pair[2][2] 
)
inlinenoexcept

The chords on a cell face, each an unordered pair of edge indices.

A face with two crossings carries one chord. A face whose corners alternate fluid and solid carries four crossings and there are two ways to join them; the bilinear interpolant of the four corner values decides it. The saddle shares its side with exactly one of the two diagonals: that diagonal meets through the middle, and the other is the pair the chords cut off. Both cells adjoining the face hold the same four values, so they cannot disagree. With four crossings each chord joins two consecutive edges of the face circuit.

Parameters
[in]a_dirCoordinate direction of the face normal.
[in]a_side0 for the low face in that direction, 1 for the high face.
[in]a_surfaceCorner values and edge crossings of the cell.
[out]a_pairEach chord's two edge indices. Entries beyond the returned count are left untouched.
Returns
Number of chords, 0, 1 or 2, or -1 if the face carries an odd number of crossings.

◆ polygonMoments()

void PolyhedralEB::detail::polygonMoments ( const RealVect *  a_vertex,
const int  a_num,
Real &  a_area,
RealVect &  a_vector,
RealVect &  a_centroid 
)
inlinenoexcept

Area vector, area and centroid of a planar polygon given in circuit order.

The area vector is the sum of the signed triangle area vectors of a fan from the first vertex, so a non-convex polygon comes out right. A face contour that is a polyline rather than a single chord leaves such a polygon, and summing unsigned triangle areas over the fan over-counts it. The centroid is the area-weighted mean of the triangle centroids with the same signs. Fewer than three vertices yield all-zero outputs.

Parameters
[in]a_vertexPolygon vertices in circuit order.
[in]a_numNumber of vertices.
[out]a_areaMagnitude of the area vector, which is the polygon area when the polygon is planar and simple.
[out]a_vectorPolygon area vector, normal to the polygon with the handedness of the circuit.
[out]a_centroidPolygon centroid, zero when the area is zero.

◆ sameVertex()

bool PolyhedralEB::detail::sameVertex ( const RealVect &  a_a,
const RealVect &  a_b 
)
inlinenoexcept

Whether two positions are the same vertex.

Parameters
[in]a_aFirst position.
[in]a_bSecond position.
Returns
True if they lie within s_weldTolerance of one another.

Variable Documentation

◆ s_transverse

constexpr int PolyhedralEB::detail::s_transverse[3][2] = {{1, 2}, {0, 2}, {0, 1}}
constexpr

The two directions transverse to each coordinate direction, in increasing order.

This is the order the transverse offsets are packed into an edge index and the order the face corners and edges are walked in.

◆ s_weldTolerance

constexpr Real PolyhedralEB::detail::s_weldTolerance = 1.0E-10
constexpr

Distance within which two vertices are taken to be the same one.

A vertex where two polygons meet is computed once along each polygon's own edge, and the two answers agree to about a part in a thousand billion rather than bit for bit. Loops are stitched by matching one segment's end to the next one's start, so the match is made at that distance and not exactly. Far below any edge that carries area – a cell is one unit across in this frame – and far above the disagreement two computations of the same point produce.