libMesh
Private Attributes | List of all members
libMesh::ElemSideBuilder Class Reference

Helper for building element sides that minimizes the construction of new elements. More...

#include <elem_side_builder.h>

Public Member Functions

Elemoperator() (Elem &elem, const unsigned int s)
 
const Elemoperator() (const Elem &elem, const unsigned int s)
 

Private Attributes

std::vector< std::unique_ptr< Elem > > _cached_elems
 Element cache for building sides; indexed by ElemType. More...
 

Detailed Description

Helper for building element sides that minimizes the construction of new elements.

The building of element side pointers has the option to pass an existing constructed element to avoid extraneous allocation. If the element that is passed is of the correct type, the build is done in place, that is, the nodes and subdomain are done in place.

This tool contains a cache with an entry per element type. When a side is requested, the cached element of the desired type is utilized. On first request of a side of a specific type, the desired element is constructed. On all subsequent calls for a side of the same type, the cached element is used and the necessary members (nodes and subdomain) are changed in place.

NOTE: This tool is meant for on-the-fly use. Because the cache is changed on each call, the references obtained from previous calls should be considered invalid.

Definition at line 50 of file elem_side_builder.h.

Member Function Documentation

◆ operator()() [1/2]

Elem & libMesh::ElemSideBuilder::operator() ( Elem elem,
const unsigned int  s 
)
Returns
an element side for side s of element elem.

Definition at line 26 of file elem_side_builder.C.

References _cached_elems, libMesh::Elem::build_side_ptr(), libMesh::Elem::n_sides(), and libMesh::Elem::side_type().

27 {
28  libmesh_assert_less(s, elem.n_sides());
29  const std::size_t type_index = static_cast<std::size_t>(elem.side_type(s));
30  if (type_index >= _cached_elems.size())
31  _cached_elems.resize(type_index + 1);
32  std::unique_ptr<Elem> & side_elem = _cached_elems[type_index];
33  elem.build_side_ptr(side_elem, s);
34  return *side_elem;
35 }
std::vector< std::unique_ptr< Elem > > _cached_elems
Element cache for building sides; indexed by ElemType.

◆ operator()() [2/2]

const Elem & libMesh::ElemSideBuilder::operator() ( const Elem elem,
const unsigned int  s 
)

Definition at line 38 of file elem_side_builder.C.

39 {
40  return (*this)(const_cast<Elem &>(elem), s);
41 }

Member Data Documentation

◆ _cached_elems

std::vector<std::unique_ptr<Elem> > libMesh::ElemSideBuilder::_cached_elems
private

Element cache for building sides; indexed by ElemType.

Definition at line 63 of file elem_side_builder.h.

Referenced by operator()().


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