https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
SurfaceElementSet Class Reference

A group of surface elements wrapped for point-containment / distance queries. More...

#include <SurfaceElementSet.h>

Public Member Functions

const std::vector< std::unique_ptr< SurfaceElement > > & elements () const
 Owned surface-element wrappers, one per input element (input order preserved).
 
const std::vector< Point > & centroids () const
 Per-element centroids (vertex averages), aligned index-for-index with elements().
 
const libMesh::BoundingBoxboundingBox () const
 Global AABB of the group (plain union of element loose bounding boxes).
 
std::size_t size () const
 Number of surface elements in the group.
 

Static Public Member Functions

static SurfaceElementSet fromMesh (const MeshBase &mesh)
 Build a set from every active element of a surface mesh.
 
static SurfaceElementSet fromElements (const std::vector< const Elem * > &elems)
 Build a set from a caller-provided subset of surface elements.
 

Private Member Functions

 SurfaceElementSet ()=default
 Built only through the factories.
 
void addElement (const Elem *elem)
 Validate, wrap, and append a single element, growing centroids and the AABB.
 

Private Attributes

std::vector< std::unique_ptr< SurfaceElement > > _elements
 
std::vector< Point > _centroids
 
libMesh::BoundingBox _bounding_box
 

Detailed Description

A group of surface elements wrapped for point-containment / distance queries.

This is the single place where a libMesh surface mesh (or a subset of its elements) is turned into SurfaceElement wrappers. It owns the wrappers, the matching per-element centroids, and the global axis-aligned bounding box (AABB) of the group. The AABB is method-independent: it is the plain union of the elements' loose bounding boxes with no algorithm-specific inflation.

Construct via the factories:

The referenced elements must outlive this object.

Definition at line 35 of file SurfaceElementSet.h.

Constructor & Destructor Documentation

◆ SurfaceElementSet()

SurfaceElementSet::SurfaceElementSet ( )
privatedefault

Built only through the factories.

Member Function Documentation

◆ addElement()

void SurfaceElementSet::addElement ( const Elem *  elem)
private

Validate, wrap, and append a single element, growing centroids and the AABB.

All elements must share one supported type (EDGE2 or TRI3).

Definition at line 47 of file SurfaceElementSet.C.

48{
49 mooseAssert(elem, "Element must not be null");
50
51 // Enforce a homogeneous element family: every element must share the type of
52 // the first one added, so a group never mixes 2D EDGE2 and 3D TRI3 faces.
53 if (!_elements.empty() && _elements.front()->elem().type() != elem->type())
54 mooseError("SurfaceElementSet: mixed element types are not supported (found ",
56 " after ",
57 libMesh::Utility::enum_to_string(_elements.front()->elem().type()),
58 ").");
59
60 std::unique_ptr<SurfaceElement> surface_elem;
61 if (elem->type() == EDGE2)
62 surface_elem = std::make_unique<SurfaceEdge2>(elem);
63 else if (elem->type() == TRI3)
64 surface_elem = std::make_unique<SurfaceTri3>(elem);
65 else
66 mooseError("SurfaceElementSet: unsupported element type ",
68 ". Only EDGE2 (2D) and TRI3 (3D) surface elements are supported.");
69
70 // Grow the AABB; initialize it from the first element so an empty union does
71 // not leave the box in libMesh's inverted default state.
72 const auto bbox = elem->loose_bounding_box();
73 if (_elements.empty())
74 _bounding_box = bbox;
75 else
77
78 _centroids.emplace_back(elem->vertex_average());
79 _elements.emplace_back(std::move(surface_elem));
80}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
std::vector< std::unique_ptr< SurfaceElement > > _elements
libMesh::BoundingBox _bounding_box
std::vector< Point > _centroids
void union_with(const Point &p)
std::string enum_to_string(const T e)

Referenced by fromElements(), and fromMesh().

◆ boundingBox()

const libMesh::BoundingBox & SurfaceElementSet::boundingBox ( ) const
inline

Global AABB of the group (plain union of element loose bounding boxes).

Definition at line 51 of file SurfaceElementSet.h.

51{ return _bounding_box; }

◆ centroids()

const std::vector< Point > & SurfaceElementSet::centroids ( ) const
inline

Per-element centroids (vertex averages), aligned index-for-index with elements().

Definition at line 48 of file SurfaceElementSet.h.

48{ return _centroids; }

◆ elements()

const std::vector< std::unique_ptr< SurfaceElement > > & SurfaceElementSet::elements ( ) const
inline

Owned surface-element wrappers, one per input element (input order preserved).

Definition at line 45 of file SurfaceElementSet.h.

45{ return _elements; }

◆ fromElements()

SurfaceElementSet SurfaceElementSet::fromElements ( const std::vector< const Elem * > &  elems)
static

Build a set from a caller-provided subset of surface elements.

Definition at line 33 of file SurfaceElementSet.C.

34{
36
37 set._elements.reserve(elems.size());
38 set._centroids.reserve(elems.size());
39
40 for (const auto * elem : elems)
41 set.addElement(elem);
42
43 return set;
44}
A group of surface elements wrapped for point-containment / distance queries.
void addElement(const Elem *elem)
Validate, wrap, and append a single element, growing centroids and the AABB.

◆ fromMesh()

SurfaceElementSet SurfaceElementSet::fromMesh ( const MeshBase &  mesh)
static

Build a set from every active element of a surface mesh.

Definition at line 18 of file SurfaceElementSet.C.

19{
21
22 const auto n = mesh.n_active_elem();
23 set._elements.reserve(n);
24 set._centroids.reserve(n);
25
26 for (const auto * elem : mesh.active_element_ptr_range())
27 set.addElement(elem);
28
29 return set;
30}
MeshBase & mesh

Referenced by BoundaryMeshBuilder::buildDefaultSet().

◆ size()

std::size_t SurfaceElementSet::size ( ) const
inline

Number of surface elements in the group.

Definition at line 54 of file SurfaceElementSet.h.

54{ return _elements.size(); }

Member Data Documentation

◆ _bounding_box

libMesh::BoundingBox SurfaceElementSet::_bounding_box
private

Definition at line 66 of file SurfaceElementSet.h.

Referenced by addElement(), and boundingBox().

◆ _centroids

std::vector<Point> SurfaceElementSet::_centroids
private

Definition at line 65 of file SurfaceElementSet.h.

Referenced by addElement(), centroids(), fromElements(), and fromMesh().

◆ _elements

std::vector<std::unique_ptr<SurfaceElement> > SurfaceElementSet::_elements
private

Definition at line 64 of file SurfaceElementSet.h.

Referenced by addElement(), elements(), fromElements(), fromMesh(), and size().


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