LCOV - code coverage report
Current view: top level - include/geom - elem.h (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4620 (a489da) with base 3f0912 Lines: 352 436 80.7 %
Date: 2026-11-19 19:20:12 Functions: 145 184 78.8 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // The libMesh Finite Element Library.
       2             : // Copyright (C) 2002-2026 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
       3             : 
       4             : // This library is free software; you can redistribute it and/or
       5             : // modify it under the terms of the GNU Lesser General Public
       6             : // License as published by the Free Software Foundation; either
       7             : // version 2.1 of the License, or (at your option) any later version.
       8             : 
       9             : // This library is distributed in the hope that it will be useful,
      10             : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      11             : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      12             : // Lesser General Public License for more details.
      13             : 
      14             : // You should have received a copy of the GNU Lesser General Public
      15             : // License along with this library; if not, write to the Free Software
      16             : // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
      17             : 
      18             : 
      19             : 
      20             : #ifndef LIBMESH_ELEM_H
      21             : #define LIBMESH_ELEM_H
      22             : 
      23             : // Local includes
      24             : #include "libmesh/libmesh_common.h"
      25             : #include "libmesh/bounding_box.h"
      26             : #include "libmesh/dof_object.h"
      27             : #include "libmesh/id_types.h"
      28             : #include "libmesh/reference_counted_object.h"
      29             : #include "libmesh/node.h"
      30             : #include "libmesh/enum_elem_type.h" // INVALID_ELEM
      31             : #include "libmesh/multi_predicates.h"
      32             : #include "libmesh/pointer_to_pointer_iter.h"
      33             : #include "libmesh/int_range.h"
      34             : #include "libmesh/simple_range.h"
      35             : #include "libmesh/variant_filter_iterator.h"
      36             : #include "libmesh/hashword.h" // Used in compute_key() functions
      37             : 
      38             : // C++ includes
      39             : #include <algorithm>
      40             : #include <cstddef>
      41             : #include <iostream>
      42             : #include <limits.h> // CHAR_BIT
      43             : #include <set>
      44             : #include <vector>
      45             : #include <memory>
      46             : #include <array>
      47             : 
      48             : namespace libMesh
      49             : {
      50             : 
      51             : // Forward declarations
      52             : class BoundaryInfo;
      53             : class Elem;
      54             : class MeshBase;
      55             : class MeshRefinement;
      56             : #ifdef LIBMESH_ENABLE_PERIODIC
      57             : class PeriodicBoundaries;
      58             : class PointLocatorBase;
      59             : #endif
      60             : template <class SideType, class ParentType>
      61             : class Side;
      62             : enum ElemQuality : int;
      63             : enum IOPackage : int;
      64             : enum Order : int;
      65             : 
      66             : 
      67             : /**
      68             :  * This is the base class from which all geometric element types are
      69             :  * derived.  The \p Elem class provides standard information such as
      70             :  * the number of nodes, edges, faces, vertices, children, and
      71             :  * neighbors it has, as well as access to (or the ability to
      72             :  * construct) these entities.
      73             :  *
      74             :  * An \p Elem has pointers to its \p Node objects.  Some of these
      75             :  * nodes live at the vertices of the element, while others may live on
      76             :  * edges (and faces in 3D), or interior to the element.  The number of
      77             :  * nodes in a given element, \p n_nodes(), is encoded into the name of
      78             :  * the class.  For example, a \p Tri3 has three nodes which correspond
      79             :  * to the vertices, while a \p Tri6 has six nodes, three of which are
      80             :  * located at vertices, and three which are located at the midpoint of
      81             :  * each edge.  Nodes on edges, faces, and element interiors are called
      82             :  * second-order nodes.
      83             :  *
      84             :  * A 1D Elem is an \p Edge, a 2D Elem is a \p Face, and a 3D Elem is a
      85             :  * \p Cell.  An \p Elem is composed of a number of sides, which can
      86             :  * be accessed as dim-1 dimensional \p Elem types.  For example, a \p
      87             :  * Hex8 is a 3D hexahedral element. A \p Hex8 has 6 sides, which are
      88             :  * \p Faces of type Quad4.
      89             :  *
      90             :  * \author Benjamin S. Kirk
      91             :  * \date 2002-2007
      92             :  * \brief The base class for all geometric element types.
      93             :  */
      94             : class Elem : public ReferenceCountedObject<Elem>,
      95             :              public DofObject
      96             : {
      97             : protected:
      98             : 
      99             :   /**
     100             :    * Constructor.  Creates an element with \p n_nodes nodes,
     101             :    * \p n_sides sides, \p n_children possible children, and
     102             :    * parent \p p.  The constructor allocates the memory necessary
     103             :    * to support this data.
     104             :    */
     105             :   Elem (const unsigned int n_nodes,
     106             :         const unsigned int n_sides,
     107             :         Elem * parent,
     108             :         Elem ** elemlinkdata,
     109             :         Node ** nodelinkdata);
     110             : 
     111             : public:
     112             : 
     113             :   /**
     114             :    * Elems are responsible for allocating and deleting space for
     115             :    * storing pointers to their children during refinement, so they
     116             :    * cannot currently be (default) copy-constructed or copy-
     117             :    * assigned. We therefore explicitly delete these operations. In
     118             :    * addition, the DofObject base class currently has private copy
     119             :    * construction and assignment operators, so that prevents us from
     120             :    * copying Elems as well.
     121             :    */
     122             :   Elem (Elem &&) = delete;
     123             :   Elem (const Elem &) = delete;
     124             :   Elem & operator= (const Elem &) = delete;
     125             :   Elem & operator= (Elem &&) = delete;
     126             : 
     127             :   /**
     128             :    * Destructor.
     129             :    */
     130   730810058 :   virtual ~Elem() = default;
     131             : 
     132             :   /**
     133             :    * \returns The \p Point associated with local \p Node \p i.
     134             :    */
     135             :   const Point & point (const unsigned int i) const;
     136             : 
     137             :   /**
     138             :    * \returns The \p Point associated with local \p Node \p i
     139             :    * as a writable reference.
     140             :    */
     141             :   Point & point (const unsigned int i);
     142             : 
     143             :   /**
     144             :    * \returns The \p Point associated with local \p Node \p i,
     145             :    * in master element rather than physical coordinates.
     146             :    */
     147             :   virtual Point master_point (const unsigned int i) const = 0;
     148             : 
     149             :   /**
     150             :    * \returns The global id number of local \p Node \p i.
     151             :    */
     152             :   dof_id_type node_id (const unsigned int i) const;
     153             : 
     154             :   /**
     155             :    * \returns The local id number of global \p Node id \p i,
     156             :    * or \p invalid_uint if Node id \p i is not local.
     157             :    */
     158             :   unsigned int local_node (const dof_id_type i) const;
     159             : 
     160             :   /**
     161             :    * \returns The local index for the \p Node pointer \p node_ptr,
     162             :    * or \p invalid_uint if \p node_ptr is not a local node.
     163             :    */
     164             :   unsigned int get_node_index (const Node * node_ptr) const;
     165             : 
     166             :   /**
     167             :    * \returns A pointer to an array of local node pointers.
     168             :    */
     169             :   const Node * const * get_nodes () const;
     170             : 
     171             :   /**
     172             :    * \returns A const pointer to local \p Node \p i.
     173             :    */
     174             :   const Node * node_ptr (const unsigned int i) const;
     175             : 
     176             :   /**
     177             :    * \returns A non-const pointer to local \p Node \p i.
     178             :    */
     179             :   Node * node_ptr (const unsigned int i);
     180             : 
     181             :   /**
     182             :    * \returns A const reference to local \p Node \p i.
     183             :    */
     184             :   const Node & node_ref (const unsigned int i) const;
     185             : 
     186             :   /**
     187             :    * \returns A writable reference to local \p Node \p i.
     188             :    */
     189             :   Node & node_ref (const unsigned int i);
     190             : 
     191             : #ifdef LIBMESH_ENABLE_DEPRECATED
     192             :   /**
     193             :    * \returns The pointer to the \p Node with local number \p i as a
     194             :    * writable reference.
     195             :    *
     196             :    * \deprecated This setter cannot update the multiple node pointers
     197             :    * used in a general polyhedron; use the \p set_node overload that
     198             :    * takes an argument.
     199             :    */
     200             :   virtual Node * & set_node (const unsigned int i);
     201             : #endif // LIBMESH_ENABLE_DEPRECATED
     202             : 
     203             :   /**
     204             :    * Sets local \p Node \p i to refer to \p node.
     205             :    */
     206             :   virtual void set_node (const unsigned int i,
     207             :                          Node * node);
     208             : 
     209             :   /**
     210             :    * Nested classes for use iterating over all nodes of an element.
     211             :    */
     212             :   class NodeRefIter;
     213             :   class ConstNodeRefIter;
     214             : 
     215             :   /**
     216             :    * Returns a range with all nodes of an element, usable in
     217             :    * range-based for loops.  The exact type of the return value here
     218             :    * may be subject to change in future libMesh releases, but the
     219             :    * iterators will always dereference to produce a reference to a
     220             :    * Node.
     221             :    */
     222             :   SimpleRange<NodeRefIter> node_ref_range();
     223             : 
     224             :   SimpleRange<ConstNodeRefIter> node_ref_range() const;
     225             : 
     226             :   /**
     227             :    * \returns The subdomain that this element belongs to.
     228             :    */
     229             :   subdomain_id_type subdomain_id () const;
     230             : 
     231             :   /**
     232             :    * \returns The subdomain that this element belongs to as a
     233             :    * writable reference.
     234             :    */
     235             :   subdomain_id_type & subdomain_id ();
     236             : 
     237             :   /**
     238             :    * A static integral constant representing an invalid subdomain id.
     239             :    * See also DofObject::{invalid_id, invalid_unique_id, invalid_processor_id}.
     240             :    *
     241             :    * \note We don't use the static_cast(-1) trick here since
     242             :    * \p subdomain_id_type is sometimes a *signed* integer for
     243             :    * compatibility reasons (see libmesh/id_types.h).
     244             :    */
     245             :   static constexpr subdomain_id_type invalid_subdomain_id
     246             :     = std::numeric_limits<subdomain_id_type>::max();
     247             : 
     248             :   /**
     249             :    * \returns true iff this element type can vary in topology (e.g.
     250             :    * have different numbers of sides and/or nodes) at runtime.  For
     251             :    * such general polygons or polyhedra, APIs which assume a fixed
     252             :    * topology are not safe to use.
     253             :    */
     254    66488609 :   virtual bool runtime_topology() const { return false; }
     255             : 
     256             :   /**
     257             :    * \returns A pointer to the "reference element" associated
     258             :    * with this element.  The reference element is the image of this
     259             :    * element in reference parametric space. Importantly, it is *not*
     260             :    * an actual element in the mesh, but rather a Singleton-type
     261             :    * object, so for example all \p Quad4 elements share the same
     262             :    * \p reference_elem().
     263             :    *
     264             :    * If the element is of a type that can admit multiple topologies,
     265             :    * such as a Polygon subtype, then there is no reference element;
     266             :    * for such types this method should not be used.
     267             :    */
     268             :   const Elem * reference_elem () const;
     269             : 
     270             :   /**
     271             :    * \returns An id associated with the \p s side of this element.
     272             :    * The id is not necessarily unique, but should be close.
     273             :    */
     274             :   virtual dof_id_type key (const unsigned int s) const = 0;
     275             : 
     276             :   /**
     277             :    * \returns An id associated with the \p s side of this element, as
     278             :    * defined solely by element vertices.  The id is not necessarily
     279             :    * unique, but should be close.  This is particularly useful in the
     280             :    * \p MeshBase::find_neighbors() routine.
     281             :    */
     282             :   virtual dof_id_type low_order_key (const unsigned int s) const = 0;
     283             : 
     284             :   /**
     285             :    * \returns An id associated with the global node ids of this
     286             :    * element.  The id is not necessarily unique, but should be
     287             :    * close. Uses the same hash as the key(s) function, so for example
     288             :    * if "tri3" is side 0 of "tet4", then tri3->key()==tet4->key(0).
     289             :    */
     290             :   virtual dof_id_type key () const;
     291             : 
     292             :   /**
     293             :    * \returns \p true if two elements are equivalent, \p false
     294             :    * otherwise.  This is true if the elements are connected to
     295             :    * identical global nodes, regardless of how those nodes might be
     296             :    * numbered local to the elements.
     297             :    */
     298             :   bool operator == (const Elem & rhs) const;
     299             : 
     300             :   /**
     301             :    * \returns \p false if two elements are equivalent, \p true
     302             :    * otherwise.
     303             :    */
     304             :   bool operator != (const Elem & rhs) const;
     305             : 
     306             :   /**
     307             :    * \returns \p true if two elements have equal topologies, false
     308             :    * otherwise.
     309             :    * This is true if the elements connect to nodes of the same id in
     310             :    * the same order, and neighbors of the same id on each side, the
     311             :    * same id on any parent and/or interior_parent link, etc.
     312             :    */
     313             :   bool topologically_equal (const Elem & rhs) const;
     314             : 
     315             :   /**
     316             :    * \returns A const pointer to the \f$ i^{th} \f$ neighbor of this
     317             :    * element, or \p nullptr if \p MeshBase::find_neighbors() has not been
     318             :    * called.
     319             :    *
     320             :    * \note If \p MeshBase::find_neighbors() has been called and this
     321             :    * function still returns \p nullptr, then the side is on a boundary of
     322             :    * the domain.
     323             :    */
     324             :   const Elem * neighbor_ptr (unsigned int i) const;
     325             : 
     326             :   /**
     327             :    * \returns A non-const pointer to the \f$ i^{th} \f$ neighbor of this element.
     328             :    */
     329             :   Elem * neighbor_ptr (unsigned int i);
     330             : 
     331             :   /**
     332             :    * Nested "classes" for use iterating over all neighbors of an element.
     333             :    */
     334             :   typedef Elem * const *       NeighborPtrIter;
     335             :   typedef const Elem * const * ConstNeighborPtrIter;
     336             : 
     337             :   /**
     338             :    * Returns a range with all neighbors of an element, usable in
     339             :    * range-based for loops.  The exact type of the return value here
     340             :    * may be subject to change in future libMesh releases, but the
     341             :    * iterators will always dereference to produce a pointer to a
     342             :    * neighbor element (or a null pointer, for sides which have no
     343             :    * neighbors).
     344             :    */
     345             :   SimpleRange<NeighborPtrIter> neighbor_ptr_range();
     346             : 
     347             :   SimpleRange<ConstNeighborPtrIter> neighbor_ptr_range() const;
     348             : 
     349             : #ifdef LIBMESH_ENABLE_PERIODIC
     350             :   /**
     351             :    * \returns A pointer to the \f$ i^{th} \f$ neighbor of this element
     352             :    * for interior elements.  If an element is on a periodic
     353             :    * boundary, it will return a corresponding element on the opposite
     354             :    * side.
     355             :    */
     356             :   const Elem * topological_neighbor (const unsigned int i,
     357             :                                      const MeshBase & mesh,
     358             :                                      const PointLocatorBase & point_locator,
     359             :                                      const PeriodicBoundaries * pb) const;
     360             : 
     361             :   /**
     362             :    * \returns A writable pointer to the \f$ i^{th} \f$ neighbor of
     363             :    * this element for interior elements.  If an element is on a
     364             :    * periodic boundary, it will return a corresponding element on the
     365             :    * opposite side.
     366             :    */
     367             :   Elem * topological_neighbor (const unsigned int i,
     368             :                                MeshBase & mesh,
     369             :                                const PointLocatorBase & point_locator,
     370             :                                const PeriodicBoundaries * pb);
     371             : 
     372             :   /**
     373             :    * \returns \p true if the element \p elem in question is a neighbor or
     374             :    * topological neighbor of this element, \p false otherwise.
     375             :    */
     376             :   bool has_topological_neighbor (const Elem * elem,
     377             :                                  const MeshBase & mesh,
     378             :                                  const PointLocatorBase & point_locator,
     379             :                                  const PeriodicBoundaries * pb) const;
     380             : #endif
     381             : 
     382             :   /**
     383             :    * Assigns \p n as the \f$ i^{th} \f$ neighbor.
     384             :    */
     385             :   void set_neighbor (const unsigned int i, Elem * n);
     386             : 
     387             :   /**
     388             :    * \returns \p true if the element \p elem in question is a neighbor
     389             :    * of this element, \p false otherwise.
     390             :    */
     391             :   bool has_neighbor (const Elem * elem) const;
     392             : 
     393             :   /**
     394             :    * \returns If \p elem is a neighbor of a child of this element, a
     395             :    * pointer to that child, otherwise \p nullptr.
     396             :    */
     397             :   Elem * child_neighbor (Elem * elem);
     398             : 
     399             :   /**
     400             :    * \returns If \p elem is a neighbor of a child of this element, a
     401             :    * pointer to that child, otherwise \p nullptr.
     402             :    */
     403             :   const Elem * child_neighbor (const Elem * elem) const;
     404             : 
     405             :   /**
     406             :    * \returns \p true if this element has a side coincident
     407             :    * with a boundary (indicated by a \p nullptr neighbor), \p false
     408             :    * otherwise.
     409             :    */
     410             :   bool on_boundary () const;
     411             : 
     412             :   /**
     413             :    * \returns \p true if this element is "semilocal" to the calling
     414             :    * processor, which must specify its rank.
     415             :    *
     416             :    * This method is discouraged, as it uses the *old* definition of
     417             :    * semilocal (elements which are not local but which are point
     418             :    * neighbors of something local) rather than any of the new
     419             :    * definitions discussed in ghosting_functor.h
     420             :    */
     421             :   bool is_semilocal (const processor_id_type my_pid) const;
     422             : 
     423             :   /**
     424             :    * This function tells you which neighbor \p e is.
     425             :    * I.e. if s = a->which_neighbor_am_i(e); then
     426             :    * a->neighbor(s) will be an ancestor of e.
     427             :    */
     428             :   unsigned int which_neighbor_am_i(const Elem * e) const;
     429             : 
     430             :   /**
     431             :    * This function tells you which side the boundary element \p e is.
     432             :    * I.e. if e = a->build_side_ptr(s) or e = a->side_ptr(s); then
     433             :    * a->which_side_am_i(e) will be s.
     434             :    *
     435             :    * \note An \e exact floating point comparison of the nodal
     436             :    * positions of \p e is made with the nodal positions of \p this in
     437             :    * order to perform this test. The idea is that the test will return
     438             :    * a valid side id if \p e either directly shares Node pointers with
     439             :    * \p this, or was created by exactly copying some of the nodes of
     440             :    * \p this (e.g. through BoundaryMesh::sync()). In these
     441             :    * circumstances, non-fuzzy floating point equality is expected.
     442             :    *
     443             :    * \returns The side of \p this the element which \p e is, otherwise
     444             :    * \p invalid_uint.
     445             :    */
     446             :   unsigned int which_side_am_i(const Elem * e) const;
     447             : 
     448             :   /**
     449             :    * \returns The local node id for node \p side_node on side \p side of
     450             :    * this Elem. Simply relies on the \p side_nodes_map for each of the
     451             :    * derived types. For example,
     452             :    * Tri3::local_side_node(0, 0) -> 0
     453             :    * Tri3::local_side_node(0, 1) -> 1
     454             :    * Tri3::local_side_node(1, 0) -> 1
     455             :    * Tri3::local_side_node(1, 1) -> 2
     456             :    * etc...
     457             :    */
     458             :   virtual unsigned int local_side_node(unsigned int side,
     459             :                                        unsigned int side_node) const = 0;
     460             : 
     461             :   /**
     462             :    * Similar to Elem::local_side_node(), but instead of a side id, takes
     463             :    * an edge id and a node id on that edge and returns a local node number
     464             :    * for the Elem. The implementation relies on the "edge_nodes_map" tables
     465             :    * for 3D elements. For 2D elements, calls local_side_node(). Throws an
     466             :    * error if called on 1D elements.
     467             :    */
     468             :   virtual unsigned int local_edge_node(unsigned int edge,
     469             :                                        unsigned int edge_node) const = 0;
     470             : 
     471             :   /**
     472             :    * \returns The local node id for node \p side_node on side \p side of
     473             :    * an element of type \p t, without needing an instantiated Elem.
     474             :    * The Polygon and Polyhedron subclasses have no such map, and the
     475             :    * infinite elements' maps are not read here, so those must be queried
     476             :    * through an actual Elem.
     477             :    */
     478             :   static unsigned int local_side_node(ElemType t,
     479             :                                       unsigned int side,
     480             :                                       unsigned int side_node);
     481             : 
     482             :   /**
     483             :    * \returns The local node id for node \p edge_node on edge \p edge of
     484             :    * an element of type \p t, without needing an instantiated Elem.  For
     485             :    * 2D types this is local_side_node(); 1D types have no edges.  The
     486             :    * same types are unsupported here as in local_side_node().
     487             :    */
     488             :   static unsigned int local_edge_node(ElemType t,
     489             :                                       unsigned int edge,
     490             :                                       unsigned int edge_node);
     491             : 
     492             :   /**
     493             :    * \returns \p true if a vertex of \p e is contained
     494             :    * in this element.  If \p mesh_connection is true, looks
     495             :    * specifically for containment possibilities of an element \p e
     496             :    * that is connected to \p this via membership in the same manifold
     497             :    * of the same mesh.
     498             :    */
     499             :   bool contains_vertex_of(const Elem * e, bool mesh_connection=false) const;
     500             : 
     501             :   /**
     502             :    * \returns \p true if an edge of \p e is contained in
     503             :    * this element.  (Internally, this is done by checking whether at
     504             :    * least two vertices of \p e are contained in this element).
     505             :    */
     506             :   bool contains_edge_of(const Elem * e) const;
     507             : 
     508             :   /**
     509             :    * This function finds all active elements (including this one)
     510             :    * which are in the same manifold as this element and which touch
     511             :    * the current active element at the specified point, which should
     512             :    * be a point in the current element.
     513             :    *
     514             :    * Elements which are not "in the same manifold" (e.g. the
     515             :    * interior_parent of a boundary element) will not be found with
     516             :    * this method.
     517             :    *
     518             :    * Elements which overlap the specified point but which are only
     519             :    * connected to the current element via elements which do not
     520             :    * overlap that point (e.g. in a folded or tangled mesh) are not
     521             :    * considered to "touch" the current element and will not be found
     522             :    * with this method.
     523             :    */
     524             :   void find_point_neighbors(const Point & p,
     525             :                             std::set<const Elem *> & neighbor_set) const;
     526             : 
     527             :   /**
     528             :    * This function finds all active elements (including this one) in
     529             :    * the same manifold as this element which touch this active element
     530             :    * at any point.
     531             :    */
     532             :   void find_point_neighbors(std::set<const Elem *> & neighbor_set) const;
     533             : 
     534             :   /**
     535             :    * This function finds all active elements (including this one) in
     536             :    * the same manifold as start_elem (which must be active and must
     537             :    * touch this element) which touch this element at any point.
     538             :    */
     539             :   void find_point_neighbors(std::set<const Elem *> & neighbor_set,
     540             :                             const Elem * start_elem) const;
     541             : 
     542             :   /**
     543             :    * Non-const version of function above. Fills a set of non-const Elem pointers.
     544             :    */
     545             :   void find_point_neighbors(std::set<Elem *> & neighbor_set,
     546             :                             Elem * start_elem);
     547             : 
     548             :   /**
     549             :    * This function finds all active elements in the same manifold as
     550             :    * this element which touch the current active element along the
     551             :    * whole edge defined by the two points \p p1 and \p p2.
     552             :    */
     553             :   void find_edge_neighbors(const Point & p1,
     554             :                            const Point & p2,
     555             :                            std::set<const Elem *> & neighbor_set) const;
     556             : 
     557             :   /**
     558             :    * This function finds all active elements in the same manifold as
     559             :    * this element which touch the current active element along any
     560             :    * edge (more precisely, at at least two points).
     561             :    *
     562             :    * In this case, elements are included even if they do not touch a
     563             :    * *whole* edge of this element.
     564             :    */
     565             :   void find_edge_neighbors(std::set<const Elem *> & neighbor_set) const;
     566             : 
     567             :   /**
     568             :    * This function finds all active elements (*not* including this
     569             :    * one) in the parent manifold of this element whose intersection
     570             :    * with this element has non-zero measure.
     571             :    */
     572             :   void find_interior_neighbors(std::set<const Elem *> & neighbor_set) const;
     573             : 
     574             :   /**
     575             :    * Non-const version of function above that fills up a vector of
     576             :    * non-const Elem pointers instead.
     577             :    */
     578             :   void find_interior_neighbors(std::set<Elem *> & neighbor_set);
     579             : 
     580             :   /**
     581             :    * Resets this element's neighbors' appropriate neighbor pointers
     582             :    * and its parent's and children's appropriate pointers
     583             :    * to point to null instead of to this.
     584             :    *
     585             :    * To be used before an element is deleted from a mesh.
     586             :    */
     587             :   void remove_links_to_me ();
     588             : 
     589             :   /**
     590             :    * Resets this element's neighbors' appropriate neighbor pointers
     591             :    * and its parent's and children's appropriate pointers
     592             :    * to point to the global remote_elem instead of this.
     593             :    * Used by the library before an element becomes remote on the
     594             :    * local processor.
     595             :    */
     596             :   void make_links_to_me_remote ();
     597             : 
     598             :   /**
     599             :    * Resets the \p neighbor_side pointers of our nth neighbor (and
     600             :    * its descendants, if appropriate) to point to this Elem instead of
     601             :    * to the global remote_elem.  Used by the library when a formerly
     602             :    * remote element is being added to the local processor.
     603             :    */
     604             :   void make_links_to_me_local (unsigned int n, unsigned int neighbor_side);
     605             : 
     606             :   /**
     607             :    * \returns \p true if this element is remote, false otherwise.
     608             :    *
     609             :    * A remote element (see \p RemoteElem) is a syntactic convenience --
     610             :    * it is a placeholder for an element which exists on some other
     611             :    * processor.  Local elements are required to have valid neighbors,
     612             :    * and these ghost elements may have remote neighbors for data
     613             :    * structure consistency.  The use of remote elements helps ensure
     614             :    * that any element we may access has a \p nullptr neighbor only if it
     615             :    * lies on the physical boundary of the domain.
     616             :    */
     617       30014 :   virtual bool is_remote () const
     618       30014 :   { return false; }
     619             : 
     620             :   /**
     621             :    * \returns The connectivity for this element in a specific
     622             :    * format, which is specified by the IOPackage tag.
     623             :    */
     624             :   virtual void connectivity(const unsigned int sc,
     625             :                             const IOPackage iop,
     626             :                             std::vector<dof_id_type> & conn) const = 0;
     627             : 
     628             :   /**
     629             :    * Writes the element connectivity for various IO packages
     630             :    * to the passed ostream "out".  Not virtual, since it is
     631             :    * implemented in the base class.
     632             :    */
     633             :   void write_connectivity (std::ostream & out,
     634             :                            const IOPackage iop) const;
     635             : 
     636             :   /**
     637             :    * \returns The type of element that has been derived from this
     638             :    * base class.
     639             :    */
     640             :   virtual ElemType type () const = 0;
     641             : 
     642             :   /**
     643             :    * This array maps the integer representation of the \p ElemType enum
     644             :    * to the geometric dimension of the element.
     645             :    *
     646             :    * This is currently usable even for complicated subclasses with
     647             :    * runtime-varying topology.
     648             :    */
     649             :   static const unsigned int type_to_dim_map[INVALID_ELEM];
     650             : 
     651             :   /**
     652             :    * \returns The dimensionality of the object.
     653             :    */
     654             :   virtual unsigned short dim () const = 0;
     655             : 
     656             :   /**
     657             :    * This array maps the integer representation of the \p ElemType enum
     658             :    * to the number of nodes in the element.
     659             :    *
     660             :    * This is only usable for simple types for which the node number
     661             :    * is fixed; for more general types like Polygon subclasses an actual
     662             :    * instantiated Elem must be queried.
     663             :    */
     664             :   static constexpr unsigned int type_to_n_nodes_map[INVALID_ELEM] =
     665             :     {
     666             :       2,  // EDGE2
     667             :       3,  // EDGE3
     668             :       4,  // EDGE4
     669             : 
     670             :       3,  // TRI3
     671             :       6,  // TRI6
     672             : 
     673             :       4,  // QUAD4
     674             :       8,  // QUAD8
     675             :       9,  // QUAD9
     676             : 
     677             :       4,  // TET4
     678             :       10, // TET10
     679             : 
     680             :       8,  // HEX8
     681             :       20, // HEX20
     682             :       27, // HEX27
     683             : 
     684             :       6,  // PRISM6
     685             :       15, // PRISM15
     686             :       18, // PRISM18
     687             : 
     688             :       5,  // PYRAMID5
     689             :       13, // PYRAMID13
     690             :       14, // PYRAMID14
     691             : 
     692             :       2,  // INFEDGE2
     693             : 
     694             :       4,  // INFQUAD4
     695             :       6,  // INFQUAD6
     696             : 
     697             :       8,  // INFHEX8
     698             :       16, // INFHEX16
     699             :       18, // INFHEX18
     700             : 
     701             :       6,  // INFPRISM6
     702             :       12, // INFPRISM12
     703             : 
     704             :       1,  // NODEELEM
     705             : 
     706             :       0,  // REMOTEELEM
     707             : 
     708             :       3,  // TRI3SUBDIVISION
     709             :       3,  // TRISHELL3
     710             :       4,  // QUADSHELL4
     711             :       8,  // QUADSHELL8
     712             : 
     713             :       7,  // TRI7
     714             :       14, // TET14
     715             :       20, // PRISM20
     716             :       21, // PRISM21
     717             :       18, // PYRAMID18
     718             : 
     719             :       9,  // QUADSHELL9
     720             : 
     721             :       invalid_uint,  // C0POLYGON
     722             :       invalid_uint,  // C0POLYHEDRON
     723             : 
     724             :       16, // QUAD16
     725             : 
     726             :     };
     727             : 
     728             :   /**
     729             :    * \returns The number of nodes this element contains.
     730             :    */
     731             :   virtual unsigned int n_nodes () const = 0;
     732             : 
     733             :   /**
     734             :    * The maximum number of nodes *any* element can contain.
     735             :    * This is useful for replacing heap vectors with stack arrays.
     736             :    */
     737             :   static const unsigned int max_n_nodes = 27;
     738             : 
     739             :   /**
     740             :    * \returns An integer range from 0 up to (but not including)
     741             :    * the number of nodes this element contains.
     742             :    */
     743             :   IntRange<unsigned short> node_index_range () const;
     744             : 
     745             :   /**
     746             :    * \returns The number of nodes the given child of this element
     747             :    * contains.  Except in odd cases like pyramid refinement this will
     748             :    * be the same as the number of nodes in the parent element.
     749             :    */
     750     2256573 :   virtual unsigned int n_nodes_in_child (unsigned int /*c*/) const
     751     2256573 :   { return this->n_nodes(); }
     752             : 
     753             :   /**
     754             :    * This array maps the integer representation of the \p ElemType enum
     755             :    * to the number of sides on the element.
     756             :    *
     757             :    * This is only usable for simple types for which the node number
     758             :    * is fixed; for more general types like Polygon subclasses an actual
     759             :    * instantiated Elem must be queried.
     760             :    */
     761             :   static const unsigned int type_to_n_sides_map[INVALID_ELEM];
     762             : 
     763             :   /**
     764             :    * \returns The number of sides the element that has been derived
     765             :    * from this class has. In 2D the number of sides is the number
     766             :    * of edges, in 3D the number of sides is the number of faces.
     767             :    */
     768             :   virtual unsigned int n_sides () const = 0;
     769             : 
     770             :   /**
     771             :    * \returns The type of element for side \p s.
     772             :    */
     773             :   virtual ElemType side_type (const unsigned int s) const = 0;
     774             : 
     775             :   /**
     776             :    * \returns The type of side \p s of an element of type \p t, without
     777             :    * needing an instantiated Elem.  The Polygon and Polyhedron subclasses
     778             :    * have one side type but no fixed number of sides, so \p s goes
     779             :    * unchecked for them; query an actual Elem when you have one.
     780             :    */
     781             :   static ElemType side_type (const ElemType t,
     782             :                              const unsigned int s);
     783             : 
     784             :   /**
     785             :    * \returns The type of every edge of an element of type \p t, or
     786             :    * \p INVALID_ELEM for the 1D types, which have no edges.  Unlike its
     787             :    * sides, a finite element's edges all have the same type, so no edge
     788             :    * index is needed; the infinite elements, whose finite and infinite
     789             :    * edges differ, are not answered here.
     790             :    */
     791             :   static ElemType edge_type (const ElemType t);
     792             : 
     793             :   /**
     794             :    * \returns the normal (outwards-facing) of the side of the element at the vertex-average of the side
     795             :    * @param s the side of interest
     796             :    */
     797             :   virtual Point side_vertex_average_normal(const unsigned int s) const;
     798             : 
     799             :   /**
     800             :    * \returns An integer range from 0 up to (but not including)
     801             :    * the number of sides this element has.
     802             :    */
     803             :   IntRange<unsigned short> side_index_range () const;
     804             : 
     805             :   /**
     806             :    * \returns The number of neighbors the element that has been derived
     807             :    * from this class has.
     808             :    *
     809             :    * Only face (or edge in 2D) neighbors are stored, so this method
     810             :    * returns n_sides().  At one point we intended to allow derived
     811             :    * classes to override this, but too much current libMesh code
     812             :    * assumes n_neighbors==n_sides.
     813             :    */
     814   140528609 :   unsigned int n_neighbors () const
     815   148234615 :   { return this->n_sides(); }
     816             : 
     817             :   /**
     818             :    * \returns The number of vertices the element that has been derived
     819             :    * from this class has.
     820             :    */
     821             :   virtual unsigned int n_vertices () const = 0;
     822             : 
     823             :   /**
     824             :    * \returns The number of edges the element that has been derived
     825             :    * from this class has.
     826             :    */
     827             :   virtual unsigned int n_edges () const = 0;
     828             : 
     829             :   /**
     830             :    * \returns An integer range from 0 up to (but not including)
     831             :    * the number of edges this element has.
     832             :    */
     833             :   IntRange<unsigned short> edge_index_range () const;
     834             : 
     835             :   /**
     836             :    * This array maps the integer representation of the \p ElemType enum
     837             :    * to the number of edges on the element.
     838             :    *
     839             :    * This is only usable for simple types for which the node number
     840             :    * is fixed; for more general types like Polygon subclasses an actual
     841             :    * instantiated Elem must be queried.
     842             :    */
     843             :   static const unsigned int type_to_n_edges_map[INVALID_ELEM];
     844             : 
     845             :   /**
     846             :    * \returns The number of faces the element that has been derived
     847             :    * from this class has.
     848             :    */
     849             :   virtual unsigned int n_faces () const = 0;
     850             : 
     851             :   /**
     852             :    * \returns An integer range from 0 up to (but not including)
     853             :    * the number of faces this element has.
     854             :    */
     855             :   IntRange<unsigned short> face_index_range () const;
     856             : 
     857             :   /**
     858             :    * \returns The number of children the element that has been derived
     859             :    * from this class may have.
     860             :    */
     861             :   virtual unsigned int n_children () const = 0;
     862             : 
     863             :   /**
     864             :    * \returns \p true if the specified (local) node number is a vertex node.
     865             :    */
     866             :   virtual bool is_vertex(const unsigned int i) const = 0;
     867             : 
     868             :   /**
     869             :    * \returns \p true if the specified child has a vertex at the
     870             :    * specified (child-local) node number.
     871             :    * Except in odd cases like pyramid refinement the child will have
     872             :    * the same local structure as the parent element.
     873             :    */
     874       14711 :   virtual bool is_vertex_on_child (unsigned int /*c*/,
     875             :                                    unsigned int n) const
     876       14711 :   { return this->is_vertex(n); }
     877             : 
     878             :   /**
     879             :    * \returns \p true if this element has a vertex at the specified
     880             :    * (child-local) node number \p n of the specified child \p c.
     881             :    */
     882             :   virtual bool is_vertex_on_parent(unsigned int c,
     883             :                                    unsigned int n) const;
     884             : 
     885             :   /**
     886             :    * \returns \p true if the specified (local) node number is an edge node.
     887             :    * For 1D elements, is_edge() is equivalent to is_internal().
     888             :    */
     889             :   virtual bool is_edge(const unsigned int i) const = 0;
     890             : 
     891             :   /**
     892             :    * \returns \p true if the specified (local) node number is a face node.
     893             :    * For 2D elements, is_face() is equivalent to is_internal().
     894             :    * For 1D elements, is_face() == false.
     895             :    */
     896             :   virtual bool is_face(const unsigned int i) const = 0;
     897             : 
     898             :   /**
     899             :    * \returns \p true if the specified (local) node number is an internal node.
     900             :    */
     901             :   bool is_internal(const unsigned int i) const;
     902             : 
     903             :   /**
     904             :    * \returns \p true if the specified (local) node number is on the
     905             :    * specified side.
     906             :    */
     907             :   virtual bool is_node_on_side(const unsigned int n,
     908             :                                const unsigned int s) const = 0;
     909             : 
     910             :   /**
     911             :    * \returns the (local) node numbers on the specified side
     912             :    */
     913             :   virtual std::vector<unsigned int> nodes_on_side(const unsigned int /*s*/) const = 0;
     914             : 
     915             :   /**
     916             :    * \returns the (local) node numbers on the specified edge
     917             :    */
     918             :   virtual std::vector<unsigned int> nodes_on_edge(const unsigned int /*e*/) const = 0;
     919             : 
     920             :   /**
     921             :    * \returns the (local) side numbers that touch the specified edge
     922             :    */
     923             :   virtual std::vector<unsigned int> sides_on_edge(const unsigned int /*e*/) const = 0;
     924             : 
     925             :   /**
     926             :    * \returns the (local) edge numbers that touch the specified node
     927             :    */
     928             :   virtual std::vector<unsigned int> edges_adjacent_to_node(const unsigned int /*n*/) const = 0;
     929             : 
     930             :   /**
     931             :    * \returns \p true if the specified (local) node number is on the
     932             :    * specified edge.
     933             :    */
     934             :   virtual bool is_node_on_edge(const unsigned int n,
     935             :                                const unsigned int e) const = 0;
     936             : 
     937             :   /**
     938             :    * \returns \p true if the specified edge is on the specified side.
     939             :    */
     940             :   virtual bool is_edge_on_side(const unsigned int e,
     941             :                                const unsigned int s) const = 0;
     942             : 
     943             :   /**
     944             :    * \returns The side number opposite to \p s (for a tensor product
     945             :    * element), or throws an error otherwise.
     946             :    */
     947             :   virtual unsigned int opposite_side(const unsigned int s) const;
     948             : 
     949             :   /**
     950             :    * \returns The local node number for the node opposite to node n
     951             :    * on side \p opposite_side(s) (for a tensor product element), or
     952             :    * throws an error otherwise.
     953             :    */
     954             :   virtual unsigned int opposite_node(const unsigned int n,
     955             :                                      const unsigned int s) const;
     956             : 
     957             :   /**
     958             :    * \returns The number of sub-elements this element may be broken
     959             :    * down into for visualization purposes.  For example, 1 for a
     960             :    * linear triangle, 4 for a quadratic (6-noded) triangle, etc...
     961             :    */
     962             :   virtual unsigned int n_sub_elem () const = 0;
     963             : 
     964             :   /**
     965             :    * \returns A temporary element coincident with side \p i.
     966             :    *
     967             :    * This method returns the _minimum_ element necessary to uniquely
     968             :    * identify the side.  For example, the side of a hexahedron is
     969             :    * always returned as a 4-noded quadrilateral, regardless of what
     970             :    * type of hex you are dealing with.  Important data like subdomain
     971             :    * id, p level, or mapping type may be omitted from the temporary
     972             :    * element.  If you want a first-class full-ordered face (i.e. a
     973             :    * 9-noded quad face for a 27-noded hexahedron), use the
     974             :    * build_side_ptr method.
     975             :    *
     976             :    * \note The const version of this function is non-virtual; it
     977             :    * simply calls the virtual non-const version and const_casts the
     978             :    * return type.
     979             :    */
     980             :   virtual std::unique_ptr<Elem> side_ptr (unsigned int i) = 0;
     981             :   std::unique_ptr<const Elem> side_ptr (unsigned int i) const;
     982             : 
     983             :   /**
     984             :    * Resets the loose element \p side, which may currently point to a
     985             :    * different side than \p i or even a different element than \p
     986             :    * this, to point to side \p i on \p this.  If \p side is currently
     987             :    * an element of the wrong type, it will be freed and a new element
     988             :    * allocated; otherwise no memory allocation will occur.
     989             :    *
     990             :    * This will cause \p side to be a minimum-ordered element, even if
     991             :    * it is handed a higher-ordered element that must be replaced.
     992             :    *
     993             :    * The const version of this function is non-virtual; it simply
     994             :    * calls the virtual non-const version and const_casts the return
     995             :    * type.
     996             :    */
     997             :   virtual void side_ptr (std::unique_ptr<Elem> & side, const unsigned int i) = 0;
     998             :   void side_ptr (std::unique_ptr<const Elem> & side, const unsigned int i) const;
     999             : 
    1000             :   /**
    1001             :    * \returns An temporary element coincident with side \p i wrapped
    1002             :    * in a smart pointer.
    1003             :    *
    1004             :    * The element returned is full-ordered and full-featured, in
    1005             :    * contrast to the side method.  For example, calling
    1006             :    * build_side_ptr(0) on a 20-noded hex in subdomain 5 will build a
    1007             :    * 8-noded quadrilateral coincident with face 0, assign it subdomain
    1008             :    * id 5, and pass back the pointer.
    1009             :    *
    1010             :    * The side element's id() is undefined; it is a temporary element
    1011             :    * not added to any mesh.
    1012             :    *
    1013             :    * A \p std::unique_ptr<Elem> is returned to prevent a memory leak.
    1014             :    * This way the user need not remember to delete the object.
    1015             :    *
    1016             :    * The const version of this function is non-virtual; it simply
    1017             :    * calls the virtual non-const version and const_casts the return
    1018             :    * type.
    1019             :    */
    1020             :   virtual std::unique_ptr<Elem> build_side_ptr (const unsigned int i) = 0;
    1021             :   std::unique_ptr<const Elem> build_side_ptr (const unsigned int i) const;
    1022             : 
    1023             : #ifdef LIBMESH_ENABLE_DEPRECATED
    1024             :   /*
    1025             :    * Older versions of libMesh supported a "proxy" option here.
    1026             :    */
    1027           0 :   virtual std::unique_ptr<Elem> build_side_ptr (const unsigned int i, bool proxy)
    1028           0 :   { if (proxy) libmesh_error(); libmesh_deprecated(); return this->build_side_ptr(i); }
    1029             : 
    1030             :   std::unique_ptr<const Elem> build_side_ptr (const unsigned int i, bool proxy) const
    1031             :   { if (proxy) libmesh_error(); libmesh_deprecated(); return this->build_side_ptr(i); }
    1032             : #endif
    1033             : 
    1034             :   /**
    1035             :    * Resets the loose element \p side, which may currently point to a
    1036             :    * different side than \p i or even a different element than \p
    1037             :    * this, to point to side \p i on \p this.  If \p side is currently
    1038             :    * an element of the wrong type, it will be freed and a new element
    1039             :    * allocated; otherwise no memory allocation will occur.
    1040             :    *
    1041             :    * This will cause \p side to be a full-ordered element, even if it
    1042             :    * is handed a lower-ordered element that must be replaced.
    1043             :    *
    1044             :    * The const version of this function is non-virtual; it simply
    1045             :    * calls the virtual non-const version and const_casts the return
    1046             :    * type.
    1047             :    */
    1048             :   virtual void build_side_ptr (std::unique_ptr<Elem> & side, const unsigned int i) = 0;
    1049             :   void build_side_ptr (std::unique_ptr<const Elem> & side, const unsigned int i) const;
    1050             : 
    1051             :   /**
    1052             :    * \returns An element coincident with edge \p i wrapped in a smart pointer.
    1053             :    *
    1054             :    * The element returned is full-ordered.  For example, calling
    1055             :    * build_edge_ptr(0) on a 20-noded hex will build a 3-noded edge
    1056             :    * coincident with edge 0 and pass back the pointer.  A \p
    1057             :    * std::unique_ptr<Elem> is returned to prevent a memory leak.  This way
    1058             :    * the user need not remember to delete the object.
    1059             :    *
    1060             :    * The const version of this function is non-virtual; it simply
    1061             :    * calls the virtual non-const version and const_casts the return
    1062             :    * type.
    1063             :    */
    1064             :   virtual std::unique_ptr<Elem> build_edge_ptr (const unsigned int i) = 0;
    1065             :   std::unique_ptr<const Elem> build_edge_ptr (const unsigned int i) const;
    1066             : 
    1067             :   /**
    1068             :    * Resets the loose element \p edge, which may currently point to a
    1069             :    * different edge than \p i or even a different element than \p
    1070             :    * this, to point to edge \p i on \p this.  If \p edge is currently
    1071             :    * an element of the wrong type, it will be freed and a new element
    1072             :    * allocated; otherwise no memory allocation will occur.
    1073             :    *
    1074             :    * This will cause \p edge to be a full-ordered element, even if it
    1075             :    * is handed a lower-ordered element that must be replaced.
    1076             :    *
    1077             :    * The const version of this function is non-virtual; it simply
    1078             :    * calls the virtual non-const version and const_casts the return
    1079             :    * type.
    1080             :    */
    1081             :   virtual void build_edge_ptr (std::unique_ptr<Elem> & edge, const unsigned int i) = 0;
    1082             :   void build_edge_ptr (std::unique_ptr<const Elem> & edge, const unsigned int i) const;
    1083             : 
    1084             :   /**
    1085             :    * This array maps the integer representation of the \p ElemType enum
    1086             :    * to the default approximation order of elements of that type.
    1087             :    *
    1088             :    * This is currently usable even for complicated subclasses with
    1089             :    * runtime-varying topology.
    1090             :    */
    1091             :   static const Order type_to_default_order_map[INVALID_ELEM];
    1092             : 
    1093             :   /**
    1094             :    * \returns The default approximation order for this element.  This
    1095             :    * is the order that will be used to compute the map to the
    1096             :    * reference element.
    1097             :    */
    1098             :   virtual Order default_order () const = 0;
    1099             : 
    1100             :   /**
    1101             :    * \returns The maximum supported approximation order for nodal
    1102             :    * (Lagrange or Rational Bezier-Bernstein) variables on this element
    1103             :    * type.  This is usually the same as the default order.
    1104             :    */
    1105     3391123 :   virtual Order supported_nodal_order() const { return default_order(); }
    1106             : 
    1107             :   /**
    1108             :    * \returns The default approximation order for side elements of
    1109             :    * this element type.  This may be lower for elements with 'bubble
    1110             :    * functions' in the Lagrange basis.
    1111             :    */
    1112      520812 :   virtual Order default_side_order () const { return default_order(); }
    1113             : 
    1114             :   /**
    1115             :    * \returns The "true" geometric centroid of the element, c=(cx, cy,
    1116             :    * cz), where:
    1117             :    *
    1118             :    * [cx]            [\int x dV]
    1119             :    * [cy] := (1/V) * [\int y dV]
    1120             :    * [cz]            [\int z dV]
    1121             :    *
    1122             :    * This method is virtual since some derived elements might want to
    1123             :    * use shortcuts to compute their centroid. For most element types,
    1124             :    * this method is more expensive than calling vertex_average(), so
    1125             :    * if you only need a point which is located "somewhere" in the
    1126             :    * interior of the element, consider calling vertex_average() instead.
    1127             :    */
    1128             :   virtual Point true_centroid () const;
    1129             : 
    1130             :   /**
    1131             :    * \returns A Point at the average of the elment's vertices.
    1132             :    *
    1133             :    * \note This used to be the base class centroid() implementation, but
    1134             :    * the centroid is only equal to the vertex average in some special cases.
    1135             :    * The centroid() implementation now returns the "true" centroid of the
    1136             :    * element (up to quadrature error).
    1137             :    */
    1138             :   Point vertex_average () const;
    1139             : 
    1140             :   /**
    1141             :    * \returns The "circumcenter of mass" (area-weighted average of
    1142             :    * triangulation circumcenters) of the element.
    1143             :    *
    1144             :    * Not implemented for infinite elements, not currently implemented
    1145             :    * for 3D elements, currently ignores curvature of element edges.
    1146             :    */
    1147           0 :   virtual Point quasicircumcenter () const
    1148           0 :   { libmesh_not_implemented(); }
    1149             : 
    1150             :   /**
    1151             :    * \returns The minimum vertex separation for the element.
    1152             :    */
    1153             :   virtual Real hmin () const;
    1154             : 
    1155             :   /**
    1156             :    * \returns The maximum vertex separation for the element.
    1157             :    */
    1158             :   virtual Real hmax () const;
    1159             : 
    1160             :   /**
    1161             :    * \returns The (length/area/volume) of the geometric element.
    1162             :    *
    1163             :    * If the element is twisted or inverted such that the mapping
    1164             :    * Jacobian is singular at any point, implementations of this method
    1165             :    * may return a "net" volume or may simply return NaN.
    1166             :    */
    1167             :   virtual Real volume () const;
    1168             : 
    1169             :   /**
    1170             :    * \returns A bounding box (not necessarily the minimal bounding box)
    1171             :    * containing the geometric element.
    1172             :    *
    1173             :    * The base class implementation determines a bounding box for the
    1174             :    * element *nodes*, which should be sufficient for first order
    1175             :    * finite elements.  Higher order geometric elements will need to
    1176             :    * override with an implementation which takes curved elements into
    1177             :    * account.
    1178             :    */
    1179             :   virtual BoundingBox loose_bounding_box () const;
    1180             : 
    1181             :   /**
    1182             :    * \returns A quantitative assessment of element quality based on
    1183             :    * the quality metric \p q specified by the user. Not all ElemQuality
    1184             :    * metrics are supported for all Elem types; consult the Elem::quality()
    1185             :    * overrides for specific Elem types to determine which quality metrics
    1186             :    * are supported. The ElemQuality metrics with generic support for all
    1187             :    * Elems with dimension > 1 are:
    1188             :    * .) EDGE_LENGTH_RATIO - ratio of maximum to minimum edge (in 2D,
    1189             :    *    side) length, where the min/max is taken over all Elem edges.
    1190             :    * .) MIN,MAX_ANGLE - The minimum (respectively maximum) angle
    1191             :    *    between all pairs of adjacent Elem edges, in degrees. In 3D,
    1192             :    *    these are *not* the dihedral angles between adjacent planar
    1193             :    *    faces of the element. In 2D, we compute the angle between
    1194             :    *    adjacent sides for this metric.
    1195             :    * .) MIN,MAX_DIHEDRAL_ANGLE - In 3D, the minimum (respectively
    1196             :    *    maximum) unoriented angle between adjacent side planes, folded
    1197             :    *    into the range [0, 90] degrees. In 2D, these are equivalent to
    1198             :    *    MIN,MAX_ANGLE.
    1199             :    */
    1200             :   virtual Real quality (const ElemQuality q) const;
    1201             : 
    1202             :   /**
    1203             :    * \returns The suggested quality bounds for the Elem based on
    1204             :    * quality measure \p q.
    1205             :    *
    1206             :    * These are the values suggested by the CUBIT User's Manual.  Since
    1207             :    * this function can have no possible meaning for an abstract Elem,
    1208             :    * it is an error in the base class.
    1209             :    */
    1210           0 :   virtual std::pair<Real,Real> qual_bounds (const ElemQuality) const
    1211           0 :   { libmesh_not_implemented(); return std::make_pair(0.,0.); }
    1212             : 
    1213             :   /**
    1214             :    * \returns \p true if the physical point p is contained in this
    1215             :    * element, false otherwise.
    1216             :    *
    1217             :    * For linear elements, performs an initial tight bounding box check
    1218             :    * (as an optimization step) and (if that passes) then uses the
    1219             :    * user-defined tolerance "tol" in a call to inverse_map() to actually
    1220             :    * test if the point is in the element.  For quadratic elements, the
    1221             :    * bounding box optimization is skipped, and only the inverse_map()
    1222             :    * steps are performed.
    1223             :    *
    1224             :    * \note This routine should not be used to determine if a point
    1225             :    * is merely "nearby" an element to within some tolerance. For that,
    1226             :    * use Elem::close_to_point() instead.
    1227             :    */
    1228             :   virtual bool contains_point (const Point & p, Real tol=TOLERANCE) const;
    1229             : 
    1230             :   /**
    1231             :    * \returns \p true if the master-space point p is contained in the
    1232             :    * reference element corresponding to this element, false otherwise.
    1233             :    *
    1234             :    * Since we are doing floating point comparisons here the parameter
    1235             :    * \p eps can be specified to indicate a tolerance.  For example,
    1236             :    * \f$ x \le 1 \f$  becomes \f$ x \le 1 + \epsilon \f$.
    1237             :    */
    1238             :   virtual bool on_reference_element(const Point & p,
    1239             :                                     const Real eps = TOLERANCE) const = 0;
    1240             : 
    1241             :   /**
    1242             :    * \returns \p true if this element is "close" to the point p, where
    1243             :    * "close" is determined by the tolerance tol.
    1244             :    */
    1245             :   virtual bool close_to_point(const Point & p, Real tol) const;
    1246             : 
    1247             :   /**
    1248             :    * \returns \p true if edge \p i is positively oriented. An edge is
    1249             :    * positively oriented iff its first vertex (i.e. zeroth node) is
    1250             :    * lexicographically greater than its second vertex (i.e. first node).
    1251             :    */
    1252             :   bool positive_edge_orientation(const unsigned int i) const;
    1253             : 
    1254             :   /**
    1255             :    * \returns \p true if face \p i is positively oriented. A face is
    1256             :    * positively oriented iff the triangle defined by the lexicographically
    1257             :    * least vertex and its two adjacent vertices on the same face is
    1258             :    * positively oriented. Said triangle is positively oriented iff its
    1259             :    * vertices are an odd permutation of their lexicographic ordering.
    1260             :    */
    1261             :   bool positive_face_orientation(const unsigned int i) const;
    1262             : 
    1263             :   /**
    1264             :    * \returns An index over the symmetries of face \p i (six for a
    1265             :    * triangle, eight for a quadrilateral): twice the position of the
    1266             :    * lexicographically least vertex in the face's node map, plus 1 if
    1267             :    * the face is positively oriented.
    1268             :    *
    1269             :    * Unlike \p positive_face_orientation(), this fixes the full ordering
    1270             :    * of the face's vertices, which a basis with face degrees of freedom
    1271             :    * (e.g. HIERARCHIC of order three or above) needs in order to be
    1272             :    * conforming across the face.
    1273             :    */
    1274             :   unsigned int face_orientation(const unsigned int i) const;
    1275             : 
    1276             :   /**
    1277             :    * \returns The local indices of the vertices of face \p i, starting
    1278             :    * at its lexicographically least vertex and continuing toward the
    1279             :    * lesser of that vertex's two neighbors on the face, as encoded by
    1280             :    * \p face_orientation(). Every element sharing the face returns the
    1281             :    * same vertices in the same order.
    1282             :    */
    1283             :   std::vector<unsigned int> oriented_face_vertices(const unsigned int i) const;
    1284             : 
    1285             :   /**
    1286             :    * \returns \p true iff, for an edge \p e on side \p s, the node map for
    1287             :    * side \p s is such that the first vertex (i.e. zeroth node) of \p e is
    1288             :    * lower positioned than the second vertex (i.e. first node) of \p e.
    1289             :    */
    1290             :   bool relative_edge_face_order(const unsigned int e, const unsigned int s) const;
    1291             : 
    1292             :   /**
    1293             :    * A helper function for copying generic element data (mapping,
    1294             :    * subdomain, processor) from an element to a derived (child, side,
    1295             :    * edge) element.  Useful for forwards compatibility when new data
    1296             :    * is added.
    1297             :    */
    1298             :   void inherit_data_from(const Elem & src);
    1299             : 
    1300             : private:
    1301             :   /**
    1302             :    * Shared private implementation used by the contains_point()
    1303             :    * and close_to_point() routines.  The box_tol tolerance is
    1304             :    * used in the bounding box optimization, the map_tol tolerance is used
    1305             :    * in the calls to inverse_map() and on_reference_element().
    1306             :    */
    1307             :   bool point_test(const Point & p, Real box_tol, Real map_tol) const;
    1308             : 
    1309             : public:
    1310             :   /**
    1311             :    * \returns \p true if the element map is definitely affine (i.e. the same at
    1312             :    * every quadrature point) within numerical tolerances.
    1313             :    */
    1314           0 :   virtual bool has_affine_map () const { return false; }
    1315             : 
    1316             :   /**
    1317             :    * \returns \p true if the element map is invertible everywhere on
    1318             :    * the element, to within a user-specified tolerance. The tolerance
    1319             :    * is generally used in comparisons against zero, so it should be an
    1320             :    * absolute rather than a relative tolerance. Throws a
    1321             :    * libmesh_not_implemented() error unless specialized by derived
    1322             :    * classes.
    1323             :    */
    1324             :   virtual bool has_invertible_map(Real tol = TOLERANCE*TOLERANCE) const;
    1325             : 
    1326             :   /**
    1327             :    * \returns \p true if the Lagrange shape functions on this element
    1328             :    * are linear.
    1329             :    */
    1330           0 :   virtual bool is_linear () const { return false; }
    1331             : 
    1332             :   /**
    1333             :    * Prints relevant information about the element.
    1334             :    */
    1335             :   void print_info (std::ostream & os=libMesh::out) const;
    1336             : 
    1337             :   /**
    1338             :    * Prints relevant information about the element to a string.
    1339             :    */
    1340             :   std::string get_info () const;
    1341             : 
    1342             :   /**
    1343             :    * \returns \p true if the element is active (i.e. has no active
    1344             :    * descendants) or AMR is disabled, \p false otherwise.
    1345             :    *
    1346             :    * \note It suffices to check the first child only.
    1347             :    */
    1348             :   bool active () const;
    1349             : 
    1350             :   /**
    1351             :    * \returns \p true if the element is an ancestor (i.e. has an
    1352             :    * active child or ancestor child), \p false otherwise or when AMR
    1353             :    * is disabled.
    1354             :    */
    1355             :   bool ancestor () const;
    1356             : 
    1357             :   /**
    1358             :    * \returns \p true if the element is subactive (i.e. has no active
    1359             :    * descendants), \p false otherwise or if AMR is disabled.
    1360             :    */
    1361             :   bool subactive () const;
    1362             : 
    1363             :   /**
    1364             :    * \returns \p true if the element has any children (active or not),
    1365             :    * \p false otherwise, or if AMR is disabled.
    1366             :    */
    1367             :   bool has_children () const;
    1368             : 
    1369             :   /**
    1370             :    * \returns \p true if the element has any descendants other than
    1371             :    * its immediate children, \p false otherwise, or if AMR is disabled.
    1372             :    */
    1373             :   bool has_ancestor_children () const;
    1374             : 
    1375             :   /**
    1376             :    * \returns \p true if \p descendant is a child of \p this, or a
    1377             :    * child of a child of \p this, etc., \p false otherwise or if AMR
    1378             :    * is disabled.
    1379             :    */
    1380             :   bool is_ancestor_of(const Elem * descendant) const;
    1381             : 
    1382             :   /**
    1383             :    * \returns A const pointer to the element's parent, or \p nullptr if
    1384             :    * the element was not created via refinement.
    1385             :    */
    1386             :   const Elem * parent () const;
    1387             : 
    1388             :   /**
    1389             :    * \returns A pointer to the element's parent, or \p nullptr if
    1390             :    * the element was not created via refinement.
    1391             :    */
    1392             :   Elem * parent ();
    1393             : 
    1394             :   /**
    1395             :    * Sets the pointer to the element's parent.
    1396             :    * Dangerous! Only use this if you know what you are doing!
    1397             :    */
    1398             :   void set_parent (Elem * p);
    1399             : 
    1400             :   /**
    1401             :    * \returns A pointer to the element's top-most (i.e. level-0) parent.
    1402             :    *
    1403             :    * That is, \p this if this is a level-0 element, this element's parent
    1404             :    * if this is a level-1 element, this element's grandparent if this is
    1405             :    * a level-2 element, etc...
    1406             :    */
    1407             :   const Elem * top_parent () const;
    1408             : 
    1409             :   /**
    1410             :    * \returns The higher-dimensional Elem for which this Elem is a face.
    1411             :    *
    1412             :    * In some cases it is desirable to extract the boundary (or a subset thereof)
    1413             :    * of a D-dimensional mesh as a (D-1)-dimensional manifold.  In this case
    1414             :    * we may want to know the 'parent' element from which the manifold elements
    1415             :    * were extracted.  We can easily do that for the level-0 manifold elements
    1416             :    * by storing the D-dimensional parent.  This method provides access to that
    1417             :    * element.
    1418             :    *
    1419             :    * This method returns nullptr if this->dim() == LIBMESH_DIM; in
    1420             :    * such cases no data storage for an interior parent pointer has
    1421             :    * been allocated.
    1422             :    */
    1423             :   const Elem * interior_parent () const;
    1424             : 
    1425             :   Elem * interior_parent ();
    1426             : 
    1427             :   /**
    1428             :    * Sets the pointer to the element's interior_parent.
    1429             :    * Dangerous! Only use this if you know what you are doing!
    1430             :    */
    1431             :   void set_interior_parent (Elem * p);
    1432             : 
    1433             :   /**
    1434             :    * \returns The distance between nodes n1 and n2.
    1435             :    *
    1436             :    * Useful for computing the lengths of the sides of elements.
    1437             :    */
    1438             :   Real length (const unsigned int n1,
    1439             :                const unsigned int n2) const;
    1440             : 
    1441             :   /**
    1442             :    * \returns The number of adjacent vertices that uniquely define the
    1443             :    * location of the \f$ n^{th} \f$ second-order node, or 0 for linear
    1444             :    * elements.
    1445             :    *
    1446             :    * This method is useful when converting linear elements to quadratic
    1447             :    * elements.
    1448             :    *
    1449             :    * \note \p n has to be greater than or equal to \p this->n_vertices().
    1450             :    */
    1451             :   virtual unsigned int n_second_order_adjacent_vertices (const unsigned int n) const;
    1452             : 
    1453             :   /**
    1454             :    * \returns The element-local number of the \f$ v^{th} \f$ vertex
    1455             :    * that defines the \f$ n^{th} \f$ second-order node, or 0 for
    1456             :    * linear elements.
    1457             :    *
    1458             :    * \note The value is always less than \p this->n_vertices(), while
    1459             :    * \p n has to be greater than or equal to \p this->n_vertices().
    1460             :    */
    1461             :   virtual unsigned short int second_order_adjacent_vertex (const unsigned int n,
    1462             :                                                            const unsigned int v) const;
    1463             : 
    1464             :   /**
    1465             :    * \returns A pair (c,v), where
    1466             :    * c == child index, and
    1467             :    * v == element-local index of the \p \f$ n^{th} \f$
    1468             :    *      second-order node on the parent element.
    1469             :    * For linear elements, (0,0) is returned.
    1470             :    *
    1471             :    * \note The return values are always less than \p this->n_children()
    1472             :    * and \p this->child_ptr(c)->n_vertices().
    1473             :    *
    1474             :    * \note \p n has to be greater than or equal to \p this->n_vertices().
    1475             :    *
    1476             :    * \note On refined second-order elements, the return value will
    1477             :    * satisfy \p this->node_ptr(n) == this->child_ptr(c)->node_ptr(v).
    1478             :    */
    1479             :   virtual std::pair<unsigned short int, unsigned short int>
    1480             :   second_order_child_vertex (const unsigned int n) const;
    1481             : 
    1482             :   /**
    1483             :    * \returns The ElemType of the associated second-order element
    1484             :    * (which will be the same as the input if the input is already a
    1485             :    * second-order ElemType) or INVALID_ELEM for elements that cannot be
    1486             :    * converted into higher order equivalents.
    1487             :    *
    1488             :    * For example, when \p this is a \p TET4, then \p TET10 is returned.
    1489             :    *
    1490             :    * For some elements, there exist two second-order equivalents, e.g.
    1491             :    * for \p Quad4 there is \p Quad8 and \p Quad9.  When the optional
    1492             :    * \p full_ordered is \p true, then \p QUAD9 is returned.  When
    1493             :    * \p full_ordered is \p false, then \p QUAD8 is returned.
    1494             :    */
    1495             :   static ElemType second_order_equivalent_type (const ElemType et,
    1496             :                                                 const bool full_ordered=true);
    1497             : 
    1498             :   /**
    1499             :    * \returns The element type of the associated first-order element,
    1500             :    * or \p INVALID_ELEM for first-order or other elements that cannot be
    1501             :    * converted into lower order equivalents.
    1502             :    *
    1503             :    * For example, when \p this is a \p TET10, then \p TET4 is returned.
    1504             :    */
    1505             :   static ElemType first_order_equivalent_type (const ElemType et);
    1506             : 
    1507             :   /**
    1508             :    * \returns The ElemType of the associated "complete" order element
    1509             :    * (which will be the same as the input if the input is already a
    1510             :    * complete-order ElemType), or INVALID_ELEM for elements that cannot be
    1511             :    * converted into complete-order equivalents.
    1512             :    *
    1513             :    * The "complete" version of an element is an element which can
    1514             :    * represent the same geometry but which has nodes available to
    1515             :    * restore degrees of freedom on any vertex, edge, or face.
    1516             :    *
    1517             :    * For example, when \p this is a \p TET4, then \p TET14 is returned.
    1518             :    */
    1519             :   static ElemType complete_order_equivalent_type (const ElemType et);
    1520             : 
    1521             :   /**
    1522             :    * \returns The refinement level of the current element.
    1523             :    *
    1524             :    * If the element's parent is \p nullptr then by convention it is at
    1525             :    * level 0, otherwise it is simply at one level greater than its
    1526             :    * parent.
    1527             :    */
    1528             :   unsigned int level () const;
    1529             : 
    1530             :   /**
    1531             :    * \returns The value of the p refinement level of an active
    1532             :    * element, or the minimum value of the p refinement levels
    1533             :    * of an ancestor element's descendants.
    1534             :    */
    1535             :   unsigned int p_level () const;
    1536             : 
    1537             :   /**
    1538             :    * \returns \p true if the specified child is on the specified side.
    1539             :    */
    1540             :   virtual bool is_child_on_side(const unsigned int c,
    1541             :                                 const unsigned int s) const = 0;
    1542             : 
    1543             :   /**
    1544             :    * \returns The value of the mapping type for the element.
    1545             :    */
    1546             :   ElemMappingType mapping_type () const;
    1547             : 
    1548             :   /**
    1549             :    * Sets the value of the mapping type for the element.
    1550             :    */
    1551             :   void set_mapping_type (const ElemMappingType type);
    1552             : 
    1553             :   /**
    1554             :    * \returns The value of the mapping data for the element.
    1555             :    */
    1556             :   unsigned char mapping_data () const;
    1557             : 
    1558             :   /**
    1559             :    * Sets the value of the mapping data for the element.
    1560             :    */
    1561             :   void set_mapping_data (const unsigned char data);
    1562             : 
    1563             : 
    1564             : #ifdef LIBMESH_ENABLE_AMR
    1565             : 
    1566             :   /**
    1567             :    * Enumeration of possible element refinement states.
    1568             :    */
    1569             :   enum RefinementState { COARSEN = 0,
    1570             :                          DO_NOTHING,
    1571             :                          REFINE,
    1572             :                          JUST_REFINED,
    1573             :                          JUST_COARSENED,
    1574             :                          INACTIVE,
    1575             :                          COARSEN_INACTIVE,
    1576             :                          INVALID_REFINEMENTSTATE };
    1577             : 
    1578             :   /**
    1579             :    * \returns A constant pointer to the \f$ i^{th} \f$ child for this element.
    1580             :    * For internal use only - skips assertions about null pointers.
    1581             :    */
    1582             :   const Elem * raw_child_ptr (unsigned int i) const;
    1583             : 
    1584             :   /**
    1585             :    * \returns A constant pointer to the \f$ i^{th} \f$ child for this element.
    1586             :    * Do not call if this element has no children, i.e. is active.
    1587             :    */
    1588             :   const Elem * child_ptr (unsigned int i) const;
    1589             : 
    1590             :   /**
    1591             :    * \returns A non-constant pointer to the \f$ i^{th} \f$ child for this element.
    1592             :    * Do not call if this element has no children, i.e. is active.
    1593             :    */
    1594             :   Elem * child_ptr (unsigned int i);
    1595             : 
    1596             :   /**
    1597             :    * Nested classes for use iterating over all children of a parent
    1598             :    * element.
    1599             :    */
    1600             :   class ChildRefIter;
    1601             :   class ConstChildRefIter;
    1602             : 
    1603             :   /**
    1604             :    * Returns a range with all children of a parent element, usable in
    1605             :    * range-based for loops.  The exact type of the return value here
    1606             :    * may be subject to change in future libMesh releases, but the
    1607             :    * iterators will always dereference to produce a reference to a
    1608             :    * child element.
    1609             :    */
    1610             :   SimpleRange<ChildRefIter> child_ref_range();
    1611             : 
    1612             :   SimpleRange<ConstChildRefIter> child_ref_range() const;
    1613             : 
    1614             : private:
    1615             :   /**
    1616             :    * Sets the pointer to the \f$ i^{th} \f$ child for this element.
    1617             :    * Do not call if this element has no children, i.e. is active.
    1618             :    */
    1619             :   void set_child (unsigned int c, Elem * elem);
    1620             : 
    1621             : public:
    1622             :   /**
    1623             :    * \returns The child index which \p e corresponds to.
    1624             :    *
    1625             :    * I.e. if c = a->which_child_am_i(e); then a->child_ptr(c) will be
    1626             :    * e.
    1627             :    */
    1628             :   unsigned int which_child_am_i(const Elem * e) const;
    1629             : 
    1630             :   /**
    1631             :    * \returns \p true if the specified child is on the specified edge.
    1632             :    */
    1633             :   virtual bool is_child_on_edge(const unsigned int c,
    1634             :                                 const unsigned int e) const;
    1635             : 
    1636             :   /**
    1637             :    * Adds a child pointer to the array of children of this element.
    1638             :    * If this is the first child to be added, this method allocates
    1639             :    * memory in the parent's _children array, otherwise, it just sets
    1640             :    * the pointer.
    1641             :    */
    1642             :   void add_child (Elem * elem);
    1643             : 
    1644             :   /**
    1645             :    * Adds a new child pointer to the specified index in the array of
    1646             :    * children of this element.  If this is the first child to be added,
    1647             :    * this method allocates memory in the parent's _children array,
    1648             :    * otherwise, it just sets the pointer.
    1649             :    */
    1650             :   void add_child (Elem * elem, unsigned int c);
    1651             : 
    1652             :   /**
    1653             :    * Replaces the child pointer at the specified index in the child array.
    1654             :    */
    1655             :   void replace_child (Elem * elem, unsigned int c);
    1656             : 
    1657             :   /**
    1658             :    * Fills the vector \p family with the children of this element,
    1659             :    * recursively.  Calling this method on a twice-refined element
    1660             :    * will give you the element itself, its direct children, and their
    1661             :    * children, etc...  When the optional parameter \p reset is
    1662             :    * true, the vector will be cleared before the element and its
    1663             :    * descendants are added.
    1664             :    *
    1665             :    * The family tree only includes ancestor and active elements. To
    1666             :    * include subactive elements as well, use total_family_tree().
    1667             :    */
    1668             :   void family_tree (std::vector<const Elem *> & family,
    1669             :                     bool reset = true) const;
    1670             : 
    1671             :   /**
    1672             :    * Non-const version of function above; fills a vector of non-const pointers.
    1673             :    */
    1674             :   void family_tree (std::vector<Elem *> & family,
    1675             :                     bool reset = true);
    1676             : 
    1677             :   /**
    1678             :    * Same as the \p family_tree() member, but also adds any subactive
    1679             :    * descendants.
    1680             :    */
    1681             :   void total_family_tree (std::vector<const Elem *> & family,
    1682             :                           bool reset = true) const;
    1683             : 
    1684             :   /**
    1685             :    * Non-const version of function above; fills a vector of non-const pointers.
    1686             :    */
    1687             :   void total_family_tree (std::vector<Elem *> & family,
    1688             :                           bool reset = true);
    1689             : 
    1690             :   /**
    1691             :    * Same as the \p family_tree() member, but only adds the active
    1692             :    * children.  Can be thought of as removing all the inactive
    1693             :    * elements from the vector created by \p family_tree, but is
    1694             :    * implemented more efficiently.
    1695             :    */
    1696             :   void active_family_tree (std::vector<const Elem *> & active_family,
    1697             :                            bool reset = true) const;
    1698             : 
    1699             :   /**
    1700             :    * Non-const version of function above; fills a vector of non-const pointers.
    1701             :    */
    1702             :   void active_family_tree (std::vector<Elem *> & active_family,
    1703             :                            bool reset = true);
    1704             : 
    1705             :   /**
    1706             :    * Same as the \p family_tree() member, but only adds elements
    1707             :    * which are next to \p side.
    1708             :    */
    1709             :   void family_tree_by_side (std::vector<const Elem *> & family,
    1710             :                             unsigned int side,
    1711             :                             bool reset = true) const;
    1712             : 
    1713             :   /**
    1714             :    * Non-const version of function above; fills a vector of non-const pointers.
    1715             :    */
    1716             :   void family_tree_by_side (std::vector<Elem *> & family,
    1717             :                             unsigned int side,
    1718             :                             bool reset = true);
    1719             : 
    1720             :   /**
    1721             :    * Same as the \p total_family_tree() member, but only adds elements
    1722             :    * which are next to \p side.
    1723             :    */
    1724             :   void total_family_tree_by_side (std::vector<const Elem *> & family,
    1725             :                                   unsigned int side,
    1726             :                                   bool reset = true) const;
    1727             : 
    1728             :   /**
    1729             :    * Non-const version of function above; fills a vector of non-const pointers.
    1730             :    */
    1731             :   void total_family_tree_by_side (std::vector<Elem *> & family,
    1732             :                                   unsigned int side,
    1733             :                                   bool reset = true);
    1734             : 
    1735             :   /**
    1736             :    * Same as the \p active_family_tree() member, but only adds elements
    1737             :    * which are next to \p side.
    1738             :    */
    1739             :   void active_family_tree_by_side (std::vector<const Elem *> & family,
    1740             :                                    unsigned int side,
    1741             :                                    bool reset = true) const;
    1742             : 
    1743             :   /**
    1744             :    * Non-const version of function above; fills a vector of non-const pointers.
    1745             :    */
    1746             :   void active_family_tree_by_side (std::vector<Elem *> & family,
    1747             :                                    unsigned int side,
    1748             :                                    bool reset = true);
    1749             : 
    1750             :   /**
    1751             :    * Same as the \p family_tree() member, but only adds elements
    1752             :    * which are next to \p neighbor.
    1753             :    */
    1754             :   void family_tree_by_neighbor (std::vector<const Elem *> & family,
    1755             :                                 const Elem * neighbor,
    1756             :                                 bool reset = true) const;
    1757             : 
    1758             :   /**
    1759             :    * Non-const version of function above; fills a vector of non-const pointers.
    1760             :    */
    1761             :   void family_tree_by_neighbor (std::vector<Elem *> & family,
    1762             :                                 Elem * neighbor,
    1763             :                                 bool reset = true);
    1764             : 
    1765             :   /**
    1766             :    * Same as the \p family_tree_by_neighbor() member, but also adds
    1767             :    * any subactive descendants.
    1768             :    */
    1769             :   void total_family_tree_by_neighbor (std::vector<const Elem *> & family,
    1770             :                                       const Elem * neighbor,
    1771             :                                       bool reset = true) const;
    1772             : 
    1773             :   /**
    1774             :    * Non-const version of function above; fills a vector of non-const pointers.
    1775             :    */
    1776             :   void total_family_tree_by_neighbor (std::vector<Elem *> & family,
    1777             :                                       Elem * neighbor,
    1778             :                                       bool reset = true);
    1779             : 
    1780             :   /**
    1781             :    * Same as the \p family_tree() member, but only adds elements
    1782             :    * which are next to \p subneighbor.  Only applicable when
    1783             :    * \p this->has_neighbor(neighbor) and
    1784             :    * \p neighbor->is_ancestor(subneighbor)
    1785             :    */
    1786             :   void family_tree_by_subneighbor (std::vector<const Elem *> & family,
    1787             :                                    const Elem * neighbor,
    1788             :                                    const Elem * subneighbor,
    1789             :                                    bool reset = true) const;
    1790             : 
    1791             :   /**
    1792             :    * Non-const version of function above; fills a vector of non-const pointers.
    1793             :    */
    1794             :   void family_tree_by_subneighbor (std::vector<Elem *> & family,
    1795             :                                    Elem * neighbor,
    1796             :                                    Elem * subneighbor,
    1797             :                                    bool reset = true);
    1798             : 
    1799             :   /**
    1800             :    * Same as the \p family_tree_by_subneighbor() member, but also adds
    1801             :    * any subactive descendants.
    1802             :    */
    1803             :   void total_family_tree_by_subneighbor (std::vector<const Elem *> & family,
    1804             :                                          const Elem * neighbor,
    1805             :                                          const Elem * subneighbor,
    1806             :                                          bool reset = true) const;
    1807             : 
    1808             :   /**
    1809             :    * Non-const version of function above; fills a vector of non-const pointers.
    1810             :    */
    1811             :   void total_family_tree_by_subneighbor (std::vector<Elem *> & family,
    1812             :                                          Elem * neighbor,
    1813             :                                          Elem * subneighbor,
    1814             :                                          bool reset = true);
    1815             : 
    1816             :   /**
    1817             :    * Same as the \p active_family_tree() member, but only adds elements
    1818             :    * which are next to \p neighbor.
    1819             :    */
    1820             :   void active_family_tree_by_neighbor (std::vector<const Elem *> & family,
    1821             :                                        const Elem * neighbor,
    1822             :                                        bool reset = true) const;
    1823             : 
    1824             :   /**
    1825             :    * Non-const version of function above; fills a vector of non-const pointers.
    1826             :    */
    1827             :   void active_family_tree_by_neighbor (std::vector<Elem *> & family,
    1828             :                                        Elem * neighbor,
    1829             :                                        bool reset = true);
    1830             : 
    1831             :   /**
    1832             :    * Same as the \p active_family_tree_by_neighbor() member, but the
    1833             :    * \p neighbor here may be a topological (e.g. periodic boundary
    1834             :    * condition) neighbor, not just a local neighbor.
    1835             :    */
    1836             :   void active_family_tree_by_topological_neighbor (std::vector<const Elem *> & family,
    1837             :                                                    const Elem * neighbor,
    1838             :                                                    const MeshBase & mesh,
    1839             :                                                    const PointLocatorBase & point_locator,
    1840             :                                                    const PeriodicBoundaries * pb,
    1841             :                                                    bool reset = true) const;
    1842             : 
    1843             :   /**
    1844             :    * Non-const version of function above; fills a vector of non-const pointers.
    1845             :    */
    1846             :   void active_family_tree_by_topological_neighbor (std::vector<Elem *> & family,
    1847             :                                                    Elem * neighbor,
    1848             :                                                    const MeshBase & mesh,
    1849             :                                                    const PointLocatorBase & point_locator,
    1850             :                                                    const PeriodicBoundaries * pb,
    1851             :                                                    bool reset = true);
    1852             : 
    1853             :   /**
    1854             :    * \returns The value of the refinement flag for the element.
    1855             :    */
    1856             :   RefinementState refinement_flag () const;
    1857             : 
    1858             :   /**
    1859             :    * Sets the value of the refinement flag for the element.
    1860             :    */
    1861             :   void set_refinement_flag (const RefinementState rflag);
    1862             : 
    1863             :   /**
    1864             :    * \returns The value of the p-refinement flag for the element.
    1865             :    */
    1866             :   RefinementState p_refinement_flag () const;
    1867             : 
    1868             :   /**
    1869             :    * Sets the value of the p-refinement flag for the element.
    1870             :    */
    1871             :   void set_p_refinement_flag (const RefinementState pflag);
    1872             : 
    1873             :   /**
    1874             :    * \returns The maximum value of the p-refinement levels of
    1875             :    * an ancestor element's descendants.
    1876             :    */
    1877             :   unsigned int max_descendant_p_level () const;
    1878             : 
    1879             :   /**
    1880             :    * \returns The minimum p-refinement level of elements which are
    1881             :    * descended from this element, and which share a side with the
    1882             :    * active \p neighbor.
    1883             :    */
    1884             :   unsigned int min_p_level_by_neighbor (const Elem * neighbor,
    1885             :                                         unsigned int current_min) const;
    1886             : 
    1887             :   /**
    1888             :    * \returns The minimum new p-refinement level (i.e. after refinement
    1889             :    * and coarsening is done) of elements which are descended from this
    1890             :    * element and which share a side with the active \p neighbor.
    1891             :    */
    1892             :   unsigned int min_new_p_level_by_neighbor (const Elem * neighbor,
    1893             :                                             unsigned int current_min) const;
    1894             : 
    1895             :   /**
    1896             :    * Sets the value of the p-refinement level for the element.
    1897             :    *
    1898             :    * \note The maximum p-refinement level is currently 255.
    1899             :    */
    1900             :   void set_p_level (const unsigned int p);
    1901             : 
    1902             :   /**
    1903             :    * Sets the value of the p-refinement level for the element
    1904             :    * without altering the p-level of its ancestors
    1905             :    */
    1906             :   void hack_p_level (const unsigned int p);
    1907             : 
    1908             :   /**
    1909             :    * Sets the value of the p-refinement level for the element
    1910             :    * without altering the p-level of its ancestors; also sets the
    1911             :    * p_refinement_flag, simultaneously so that they can be safely
    1912             :    * checked for mutual consistency
    1913             :    */
    1914             :   void hack_p_level_and_refinement_flag (const unsigned int p,
    1915             :                                          RefinementState pflag);
    1916             : 
    1917             :   /**
    1918             :    * Refine the element.
    1919             :    */
    1920             :   virtual void refine (MeshRefinement & mesh_refinement);
    1921             : 
    1922             :   /**
    1923             :    * Coarsen the element.  This function is non-virtual since it is the same
    1924             :    * for all element types.
    1925             :    */
    1926             :   void coarsen ();
    1927             : 
    1928             :   /**
    1929             :    * Contract an active element, i.e. remove pointers to any
    1930             :    * subactive children.  This should only be called via
    1931             :    * MeshRefinement::contract, which will also remove subactive
    1932             :    * children from the mesh.
    1933             :    */
    1934             :   void contract ();
    1935             : 
    1936             : #endif
    1937             : 
    1938             : #ifndef NDEBUG
    1939             :   /**
    1940             :    * Checks for consistent neighbor links on this element.
    1941             :    */
    1942             :   void libmesh_assert_valid_neighbors() const;
    1943             : 
    1944             :   /**
    1945             :    * Checks for a valid id and pointers to nodes with valid ids on
    1946             :    * this element.
    1947             :    */
    1948             :   void libmesh_assert_valid_node_pointers() const;
    1949             : #endif // !NDEBUG
    1950             : 
    1951             :   /**
    1952             :    * \returns The local node index of the given point IF said node
    1953             :    * has a singular Jacobian for this element. If the given point
    1954             :    * is not a node or is a node and does not have a singular Jacobian,
    1955             :    * this will return invalid_uint.
    1956             :    *
    1957             :    * The intention is for this to be overridden in derived element
    1958             :    * classes that do have nodes that have singular Jacobians. When
    1959             :    * mapping failures are caught, we can check this to see if the
    1960             :    * failed physical point is actually a singular point and
    1961             :    * return the correct master point.
    1962             :    */
    1963           0 :   virtual unsigned int local_singular_node(const Point & /* p */, const Real /* tol */ = TOLERANCE*TOLERANCE) const
    1964           0 :   { return invalid_uint; }
    1965             : 
    1966             :   /**
    1967             :    * \returns true iff the node at the given index has a singular
    1968             :    * mapping; i.e. is the degree-4 node on a Pyramid.
    1969             :    */
    1970           0 :   virtual bool is_singular_node(unsigned int /* node_i */) const { return false; }
    1971             : 
    1972             :   /**
    1973             :    * \returns The local index of the center node on the side \p side.
    1974             :    *
    1975             :    * A center node is a node that is located at the centroid of the given side.
    1976             :    * If the given side does not have a center node, this will return invalid_uint.
    1977             :    */
    1978             :   virtual unsigned int center_node_on_side(const unsigned short side) const;
    1979             : 
    1980             : protected:
    1981             : 
    1982             :   /**
    1983             :    * The protected nested SideIter class is used to iterate over the
    1984             :    * sides of this Elem.  It is a specially-designed class since
    1985             :    * no sides are actually stored by the element.  This iterator-like
    1986             :    * class has to provide the following three operations
    1987             :    * 1) operator*
    1988             :    * 2) operator++
    1989             :    * 3) operator==
    1990             :    * The definition can be found at the end of this header file.
    1991             :    */
    1992             :   class SideIter;
    1993             : 
    1994             : public:
    1995             :   /**
    1996             :    * Useful iterator typedefs
    1997             :    */
    1998             :   typedef Predicates::multi_predicate Predicate;
    1999             : 
    2000             :   /**
    2001             :    * Data structure for iterating over sides.  Defined at the end of
    2002             :    * this header file.
    2003             :    */
    2004             :   struct side_iterator;
    2005             : 
    2006             :   /**
    2007             :    * Iterator accessor functions
    2008             :    */
    2009             :   side_iterator boundary_sides_begin();
    2010             :   side_iterator boundary_sides_end();
    2011             : 
    2012             : private:
    2013             :   /**
    2014             :    * Side iterator helper functions.  Used to replace the begin()
    2015             :    * and end() functions of the STL containers.
    2016             :    */
    2017             :   SideIter _first_side();
    2018             :   SideIter _last_side();
    2019             : 
    2020             : public:
    2021             : 
    2022             : #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
    2023             : 
    2024             :   /**
    2025             :    * \returns \p true if the element is an infinite element,
    2026             :    * \p false otherwise.
    2027             :    */
    2028             :   virtual bool infinite () const = 0;
    2029             : 
    2030             :   /**
    2031             :    * \returns \p true if the specified (local) node number is a
    2032             :    * "mid-edge" node on an infinite element edge.
    2033             :    *
    2034             :    * This is false for all nodes on non-infinite elements, so we won't
    2035             :    * make it pure virtual, to simplify their code.
    2036             :    */
    2037           0 :   virtual bool is_mid_infinite_edge_node(const unsigned int /* n */) const
    2038           0 :   { libmesh_assert (!this->infinite()); return false; }
    2039             : 
    2040             :   /**
    2041             :    * \returns The origin for an infinite element.
    2042             :    *
    2043             :    * Currently, all infinite elements used in a mesh share the same
    2044             :    * origin.  Override this in infinite element classes.
    2045             :    */
    2046           0 :   virtual Point origin () const { libmesh_not_implemented(); return Point(); }
    2047             : 
    2048             : #else
    2049             : 
    2050             :   static constexpr bool infinite () { return false; }
    2051             : 
    2052             : #endif
    2053             : 
    2054             :   /**
    2055             :    * \returns An Elem of type \p type wrapped in a smart pointer.
    2056             :    */
    2057             :   static std::unique_ptr<Elem> build (const ElemType type,
    2058             :                                       Elem * p=nullptr);
    2059             : 
    2060             :   /**
    2061             :    * Calls the build() method above with a nullptr parent, and
    2062             :    * additionally sets the newly-created Elem's id. This can be useful
    2063             :    * when adding pre-numbered Elems to a Mesh via add_elem() calls.
    2064             :    */
    2065             :   static std::unique_ptr<Elem> build_with_id (const ElemType type,
    2066             :                                               dof_id_type id);
    2067             : 
    2068             :   /**
    2069             :    * \returns An Elem of the same type as \p this, wrapped in a smart
    2070             :    * pointer.
    2071             :    *
    2072             :    * This is not a complete clone() method (since e.g. it does not set
    2073             :    * node pointers; the standard use case reassigns node pointers from
    2074             :    * a different mesh), but it is necessary to use this instead of
    2075             :    * build() for runtime-polymorphic elements like Polygon subtypes
    2076             :    * whose "type" depends on more than their type(), and it is useful
    2077             :    * to use this for elements whose id, unique_id, extra integers,
    2078             :    * etc. should be preserved in the near-clone.
    2079             :    */
    2080             :   virtual std::unique_ptr<Elem> disconnected_clone () const;
    2081             : 
    2082             :   /**
    2083             :    * Returns the number of independent permutations of element nodes -
    2084             :    * e.g. a cube can be reoriented to put side 0 where side N is (for
    2085             :    * 0 <= N < 6) and then rotated in one of four ways, giving 24
    2086             :    * possible permutations.
    2087             :    *
    2088             :    * Permutations which change the mapping Jacobian of an element
    2089             :    * (i.e. flipping the element) are not allowed in this definition.
    2090             :    */
    2091             :   virtual unsigned int n_permutations() const = 0;
    2092             : 
    2093             :   /**
    2094             :    * Permutes the element (by swapping node and neighbor pointers)
    2095             :    * according to the specified index.
    2096             :    *
    2097             :    * This is useful for regression testing, by making it easy to make
    2098             :    * a structured mesh behave more like an arbitrarily unstructured
    2099             :    * mesh.
    2100             :    *
    2101             :    * This is so far *only* used for regression testing, so we do
    2102             :    * not currently provide a way to permute any boundary side/edge ids
    2103             :    * along with the element permutation.
    2104             :    */
    2105             :   virtual void permute(unsigned int perm_num) = 0;
    2106             : 
    2107             :   /**
    2108             :    * Flips the element (by swapping node and neighbor pointers) to
    2109             :    * have a mapping Jacobian of opposite sign.
    2110             :    *
    2111             :    * This is useful for automatically fixing up elements that have
    2112             :    * been newly created (e.g. from extrusions) with a negative
    2113             :    * Jacobian.
    2114             :    *
    2115             :    * If \p boundary_info is not null, swap boundary side/edge ids
    2116             :    * consistently.
    2117             :    */
    2118             :   virtual void flip(BoundaryInfo * boundary_info) = 0;
    2119             : 
    2120             :   /**
    2121             :    * \returns Whether the element is flipped compared to standard
    2122             :    * libMesh (e.g. clockwise for 2D elements) node orientations.
    2123             :    *
    2124             :    * Always returns \p false if a 2D element is not in the XY plane or
    2125             :    * a 1D element is not on the X axis; user code designed to work for
    2126             :    * embedded manifolds should handle any consistent orientation, and
    2127             :    * determining whether an orientation is consistent is not a local
    2128             :    * operation.
    2129             :    */
    2130             :    virtual bool is_flipped() const = 0;
    2131             : 
    2132             :   /**
    2133             :    * Flips the element (by swapping node and neighbor pointers) to
    2134             :    * have a mapping Jacobian of opposite sign, iff we find a negative
    2135             :    * orientation.  This only fixes flipped elements; for tangled
    2136             :    * elements the only fixes possible are non-local.
    2137             :    */
    2138             :   void orient(BoundaryInfo * boundary_info);
    2139             : 
    2140             : #ifdef LIBMESH_ENABLE_AMR
    2141             : 
    2142             :   /**
    2143             :    * \returns The local node id on the parent which corresponds to node
    2144             :    * \p n of child \p c, or \p invalid_uint if no such parent
    2145             :    * node exists.
    2146             :    */
    2147             :   virtual unsigned int as_parent_node (unsigned int c,
    2148             :                                        unsigned int n) const;
    2149             : 
    2150             :   /**
    2151             :    * \returns All the pairs of nodes (indexed by local node id) which
    2152             :    * should bracket node \p n of child \p c.
    2153             :    */
    2154             :   virtual
    2155             :   const std::vector<std::pair<unsigned char, unsigned char>> &
    2156             :   parent_bracketing_nodes(unsigned int c,
    2157             :                           unsigned int n) const;
    2158             : 
    2159             :   /**
    2160             :    * \returns All the pairs of nodes (indexed by global node id) which
    2161             :    * should bracket node \p n of child \p c.
    2162             :    */
    2163             :   virtual
    2164             :   const std::vector<std::pair<dof_id_type, dof_id_type>>
    2165             :   bracketing_nodes(unsigned int c,
    2166             :                    unsigned int n) const;
    2167             : 
    2168             : 
    2169             :   /**
    2170             :    * \returns The embedding matrix entry for the requested child.
    2171             :    */
    2172             :   virtual Real embedding_matrix (const unsigned int child_num,
    2173             :                                  const unsigned int child_node_num,
    2174             :                                  const unsigned int parent_node_num) const = 0;
    2175             : 
    2176             :   /**
    2177             :    * \returns A "version number" that identifies which embedding
    2178             :    * matrix is in use.
    2179             :    *
    2180             :    * Some element types may use a different embedding matrix depending
    2181             :    * on their geometric characteristics.
    2182             :    */
    2183           0 :   virtual unsigned int embedding_matrix_version () const { return 0; }
    2184             : 
    2185             : #endif // LIBMESH_ENABLE_AMR
    2186             : 
    2187             : 
    2188             : protected:
    2189             : 
    2190             :   /**
    2191             :    * Default tolerance to use in has_affine_map().
    2192             :    */
    2193             :   static constexpr Real affine_tol = TOLERANCE*TOLERANCE;
    2194             : 
    2195             :   /**
    2196             :    * \returns A hash key computed from a single node id.
    2197             :    */
    2198             :   static dof_id_type compute_key (dof_id_type n0);
    2199             : 
    2200             :   /**
    2201             :    * \returns A hash key computed from two node ids.
    2202             :    */
    2203             :   static dof_id_type compute_key (dof_id_type n0,
    2204             :                                   dof_id_type n1);
    2205             : 
    2206             :   /**
    2207             :    * \returns A hash key computed from three node ids.
    2208             :    */
    2209             :   static dof_id_type compute_key (dof_id_type n0,
    2210             :                                   dof_id_type n1,
    2211             :                                   dof_id_type n2);
    2212             : 
    2213             :   /**
    2214             :    * \returns A hash key computed from four node ids.
    2215             :    */
    2216             :   static dof_id_type compute_key (dof_id_type n0,
    2217             :                                   dof_id_type n1,
    2218             :                                   dof_id_type n2,
    2219             :                                   dof_id_type n3);
    2220             : 
    2221             :   /**
    2222             :    * Swaps two node_ptrs
    2223             :    */
    2224     9270817 :   void swap2nodes(unsigned int n1, unsigned int n2)
    2225             :   {
    2226     4909128 :     Node * temp = this->node_ptr(n1);
    2227    11725381 :     this->set_node(n1, this->node_ptr(n2));
    2228     9270817 :     this->set_node(n2, temp);
    2229     9270817 :   }
    2230             : 
    2231             :   /**
    2232             :    * Swaps two neighbor_ptrs
    2233             :    */
    2234     1737262 :   void swap2neighbors(unsigned int n1, unsigned int n2)
    2235             :   {
    2236      940284 :     Elem * temp = this->neighbor_ptr(n1);
    2237      646922 :     this->set_neighbor(n1, this->neighbor_ptr(n2));
    2238      646922 :     this->set_neighbor(n2, temp);
    2239     1753820 :   }
    2240             : 
    2241             :   /**
    2242             :    * Swaps two sides in \p boundary_info, if it is non-null.
    2243             :    */
    2244             :   void swap2boundarysides(unsigned short s1, unsigned short s2,
    2245             :                           BoundaryInfo * boundary_info) const;
    2246             : 
    2247             :   /**
    2248             :    * Swaps two edges in \p boundary_info, if it is non-null.
    2249             :    */
    2250             :   void swap2boundaryedges(unsigned short e1, unsigned short e2,
    2251             :                           BoundaryInfo * boundary_info) const;
    2252             : 
    2253             :   /**
    2254             :    * Swaps three node_ptrs, "rotating" them.
    2255             :    */
    2256     2798046 :   void swap3nodes(unsigned int n1, unsigned int n2, unsigned int n3)
    2257             :   {
    2258     3809594 :     swap2nodes(n1, n2);
    2259     3809594 :     swap2nodes(n2, n3);
    2260     2798046 :   }
    2261             : 
    2262             :   /**
    2263             :    * Swaps three neighbor_ptrs, "rotating" them.
    2264             :    */
    2265      754951 :   void swap3neighbors(unsigned int n1, unsigned int n2,
    2266             :                       unsigned int n3)
    2267             :   {
    2268      754951 :     swap2neighbors(n1, n2);
    2269      754951 :     swap2neighbors(n2, n3);
    2270      754951 :   }
    2271             : 
    2272             :   /**
    2273             :    * Swaps four node_ptrs, "rotating" them.
    2274             :    */
    2275     1247742 :   void swap4nodes(unsigned int n1, unsigned int n2, unsigned int n3,
    2276             :                   unsigned int n4)
    2277             :   {
    2278      924962 :     swap3nodes(n1, n2, n3);
    2279     1247742 :     swap2nodes(n3, n4);
    2280     1247742 :   }
    2281             : 
    2282             :   /**
    2283             :    * Swaps four neighbor_ptrs, "rotating" them.
    2284             :    */
    2285      198048 :   void swap4neighbors(unsigned int n1, unsigned int n2,
    2286             :                       unsigned int n3, unsigned int n4)
    2287             :   {
    2288      198048 :     swap3neighbors(n1, n2, n3);
    2289      198048 :     swap2neighbors(n3, n4);
    2290      198048 :   }
    2291             : 
    2292             : 
    2293             :   /**
    2294             :    * An implementation for simple (all sides equal) elements
    2295             :    */
    2296             :   template <typename Sideclass, typename Subclass>
    2297             :   std::unique_ptr<Elem>
    2298             :   simple_build_side_ptr(const unsigned int i);
    2299             : 
    2300             :   /**
    2301             :    * An implementation for simple (all sides equal) elements
    2302             :    */
    2303             :   template <typename Subclass>
    2304             :   void simple_build_side_ptr(std::unique_ptr<Elem> & side,
    2305             :                              const unsigned int i,
    2306             :                              ElemType sidetype);
    2307             : 
    2308             :   /**
    2309             :    * An implementation for simple (all sides equal) elements
    2310             :    */
    2311             :   template <typename Subclass, typename Mapclass>
    2312             :   void simple_side_ptr(std::unique_ptr<Elem> & side,
    2313             :                        const unsigned int i,
    2314             :                        ElemType sidetype);
    2315             : 
    2316             :   /**
    2317             :    * An implementation for simple (all edges equal) elements
    2318             :    */
    2319             :   template <typename Edgeclass, typename Subclass>
    2320             :   std::unique_ptr<Elem>
    2321             :   simple_build_edge_ptr(const unsigned int i);
    2322             : 
    2323             :   /**
    2324             :    * An implementation for simple (all edges equal) elements
    2325             :    */
    2326             :   template <typename Subclass>
    2327             :   void simple_build_edge_ptr(std::unique_ptr<Elem> & edge,
    2328             :                              const unsigned int i,
    2329             :                              ElemType edgetype);
    2330             : 
    2331             : 
    2332             : #ifdef LIBMESH_ENABLE_AMR
    2333             : 
    2334             :   /**
    2335             :    * Elem subclasses which don't do their own bracketing node
    2336             :    * calculations will need to supply a static cache, since the
    2337             :    * default calculation is slow.
    2338             :    */
    2339             :   virtual
    2340             :   std::vector<std::vector<std::vector<std::vector<std::pair<unsigned char, unsigned char>>>>> &
    2341           0 :   _get_bracketing_node_cache() const
    2342             :   {
    2343           0 :     static std::vector<std::vector<std::vector<std::vector<std::pair<unsigned char, unsigned char>>>>> c;
    2344           0 :     libmesh_error();
    2345             :     return c;
    2346             :   }
    2347             : 
    2348             :   /**
    2349             :    * Elem subclasses which don't do their own child-to-parent node
    2350             :    * calculations will need to supply a static cache, since the
    2351             :    * default calculation is slow.
    2352             :    */
    2353             :   virtual
    2354             :   std::vector<std::vector<std::vector<signed char>>> &
    2355           0 :   _get_parent_indices_cache() const
    2356             :   {
    2357           0 :     static std::vector<std::vector<std::vector<signed char>>> c;
    2358           0 :     libmesh_error();
    2359             :     return c;
    2360             :   }
    2361             : 
    2362             : #endif // LIBMESH_ENABLE_AMR
    2363             : 
    2364             : public:
    2365             : 
    2366             :   /**
    2367             :    * Replaces this element with \p nullptr for all of its neighbors.
    2368             :    * This is useful when deleting an element.
    2369             :    */
    2370             :   void nullify_neighbors ();
    2371             : 
    2372             : protected:
    2373             : 
    2374             :   /**
    2375             :    * Pointers to the nodes we are connected to.
    2376             :    */
    2377             :   Node ** _nodes;
    2378             : 
    2379             :   /**
    2380             :    * Pointers to this element's parent and neighbors, and for
    2381             :    * lower-dimensional elements' interior_parent.
    2382             :    */
    2383             :   Elem ** _elemlinks;
    2384             : 
    2385             : #ifdef LIBMESH_ENABLE_AMR
    2386             :   /**
    2387             :    * unique_ptr to array of this element's children.
    2388             :    *
    2389             :    * A Mesh ultimately owns the child Elems so we are not responsible
    2390             :    * for deleting them, but we are responsible for cleaning up the
    2391             :    * array allocated to hold those Elems, hence the unique_ptr.
    2392             :    */
    2393             :   std::unique_ptr<Elem *[]> _children;
    2394             : #endif
    2395             : 
    2396             :   /**
    2397             :    * The subdomain to which this element belongs.
    2398             :    */
    2399             :   subdomain_id_type _sbd_id;
    2400             : 
    2401             : #ifdef LIBMESH_ENABLE_AMR
    2402             :   /**
    2403             :    * h refinement flag. This is stored as an unsigned char
    2404             :    * to save space.
    2405             :    */
    2406             :   unsigned char _rflag;
    2407             : 
    2408             :   /**
    2409             :    * p refinement flag. This is stored as an unsigned char
    2410             :    * to save space.
    2411             :    */
    2412             :   unsigned char _pflag;
    2413             : 
    2414             :   /**
    2415             :    * p refinement level - the difference between the
    2416             :    * polynomial degree on this element and the minimum
    2417             :    * polynomial degree on the mesh.
    2418             :    * This is stored as an unsigned char to save space.
    2419             :    * In theory, these last four bytes might have
    2420             :    * been padding anyway.
    2421             :    */
    2422             :   unsigned char _p_level;
    2423             : #endif
    2424             : 
    2425             :   /**
    2426             :    * Mapping function type; currently either 0 (LAGRANGE) or 1
    2427             :    * (RATIONAL_BERNSTEIN).
    2428             :    */
    2429             :   unsigned char _map_type;
    2430             : 
    2431             :   /**
    2432             :    * Mapping function data; currently used when needed to store the
    2433             :    * RATIONAL_BERNSTEIN nodal weight data index.
    2434             :    */
    2435             :   unsigned char _map_data;
    2436             : };
    2437             : 
    2438             : 
    2439             : 
    2440             : // ------------------------------------------------------------
    2441             : // Elem helper classes
    2442             : //
    2443             : class
    2444             : Elem::NodeRefIter : public PointerToPointerIter<Node>
    2445             : {
    2446             : public:
    2447    25575544 :   NodeRefIter (Node * const * nodepp) : PointerToPointerIter<Node>(nodepp) {}
    2448             : };
    2449             : 
    2450             : 
    2451             : class
    2452             : Elem::ConstNodeRefIter : public PointerToPointerIter<const Node>
    2453             : {
    2454             : public:
    2455    18291628 :   ConstNodeRefIter (const Node * const * nodepp) : PointerToPointerIter<const Node>(nodepp) {}
    2456             : };
    2457             : 
    2458             : 
    2459             : #ifdef LIBMESH_ENABLE_AMR
    2460             : class
    2461             : Elem::ChildRefIter : public PointerToPointerIter<Elem>
    2462             : {
    2463             : public:
    2464     6914828 :   ChildRefIter (Elem * const * childpp) : PointerToPointerIter<Elem>(childpp) {}
    2465             : };
    2466             : 
    2467             : 
    2468             : class
    2469             : Elem::ConstChildRefIter : public PointerToPointerIter<const Elem>
    2470             : {
    2471             : public:
    2472     2769972 :   ConstChildRefIter (const Elem * const * childpp) : PointerToPointerIter<const Elem>(childpp) {}
    2473             : };
    2474             : 
    2475             : 
    2476             : 
    2477             : inline
    2478     5928220 : SimpleRange<Elem::ChildRefIter> Elem::child_ref_range()
    2479             : {
    2480     3457414 :   libmesh_assert(_children);
    2481     8788944 :   return {_children.get(), _children.get() + this->n_children()};
    2482             : }
    2483             : 
    2484             : 
    2485             : inline
    2486     1657855 : SimpleRange<Elem::ConstChildRefIter> Elem::child_ref_range() const
    2487             : {
    2488     1384986 :   libmesh_assert(_children);
    2489     1943834 :   return {_children.get(), _children.get() + this->n_children()};
    2490             : }
    2491             : #endif // LIBMESH_ENABLE_AMR
    2492             : 
    2493             : 
    2494             : 
    2495             : 
    2496             : // ------------------------------------------------------------
    2497             : // global Elem functions
    2498             : 
    2499             : inline
    2500           0 : std::ostream & operator << (std::ostream & os, const Elem & e)
    2501             : {
    2502           0 :   e.print_info(os);
    2503           0 :   return os;
    2504             : }
    2505             : 
    2506             : 
    2507             : // ------------------------------------------------------------
    2508             : // Elem class member functions
    2509             : inline
    2510   327703237 : Elem::Elem(const unsigned int nn,
    2511             :            const unsigned int ns,
    2512             :            Elem * p,
    2513             :            Elem ** elemlinkdata,
    2514   327703237 :            Node ** nodelinkdata) :
    2515    15782773 :   _nodes(nodelinkdata),
    2516    15782773 :   _elemlinks(elemlinkdata),
    2517    15782773 :   _sbd_id(0),
    2518             : #ifdef LIBMESH_ENABLE_AMR
    2519    15782773 :   _rflag(Elem::DO_NOTHING),
    2520    15782773 :   _pflag(Elem::DO_NOTHING),
    2521    15782773 :   _p_level(0),
    2522             : #endif
    2523    16374365 :   _map_type(p ? p->mapping_type() : 0),
    2524   328610327 :   _map_data(p ? p->mapping_data() : 0)
    2525             : {
    2526   327703237 :   this->processor_id() = DofObject::invalid_processor_id;
    2527             : 
    2528             :   // If this ever legitimately fails we need to increase max_n_nodes
    2529    56673417 :   libmesh_assert_less_equal(nn, max_n_nodes);
    2530             : 
    2531             :   // We currently only support refinement of elements into child
    2532             :   // elements of the same type.  We can't test elem->type() here,
    2533             :   // because that's virtual and we're still in the base class
    2534             :   // constructor, but we can at least usually verify constency with
    2535             :   // the arguments we were handed.
    2536             : #ifndef NDEBUG
    2537    56673417 :   if (p && !p->runtime_topology())
    2538             :     {
    2539      294636 :       libmesh_assert_equal_to(nn, p->n_nodes());
    2540      294636 :       libmesh_assert_equal_to(ns, p->n_sides());
    2541             :     }
    2542             : #endif
    2543             : 
    2544             :   // Initialize the nodes data structure if we're given a pointer to
    2545             :   // memory for it.
    2546   327703237 :   if (_nodes)
    2547             :     {
    2548  1349678340 :       for (unsigned int n=0; n<nn; n++)
    2549  1021996069 :         _nodes[n] = nullptr;
    2550             :     }
    2551             : 
    2552             :   // Initialize the neighbors/parent data structure
    2553             :   // _elemlinks = new Elem *[ns+1];
    2554             : 
    2555             :   // Initialize the elements data structure if we're given a pointer
    2556             :   // to memory for it.  If we *weren't* given memory for it, e.g.
    2557             :   // because a subclass like an arbitrary Polygon needs to
    2558             :   // heap-allocate this memory, then that subclass will have to handle
    2559             :   // this initialization too.
    2560   327703237 :   if (_elemlinks)
    2561             :     {
    2562   327683914 :       _elemlinks[0] = p;
    2563             : 
    2564  1266736728 :       for (unsigned int n=1; n<ns+1; n++)
    2565   939052814 :         _elemlinks[n] = nullptr;
    2566             : 
    2567             :       // Optionally initialize data from the parent
    2568   327683914 :       if (this->parent())
    2569             :         {
    2570      907090 :           this->subdomain_id() = this->parent()->subdomain_id();
    2571      907090 :           this->processor_id() = this->parent()->processor_id();
    2572      907090 :           _map_type = this->parent()->_map_type;
    2573      907090 :           _map_data = this->parent()->_map_data;
    2574             : 
    2575             : #ifdef LIBMESH_ENABLE_AMR
    2576     1204046 :           this->set_p_level(this->parent()->p_level());
    2577             : #endif
    2578             :         }
    2579             :     }
    2580   327703237 : }
    2581             : 
    2582             : 
    2583             : 
    2584             : inline
    2585  3494519277 : const Point & Elem::point (const unsigned int i) const
    2586             : {
    2587  3494519277 :   libmesh_assert_less (i, this->n_nodes());
    2588  3494519277 :   libmesh_assert(_nodes[i]);
    2589  3494519277 :   libmesh_assert_not_equal_to (_nodes[i]->id(), Node::invalid_id);
    2590             : 
    2591 14875028580 :   return *_nodes[i];
    2592             : }
    2593             : 
    2594             : 
    2595             : 
    2596             : inline
    2597     2872998 : Point & Elem::point (const unsigned int i)
    2598             : {
    2599     2872998 :   libmesh_assert_less (i, this->n_nodes());
    2600             : 
    2601    46941395 :   return *_nodes[i];
    2602             : }
    2603             : 
    2604             : 
    2605             : 
    2606             : inline
    2607   172359520 : dof_id_type Elem::node_id (const unsigned int i) const
    2608             : {
    2609   172359520 :   libmesh_assert_less (i, this->n_nodes());
    2610   172359520 :   libmesh_assert(_nodes[i]);
    2611   172359520 :   libmesh_assert_not_equal_to (_nodes[i]->id(), Node::invalid_id);
    2612             : 
    2613   265577304 :   return _nodes[i]->id();
    2614             : }
    2615             : 
    2616             : 
    2617             : 
    2618             : inline
    2619       74059 : unsigned int Elem::local_node (const dof_id_type i) const
    2620             : {
    2621      516708 :   for (auto n : make_range(this->n_nodes()))
    2622      516708 :     if (this->node_id(n) == i)
    2623        2328 :       return n;
    2624             : 
    2625           0 :   return libMesh::invalid_uint;
    2626             : }
    2627             : 
    2628             : 
    2629             : 
    2630             : inline
    2631    25164588 : const Node * const * Elem::get_nodes () const
    2632             : {
    2633    41475998 :   return _nodes;
    2634             : }
    2635             : 
    2636             : 
    2637             : 
    2638             : inline
    2639   127472059 : const Node * Elem::node_ptr (const unsigned int i) const
    2640             : {
    2641   127472059 :   libmesh_assert_less (i, this->n_nodes());
    2642   127472059 :   libmesh_assert(_nodes[i]);
    2643             : 
    2644   805268189 :   return _nodes[i];
    2645             : }
    2646             : 
    2647             : 
    2648             : 
    2649             : inline
    2650   177723506 : Node * Elem::node_ptr (const unsigned int i)
    2651             : {
    2652   177723506 :   libmesh_assert_less (i, this->n_nodes());
    2653   177723506 :   libmesh_assert(_nodes[i]);
    2654             : 
    2655   379618475 :   return _nodes[i];
    2656             : }
    2657             : 
    2658             : 
    2659             : 
    2660             : inline
    2661    19908447 : const Node & Elem::node_ref (const unsigned int i) const
    2662             : {
    2663   187895448 :   return *this->node_ptr(i);
    2664             : }
    2665             : 
    2666             : 
    2667             : 
    2668             : inline
    2669    25717705 : Node & Elem::node_ref (const unsigned int i)
    2670             : {
    2671    54467264 :   return *this->node_ptr(i);
    2672             : }
    2673             : 
    2674             : 
    2675             : 
    2676             : inline
    2677      259677 : unsigned int Elem::get_node_index (const Node * node_ptr) const
    2678             : {
    2679     1134721 :   for (auto n : make_range(this->n_nodes()))
    2680     1109934 :     if (this->_nodes[n] == node_ptr)
    2681      161293 :       return n;
    2682             : 
    2683           0 :   return libMesh::invalid_uint;
    2684             : }
    2685             : 
    2686             : 
    2687             : 
    2688             : #ifdef LIBMESH_ENABLE_DEPRECATED
    2689             : inline
    2690           0 : Node * & Elem::set_node (const unsigned int i)
    2691             : {
    2692           0 :   libmesh_assert_less (i, this->n_nodes());
    2693             : 
    2694             :   libmesh_deprecated();
    2695             : 
    2696           0 :   return _nodes[i];
    2697             : }
    2698             : #endif // LIBMESH_ENABLE_DEPRECATED
    2699             : 
    2700             : 
    2701             : 
    2702             : inline
    2703   567372412 : void Elem::set_node (const unsigned int i,
    2704             :                      Node * node)
    2705             : {
    2706      355404 :   libmesh_assert_less (i, this->n_nodes());
    2707             : 
    2708   808066076 :   _nodes[i] = node;
    2709   494303490 : }
    2710             : 
    2711             : 
    2712             : 
    2713             : inline
    2714    79666186 : subdomain_id_type Elem::subdomain_id () const
    2715             : {
    2716   147993657 :   return _sbd_id;
    2717             : }
    2718             : 
    2719             : 
    2720             : 
    2721             : inline
    2722    71043796 : subdomain_id_type & Elem::subdomain_id ()
    2723             : {
    2724    76216615 :   return _sbd_id;
    2725             : }
    2726             : 
    2727             : 
    2728             : 
    2729             : inline
    2730           0 : bool Elem::operator != (const Elem & rhs) const
    2731             : {
    2732           0 :   return !(*this == rhs);
    2733             : }
    2734             : 
    2735             : 
    2736             : 
    2737             : inline
    2738   172046241 : const Elem * Elem::neighbor_ptr (unsigned int i) const
    2739             : {
    2740   172046241 :   libmesh_assert_less (i, this->n_neighbors());
    2741             : 
    2742   207563501 :   return _elemlinks[i+1];
    2743             : }
    2744             : 
    2745             : 
    2746             : 
    2747             : inline
    2748    28818749 : Elem * Elem::neighbor_ptr (unsigned int i)
    2749             : {
    2750    28818749 :   libmesh_assert_less (i, this->n_neighbors());
    2751             : 
    2752    99796675 :   return _elemlinks[i+1];
    2753             : }
    2754             : 
    2755             : 
    2756             : 
    2757             : inline
    2758    21059328 : void Elem::set_neighbor (const unsigned int i, Elem * n)
    2759             : {
    2760    21059328 :   libmesh_assert_less (i, this->n_neighbors());
    2761             : 
    2762    38938075 :   _elemlinks[i+1] = n;
    2763    32589358 : }
    2764             : 
    2765             : 
    2766             : 
    2767             : inline
    2768     4325386 : bool Elem::has_neighbor (const Elem * elem) const
    2769             : {
    2770    15258784 :   for (auto n : this->neighbor_ptr_range())
    2771    14203368 :     if (n == elem)
    2772     3626829 :       return true;
    2773             : 
    2774      698557 :   return false;
    2775             : }
    2776             : 
    2777             : 
    2778             : 
    2779             : inline
    2780             : Elem * Elem::child_neighbor (Elem * elem)
    2781             : {
    2782             :   for (auto n : elem->neighbor_ptr_range())
    2783             :     if (n && n->parent() == this)
    2784             :       return n;
    2785             : 
    2786             :   return nullptr;
    2787             : }
    2788             : 
    2789             : 
    2790             : 
    2791             : inline
    2792             : const Elem * Elem::child_neighbor (const Elem * elem) const
    2793             : {
    2794             :   for (auto n : elem->neighbor_ptr_range())
    2795             :     if (n && n->parent() == this)
    2796             :       return n;
    2797             : 
    2798             :   return nullptr;
    2799             : }
    2800             : 
    2801             : 
    2802             : 
    2803             : inline
    2804             : SimpleRange<Elem::NodeRefIter>
    2805    25037918 : Elem::node_ref_range()
    2806             : {
    2807    35049472 :   return {_nodes, _nodes+this->n_nodes()};
    2808             : }
    2809             : 
    2810             : 
    2811             : 
    2812             : inline
    2813             : SimpleRange<Elem::ConstNodeRefIter>
    2814    41727867 : Elem::node_ref_range() const
    2815             : {
    2816    60571496 :   return {_nodes, _nodes+this->n_nodes()};
    2817             : }
    2818             : 
    2819             : 
    2820             : 
    2821             : inline
    2822             : IntRange<unsigned short>
    2823    63164227 : Elem::node_index_range() const
    2824             : {
    2825   109811857 :   return {0, cast_int<unsigned short>(this->n_nodes())};
    2826             : }
    2827             : 
    2828             : 
    2829             : 
    2830             : inline
    2831             : IntRange<unsigned short>
    2832      384027 : Elem::edge_index_range() const
    2833             : {
    2834     1902331 :   return {0, cast_int<unsigned short>(this->n_edges())};
    2835             : }
    2836             : 
    2837             : 
    2838             : 
    2839             : inline
    2840             : IntRange<unsigned short>
    2841      294956 : Elem::face_index_range() const
    2842             : {
    2843     1186017 :   return {0, cast_int<unsigned short>(this->n_faces())};
    2844             : }
    2845             : 
    2846             : 
    2847             : 
    2848             : inline
    2849             : IntRange<unsigned short>
    2850    14378599 : Elem::side_index_range() const
    2851             : {
    2852    29974726 :   return {0, cast_int<unsigned short>(this->n_sides())};
    2853             : }
    2854             : 
    2855             : 
    2856             : 
    2857             : 
    2858             : inline
    2859             : std::unique_ptr<const Elem> Elem::side_ptr (unsigned int i) const
    2860             : {
    2861             :   // Call the non-const version of this function, return the result as
    2862             :   // a std::unique_ptr<const Elem>.
    2863             :   Elem * me = const_cast<Elem *>(this);
    2864             :   return me->side_ptr(i);
    2865             : }
    2866             : 
    2867             : 
    2868             : 
    2869             : inline
    2870             : void
    2871        1568 : Elem::side_ptr (std::unique_ptr<const Elem> & elem,
    2872             :                 const unsigned int i) const
    2873             : {
    2874             :   // Hand off to the non-const version of this function
    2875         448 :   Elem * me = const_cast<Elem *>(this);
    2876         896 :   std::unique_ptr<Elem> e {const_cast<Elem *>(elem.release())};
    2877        1568 :   me->side_ptr(e, i);
    2878        1120 :   elem = std::move(e);
    2879        1568 : }
    2880             : 
    2881             : 
    2882             : 
    2883             : inline
    2884             : std::unique_ptr<const Elem>
    2885    22715334 : Elem::build_side_ptr (const unsigned int i) const
    2886             : {
    2887             :   // Call the non-const version of this function, return the result as
    2888             :   // a std::unique_ptr<const Elem>.
    2889     2807717 :   Elem * me = const_cast<Elem *>(this);
    2890    33171509 :   return me->build_side_ptr(i);
    2891             : }
    2892             : 
    2893             : 
    2894             : 
    2895             : inline
    2896             : void
    2897     2712801 : Elem::build_side_ptr (std::unique_ptr<const Elem> & elem,
    2898             :                       const unsigned int i) const
    2899             : {
    2900             :   // Hand off to the non-const version of this function
    2901      465571 :   Elem * me = const_cast<Elem *>(this);
    2902      931142 :   std::unique_ptr<Elem> e {const_cast<Elem *>(elem.release())};
    2903     2712801 :   me->build_side_ptr(e, i);
    2904     1576017 :   elem = std::move(e);
    2905     2712801 : }
    2906             : 
    2907             : 
    2908             : 
    2909             : template <typename Sideclass, typename Subclass>
    2910             : inline
    2911             : std::unique_ptr<Elem>
    2912    83147209 : Elem::simple_build_side_ptr (const unsigned int i)
    2913             : {
    2914    50557558 :   libmesh_assert_less (i, this->n_sides());
    2915             : 
    2916    83147209 :   std::unique_ptr<Elem> face = std::make_unique<Sideclass>();
    2917   501659631 :   for (auto n : face->node_index_range())
    2918   418512422 :     face->set_node(n, this->node_ptr(Subclass::side_nodes_map[i][n]));
    2919             : 
    2920    83147209 :   face->set_interior_parent(this);
    2921    71799844 :   face->inherit_data_from(*this);
    2922             : 
    2923    83147209 :   return face;
    2924           0 : }
    2925             : 
    2926             : 
    2927             : 
    2928             : template <typename Subclass>
    2929             : inline
    2930             : void
    2931     3698603 : Elem::simple_build_side_ptr (std::unique_ptr<Elem> & side,
    2932             :                              const unsigned int i,
    2933             :                              ElemType sidetype)
    2934             : {
    2935     1194170 :   libmesh_assert_less (i, this->n_sides());
    2936             : 
    2937     3698603 :   if (!side.get() || side->type() != sidetype)
    2938             :     {
    2939      174079 :       Subclass & real_me = cast_ref<Subclass&>(*this);
    2940      736849 :       side = real_me.Subclass::build_side_ptr(i);
    2941             :     }
    2942             :   else
    2943             :     {
    2944     3243139 :       side->set_interior_parent(this);
    2945     2223596 :       side->inherit_data_from(*this);
    2946    21055716 :       for (auto n : side->node_index_range())
    2947    17812577 :         side->set_node(n, this->node_ptr(Subclass::side_nodes_map[i][n]));
    2948             :     }
    2949     3698603 : }
    2950             : 
    2951             : 
    2952             : 
    2953             : template <typename Subclass, typename Mapclass>
    2954             : inline
    2955             : void
    2956    21244440 : Elem::simple_side_ptr (std::unique_ptr<Elem> & side,
    2957             :                        const unsigned int i,
    2958             :                        ElemType sidetype)
    2959             : {
    2960     9740558 :   libmesh_assert_less (i, this->n_sides());
    2961             : 
    2962    21244440 :   if (!side.get() || side->type() != sidetype)
    2963             :     {
    2964       42656 :       Subclass & real_me = cast_ref<Subclass&>(*this);
    2965      142814 :       side = real_me.Subclass::side_ptr(i);
    2966             :     }
    2967             :   else
    2968             :     {
    2969    26092011 :       side->subdomain_id() = this->subdomain_id();
    2970             : 
    2971    77077953 :       for (auto n : side->node_index_range())
    2972    55926248 :         side->set_node(n, this->node_ptr(Mapclass::side_nodes_map[i][n]));
    2973             :     }
    2974    21244440 : }
    2975             : 
    2976             : 
    2977             : 
    2978             : inline
    2979             : std::unique_ptr<const Elem>
    2980    50742560 : Elem::build_edge_ptr (const unsigned int i) const
    2981             : {
    2982             :   // Call the non-const version of this function, return the result as
    2983             :   // a std::unique_ptr<const Elem>.
    2984    47490742 :   Elem * me = const_cast<Elem *>(this);
    2985    52856577 :   return me->build_edge_ptr(i);
    2986             : }
    2987             : 
    2988             : 
    2989             : 
    2990             : inline
    2991             : void
    2992       40880 : Elem::build_edge_ptr (std::unique_ptr<const Elem> & elem,
    2993             :                       const unsigned int i) const
    2994             : {
    2995             :   // Hand off to the non-const version of this function
    2996       17744 :   Elem * me = const_cast<Elem *>(this);
    2997       35488 :   std::unique_ptr<Elem> e {const_cast<Elem *>(elem.release())};
    2998       40880 :   me->build_edge_ptr(e, i);
    2999       31704 :   elem = std::move(e);
    3000       40880 : }
    3001             : 
    3002             : 
    3003             : template <typename Edgeclass, typename Subclass>
    3004             : inline
    3005             : std::unique_ptr<Elem>
    3006    21210955 : Elem::simple_build_edge_ptr (const unsigned int i)
    3007             : {
    3008    16611702 :   libmesh_assert_less (i, this->n_edges());
    3009             : 
    3010    21210955 :   std::unique_ptr<Elem> edge = std::make_unique<Edgeclass>();
    3011             : 
    3012    71631751 :   for (auto n : edge->node_index_range())
    3013    50420796 :     edge->set_node(n, this->node_ptr(Subclass::edge_nodes_map[i][n]));
    3014             : 
    3015    21210955 :   edge->set_interior_parent(this);
    3016    19414613 :   edge->inherit_data_from(*this);
    3017             : 
    3018    21210955 :   return edge;
    3019           0 : }
    3020             : 
    3021             : 
    3022             : 
    3023             : 
    3024             : template <typename Subclass>
    3025             : inline
    3026             : void
    3027       21476 : Elem::simple_build_edge_ptr (std::unique_ptr<Elem> & edge,
    3028             :                              const unsigned int i,
    3029             :                              ElemType edgetype)
    3030             : {
    3031        6068 :   libmesh_assert_less (i, this->n_edges());
    3032             : 
    3033       21476 :   if (!edge.get() || edge->type() != edgetype)
    3034             :     {
    3035          35 :       Subclass & real_me = cast_ref<Subclass&>(*this);
    3036         233 :       edge = real_me.Subclass::build_edge_ptr(i);
    3037             :     }
    3038             :   else
    3039             :     {
    3040       15309 :       edge->inherit_data_from(*this);
    3041       71307 :       for (auto n : edge->node_index_range())
    3042       49965 :         edge->set_node(n, this->node_ptr(Subclass::edge_nodes_map[i][n]));
    3043             :     }
    3044       21476 : }
    3045             : 
    3046             : 
    3047             : 
    3048             : inline
    3049          39 : bool Elem::on_boundary () const
    3050             : {
    3051             :   // By convention, the element is on the boundary
    3052             :   // if it has a nullptr neighbor.
    3053          78 :   return this->has_neighbor(nullptr);
    3054             : }
    3055             : 
    3056             : 
    3057             : 
    3058             : inline
    3059    12546512 : unsigned int Elem::which_neighbor_am_i (const Elem * e) const
    3060             : {
    3061    12285755 :   libmesh_assert(e);
    3062             : 
    3063    12285755 :   const Elem * eparent = e;
    3064             : 
    3065    12992802 :   while (eparent->level() > this->level())
    3066             :     {
    3067      434196 :       eparent = eparent->parent();
    3068      424178 :       libmesh_assert(eparent);
    3069             :     }
    3070             : 
    3071    31612173 :   for (auto s : make_range(this->n_sides()))
    3072    31612173 :     if (this->neighbor_ptr(s) == eparent)
    3073    12285755 :       return s;
    3074             : 
    3075           0 :   return libMesh::invalid_uint;
    3076             : }
    3077             : 
    3078             : 
    3079             : 
    3080             : inline
    3081   207618018 : bool Elem::active() const
    3082             : {
    3083             : #ifdef LIBMESH_ENABLE_AMR
    3084   542934862 :   if ((this->refinement_flag() == INACTIVE) ||
    3085   139659679 :       (this->refinement_flag() == COARSEN_INACTIVE))
    3086    68084617 :     return false;
    3087             :   else
    3088   139533401 :     return true;
    3089             : #else
    3090             :   return true;
    3091             : #endif
    3092             : }
    3093             : 
    3094             : 
    3095             : 
    3096             : 
    3097             : 
    3098             : inline
    3099    85318685 : bool Elem::subactive() const
    3100             : {
    3101             : #ifdef LIBMESH_ENABLE_AMR
    3102    67720454 :   if (this->active())
    3103    50470069 :     return false;
    3104    17250385 :   if (!this->has_children())
    3105     5489236 :     return true;
    3106    19160227 :   for (const Elem * my_ancestor = this->parent();
    3107    57840818 :        my_ancestor != nullptr;
    3108    38181439 :        my_ancestor = my_ancestor->parent())
    3109    34091509 :     if (my_ancestor->active())
    3110       10516 :       return true;
    3111             : #endif
    3112             : 
    3113    11750633 :   return false;
    3114             : }
    3115             : 
    3116             : 
    3117             : 
    3118             : inline
    3119    76344485 : bool Elem::has_children() const
    3120             : {
    3121             : #ifdef LIBMESH_ENABLE_AMR
    3122    86271526 :   if (!_children)
    3123    12481461 :     return false;
    3124             :   else
    3125    63863024 :     return true;
    3126             : #else
    3127             :   return false;
    3128             : #endif
    3129             : }
    3130             : 
    3131             : 
    3132             : inline
    3133             : bool Elem::has_ancestor_children() const
    3134             : {
    3135             : #ifdef LIBMESH_ENABLE_AMR
    3136             :   if (!_children)
    3137             :     return false;
    3138             :   else
    3139             :     for (auto & c : child_ref_range())
    3140             :       if (c.has_children())
    3141             :         return true;
    3142             : #endif
    3143             :   return false;
    3144             : }
    3145             : 
    3146             : 
    3147             : 
    3148             : inline
    3149        1630 : bool Elem::is_ancestor_of(const Elem *
    3150             : #ifdef LIBMESH_ENABLE_AMR
    3151             :                           descendant
    3152             : #endif
    3153             :                           ) const
    3154             : {
    3155             : #ifdef LIBMESH_ENABLE_AMR
    3156        1630 :   const Elem * e = descendant;
    3157        2096 :   while (e)
    3158             :     {
    3159        2096 :       if (this == e)
    3160        1630 :         return true;
    3161         466 :       e = e->parent();
    3162             :     }
    3163             : #endif
    3164           0 :   return false;
    3165             : }
    3166             : 
    3167             : 
    3168             : 
    3169             : inline
    3170  1673645923 : const Elem * Elem::parent () const
    3171             : {
    3172  1816359890 :   return _elemlinks[0];
    3173             : }
    3174             : 
    3175             : 
    3176             : 
    3177             : inline
    3178   124611683 : Elem * Elem::parent ()
    3179             : {
    3180   448110099 :   return _elemlinks[0];
    3181             : }
    3182             : 
    3183             : 
    3184             : 
    3185             : inline
    3186     1726792 : void Elem::set_parent (Elem * p)
    3187             : {
    3188             :   // We no longer support using parent() as interior_parent()
    3189     1726792 :   libmesh_assert_equal_to(this->dim(), p ? p->dim() : this->dim());
    3190     2357697 :   _elemlinks[0] = p;
    3191     1756740 : }
    3192             : 
    3193             : 
    3194             : 
    3195             : inline
    3196     1282383 : const Elem * Elem::top_parent () const
    3197             : {
    3198     1282383 :   const Elem * tp = this;
    3199             : 
    3200             :   // Keep getting the element's parent
    3201             :   // until that parent is at level-0
    3202     5115424 :   while (tp->parent() != nullptr)
    3203     3220691 :     tp = tp->parent();
    3204             : 
    3205     1282383 :   libmesh_assert(tp);
    3206     1282383 :   libmesh_assert_equal_to (tp->level(), 0);
    3207             : 
    3208     1282383 :   return tp;
    3209             : }
    3210             : 
    3211             : 
    3212             : 
    3213             : inline
    3214   668042881 : unsigned int Elem::level() const
    3215             : {
    3216             : #ifdef LIBMESH_ENABLE_AMR
    3217             : 
    3218             :   // if I don't have a parent I was
    3219             :   // created directly from file
    3220             :   // or by the user, so I am a
    3221             :   // level-0 element
    3222   948141501 :   if (this->parent() == nullptr)
    3223   148986463 :     return 0;
    3224             : 
    3225             :   // if the parent and this element are of different
    3226             :   // dimensionality we are at the same level as
    3227             :   // the parent (e.g. we are the 2D side of a
    3228             :   // 3D element)
    3229   698743837 :   if (this->dim() != this->parent()->dim())
    3230           0 :     return this->parent()->level();
    3231             : 
    3232             :   // otherwise we are at a level one
    3233             :   // higher than our parent
    3234   831554664 :   return (this->parent()->level() + 1);
    3235             : 
    3236             : #else
    3237             : 
    3238             :   // Without AMR all elements are
    3239             :   // at level 0.
    3240             :   return 0;
    3241             : 
    3242             : #endif
    3243             : }
    3244             : 
    3245             : 
    3246             : 
    3247             : inline
    3248  2374575339 : unsigned int Elem::p_level() const
    3249             : {
    3250             : #ifdef LIBMESH_ENABLE_AMR
    3251 16183383186 :   return _p_level;
    3252             : #else
    3253             :   return 0;
    3254             : #endif
    3255             : }
    3256             : 
    3257             : 
    3258             : 
    3259             : inline
    3260   133819984 : ElemMappingType Elem::mapping_type () const
    3261             : {
    3262   328251956 :   return static_cast<ElemMappingType>(_map_type);
    3263             : }
    3264             : 
    3265             : 
    3266             : 
    3267             : inline
    3268    73414242 : void Elem::set_mapping_type(const ElemMappingType type)
    3269             : {
    3270   117720835 :   _map_type = cast_int<unsigned char>(type);
    3271    73414242 : }
    3272             : 
    3273             : 
    3274             : 
    3275             : inline
    3276    54172520 : unsigned char Elem::mapping_data () const
    3277             : {
    3278    68090039 :   return _map_data;
    3279             : }
    3280             : 
    3281             : 
    3282             : 
    3283             : inline
    3284    73414235 : void Elem::set_mapping_data(const unsigned char data)
    3285             : {
    3286   117703978 :   _map_data = data;
    3287    73433209 : }
    3288             : 
    3289             : 
    3290             : 
    3291             : #ifdef LIBMESH_ENABLE_AMR
    3292             : 
    3293             : inline
    3294           0 : const Elem * Elem::raw_child_ptr (unsigned int i) const
    3295             : {
    3296           0 :   if (!_children)
    3297           0 :     return nullptr;
    3298             : 
    3299           0 :   return _children[i];
    3300             : }
    3301             : 
    3302             : inline
    3303   159577744 : const Elem * Elem::child_ptr (unsigned int i) const
    3304             : {
    3305   159577744 :   libmesh_assert(_children);
    3306   159577744 :   libmesh_assert(_children[i]);
    3307             : 
    3308   180076459 :   return _children[i];
    3309             : }
    3310             : 
    3311             : inline
    3312     3062856 : Elem * Elem::child_ptr (unsigned int i)
    3313             : {
    3314     3062856 :   libmesh_assert(_children);
    3315     3062856 :   libmesh_assert(_children[i]);
    3316             : 
    3317     6344995 :   return _children[i];
    3318             : }
    3319             : 
    3320             : 
    3321             : inline
    3322     1765084 : void Elem::set_child (unsigned int c, Elem * elem)
    3323             : {
    3324     1765084 :   libmesh_assert (this->has_children());
    3325             : 
    3326     1956392 :   _children[c] = elem;
    3327     1765756 : }
    3328             : 
    3329             : 
    3330             : 
    3331             : inline
    3332    52415072 : unsigned int Elem::which_child_am_i (const Elem * e) const
    3333             : {
    3334    48583755 :   libmesh_assert(e);
    3335    48583755 :   libmesh_assert (this->has_children());
    3336             : 
    3337    52415072 :   unsigned int nc = this->n_children();
    3338   146902555 :   for (unsigned int c=0; c != nc; c++)
    3339   146902555 :     if (this->child_ptr(c) == e)
    3340    48583755 :       return c;
    3341             : 
    3342           0 :   libmesh_error_msg("ERROR:  which_child_am_i() was called with a non-child!");
    3343             : 
    3344             :   return libMesh::invalid_uint;
    3345             : }
    3346             : 
    3347             : 
    3348             : 
    3349             : inline
    3350   370955753 : Elem::RefinementState Elem::refinement_flag () const
    3351             : {
    3352   631408543 :   return static_cast<RefinementState>(_rflag);
    3353             : }
    3354             : 
    3355             : 
    3356             : 
    3357             : inline
    3358     4674247 : void Elem::set_refinement_flag(RefinementState rflag)
    3359             : {
    3360     9461520 :   _rflag = cast_int<unsigned char>(rflag);
    3361     5333544 : }
    3362             : 
    3363             : 
    3364             : 
    3365             : inline
    3366    94397799 : Elem::RefinementState Elem::p_refinement_flag () const
    3367             : {
    3368   112738713 :   return static_cast<RefinementState>(_pflag);
    3369             : }
    3370             : 
    3371             : 
    3372             : 
    3373             : inline
    3374     3990987 : void Elem::set_p_refinement_flag(RefinementState pflag)
    3375             : {
    3376     3990930 :   if (this->p_level() == 0)
    3377     3983446 :     libmesh_assert_not_equal_to
    3378             :       (pflag, Elem::JUST_REFINED);
    3379             : 
    3380     7158303 :   _pflag = cast_int<unsigned char>(pflag);
    3381     6114047 : }
    3382             : 
    3383             : 
    3384             : 
    3385             : inline
    3386           0 : unsigned int Elem::max_descendant_p_level () const
    3387             : {
    3388             :   // This is undefined for subactive elements,
    3389             :   // which have no active descendants
    3390           0 :   libmesh_assert (!this->subactive());
    3391           0 :   if (this->active())
    3392           0 :     return this->p_level();
    3393             : 
    3394           0 :   unsigned int max_p_level = _p_level;
    3395           0 :   for (auto & c : child_ref_range())
    3396           0 :     max_p_level = std::max(max_p_level,
    3397           0 :                            c.max_descendant_p_level());
    3398           0 :   return max_p_level;
    3399             : }
    3400             : 
    3401             : 
    3402             : 
    3403             : inline
    3404    73326963 : void Elem::hack_p_level(unsigned int p)
    3405             : {
    3406    73326963 :   if (p == 0)
    3407    73193044 :     libmesh_assert_not_equal_to
    3408             :       (this->p_refinement_flag(), Elem::JUST_REFINED);
    3409             : 
    3410   117617581 :   _p_level = cast_int<unsigned char>(p);
    3411   100847830 : }
    3412             : 
    3413             : 
    3414             : inline
    3415        4126 : void Elem::hack_p_level_and_refinement_flag (unsigned int p,
    3416             :                                              RefinementState pflag)
    3417             : {
    3418       12373 :   _pflag = cast_int<unsigned char>(pflag);
    3419        4126 :   this->hack_p_level(p);
    3420        8247 : }
    3421             : 
    3422             : #endif // ifdef LIBMESH_ENABLE_AMR
    3423             : 
    3424             : 
    3425             : inline
    3426       20238 : void Elem::orient(BoundaryInfo * boundary_info)
    3427             : {
    3428       33526 :   if (this->is_flipped())
    3429       16773 :     this->flip(boundary_info);
    3430       20238 : }
    3431             : 
    3432             : 
    3433             : inline
    3434       92284 : dof_id_type Elem::compute_key (dof_id_type n0)
    3435             : {
    3436       92284 :   return n0;
    3437             : }
    3438             : 
    3439             : 
    3440             : 
    3441             : inline
    3442     9614468 : dof_id_type Elem::compute_key (dof_id_type n0,
    3443             :                                dof_id_type n1)
    3444             : {
    3445             :   // Order the two so that n0 < n1
    3446    11986436 :   if (n0 > n1) std::swap (n0, n1);
    3447             : 
    3448    11986436 :   return Utility::hashword2(n0, n1);
    3449             : }
    3450             : 
    3451             : 
    3452             : 
    3453             : inline
    3454     8369488 : dof_id_type Elem::compute_key (dof_id_type n0,
    3455             :                                dof_id_type n1,
    3456             :                                dof_id_type n2)
    3457             : {
    3458     8369488 :   std::array<dof_id_type, 3> array = {{n0, n1, n2}};
    3459     3775760 :   std::sort(array.begin(), array.end());
    3460    12145248 :   return Utility::hashword(array);
    3461             : }
    3462             : 
    3463             : 
    3464             : 
    3465             : inline
    3466     4709676 : dof_id_type Elem::compute_key (dof_id_type n0,
    3467             :                                dof_id_type n1,
    3468             :                                dof_id_type n2,
    3469             :                                dof_id_type n3)
    3470             : {
    3471     4709676 :   std::array<dof_id_type, 4> array = {{n0, n1, n2, n3}};
    3472     2141546 :   std::sort(array.begin(), array.end());
    3473     6851222 :   return Utility::hashword(array);
    3474             : }
    3475             : 
    3476             : 
    3477             : 
    3478             : inline
    3479    97086012 : void Elem::inherit_data_from (const Elem & src)
    3480             : {
    3481    85852099 :   this->set_mapping_type(src.mapping_type());
    3482    85852099 :   this->set_mapping_data(src.mapping_data());
    3483   112266681 :   this->subdomain_id() = src.subdomain_id();
    3484    85852099 :   this->processor_id(src.processor_id());
    3485             : #ifdef LIBMESH_ENABLE_AMR
    3486   112266681 :   this->set_p_level(src.p_level());
    3487             : #endif
    3488    97086012 : }
    3489             : 
    3490             : 
    3491             : 
    3492             : /**
    3493             :  * The definition of the protected nested SideIter class.
    3494             :  */
    3495           0 : class Elem::SideIter
    3496             : {
    3497             : public:
    3498             :   // Constructor with arguments.
    3499           0 :   SideIter(const unsigned int side_number,
    3500             :            Elem * parent)
    3501           0 :     : _side(),
    3502           0 :       _side_ptr(nullptr),
    3503           0 :       _parent(parent),
    3504           0 :       _side_number(side_number)
    3505           0 :   {}
    3506             : 
    3507             : 
    3508             :   // Empty constructor.
    3509             :   SideIter()
    3510             :     : _side(),
    3511             :       _side_ptr(nullptr),
    3512             :       _parent(nullptr),
    3513             :       _side_number(libMesh::invalid_uint)
    3514             :   {}
    3515             : 
    3516             : 
    3517             :   // Copy constructor
    3518           0 :   SideIter(const SideIter & other)
    3519           0 :     : _side(),
    3520           0 :       _side_ptr(nullptr),
    3521           0 :       _parent(other._parent),
    3522           0 :       _side_number(other._side_number)
    3523           0 :   {}
    3524             : 
    3525             : 
    3526             :   // op=
    3527             :   SideIter & operator=(const SideIter & other)
    3528             :   {
    3529             :     this->_parent      = other._parent;
    3530             :     this->_side_number = other._side_number;
    3531             :     return *this;
    3532             :   }
    3533             : 
    3534             :   // unary op*
    3535           0 :   Elem *& operator*() const
    3536             :   {
    3537             :     // Set the std::unique_ptr
    3538           0 :     this->_update_side_ptr();
    3539             : 
    3540             :     // Return a reference to _side_ptr
    3541           0 :     return this->_side_ptr;
    3542             :   }
    3543             : 
    3544             :   // op++
    3545           0 :   SideIter & operator++()
    3546             :   {
    3547           0 :     ++_side_number;
    3548           0 :     return *this;
    3549             :   }
    3550             : 
    3551             :   // op==  Two side iterators are equal if they have
    3552             :   // the same side number and the same parent element.
    3553           0 :   bool operator == (const SideIter & other) const
    3554             :   {
    3555           0 :     return (this->_side_number == other._side_number &&
    3556           0 :             this->_parent      == other._parent);
    3557             :   }
    3558             : 
    3559             : 
    3560             :   // Consults the parent Elem to determine if the side
    3561             :   // is a boundary side.  Note: currently side N is a
    3562             :   // boundary side if neighbor N is nullptr.  Be careful,
    3563             :   // this could possibly change in the future?
    3564           0 :   bool side_on_boundary() const
    3565             :   {
    3566           0 :     return this->_parent->neighbor_ptr(_side_number) == nullptr;
    3567             :   }
    3568             : 
    3569             : private:
    3570             :   // Update the _side pointer by building the correct side.
    3571             :   // This has to be called before dereferencing.
    3572           0 :   void _update_side_ptr() const
    3573             :   {
    3574             :     // Construct new side, store in std::unique_ptr
    3575           0 :     this->_side = this->_parent->build_side_ptr(this->_side_number);
    3576             : 
    3577             :     // Also set our internal naked pointer.  Memory is still owned
    3578             :     // by the std::unique_ptr.
    3579           0 :     this->_side_ptr = _side.get();
    3580           0 :   }
    3581             : 
    3582             :   // std::unique_ptr to the actual side, handles memory management for
    3583             :   // the sides which are created during the course of iteration.
    3584             :   mutable std::unique_ptr<Elem> _side;
    3585             : 
    3586             :   // Raw pointer needed to facilitate passing back to the user a
    3587             :   // reference to a non-temporary raw pointer in order to conform to
    3588             :   // the variant_filter_iterator interface.  It points to the same
    3589             :   // thing the std::unique_ptr "_side" above holds.  What happens if the user
    3590             :   // calls delete on the pointer passed back?  Well, this is an issue
    3591             :   // which is not addressed by the iterators in libMesh.  Basically it
    3592             :   // is a bad idea to ever call delete on an iterator from the library.
    3593             :   mutable Elem * _side_ptr;
    3594             : 
    3595             :   // Pointer to the parent Elem class which generated this iterator
    3596             :   Elem * _parent;
    3597             : 
    3598             :   // A counter variable which keeps track of the side number
    3599             :   unsigned int _side_number;
    3600             : };
    3601             : 
    3602             : 
    3603             : 
    3604             : 
    3605             : 
    3606             : 
    3607             : // Private implementation functions in the Elem class for the side iterators.
    3608             : // They have to come after the definition of the SideIter class.
    3609             : inline
    3610           0 : Elem::SideIter Elem::_first_side()
    3611             : {
    3612           0 :   return SideIter(0, this);
    3613             : }
    3614             : 
    3615             : 
    3616             : 
    3617             : inline
    3618           0 : Elem::SideIter Elem::_last_side()
    3619             : {
    3620           0 :   return SideIter(this->n_neighbors(), this);
    3621             : }
    3622             : 
    3623             : 
    3624             : 
    3625             : 
    3626             : /**
    3627             :  * The definition of the struct used for iterating over sides.
    3628             :  */
    3629             : struct
    3630             : Elem::side_iterator : variant_filter_iterator<Elem::Predicate, Elem *>
    3631             : {
    3632             :   // Templated forwarding ctor -- forwards to appropriate variant_filter_iterator ctor
    3633             :   template <typename PredType, typename IterType>
    3634           0 :   side_iterator (const IterType & d,
    3635             :                  const IterType & e,
    3636             :                  const PredType & p ) :
    3637           0 :     variant_filter_iterator<Elem::Predicate, Elem *>(d,e,p) {}
    3638             : };
    3639             : 
    3640             : 
    3641             : 
    3642             : inline
    3643     6942531 : SimpleRange<Elem::NeighborPtrIter> Elem::neighbor_ptr_range()
    3644             : {
    3645    10291077 :   return {_elemlinks+1, _elemlinks + 1 + this->n_neighbors()};
    3646             : }
    3647             : 
    3648             : 
    3649             : inline
    3650     5878910 : SimpleRange<Elem::ConstNeighborPtrIter> Elem::neighbor_ptr_range() const
    3651             : {
    3652     7435063 :   return {_elemlinks+1, _elemlinks + 1 + this->n_neighbors()};
    3653             : }
    3654             : 
    3655             : } // namespace libMesh
    3656             : 
    3657             : 
    3658             : // Helper function for default caches in Elem subclasses
    3659             : 
    3660             : #define LIBMESH_ENABLE_TOPOLOGY_CACHES                                  \
    3661             :   virtual                                                               \
    3662             :   std::vector<std::vector<std::vector<std::vector<std::pair<unsigned char, unsigned char>>>>> & \
    3663             :   _get_bracketing_node_cache() const override                   \
    3664             :   {                                                                     \
    3665             :     static std::vector<std::vector<std::vector<std::vector<std::pair<unsigned char, unsigned char>>>>> c; \
    3666             :     return c;                                                           \
    3667             :   }                                                                     \
    3668             :                                                                         \
    3669             :   virtual                                                               \
    3670             :   std::vector<std::vector<std::vector<signed char>>> &                  \
    3671             :   _get_parent_indices_cache() const override                    \
    3672             :   {                                                                     \
    3673             :     static std::vector<std::vector<std::vector<signed char>>> c;        \
    3674             :     return c;                                                           \
    3675             :   }
    3676             : 
    3677             : 
    3678             : 
    3679             : 
    3680             : 
    3681             : 
    3682             : #endif // LIBMESH_ELEM_H

Generated by: LCOV version 1.14