EBGeometry
Compact, header-only C++ library for fast evaluation of signed distance functions
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Public Attributes | List of all members
EBGeometry::ExprIndex< T > Class Template Reference

The nodes of an expression, numbered, with the leaves below each and their labels: on the host, the way from what a Tape reports (a leaf, see LeafRef::m_leaf and HitT::m_primitive) back to the expression. More...

#include <EBGeometry_Expr.hpp>

Classes

struct  Node
 One node of the expression. More...
 
struct  Region
 One region of the object (see Overlay()): the background (region 0), an operand of an Overlay, or, for an expression with no Overlay, the whole object (region 1). More...
 
struct  RegionGroup
 A group of regions: an Overlay, whose regions are a contiguous range (a nested Overlay a range inside its parent's). More...
 

Public Member Functions

 ExprIndex ()=delete
 No empty index.
 
 ExprIndex (const Expr< T > &a_expr)
 Number the nodes, leaves and labels of an expression.
 
uint32_t getNumNodes () const noexcept
 The number of nodes.
 
const Node & getNode (uint32_t a_node) const
 A node.
 
uint32_t getNumLeaves () const noexcept
 The number of leaves: Tape::getNumPrimitives() of a tape compiled from the expression.
 
uint32_t getLeafNode (uint32_t a_leaf) const
 The node of a leaf.
 
std::vector< uint32_t > pathOf (uint32_t a_leaf) const
 The nodes from the root down to a leaf: the levels a surface belongs to, from the whole object to the shape.
 
uint32_t getNumSurfaces () const noexcept
 The number of surfaces: Tape::getNumSurfaces() of a tape compiled from the expression.
 
uint32_t getFirstSurface (uint32_t a_leaf) const
 A leaf's first surface: the leaf covers [getFirstSurface(leaf), getFirstSurface(leaf + 1)), as Tape::getFirstSurface() numbers them.
 
uint32_t getLeafOfSurface (uint32_t a_surface) const
 The leaf a surface belongs to: SurfaceRef::m_leaf of a tape's closestSurface() that reported it.
 
SurfaceLabelId getSurfaceLabel (uint32_t a_leaf) const
 A leaf's label: that of the nearest labeled node on its path, the leaf's own included, except that a label above a chain of maps relabels the object below them (see SurfaceLabel()).
 
uint32_t getNumPartsOfLeaf (uint32_t a_leaf) const
 How many parts a leaf's shape has (see hasParts): one for a shape without parts, a mesh's faces, a box's six; 0 for a collection (a cloud, a BVH union, a tape), whose surfaces are its members, each with its own parts.
 
SurfaceLabelId getPartSurfaceLabel (uint32_t a_leaf, uint32_t a_part) const
 The label of a part of a leaf (see hasParts): its face group's label when SurfaceLabel(shape, FaceGroups) put it in one, and otherwise the leaf's (getSurfaceLabel()).
 
const std::vector< SurfaceLabelId > & getPartSurfaceLabels (uint32_t a_leaf) const
 The labels of a leaf's parts, one per part, as getPartSurfaceLabel() gives them; empty for a leaf whose parts SurfaceLabel(shape, FaceGroups) did not name.
 
uint32_t getNumSurfaceLabels () const noexcept
 The number of distinct labels.
 
const std::string & getSurfaceLabelName (SurfaceLabelId a_label) const
 A label's name.
 
SurfaceLabelId findSurfaceLabel (std::string_view a_name) const
 The label of a name.
 
uint32_t getNumRegions () const noexcept
 The number of regions: the background (region 0), and one per operand of the Overlays, flattened into one priority order depth first (later regions on top); an expression with no Overlay has one, the whole object.
 
const Region & getRegion (uint32_t a_region) const
 A region.
 
uint32_t getRegionOfLeaf (uint32_t a_leaf) const
 The region a leaf belongs to: the region whose operand holds it.
 
MaterialLabelId getMaterialOf (uint32_t a_region) const
 A region's material (see Region::m_material).
 
std::vector< uint32_t > getRegionsOfRegionGroup (uint32_t a_group) const
 The regions of a group, for a subdomain (Subdomains::addSubdomain()).
 
std::vector< uint32_t > getRegionsOfMaterial (MaterialLabelId a_material) const
 The regions of a material, for a subdomain (Subdomains::addSubdomain()).
 
const std::vector< std::pair< uint32_t, uint32_t > > & getSidesOfLeaf (uint32_t a_leaf) const
 The pairs of regions a leaf's surface may separate, conservatively: every pair it does is listed, and some listed may not occur (the boxes overlap, the shapes need not meet). A region's own surface separates it from the background and from earlier regions whose boxes meet its own (a later region covers it, and the interface is that region's surface); a mask's separates a region it cuts from the background or a region outside the masked Overlay. Each pair smaller region first, sorted. For an expression with no Overlay: (0, 1).
 
std::vector< std::pair< uint32_t, uint32_t > > getInterfaces () const
 The pairs of regions any surface may separate (see getSidesOfLeaf()): the interfaces a solver can meet.
 
uint32_t getNumRegionGroups () const noexcept
 The number of groups: one per Overlay, numbered depth first.
 
const RegionGroup & getRegionGroup (uint32_t a_group) const
 A group.
 
uint32_t getNumMaterialLabels () const noexcept
 The number of distinct material labels.
 
const std::string & getMaterialLabelName (MaterialLabelId a_label) const
 A material label's name.
 
MaterialLabelId findMaterialLabel (std::string_view a_name) const
 The material label of a name.
 
uint32_t findRegion (std::string_view a_name) const
 The region with a name (RegionName()).
 
template<class TapeType >
std::vector< std::string > checkLabels (const Expr< T > &a_expr, const TapeType &a_tape) const
 Warnings about names that cannot appear on the object: a surface label none of whose leaves (or parts named through face groups) can reach the object's boundary, or that every leaf below it overrides with a label of its own; a region with no volume (covered by later regions of its Overlay, or outside a mask); a material all of whose regions have none.
 

Static Public Attributes

static constexpr uint32_t None = 0xFFFFFFFFU
 No node, leaf or label.
 

Detailed Description

template<class T>
class EBGeometry::ExprIndex< T >

The nodes of an expression, numbered, with the leaves below each and their labels: on the host, the way from what a Tape reports (a leaf, see LeafRef::m_leaf and HitT::m_primitive) back to the expression.

The nodes are numbered from 0 at the root, depth first, the operands in order, each occurrence of a shared subexpression counted; the leaves (the shapes) are numbered the same way, as a Tape compiled from the expression numbers them. So the leaves below a node are a contiguous range, [m_firstLeaf, m_firstLeaf + m_numLeaves), and so are its surfaces, [m_firstSurface, m_firstSurface + m_numSurfaces): one per leaf, or all of a container leaf's (a sphere cloud's spheres, a BVH union's members). A group of surfaces can be handed to a device as two numbers. The nodes The labels are numbered in the order their names first appear, depth first, a leaf's face groups (SurfaceLabel(shape, FaceGroups)) after the leaf's own label. The nodes are those the builder functions made: Difference(a, b) is an Intersection of a and a Complement of b, and nested maps (Translate, Rotate, Scale, ...) are one Transform node.

Template Parameters
TFloating-point precision.

Constructor & Destructor Documentation

◆ ExprIndex()

template<class T >
EBGeometry::ExprIndex< T >::ExprIndex ( const Expr< T > &  a_expr)
explicit

Number the nodes, leaves and labels of an expression.

Parameters
[in]a_exprExpression.

Member Function Documentation

◆ checkLabels()

template<class T >
template<class TapeType >
std::vector< std::string > EBGeometry::ExprIndex< T >::checkLabels ( const Expr< T > &  a_expr,
const TapeType &  a_tape 
) const

Warnings about names that cannot appear on the object: a surface label none of whose leaves (or parts named through face groups) can reach the object's boundary, or that every leaf below it overrides with a label of its own; a region with no volume (covered by later regions of its Overlay, or outside a mask); a material all of whose regions have none.

A diagnostic only: it changes nothing, and the expression is evaluated as written; a correct geometry is the user's to make. It is conservative: it reports only what it has proved, so a lost name can go unreported (surfaces that coincide exactly, as a core filling a cavity, are never reported), but a reported one is lost. The shapes are evaluated through the tape compiled from the expression (Tape::leafValue()), on the host, a few times per leaf; a leaf the tape does not hold (inside a collection) is never evaluated.

A leaf is proved hidden when, on its way to the root, its box lies strictly inside another operand of a union, strictly inside later operands of an Overlay (its region has no volume; an earlier operand only lies under it, which leaves an interface), or strictly outside another operand of an intersection (a mask included), and only maps, Elongate, FiniteRepetition, complements, unions, Overlays and intersections lie on that way. An operation that acts on values (Offset, Annular, Blur, Mollify, the smooth operations) on the way leaves it unproved. Inside and outside are proved with bounds of the other operand's value over a ball around the box (a shape's value at the center, plus or minus the radius, for a shape whose value is a distance or a bound), the box split into up to 64 pieces when it is not proved whole. A region is proved empty the same way, from its operand. The index does not hold the expression, so it is given again; it must be the one the index was built from (aborts with a message, in every build, when its nodes do not match).

Template Parameters
TapeTypeThe Tape compiled from the same expression, its pool readable on the host.
Parameters
[in]a_exprThe expression the index was built from.
[in]a_tapeThe tape compiled from it.
Returns
The warnings, empty when there are none.

◆ findMaterialLabel()

template<class T >
MaterialLabelId EBGeometry::ExprIndex< T >::findMaterialLabel ( std::string_view  a_name) const

The material label of a name.

Parameters
[in]a_nameName.
Returns
The label, or none if no region has that material.

◆ findRegion()

template<class T >
uint32_t EBGeometry::ExprIndex< T >::findRegion ( std::string_view  a_name) const

The region with a name (RegionName()).

Parameters
[in]a_nameThe name.
Returns
Its number, or None if no region has it.

◆ findSurfaceLabel()

template<class T >
SurfaceLabelId EBGeometry::ExprIndex< T >::findSurfaceLabel ( std::string_view  a_name) const

The label of a name.

Parameters
[in]a_nameName.
Returns
The label, or none if no node has that name.

◆ getFirstSurface()

template<class T >
uint32_t EBGeometry::ExprIndex< T >::getFirstSurface ( uint32_t  a_leaf) const

A leaf's first surface: the leaf covers [getFirstSurface(leaf), getFirstSurface(leaf + 1)), as Tape::getFirstSurface() numbers them.

Parameters
[in]a_leafLeaf number, at most getNumLeaves() (which gives getNumSurfaces()).
Returns
The surface.

◆ getInterfaces()

template<class T >
std::vector< std::pair< uint32_t, uint32_t > > EBGeometry::ExprIndex< T >::getInterfaces ( ) const

The pairs of regions any surface may separate (see getSidesOfLeaf()): the interfaces a solver can meet.

Returns
The pairs, smaller region first, sorted, without repeats.

◆ getLeafNode()

template<class T >
uint32_t EBGeometry::ExprIndex< T >::getLeafNode ( uint32_t  a_leaf) const

The node of a leaf.

Parameters
[in]a_leafLeaf number (below getNumLeaves()).
Returns
The node number.

◆ getLeafOfSurface()

template<class T >
uint32_t EBGeometry::ExprIndex< T >::getLeafOfSurface ( uint32_t  a_surface) const

The leaf a surface belongs to: SurfaceRef::m_leaf of a tape's closestSurface() that reported it.

Parameters
[in]a_surfaceSurface (below getNumSurfaces()).
Returns
The leaf number.

◆ getMaterialLabelName()

template<class T >
const std::string & EBGeometry::ExprIndex< T >::getMaterialLabelName ( MaterialLabelId  a_label) const

A material label's name.

Parameters
[in]a_labelLabel (below getNumMaterialLabels()).
Returns
The name.

◆ getMaterialOf()

template<class T >
MaterialLabelId EBGeometry::ExprIndex< T >::getMaterialOf ( uint32_t  a_region) const

A region's material (see Region::m_material).

Parameters
[in]a_regionRegion number (below getNumRegions()).
Returns
The material, or none.

◆ getNode()

template<class T >
const Node & EBGeometry::ExprIndex< T >::getNode ( uint32_t  a_node) const

A node.

Parameters
[in]a_nodeNode number (below getNumNodes()).
Returns
The node.

◆ getNumLeaves()

template<class T >
uint32_t EBGeometry::ExprIndex< T >::getNumLeaves ( ) const
noexcept

The number of leaves: Tape::getNumPrimitives() of a tape compiled from the expression.

Returns
The count.

◆ getNumMaterialLabels()

template<class T >
uint32_t EBGeometry::ExprIndex< T >::getNumMaterialLabels ( ) const
noexcept

The number of distinct material labels.

Returns
The count.

◆ getNumNodes()

template<class T >
uint32_t EBGeometry::ExprIndex< T >::getNumNodes ( ) const
noexcept

The number of nodes.

Returns
The count.

◆ getNumPartsOfLeaf()

template<class T >
uint32_t EBGeometry::ExprIndex< T >::getNumPartsOfLeaf ( uint32_t  a_leaf) const

How many parts a leaf's shape has (see hasParts): one for a shape without parts, a mesh's faces, a box's six; 0 for a collection (a cloud, a BVH union, a tape), whose surfaces are its members, each with its own parts.

Parameters
[in]a_leafLeaf number (below getNumLeaves()).
Returns
The count, or 0.

◆ getNumRegionGroups()

template<class T >
uint32_t EBGeometry::ExprIndex< T >::getNumRegionGroups ( ) const
noexcept

The number of groups: one per Overlay, numbered depth first.

Returns
The count.

◆ getNumRegions()

template<class T >
uint32_t EBGeometry::ExprIndex< T >::getNumRegions ( ) const
noexcept

The number of regions: the background (region 0), and one per operand of the Overlays, flattened into one priority order depth first (later regions on top); an expression with no Overlay has one, the whole object.

Returns
The count.

◆ getNumSurfaceLabels()

template<class T >
uint32_t EBGeometry::ExprIndex< T >::getNumSurfaceLabels ( ) const
noexcept

The number of distinct labels.

Returns
The count.

◆ getNumSurfaces()

template<class T >
uint32_t EBGeometry::ExprIndex< T >::getNumSurfaces ( ) const
noexcept

The number of surfaces: Tape::getNumSurfaces() of a tape compiled from the expression.

Returns
The count.

◆ getPartSurfaceLabel()

template<class T >
SurfaceLabelId EBGeometry::ExprIndex< T >::getPartSurfaceLabel ( uint32_t  a_leaf,
uint32_t  a_part 
) const

The label of a part of a leaf (see hasParts): its face group's label when SurfaceLabel(shape, FaceGroups) put it in one, and otherwise the leaf's (getSurfaceLabel()).

Parameters
[in]a_leafLeaf number (below getNumLeaves()).
[in]a_partPart of the leaf's shape (SurfaceRef::m_part).
Returns
The label, or none.

◆ getPartSurfaceLabels()

template<class T >
const std::vector< SurfaceLabelId > & EBGeometry::ExprIndex< T >::getPartSurfaceLabels ( uint32_t  a_leaf) const

The labels of a leaf's parts, one per part, as getPartSurfaceLabel() gives them; empty for a leaf whose parts SurfaceLabel(shape, FaceGroups) did not name.

Parameters
[in]a_leafLeaf number (below getNumLeaves()).
Returns
The labels.

◆ getRegion()

template<class T >
const Region & EBGeometry::ExprIndex< T >::getRegion ( uint32_t  a_region) const

A region.

Parameters
[in]a_regionRegion number (below getNumRegions()).
Returns
The region.

◆ getRegionGroup()

template<class T >
const RegionGroup & EBGeometry::ExprIndex< T >::getRegionGroup ( uint32_t  a_group) const

A group.

Parameters
[in]a_groupGroup number (below getNumRegionGroups()).
Returns
The group.

◆ getRegionOfLeaf()

template<class T >
uint32_t EBGeometry::ExprIndex< T >::getRegionOfLeaf ( uint32_t  a_leaf) const

The region a leaf belongs to: the region whose operand holds it.

Parameters
[in]a_leafLeaf number (below getNumLeaves()).
Returns
The region, or None for a leaf of a mask (an operand that clips or drills the regions).

◆ getRegionsOfMaterial()

template<class T >
std::vector< uint32_t > EBGeometry::ExprIndex< T >::getRegionsOfMaterial ( MaterialLabelId  a_material) const

The regions of a material, for a subdomain (Subdomains::addSubdomain()).

Parameters
[in]a_materialMaterial label.
Returns
Its regions, in order; empty for a material no region has.

◆ getRegionsOfRegionGroup()

template<class T >
std::vector< uint32_t > EBGeometry::ExprIndex< T >::getRegionsOfRegionGroup ( uint32_t  a_group) const

The regions of a group, for a subdomain (Subdomains::addSubdomain()).

Parameters
[in]a_groupGroup number (below getNumRegionGroups()).
Returns
Its regions, a contiguous range.

◆ getSidesOfLeaf()

template<class T >
const std::vector< std::pair< uint32_t, uint32_t > > & EBGeometry::ExprIndex< T >::getSidesOfLeaf ( uint32_t  a_leaf) const

The pairs of regions a leaf's surface may separate, conservatively: every pair it does is listed, and some listed may not occur (the boxes overlap, the shapes need not meet). A region's own surface separates it from the background and from earlier regions whose boxes meet its own (a later region covers it, and the interface is that region's surface); a mask's separates a region it cuts from the background or a region outside the masked Overlay. Each pair smaller region first, sorted. For an expression with no Overlay: (0, 1).

Parameters
[in]a_leafLeaf number (below getNumLeaves()).
Returns
The pairs.

◆ getSurfaceLabel()

template<class T >
SurfaceLabelId EBGeometry::ExprIndex< T >::getSurfaceLabel ( uint32_t  a_leaf) const

A leaf's label: that of the nearest labeled node on its path, the leaf's own included, except that a label above a chain of maps relabels the object below them (see SurfaceLabel()).

Parameters
[in]a_leafLeaf number (below getNumLeaves()).
Returns
The label, or none if no node on the path has one.

◆ getSurfaceLabelName()

template<class T >
const std::string & EBGeometry::ExprIndex< T >::getSurfaceLabelName ( SurfaceLabelId  a_label) const

A label's name.

Parameters
[in]a_labelLabel (below getNumSurfaceLabels()).
Returns
The name.

◆ pathOf()

template<class T >
std::vector< uint32_t > EBGeometry::ExprIndex< T >::pathOf ( uint32_t  a_leaf) const

The nodes from the root down to a leaf: the levels a surface belongs to, from the whole object to the shape.

Parameters
[in]a_leafLeaf number (below getNumLeaves()).
Returns
The node numbers, the root first and the leaf's node last.

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