libMesh
Loading...
Searching...
No Matches
elem.h
Go to the documentation of this file.
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
48namespace libMesh
49{
50
51// Forward declarations
52class BoundaryInfo;
53class Elem;
54class MeshBase;
55class MeshRefinement;
56#ifdef LIBMESH_ENABLE_PERIODIC
57class PeriodicBoundaries;
58class PointLocatorBase;
59#endif
60template <class SideType, class ParentType>
61class Side;
62enum ElemQuality : int;
63enum IOPackage : int;
64enum Order : int;
65
66
94class Elem : public ReferenceCountedObject<Elem>,
95 public DofObject
96{
97protected:
98
105 Elem (const unsigned int n_nodes,
106 const unsigned int n_sides,
107 Elem * parent,
108 Elem ** elemlinkdata,
109 Node ** nodelinkdata);
110
111public:
122 Elem (Elem &&) = delete;
123 Elem (const Elem &) = delete;
124 Elem & operator= (const Elem &) = delete;
125 Elem & operator= (Elem &&) = delete;
126
130 virtual ~Elem() = default;
131
135 const Point & point (const unsigned int i) const;
136
141 Point & point (const unsigned int i);
142
147 virtual Point master_point (const unsigned int i) const = 0;
148
152 dof_id_type node_id (const unsigned int i) const;
153
158 unsigned int local_node (const dof_id_type i) const;
159
164 unsigned int get_node_index (const Node * node_ptr) const;
165
169 const Node * const * get_nodes () const;
170
174 const Node * node_ptr (const unsigned int i) const;
175
179 Node * node_ptr (const unsigned int i);
180
184 const Node & node_ref (const unsigned int i) const;
185
189 Node & node_ref (const unsigned int i);
190
191#ifdef LIBMESH_ENABLE_DEPRECATED
200 virtual Node * & set_node (const unsigned int i);
201#endif // LIBMESH_ENABLE_DEPRECATED
202
206 virtual void set_node (const unsigned int i,
207 Node * node);
208
212 class NodeRefIter;
213 class ConstNodeRefIter;
214
223
225
230
236
246 = std::numeric_limits<subdomain_id_type>::max();
247
254 virtual bool runtime_topology() const { return false; }
255
268 const Elem * reference_elem () const;
269
274 virtual dof_id_type key (const unsigned int s) const = 0;
275
282 virtual dof_id_type low_order_key (const unsigned int s) const = 0;
283
290 virtual dof_id_type key () const;
291
298 bool operator == (const Elem & rhs) const;
299
304 bool operator != (const Elem & rhs) const;
305
313 bool topologically_equal (const Elem & rhs) const;
314
324 const Elem * neighbor_ptr (unsigned int i) const;
325
329 Elem * neighbor_ptr (unsigned int i);
330
334 typedef Elem * const * NeighborPtrIter;
335 typedef const Elem * const * ConstNeighborPtrIter;
336
346
348
349#ifdef LIBMESH_ENABLE_PERIODIC
356 const Elem * topological_neighbor (const unsigned int i,
357 const MeshBase & mesh,
358 const PointLocatorBase & point_locator,
359 const PeriodicBoundaries * pb) const;
360
367 Elem * topological_neighbor (const unsigned int i,
368 MeshBase & mesh,
369 const PointLocatorBase & point_locator,
370 const PeriodicBoundaries * pb);
371
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
385 void set_neighbor (const unsigned int i, Elem * n);
386
391 bool has_neighbor (const Elem * elem) const;
392
397 Elem * child_neighbor (Elem * elem);
398
403 const Elem * child_neighbor (const Elem * elem) const;
404
410 bool on_boundary () const;
411
421 bool is_semilocal (const processor_id_type my_pid) const;
422
428 unsigned int which_neighbor_am_i(const Elem * e) const;
429
446 unsigned int which_side_am_i(const Elem * e) const;
447
458 virtual unsigned int local_side_node(unsigned int side,
459 unsigned int side_node) const = 0;
460
468 virtual unsigned int local_edge_node(unsigned int edge,
469 unsigned int edge_node) const = 0;
470
478 static unsigned int local_side_node(ElemType t,
479 unsigned int side,
480 unsigned int side_node);
481
488 static unsigned int local_edge_node(ElemType t,
489 unsigned int edge,
490 unsigned int edge_node);
491
499 bool contains_vertex_of(const Elem * e, bool mesh_connection=false) const;
500
506 bool contains_edge_of(const Elem * e) const;
507
524 void find_point_neighbors(const Point & p,
525 std::set<const Elem *> & neighbor_set) const;
526
532 void find_point_neighbors(std::set<const Elem *> & neighbor_set) const;
533
539 void find_point_neighbors(std::set<const Elem *> & neighbor_set,
540 const Elem * start_elem) const;
541
545 void find_point_neighbors(std::set<Elem *> & neighbor_set,
546 Elem * start_elem);
547
553 void find_edge_neighbors(const Point & p1,
554 const Point & p2,
555 std::set<const Elem *> & neighbor_set) const;
556
565 void find_edge_neighbors(std::set<const Elem *> & neighbor_set) const;
566
572 void find_interior_neighbors(std::set<const Elem *> & neighbor_set) const;
573
578 void find_interior_neighbors(std::set<Elem *> & neighbor_set);
579
587 void remove_links_to_me ();
588
597
604 void make_links_to_me_local (unsigned int n, unsigned int neighbor_side);
605
617 virtual bool is_remote () const
618 { return false; }
619
624 virtual void connectivity(const unsigned int sc,
625 const IOPackage iop,
626 std::vector<dof_id_type> & conn) const = 0;
627
633 void write_connectivity (std::ostream & out,
634 const IOPackage iop) const;
635
640 virtual ElemType type () const = 0;
641
649 static const unsigned int type_to_dim_map[INVALID_ELEM];
650
654 virtual unsigned short dim () const = 0;
655
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 };
725
729 virtual unsigned int n_nodes () const = 0;
730
735 static const unsigned int max_n_nodes = 27;
736
742
748 virtual unsigned int n_nodes_in_child (unsigned int /*c*/) const
749 { return this->n_nodes(); }
750
759 static const unsigned int type_to_n_sides_map[INVALID_ELEM];
760
766 virtual unsigned int n_sides () const = 0;
767
771 virtual ElemType side_type (const unsigned int s) const = 0;
772
779 static ElemType side_type (const ElemType t,
780 const unsigned int s);
781
789 static ElemType edge_type (const ElemType t);
790
795 virtual Point side_vertex_average_normal(const unsigned int s) const;
796
802
812 unsigned int n_neighbors () const
813 { return this->n_sides(); }
814
819 virtual unsigned int n_vertices () const = 0;
820
825 virtual unsigned int n_edges () const = 0;
826
832
841 static const unsigned int type_to_n_edges_map[INVALID_ELEM];
842
847 virtual unsigned int n_faces () const = 0;
848
854
859 virtual unsigned int n_children () const = 0;
860
864 virtual bool is_vertex(const unsigned int i) const = 0;
865
872 virtual bool is_vertex_on_child (unsigned int /*c*/,
873 unsigned int n) const
874 { return this->is_vertex(n); }
875
880 virtual bool is_vertex_on_parent(unsigned int c,
881 unsigned int n) const;
882
887 virtual bool is_edge(const unsigned int i) const = 0;
888
894 virtual bool is_face(const unsigned int i) const = 0;
895
899 bool is_internal(const unsigned int i) const;
900
905 virtual bool is_node_on_side(const unsigned int n,
906 const unsigned int s) const = 0;
907
911 virtual std::vector<unsigned int> nodes_on_side(const unsigned int /*s*/) const = 0;
912
916 virtual std::vector<unsigned int> nodes_on_edge(const unsigned int /*e*/) const = 0;
917
921 virtual std::vector<unsigned int> sides_on_edge(const unsigned int /*e*/) const = 0;
922
926 virtual std::vector<unsigned int> edges_adjacent_to_node(const unsigned int /*n*/) const = 0;
927
932 virtual bool is_node_on_edge(const unsigned int n,
933 const unsigned int e) const = 0;
934
938 virtual bool is_edge_on_side(const unsigned int e,
939 const unsigned int s) const = 0;
940
945 virtual unsigned int opposite_side(const unsigned int s) const;
946
952 virtual unsigned int opposite_node(const unsigned int n,
953 const unsigned int s) const;
954
960 virtual unsigned int n_sub_elem () const = 0;
961
978 virtual std::unique_ptr<Elem> side_ptr (unsigned int i) = 0;
979 std::unique_ptr<const Elem> side_ptr (unsigned int i) const;
980
995 virtual void side_ptr (std::unique_ptr<Elem> & side, const unsigned int i) = 0;
996 void side_ptr (std::unique_ptr<const Elem> & side, const unsigned int i) const;
997
1018 virtual std::unique_ptr<Elem> build_side_ptr (const unsigned int i) = 0;
1019 std::unique_ptr<const Elem> build_side_ptr (const unsigned int i) const;
1020
1021#ifdef LIBMESH_ENABLE_DEPRECATED
1022 /*
1023 * Older versions of libMesh supported a "proxy" option here.
1024 */
1025 virtual std::unique_ptr<Elem> build_side_ptr (const unsigned int i, bool proxy)
1026 { if (proxy) libmesh_error(); libmesh_deprecated(); return this->build_side_ptr(i); }
1027
1028 std::unique_ptr<const Elem> build_side_ptr (const unsigned int i, bool proxy) const
1029 { if (proxy) libmesh_error(); libmesh_deprecated(); return this->build_side_ptr(i); }
1030#endif
1031
1046 virtual void build_side_ptr (std::unique_ptr<Elem> & side, const unsigned int i) = 0;
1047 void build_side_ptr (std::unique_ptr<const Elem> & side, const unsigned int i) const;
1048
1062 virtual std::unique_ptr<Elem> build_edge_ptr (const unsigned int i) = 0;
1063 std::unique_ptr<const Elem> build_edge_ptr (const unsigned int i) const;
1064
1079 virtual void build_edge_ptr (std::unique_ptr<Elem> & edge, const unsigned int i) = 0;
1080 void build_edge_ptr (std::unique_ptr<const Elem> & edge, const unsigned int i) const;
1081
1090
1096 virtual Order default_order () const = 0;
1097
1103 virtual Order supported_nodal_order() const { return default_order(); }
1104
1110 virtual Order default_side_order () const { return default_order(); }
1111
1126 virtual Point true_centroid () const;
1127
1136 Point vertex_average () const;
1137
1145 virtual Point quasicircumcenter () const
1146 { libmesh_not_implemented(); }
1147
1151 virtual Real hmin () const;
1152
1156 virtual Real hmax () const;
1157
1165 virtual Real volume () const;
1166
1177 virtual BoundingBox loose_bounding_box () const;
1178
1198 virtual Real quality (const ElemQuality q) const;
1199
1208 virtual std::pair<Real,Real> qual_bounds (const ElemQuality) const
1209 { libmesh_not_implemented(); return std::make_pair(0.,0.); }
1210
1226 virtual bool contains_point (const Point & p, Real tol=TOLERANCE) const;
1227
1236 virtual bool on_reference_element(const Point & p,
1237 const Real eps = TOLERANCE) const = 0;
1238
1243 virtual bool close_to_point(const Point & p, Real tol) const;
1244
1250 bool positive_edge_orientation(const unsigned int i) const;
1251
1259 bool positive_face_orientation(const unsigned int i) const;
1260
1272 unsigned int face_orientation(const unsigned int i) const;
1273
1281 std::vector<unsigned int> oriented_face_vertices(const unsigned int i) const;
1282
1288 bool relative_edge_face_order(const unsigned int e, const unsigned int s) const;
1289
1296 void inherit_data_from(const Elem & src);
1297
1298private:
1305 bool point_test(const Point & p, Real box_tol, Real map_tol) const;
1306
1307public:
1312 virtual bool has_affine_map () const { return false; }
1313
1322 virtual bool has_invertible_map(Real tol = TOLERANCE*TOLERANCE) const;
1323
1328 virtual bool is_linear () const { return false; }
1329
1333 void print_info (std::ostream & os=libMesh::out) const;
1334
1338 std::string get_info () const;
1339
1346 bool active () const;
1347
1353 bool ancestor () const;
1354
1359 bool subactive () const;
1360
1365 bool has_children () const;
1366
1371 bool has_ancestor_children () const;
1372
1378 bool is_ancestor_of(const Elem * descendant) const;
1379
1384 const Elem * parent () const;
1385
1390 Elem * parent ();
1391
1396 void set_parent (Elem * p);
1397
1405 const Elem * top_parent () const;
1406
1421 const Elem * interior_parent () const;
1422
1423 Elem * interior_parent ();
1424
1429 void set_interior_parent (Elem * p);
1430
1436 Real length (const unsigned int n1,
1437 const unsigned int n2) const;
1438
1449 virtual unsigned int n_second_order_adjacent_vertices (const unsigned int n) const;
1450
1459 virtual unsigned short int second_order_adjacent_vertex (const unsigned int n,
1460 const unsigned int v) const;
1461
1477 virtual std::pair<unsigned short int, unsigned short int>
1478 second_order_child_vertex (const unsigned int n) const;
1479
1494 const bool full_ordered=true);
1495
1504
1518
1526 unsigned int level () const;
1527
1533 unsigned int p_level () const;
1534
1538 virtual bool is_child_on_side(const unsigned int c,
1539 const unsigned int s) const = 0;
1540
1545
1550
1554 unsigned char mapping_data () const;
1555
1559 void set_mapping_data (const unsigned char data);
1560
1561
1562#ifdef LIBMESH_ENABLE_AMR
1563
1575
1580 const Elem * raw_child_ptr (unsigned int i) const;
1581
1586 const Elem * child_ptr (unsigned int i) const;
1587
1592 Elem * child_ptr (unsigned int i);
1593
1598 class ChildRefIter;
1599 class ConstChildRefIter;
1600
1609
1611
1612private:
1617 void set_child (unsigned int c, Elem * elem);
1618
1619public:
1626 unsigned int which_child_am_i(const Elem * e) const;
1627
1631 virtual bool is_child_on_edge(const unsigned int c,
1632 const unsigned int e) const;
1633
1640 void add_child (Elem * elem);
1641
1648 void add_child (Elem * elem, unsigned int c);
1649
1653 void replace_child (Elem * elem, unsigned int c);
1654
1666 void family_tree (std::vector<const Elem *> & family,
1667 bool reset = true) const;
1668
1672 void family_tree (std::vector<Elem *> & family,
1673 bool reset = true);
1674
1679 void total_family_tree (std::vector<const Elem *> & family,
1680 bool reset = true) const;
1681
1685 void total_family_tree (std::vector<Elem *> & family,
1686 bool reset = true);
1687
1694 void active_family_tree (std::vector<const Elem *> & active_family,
1695 bool reset = true) const;
1696
1700 void active_family_tree (std::vector<Elem *> & active_family,
1701 bool reset = true);
1702
1707 void family_tree_by_side (std::vector<const Elem *> & family,
1708 unsigned int side,
1709 bool reset = true) const;
1710
1714 void family_tree_by_side (std::vector<Elem *> & family,
1715 unsigned int side,
1716 bool reset = true);
1717
1722 void total_family_tree_by_side (std::vector<const Elem *> & family,
1723 unsigned int side,
1724 bool reset = true) const;
1725
1729 void total_family_tree_by_side (std::vector<Elem *> & family,
1730 unsigned int side,
1731 bool reset = true);
1732
1737 void active_family_tree_by_side (std::vector<const Elem *> & family,
1738 unsigned int side,
1739 bool reset = true) const;
1740
1744 void active_family_tree_by_side (std::vector<Elem *> & family,
1745 unsigned int side,
1746 bool reset = true);
1747
1752 void family_tree_by_neighbor (std::vector<const Elem *> & family,
1753 const Elem * neighbor,
1754 bool reset = true) const;
1755
1759 void family_tree_by_neighbor (std::vector<Elem *> & family,
1760 Elem * neighbor,
1761 bool reset = true);
1762
1767 void total_family_tree_by_neighbor (std::vector<const Elem *> & family,
1768 const Elem * neighbor,
1769 bool reset = true) const;
1770
1774 void total_family_tree_by_neighbor (std::vector<Elem *> & family,
1775 Elem * neighbor,
1776 bool reset = true);
1777
1784 void family_tree_by_subneighbor (std::vector<const Elem *> & family,
1785 const Elem * neighbor,
1786 const Elem * subneighbor,
1787 bool reset = true) const;
1788
1792 void family_tree_by_subneighbor (std::vector<Elem *> & family,
1793 Elem * neighbor,
1794 Elem * subneighbor,
1795 bool reset = true);
1796
1801 void total_family_tree_by_subneighbor (std::vector<const Elem *> & family,
1802 const Elem * neighbor,
1803 const Elem * subneighbor,
1804 bool reset = true) const;
1805
1809 void total_family_tree_by_subneighbor (std::vector<Elem *> & family,
1810 Elem * neighbor,
1811 Elem * subneighbor,
1812 bool reset = true);
1813
1818 void active_family_tree_by_neighbor (std::vector<const Elem *> & family,
1819 const Elem * neighbor,
1820 bool reset = true) const;
1821
1825 void active_family_tree_by_neighbor (std::vector<Elem *> & family,
1826 Elem * neighbor,
1827 bool reset = true);
1828
1834 void active_family_tree_by_topological_neighbor (std::vector<const Elem *> & family,
1835 const Elem * neighbor,
1836 const MeshBase & mesh,
1837 const PointLocatorBase & point_locator,
1838 const PeriodicBoundaries * pb,
1839 bool reset = true) const;
1840
1844 void active_family_tree_by_topological_neighbor (std::vector<Elem *> & family,
1845 Elem * neighbor,
1846 const MeshBase & mesh,
1847 const PointLocatorBase & point_locator,
1848 const PeriodicBoundaries * pb,
1849 bool reset = true);
1850
1855
1859 void set_refinement_flag (const RefinementState rflag);
1860
1865
1869 void set_p_refinement_flag (const RefinementState pflag);
1870
1875 unsigned int max_descendant_p_level () const;
1876
1882 unsigned int min_p_level_by_neighbor (const Elem * neighbor,
1883 unsigned int current_min) const;
1884
1890 unsigned int min_new_p_level_by_neighbor (const Elem * neighbor,
1891 unsigned int current_min) const;
1892
1898 void set_p_level (const unsigned int p);
1899
1904 void hack_p_level (const unsigned int p);
1905
1912 void hack_p_level_and_refinement_flag (const unsigned int p,
1913 RefinementState pflag);
1914
1918 virtual void refine (MeshRefinement & mesh_refinement);
1919
1924 void coarsen ();
1925
1932 void contract ();
1933
1934#endif
1935
1936#ifndef NDEBUG
1940 void libmesh_assert_valid_neighbors() const;
1941
1947#endif // !NDEBUG
1948
1961 virtual unsigned int local_singular_node(const Point & /* p */, const Real /* tol */ = TOLERANCE*TOLERANCE) const
1962 { return invalid_uint; }
1963
1968 virtual bool is_singular_node(unsigned int /* node_i */) const { return false; }
1969
1976 virtual unsigned int center_node_on_side(const unsigned short side) const;
1977
1978protected:
1979
1990 class SideIter;
1991
1992public:
1997
2002 struct side_iterator;
2003
2009
2010private:
2017
2018public:
2019
2020#ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
2021
2026 virtual bool infinite () const = 0;
2027
2035 virtual bool is_mid_infinite_edge_node(const unsigned int /* n */) const
2036 { libmesh_assert (!this->infinite()); return false; }
2037
2044 virtual Point origin () const { libmesh_not_implemented(); return Point(); }
2045
2046#else
2047
2048 static constexpr bool infinite () { return false; }
2049
2050#endif
2051
2055 static std::unique_ptr<Elem> build (const ElemType type,
2056 Elem * p=nullptr);
2057
2063 static std::unique_ptr<Elem> build_with_id (const ElemType type,
2064 dof_id_type id);
2065
2078 virtual std::unique_ptr<Elem> disconnected_clone () const;
2079
2089 virtual unsigned int n_permutations() const = 0;
2090
2103 virtual void permute(unsigned int perm_num) = 0;
2104
2116 virtual void flip(BoundaryInfo * boundary_info) = 0;
2117
2128 virtual bool is_flipped() const = 0;
2129
2136 void orient(BoundaryInfo * boundary_info);
2137
2138#ifdef LIBMESH_ENABLE_AMR
2139
2145 virtual unsigned int as_parent_node (unsigned int c,
2146 unsigned int n) const;
2147
2152 virtual
2153 const std::vector<std::pair<unsigned char, unsigned char>> &
2154 parent_bracketing_nodes(unsigned int c,
2155 unsigned int n) const;
2156
2161 virtual
2162 const std::vector<std::pair<dof_id_type, dof_id_type>>
2163 bracketing_nodes(unsigned int c,
2164 unsigned int n) const;
2165
2166
2170 virtual Real embedding_matrix (const unsigned int child_num,
2171 const unsigned int child_node_num,
2172 const unsigned int parent_node_num) const = 0;
2173
2181 virtual unsigned int embedding_matrix_version () const { return 0; }
2182
2183#endif // LIBMESH_ENABLE_AMR
2184
2185
2186protected:
2187
2192
2197
2202 dof_id_type n1);
2203
2208 dof_id_type n1,
2209 dof_id_type n2);
2210
2215 dof_id_type n1,
2216 dof_id_type n2,
2217 dof_id_type n3);
2218
2222 void swap2nodes(unsigned int n1, unsigned int n2)
2223 {
2224 Node * temp = this->node_ptr(n1);
2225 this->set_node(n1, this->node_ptr(n2));
2226 this->set_node(n2, temp);
2227 }
2228
2232 void swap2neighbors(unsigned int n1, unsigned int n2)
2233 {
2234 Elem * temp = this->neighbor_ptr(n1);
2235 this->set_neighbor(n1, this->neighbor_ptr(n2));
2236 this->set_neighbor(n2, temp);
2237 }
2238
2242 void swap2boundarysides(unsigned short s1, unsigned short s2,
2243 BoundaryInfo * boundary_info) const;
2244
2248 void swap2boundaryedges(unsigned short e1, unsigned short e2,
2249 BoundaryInfo * boundary_info) const;
2250
2254 void swap3nodes(unsigned int n1, unsigned int n2, unsigned int n3)
2255 {
2256 swap2nodes(n1, n2);
2257 swap2nodes(n2, n3);
2258 }
2259
2263 void swap3neighbors(unsigned int n1, unsigned int n2,
2264 unsigned int n3)
2265 {
2266 swap2neighbors(n1, n2);
2267 swap2neighbors(n2, n3);
2268 }
2269
2273 void swap4nodes(unsigned int n1, unsigned int n2, unsigned int n3,
2274 unsigned int n4)
2275 {
2276 swap3nodes(n1, n2, n3);
2277 swap2nodes(n3, n4);
2278 }
2279
2283 void swap4neighbors(unsigned int n1, unsigned int n2,
2284 unsigned int n3, unsigned int n4)
2285 {
2286 swap3neighbors(n1, n2, n3);
2287 swap2neighbors(n3, n4);
2288 }
2289
2290
2294 template <typename Sideclass, typename Subclass>
2295 std::unique_ptr<Elem>
2296 simple_build_side_ptr(const unsigned int i);
2297
2301 template <typename Subclass>
2302 void simple_build_side_ptr(std::unique_ptr<Elem> & side,
2303 const unsigned int i,
2304 ElemType sidetype);
2305
2309 template <typename Subclass, typename Mapclass>
2310 void simple_side_ptr(std::unique_ptr<Elem> & side,
2311 const unsigned int i,
2312 ElemType sidetype);
2313
2317 template <typename Edgeclass, typename Subclass>
2318 std::unique_ptr<Elem>
2319 simple_build_edge_ptr(const unsigned int i);
2320
2324 template <typename Subclass>
2325 void simple_build_edge_ptr(std::unique_ptr<Elem> & edge,
2326 const unsigned int i,
2327 ElemType edgetype);
2328
2329
2330#ifdef LIBMESH_ENABLE_AMR
2331
2337 virtual
2338 std::vector<std::vector<std::vector<std::vector<std::pair<unsigned char, unsigned char>>>>> &
2340 {
2341 static std::vector<std::vector<std::vector<std::vector<std::pair<unsigned char, unsigned char>>>>> c;
2342 libmesh_error();
2343 return c;
2344 }
2345
2351 virtual
2352 std::vector<std::vector<std::vector<signed char>>> &
2354 {
2355 static std::vector<std::vector<std::vector<signed char>>> c;
2356 libmesh_error();
2357 return c;
2358 }
2359
2360#endif // LIBMESH_ENABLE_AMR
2361
2362public:
2363
2368 void nullify_neighbors ();
2369
2370protected:
2371
2376
2382
2383#ifdef LIBMESH_ENABLE_AMR
2391 std::unique_ptr<Elem *[]> _children;
2392#endif
2393
2398
2399#ifdef LIBMESH_ENABLE_AMR
2404 unsigned char _rflag;
2405
2410 unsigned char _pflag;
2411
2420 unsigned char _p_level;
2421#endif
2422
2427 unsigned char _map_type;
2428
2433 unsigned char _map_data;
2434};
2435
2436
2437
2438// ------------------------------------------------------------
2439// Elem helper classes
2440//
2441class
2443{
2444public:
2445 NodeRefIter (Node * const * nodepp) : PointerToPointerIter<Node>(nodepp) {}
2446};
2447
2448
2449class
2451{
2452public:
2453 ConstNodeRefIter (const Node * const * nodepp) : PointerToPointerIter<const Node>(nodepp) {}
2454};
2455
2456
2457#ifdef LIBMESH_ENABLE_AMR
2458class
2460{
2461public:
2462 ChildRefIter (Elem * const * childpp) : PointerToPointerIter<Elem>(childpp) {}
2463};
2464
2465
2466class
2468{
2469public:
2470 ConstChildRefIter (const Elem * const * childpp) : PointerToPointerIter<const Elem>(childpp) {}
2471};
2472
2473
2474
2475inline
2481
2482
2483inline
2489#endif // LIBMESH_ENABLE_AMR
2490
2491
2492
2493
2494// ------------------------------------------------------------
2495// global Elem functions
2496
2497inline
2498std::ostream & operator << (std::ostream & os, const Elem & e)
2499{
2500 e.print_info(os);
2501 return os;
2502}
2503
2504
2505// ------------------------------------------------------------
2506// Elem class member functions
2507inline
2508Elem::Elem(const unsigned int nn,
2509 const unsigned int ns,
2510 Elem * p,
2511 Elem ** elemlinkdata,
2512 Node ** nodelinkdata) :
2513 _nodes(nodelinkdata),
2514 _elemlinks(elemlinkdata),
2515 _sbd_id(0),
2516#ifdef LIBMESH_ENABLE_AMR
2517 _rflag(Elem::DO_NOTHING),
2518 _pflag(Elem::DO_NOTHING),
2519 _p_level(0),
2520#endif
2521 _map_type(p ? p->mapping_type() : 0),
2522 _map_data(p ? p->mapping_data() : 0)
2523{
2525
2526 // If this ever legitimately fails we need to increase max_n_nodes
2527 libmesh_assert_less_equal(nn, max_n_nodes);
2528
2529 // We currently only support refinement of elements into child
2530 // elements of the same type. We can't test elem->type() here,
2531 // because that's virtual and we're still in the base class
2532 // constructor, but we can at least usually verify constency with
2533 // the arguments we were handed.
2534#ifndef NDEBUG
2535 if (p && !p->runtime_topology())
2536 {
2537 libmesh_assert_equal_to(nn, p->n_nodes());
2538 libmesh_assert_equal_to(ns, p->n_sides());
2539 }
2540#endif
2541
2542 // Initialize the nodes data structure if we're given a pointer to
2543 // memory for it.
2544 if (_nodes)
2545 {
2546 for (unsigned int n=0; n<nn; n++)
2547 _nodes[n] = nullptr;
2548 }
2549
2550 // Initialize the neighbors/parent data structure
2551 // _elemlinks = new Elem *[ns+1];
2552
2553 // Initialize the elements data structure if we're given a pointer
2554 // to memory for it. If we *weren't* given memory for it, e.g.
2555 // because a subclass like an arbitrary Polygon needs to
2556 // heap-allocate this memory, then that subclass will have to handle
2557 // this initialization too.
2558 if (_elemlinks)
2559 {
2560 _elemlinks[0] = p;
2561
2562 for (unsigned int n=1; n<ns+1; n++)
2563 _elemlinks[n] = nullptr;
2564
2565 // Optionally initialize data from the parent
2566 if (this->parent())
2567 {
2568 this->subdomain_id() = this->parent()->subdomain_id();
2569 this->processor_id() = this->parent()->processor_id();
2570 _map_type = this->parent()->_map_type;
2571 _map_data = this->parent()->_map_data;
2572
2573#ifdef LIBMESH_ENABLE_AMR
2574 this->set_p_level(this->parent()->p_level());
2575#endif
2576 }
2577 }
2578}
2579
2580
2581
2582inline
2583const Point & Elem::point (const unsigned int i) const
2584{
2585 libmesh_assert_less (i, this->n_nodes());
2587 libmesh_assert_not_equal_to (_nodes[i]->id(), Node::invalid_id);
2588
2589 return *_nodes[i];
2590}
2591
2592
2593
2594inline
2595Point & Elem::point (const unsigned int i)
2596{
2597 libmesh_assert_less (i, this->n_nodes());
2598
2599 return *_nodes[i];
2600}
2601
2602
2603
2604inline
2605dof_id_type Elem::node_id (const unsigned int i) const
2606{
2607 libmesh_assert_less (i, this->n_nodes());
2609 libmesh_assert_not_equal_to (_nodes[i]->id(), Node::invalid_id);
2610
2611 return _nodes[i]->id();
2612}
2613
2614
2615
2616inline
2617unsigned int Elem::local_node (const dof_id_type i) const
2618{
2619 for (auto n : make_range(this->n_nodes()))
2620 if (this->node_id(n) == i)
2621 return n;
2622
2623 return libMesh::invalid_uint;
2624}
2625
2626
2627
2628inline
2629const Node * const * Elem::get_nodes () const
2630{
2631 return _nodes;
2632}
2633
2634
2635
2636inline
2637const Node * Elem::node_ptr (const unsigned int i) const
2638{
2639 libmesh_assert_less (i, this->n_nodes());
2641
2642 return _nodes[i];
2643}
2644
2645
2646
2647inline
2648Node * Elem::node_ptr (const unsigned int i)
2649{
2650 libmesh_assert_less (i, this->n_nodes());
2652
2653 return _nodes[i];
2654}
2655
2656
2657
2658inline
2659const Node & Elem::node_ref (const unsigned int i) const
2660{
2661 return *this->node_ptr(i);
2662}
2663
2664
2665
2666inline
2667Node & Elem::node_ref (const unsigned int i)
2668{
2669 return *this->node_ptr(i);
2670}
2671
2672
2673
2674inline
2675unsigned int Elem::get_node_index (const Node * node_ptr) const
2676{
2677 for (auto n : make_range(this->n_nodes()))
2678 if (this->_nodes[n] == node_ptr)
2679 return n;
2680
2681 return libMesh::invalid_uint;
2682}
2683
2684
2685
2686#ifdef LIBMESH_ENABLE_DEPRECATED
2687inline
2688Node * & Elem::set_node (const unsigned int i)
2689{
2690 libmesh_assert_less (i, this->n_nodes());
2691
2692 libmesh_deprecated();
2693
2694 return _nodes[i];
2695}
2696#endif // LIBMESH_ENABLE_DEPRECATED
2697
2698
2699
2700inline
2701void Elem::set_node (const unsigned int i,
2702 Node * node)
2703{
2704 libmesh_assert_less (i, this->n_nodes());
2705
2706 _nodes[i] = node;
2707}
2708
2709
2710
2711inline
2713{
2714 return _sbd_id;
2715}
2716
2717
2718
2719inline
2721{
2722 return _sbd_id;
2723}
2724
2725
2726
2727inline
2728bool Elem::operator != (const Elem & rhs) const
2729{
2730 return !(*this == rhs);
2731}
2732
2733
2734
2735inline
2736const Elem * Elem::neighbor_ptr (unsigned int i) const
2737{
2738 libmesh_assert_less (i, this->n_neighbors());
2739
2740 return _elemlinks[i+1];
2741}
2742
2743
2744
2745inline
2746Elem * Elem::neighbor_ptr (unsigned int i)
2747{
2748 libmesh_assert_less (i, this->n_neighbors());
2749
2750 return _elemlinks[i+1];
2751}
2752
2753
2754
2755inline
2756void Elem::set_neighbor (const unsigned int i, Elem * n)
2757{
2758 libmesh_assert_less (i, this->n_neighbors());
2759
2760 _elemlinks[i+1] = n;
2761}
2762
2763
2764
2765inline
2766bool Elem::has_neighbor (const Elem * elem) const
2767{
2768 for (auto n : this->neighbor_ptr_range())
2769 if (n == elem)
2770 return true;
2771
2772 return false;
2773}
2774
2775
2776
2777inline
2779{
2780 for (auto n : elem->neighbor_ptr_range())
2781 if (n && n->parent() == this)
2782 return n;
2783
2784 return nullptr;
2785}
2786
2787
2788
2789inline
2790const Elem * Elem::child_neighbor (const Elem * elem) const
2791{
2792 for (auto n : elem->neighbor_ptr_range())
2793 if (n && n->parent() == this)
2794 return n;
2795
2796 return nullptr;
2797}
2798
2799
2800
2801inline
2804{
2805 return {_nodes, _nodes+this->n_nodes()};
2806}
2807
2808
2809
2810inline
2813{
2814 return {_nodes, _nodes+this->n_nodes()};
2815}
2816
2817
2818
2819inline
2822{
2823 return {0, cast_int<unsigned short>(this->n_nodes())};
2824}
2825
2826
2827
2828inline
2831{
2832 return {0, cast_int<unsigned short>(this->n_edges())};
2833}
2834
2835
2836
2837inline
2840{
2841 return {0, cast_int<unsigned short>(this->n_faces())};
2842}
2843
2844
2845
2846inline
2849{
2850 return {0, cast_int<unsigned short>(this->n_sides())};
2851}
2852
2853
2854
2855
2856inline
2857std::unique_ptr<const Elem> Elem::side_ptr (unsigned int i) const
2858{
2859 // Call the non-const version of this function, return the result as
2860 // a std::unique_ptr<const Elem>.
2861 Elem * me = const_cast<Elem *>(this);
2862 return me->side_ptr(i);
2863}
2864
2865
2866
2867inline
2868void
2869Elem::side_ptr (std::unique_ptr<const Elem> & elem,
2870 const unsigned int i) const
2871{
2872 // Hand off to the non-const version of this function
2873 Elem * me = const_cast<Elem *>(this);
2874 std::unique_ptr<Elem> e {const_cast<Elem *>(elem.release())};
2875 me->side_ptr(e, i);
2876 elem = std::move(e);
2877}
2878
2879
2880
2881inline
2882std::unique_ptr<const Elem>
2883Elem::build_side_ptr (const unsigned int i) const
2884{
2885 // Call the non-const version of this function, return the result as
2886 // a std::unique_ptr<const Elem>.
2887 Elem * me = const_cast<Elem *>(this);
2888 return me->build_side_ptr(i);
2889}
2890
2891
2892
2893inline
2894void
2895Elem::build_side_ptr (std::unique_ptr<const Elem> & elem,
2896 const unsigned int i) const
2897{
2898 // Hand off to the non-const version of this function
2899 Elem * me = const_cast<Elem *>(this);
2900 std::unique_ptr<Elem> e {const_cast<Elem *>(elem.release())};
2901 me->build_side_ptr(e, i);
2902 elem = std::move(e);
2903}
2904
2905
2906
2907template <typename Sideclass, typename Subclass>
2908inline
2909std::unique_ptr<Elem>
2910Elem::simple_build_side_ptr (const unsigned int i)
2911{
2912 libmesh_assert_less (i, this->n_sides());
2913
2914 std::unique_ptr<Elem> face = std::make_unique<Sideclass>();
2915 for (auto n : face->node_index_range())
2916 face->set_node(n, this->node_ptr(Subclass::side_nodes_map[i][n]));
2917
2918 face->set_interior_parent(this);
2919 face->inherit_data_from(*this);
2920
2921 return face;
2922}
2923
2924
2925
2926template <typename Subclass>
2927inline
2928void
2929Elem::simple_build_side_ptr (std::unique_ptr<Elem> & side,
2930 const unsigned int i,
2931 ElemType sidetype)
2932{
2933 libmesh_assert_less (i, this->n_sides());
2934
2935 if (!side.get() || side->type() != sidetype)
2936 {
2937 Subclass & real_me = cast_ref<Subclass&>(*this);
2938 side = real_me.Subclass::build_side_ptr(i);
2939 }
2940 else
2941 {
2942 side->set_interior_parent(this);
2943 side->inherit_data_from(*this);
2944 for (auto n : side->node_index_range())
2945 side->set_node(n, this->node_ptr(Subclass::side_nodes_map[i][n]));
2946 }
2947}
2948
2949
2950
2951template <typename Subclass, typename Mapclass>
2952inline
2953void
2954Elem::simple_side_ptr (std::unique_ptr<Elem> & side,
2955 const unsigned int i,
2956 ElemType sidetype)
2957{
2958 libmesh_assert_less (i, this->n_sides());
2959
2960 if (!side.get() || side->type() != sidetype)
2961 {
2962 Subclass & real_me = cast_ref<Subclass&>(*this);
2963 side = real_me.Subclass::side_ptr(i);
2964 }
2965 else
2966 {
2967 side->subdomain_id() = this->subdomain_id();
2968
2969 for (auto n : side->node_index_range())
2970 side->set_node(n, this->node_ptr(Mapclass::side_nodes_map[i][n]));
2971 }
2972}
2973
2974
2975
2976inline
2977std::unique_ptr<const Elem>
2978Elem::build_edge_ptr (const unsigned int i) const
2979{
2980 // Call the non-const version of this function, return the result as
2981 // a std::unique_ptr<const Elem>.
2982 Elem * me = const_cast<Elem *>(this);
2983 return me->build_edge_ptr(i);
2984}
2985
2986
2987
2988inline
2989void
2990Elem::build_edge_ptr (std::unique_ptr<const Elem> & elem,
2991 const unsigned int i) const
2992{
2993 // Hand off to the non-const version of this function
2994 Elem * me = const_cast<Elem *>(this);
2995 std::unique_ptr<Elem> e {const_cast<Elem *>(elem.release())};
2996 me->build_edge_ptr(e, i);
2997 elem = std::move(e);
2998}
2999
3000
3001template <typename Edgeclass, typename Subclass>
3002inline
3003std::unique_ptr<Elem>
3004Elem::simple_build_edge_ptr (const unsigned int i)
3005{
3006 libmesh_assert_less (i, this->n_edges());
3007
3008 std::unique_ptr<Elem> edge = std::make_unique<Edgeclass>();
3009
3010 for (auto n : edge->node_index_range())
3011 edge->set_node(n, this->node_ptr(Subclass::edge_nodes_map[i][n]));
3012
3013 edge->set_interior_parent(this);
3014 edge->inherit_data_from(*this);
3015
3016 return edge;
3017}
3018
3019
3020
3021
3022template <typename Subclass>
3023inline
3024void
3025Elem::simple_build_edge_ptr (std::unique_ptr<Elem> & edge,
3026 const unsigned int i,
3027 ElemType edgetype)
3028{
3029 libmesh_assert_less (i, this->n_edges());
3030
3031 if (!edge.get() || edge->type() != edgetype)
3032 {
3033 Subclass & real_me = cast_ref<Subclass&>(*this);
3034 edge = real_me.Subclass::build_edge_ptr(i);
3035 }
3036 else
3037 {
3038 edge->inherit_data_from(*this);
3039 for (auto n : edge->node_index_range())
3040 edge->set_node(n, this->node_ptr(Subclass::edge_nodes_map[i][n]));
3041 }
3042}
3043
3044
3045
3046inline
3048{
3049 // By convention, the element is on the boundary
3050 // if it has a nullptr neighbor.
3051 return this->has_neighbor(nullptr);
3052}
3053
3054
3055
3056inline
3057unsigned int Elem::which_neighbor_am_i (const Elem * e) const
3058{
3059 libmesh_assert(e);
3060
3061 const Elem * eparent = e;
3062
3063 while (eparent->level() > this->level())
3064 {
3065 eparent = eparent->parent();
3066 libmesh_assert(eparent);
3067 }
3068
3069 for (auto s : make_range(this->n_sides()))
3070 if (this->neighbor_ptr(s) == eparent)
3071 return s;
3072
3073 return libMesh::invalid_uint;
3074}
3075
3076
3077
3078inline
3079bool Elem::active() const
3080{
3081#ifdef LIBMESH_ENABLE_AMR
3082 if ((this->refinement_flag() == INACTIVE) ||
3083 (this->refinement_flag() == COARSEN_INACTIVE))
3084 return false;
3085 else
3086 return true;
3087#else
3088 return true;
3089#endif
3090}
3091
3092
3093
3094
3095
3096inline
3098{
3099#ifdef LIBMESH_ENABLE_AMR
3100 if (this->active())
3101 return false;
3102 if (!this->has_children())
3103 return true;
3104 for (const Elem * my_ancestor = this->parent();
3105 my_ancestor != nullptr;
3106 my_ancestor = my_ancestor->parent())
3107 if (my_ancestor->active())
3108 return true;
3109#endif
3110
3111 return false;
3112}
3113
3114
3115
3116inline
3118{
3119#ifdef LIBMESH_ENABLE_AMR
3120 if (!_children)
3121 return false;
3122 else
3123 return true;
3124#else
3125 return false;
3126#endif
3127}
3128
3129
3130inline
3132{
3133#ifdef LIBMESH_ENABLE_AMR
3134 if (!_children)
3135 return false;
3136 else
3137 for (auto & c : child_ref_range())
3138 if (c.has_children())
3139 return true;
3140#endif
3141 return false;
3142}
3143
3144
3145
3146inline
3148#ifdef LIBMESH_ENABLE_AMR
3149 descendant
3150#endif
3151 ) const
3152{
3153#ifdef LIBMESH_ENABLE_AMR
3154 const Elem * e = descendant;
3155 while (e)
3156 {
3157 if (this == e)
3158 return true;
3159 e = e->parent();
3160 }
3161#endif
3162 return false;
3163}
3164
3165
3166
3167inline
3168const Elem * Elem::parent () const
3169{
3170 return _elemlinks[0];
3171}
3172
3173
3174
3175inline
3177{
3178 return _elemlinks[0];
3179}
3180
3181
3182
3183inline
3185{
3186 // We no longer support using parent() as interior_parent()
3187 libmesh_assert_equal_to(this->dim(), p ? p->dim() : this->dim());
3188 _elemlinks[0] = p;
3189}
3190
3191
3192
3193inline
3194const Elem * Elem::top_parent () const
3195{
3196 const Elem * tp = this;
3197
3198 // Keep getting the element's parent
3199 // until that parent is at level-0
3200 while (tp->parent() != nullptr)
3201 tp = tp->parent();
3202
3203 libmesh_assert(tp);
3204 libmesh_assert_equal_to (tp->level(), 0);
3205
3206 return tp;
3207}
3208
3209
3210
3211inline
3212unsigned int Elem::level() const
3213{
3214#ifdef LIBMESH_ENABLE_AMR
3215
3216 // if I don't have a parent I was
3217 // created directly from file
3218 // or by the user, so I am a
3219 // level-0 element
3220 if (this->parent() == nullptr)
3221 return 0;
3222
3223 // if the parent and this element are of different
3224 // dimensionality we are at the same level as
3225 // the parent (e.g. we are the 2D side of a
3226 // 3D element)
3227 if (this->dim() != this->parent()->dim())
3228 return this->parent()->level();
3229
3230 // otherwise we are at a level one
3231 // higher than our parent
3232 return (this->parent()->level() + 1);
3233
3234#else
3235
3236 // Without AMR all elements are
3237 // at level 0.
3238 return 0;
3239
3240#endif
3241}
3242
3243
3244
3245inline
3246unsigned int Elem::p_level() const
3247{
3248#ifdef LIBMESH_ENABLE_AMR
3249 return _p_level;
3250#else
3251 return 0;
3252#endif
3253}
3254
3255
3256
3257inline
3259{
3260 return static_cast<ElemMappingType>(_map_type);
3261}
3262
3263
3264
3265inline
3267{
3268 _map_type = cast_int<unsigned char>(type);
3269}
3270
3271
3272
3273inline
3274unsigned char Elem::mapping_data () const
3275{
3276 return _map_data;
3277}
3278
3279
3280
3281inline
3282void Elem::set_mapping_data(const unsigned char data)
3283{
3284 _map_data = data;
3285}
3286
3287
3288
3289#ifdef LIBMESH_ENABLE_AMR
3290
3291inline
3292const Elem * Elem::raw_child_ptr (unsigned int i) const
3293{
3294 if (!_children)
3295 return nullptr;
3296
3297 return _children[i];
3298}
3299
3300inline
3301const Elem * Elem::child_ptr (unsigned int i) const
3302{
3305
3306 return _children[i];
3307}
3308
3309inline
3310Elem * Elem::child_ptr (unsigned int i)
3311{
3314
3315 return _children[i];
3316}
3317
3318
3319inline
3320void Elem::set_child (unsigned int c, Elem * elem)
3321{
3322 libmesh_assert (this->has_children());
3323
3324 _children[c] = elem;
3325}
3326
3327
3328
3329inline
3330unsigned int Elem::which_child_am_i (const Elem * e) const
3331{
3332 libmesh_assert(e);
3333 libmesh_assert (this->has_children());
3334
3335 unsigned int nc = this->n_children();
3336 for (unsigned int c=0; c != nc; c++)
3337 if (this->child_ptr(c) == e)
3338 return c;
3339
3340 libmesh_error_msg("ERROR: which_child_am_i() was called with a non-child!");
3341
3342 return libMesh::invalid_uint;
3343}
3344
3345
3346
3347inline
3349{
3350 return static_cast<RefinementState>(_rflag);
3351}
3352
3353
3354
3355inline
3357{
3358 _rflag = cast_int<unsigned char>(rflag);
3359}
3360
3361
3362
3363inline
3365{
3366 return static_cast<RefinementState>(_pflag);
3367}
3368
3369
3370
3371inline
3373{
3374 if (this->p_level() == 0)
3375 libmesh_assert_not_equal_to
3376 (pflag, Elem::JUST_REFINED);
3377
3378 _pflag = cast_int<unsigned char>(pflag);
3379}
3380
3381
3382
3383inline
3384unsigned int Elem::max_descendant_p_level () const
3385{
3386 // This is undefined for subactive elements,
3387 // which have no active descendants
3388 libmesh_assert (!this->subactive());
3389 if (this->active())
3390 return this->p_level();
3391
3392 unsigned int max_p_level = _p_level;
3393 for (auto & c : child_ref_range())
3394 max_p_level = std::max(max_p_level,
3395 c.max_descendant_p_level());
3396 return max_p_level;
3397}
3398
3399
3400
3401inline
3402void Elem::hack_p_level(unsigned int p)
3403{
3404 if (p == 0)
3405 libmesh_assert_not_equal_to
3407
3408 _p_level = cast_int<unsigned char>(p);
3409}
3410
3411
3412inline
3414 RefinementState pflag)
3415{
3416 _pflag = cast_int<unsigned char>(pflag);
3417 this->hack_p_level(p);
3418}
3419
3420#endif // ifdef LIBMESH_ENABLE_AMR
3421
3422
3423inline
3424void Elem::orient(BoundaryInfo * boundary_info)
3425{
3426 if (this->is_flipped())
3427 this->flip(boundary_info);
3428}
3429
3430
3431inline
3433{
3434 return n0;
3435}
3436
3437
3438
3439inline
3441 dof_id_type n1)
3442{
3443 // Order the two so that n0 < n1
3444 if (n0 > n1) std::swap (n0, n1);
3445
3446 return Utility::hashword2(n0, n1);
3447}
3448
3449
3450
3451inline
3453 dof_id_type n1,
3454 dof_id_type n2)
3455{
3456 std::array<dof_id_type, 3> array = {{n0, n1, n2}};
3457 std::sort(array.begin(), array.end());
3458 return Utility::hashword(array);
3459}
3460
3461
3462
3463inline
3465 dof_id_type n1,
3466 dof_id_type n2,
3467 dof_id_type n3)
3468{
3469 std::array<dof_id_type, 4> array = {{n0, n1, n2, n3}};
3470 std::sort(array.begin(), array.end());
3471 return Utility::hashword(array);
3472}
3473
3474
3475
3476inline
3478{
3479 this->set_mapping_type(src.mapping_type());
3480 this->set_mapping_data(src.mapping_data());
3481 this->subdomain_id() = src.subdomain_id();
3482 this->processor_id(src.processor_id());
3483#ifdef LIBMESH_ENABLE_AMR
3484 this->set_p_level(src.p_level());
3485#endif
3486}
3487
3488
3489
3494{
3495public:
3496 // Constructor with arguments.
3497 SideIter(const unsigned int side_number,
3498 Elem * parent)
3499 : _side(),
3500 _side_ptr(nullptr),
3501 _parent(parent),
3502 _side_number(side_number)
3503 {}
3504
3505
3506 // Empty constructor.
3508 : _side(),
3509 _side_ptr(nullptr),
3510 _parent(nullptr),
3512 {}
3513
3514
3515 // Copy constructor
3516 SideIter(const SideIter & other)
3517 : _side(),
3518 _side_ptr(nullptr),
3519 _parent(other._parent),
3521 {}
3522
3523
3524 // op=
3525 SideIter & operator=(const SideIter & other)
3526 {
3527 this->_parent = other._parent;
3528 this->_side_number = other._side_number;
3529 return *this;
3530 }
3531
3532 // unary op*
3533 Elem *& operator*() const
3534 {
3535 // Set the std::unique_ptr
3536 this->_update_side_ptr();
3537
3538 // Return a reference to _side_ptr
3539 return this->_side_ptr;
3540 }
3541
3542 // op++
3544 {
3545 ++_side_number;
3546 return *this;
3547 }
3548
3549 // op== Two side iterators are equal if they have
3550 // the same side number and the same parent element.
3551 bool operator == (const SideIter & other) const
3552 {
3553 return (this->_side_number == other._side_number &&
3554 this->_parent == other._parent);
3555 }
3556
3557
3558 // Consults the parent Elem to determine if the side
3559 // is a boundary side. Note: currently side N is a
3560 // boundary side if neighbor N is nullptr. Be careful,
3561 // this could possibly change in the future?
3562 bool side_on_boundary() const
3563 {
3564 return this->_parent->neighbor_ptr(_side_number) == nullptr;
3565 }
3566
3567private:
3568 // Update the _side pointer by building the correct side.
3569 // This has to be called before dereferencing.
3570 void _update_side_ptr() const
3571 {
3572 // Construct new side, store in std::unique_ptr
3573 this->_side = this->_parent->build_side_ptr(this->_side_number);
3574
3575 // Also set our internal naked pointer. Memory is still owned
3576 // by the std::unique_ptr.
3577 this->_side_ptr = _side.get();
3578 }
3579
3580 // std::unique_ptr to the actual side, handles memory management for
3581 // the sides which are created during the course of iteration.
3582 mutable std::unique_ptr<Elem> _side;
3583
3584 // Raw pointer needed to facilitate passing back to the user a
3585 // reference to a non-temporary raw pointer in order to conform to
3586 // the variant_filter_iterator interface. It points to the same
3587 // thing the std::unique_ptr "_side" above holds. What happens if the user
3588 // calls delete on the pointer passed back? Well, this is an issue
3589 // which is not addressed by the iterators in libMesh. Basically it
3590 // is a bad idea to ever call delete on an iterator from the library.
3591 mutable Elem * _side_ptr;
3592
3593 // Pointer to the parent Elem class which generated this iterator
3595
3596 // A counter variable which keeps track of the side number
3597 unsigned int _side_number;
3598};
3599
3600
3601
3602
3603
3604
3605// Private implementation functions in the Elem class for the side iterators.
3606// They have to come after the definition of the SideIter class.
3607inline
3609{
3610 return SideIter(0, this);
3611}
3612
3613
3614
3615inline
3617{
3618 return SideIter(this->n_neighbors(), this);
3619}
3620
3621
3622
3623
3627struct
3629{
3630 // Templated forwarding ctor -- forwards to appropriate variant_filter_iterator ctor
3631 template <typename PredType, typename IterType>
3632 side_iterator (const IterType & d,
3633 const IterType & e,
3634 const PredType & p ) :
3636};
3637
3638
3639
3640inline
3645
3646
3647inline
3652
3653} // namespace libMesh
3654
3655
3656// Helper function for default caches in Elem subclasses
3657
3658#define LIBMESH_ENABLE_TOPOLOGY_CACHES \
3659 virtual \
3660 std::vector<std::vector<std::vector<std::vector<std::pair<unsigned char, unsigned char>>>>> & \
3661 _get_bracketing_node_cache() const override \
3662 { \
3663 static std::vector<std::vector<std::vector<std::vector<std::pair<unsigned char, unsigned char>>>>> c; \
3664 return c; \
3665 } \
3666 \
3667 virtual \
3668 std::vector<std::vector<std::vector<signed char>>> & \
3669 _get_parent_indices_cache() const override \
3670 { \
3671 static std::vector<std::vector<std::vector<signed char>>> c; \
3672 return c; \
3673 }
3674
3675
3676
3677
3678
3679
3680#endif // LIBMESH_ELEM_H
void ErrorVector unsigned int
The BoundaryInfo class contains information relevant to boundary conditions including storing faces,...
Defines a Cartesian bounding box by the two corner extremum.
The DofObject defines an abstract base class for objects that have degrees of freedom associated with...
Definition dof_object.h:55
processor_id_type processor_id() const
Definition dof_object.h:895
static constexpr dof_id_type invalid_id
An invalid id to distinguish an uninitialized DofObject.
Definition dof_object.h:473
dof_id_type id() const
Definition dof_object.h:833
static constexpr processor_id_type invalid_processor_id
An invalid processor_id to distinguish DoFs that have not been assigned to a processor.
Definition dof_object.h:484
ChildRefIter(Elem *const *childpp)
Definition elem.h:2462
ConstChildRefIter(const Elem *const *childpp)
Definition elem.h:2470
ConstNodeRefIter(const Node *const *nodepp)
Definition elem.h:2453
NodeRefIter(Node *const *nodepp)
Definition elem.h:2445
The definition of the protected nested SideIter class.
Definition elem.h:3494
bool side_on_boundary() const
Definition elem.h:3562
Elem *& operator*() const
Definition elem.h:3533
std::unique_ptr< Elem > _side
Definition elem.h:3582
bool operator==(const SideIter &other) const
Definition elem.h:3551
unsigned int _side_number
Definition elem.h:3597
SideIter & operator=(const SideIter &other)
Definition elem.h:3525
SideIter & operator++()
Definition elem.h:3543
void _update_side_ptr() const
Definition elem.h:3570
SideIter(const SideIter &other)
Definition elem.h:3516
SideIter(const unsigned int side_number, Elem *parent)
Definition elem.h:3497
This is the base class from which all geometric element types are derived.
Definition elem.h:96
bool has_ancestor_children() const
Definition elem.h:3131
virtual unsigned int n_nodes_in_child(unsigned int) const
Definition elem.h:748
void swap4nodes(unsigned int n1, unsigned int n2, unsigned int n3, unsigned int n4)
Swaps four node_ptrs, "rotating" them.
Definition elem.h:2273
bool operator!=(const Elem &rhs) const
Definition elem.h:2728
void family_tree(std::vector< const Elem * > &family, bool reset=true) const
Fills the vector family with the children of this element, recursively.
Definition elem.C:2212
virtual bool is_node_on_side(const unsigned int n, const unsigned int s) const =0
virtual std::unique_ptr< Elem > disconnected_clone() const
Definition elem.C:350
void total_family_tree_by_side(std::vector< const Elem * > &family, unsigned int side, bool reset=true) const
Same as the total_family_tree() member, but only adds elements which are next to side.
Definition elem.C:2278
std::unique_ptr< const Elem > build_side_ptr(const unsigned int i, bool proxy) const
Definition elem.h:1028
virtual Node *& set_node(const unsigned int i)
Definition elem.h:2688
virtual const std::vector< std::pair< unsigned char, unsigned char > > & parent_bracketing_nodes(unsigned int c, unsigned int n) const
Definition elem.C:2583
virtual Point quasicircumcenter() const
Definition elem.h:1145
const Elem * raw_child_ptr(unsigned int i) const
Definition elem.h:3292
virtual BoundingBox loose_bounding_box() const
Definition elem.C:3901
void set_p_refinement_flag(const RefinementState pflag)
Sets the value of the p-refinement flag for the element.
Definition elem.h:3372
static constexpr Real affine_tol
Default tolerance to use in has_affine_map().
Definition elem.h:2191
SimpleRange< NeighborPtrIter > neighbor_ptr_range()
Returns a range with all neighbors of an element, usable in range-based for loops.
Definition elem.h:3641
Elem(Elem &&)=delete
Elems are responsible for allocating and deleting space for storing pointers to their children during...
virtual void refine(MeshRefinement &mesh_refinement)
Refine the element.
virtual bool is_child_on_side(const unsigned int c, const unsigned int s) const =0
virtual std::vector< std::vector< std::vector< std::vector< std::pair< unsigned char, unsigned char > > > > > & _get_bracketing_node_cache() const
Elem subclasses which don't do their own bracketing node calculations will need to supply a static ca...
Definition elem.h:2339
void contract()
Contract an active element, i.e.
RefinementState refinement_flag() const
Definition elem.h:3348
virtual unsigned int center_node_on_side(const unsigned short side) const
Definition elem.C:3975
unsigned char _rflag
h refinement flag.
Definition elem.h:2404
void total_family_tree_by_subneighbor(std::vector< const Elem * > &family, const Elem *neighbor, const Elem *subneighbor, bool reset=true) const
Same as the family_tree_by_subneighbor() member, but also adds any subactive descendants.
Definition elem.C:2370
bool active() const
Definition elem.h:3079
virtual std::pair< Real, Real > qual_bounds(const ElemQuality) const
Definition elem.h:1208
bool is_ancestor_of(const Elem *descendant) const
Definition elem.h:3147
unsigned char mapping_data() const
Definition elem.h:3274
bool has_neighbor(const Elem *elem) const
Definition elem.h:2766
void print_info(std::ostream &os=libMesh::out) const
Prints relevant information about the element.
Definition elem.C:3050
virtual unsigned int n_vertices() const =0
Elem * child_neighbor(Elem *elem)
Definition elem.h:2778
void hack_p_level_and_refinement_flag(const unsigned int p, RefinementState pflag)
Sets the value of the p-refinement level for the element without altering the p-level of its ancestor...
Definition elem.h:3413
const Point & point(const unsigned int i) const
Definition elem.h:2583
virtual unsigned int local_side_node(unsigned int side, unsigned int side_node) const =0
const Node & node_ref(const unsigned int i) const
Definition elem.h:2659
virtual Point true_centroid() const
Definition elem.C:515
virtual Point origin() const
Definition elem.h:2044
Elem & operator=(const Elem &)=delete
static const unsigned int type_to_n_edges_map[INVALID_ELEM]
This array maps the integer representation of the ElemType enum to the number of edges on the element...
Definition elem.h:841
virtual bool is_child_on_edge(const unsigned int c, const unsigned int e) const
Definition elem.C:2435
void set_child(unsigned int c, Elem *elem)
Sets the pointer to the child for this element.
Definition elem.h:3320
bool has_children() const
Definition elem.h:3117
virtual std::unique_ptr< Elem > side_ptr(unsigned int i)=0
static std::unique_ptr< Elem > build_with_id(const ElemType type, dof_id_type id)
Calls the build() method above with a nullptr parent, and additionally sets the newly-created Elem's ...
Definition elem.C:496
bool topologically_equal(const Elem &rhs) const
Definition elem.C:728
virtual unsigned int n_nodes() const =0
static ElemType edge_type(const ElemType t)
Definition elem.C:3380
void active_family_tree_by_side(std::vector< const Elem * > &family, unsigned int side, bool reset=true) const
Same as the active_family_tree() member, but only adds elements which are next to side.
Definition elem.C:2296
const Elem * parent() const
Definition elem.h:3168
void family_tree_by_subneighbor(std::vector< const Elem * > &family, const Elem *neighbor, const Elem *subneighbor, bool reset=true) const
Same as the family_tree() member, but only adds elements which are next to subneighbor.
Definition elem.C:2350
Elem(const Elem &)=delete
void swap2nodes(unsigned int n1, unsigned int n2)
Swaps two node_ptrs.
Definition elem.h:2222
virtual std::pair< unsigned short int, unsigned short int > second_order_child_vertex(const unsigned int n) const
Definition elem.C:3193
void make_links_to_me_local(unsigned int n, unsigned int neighbor_side)
Resets the neighbor_side pointers of our nth neighbor (and its descendants, if appropriate) to point ...
Definition elem.C:1369
bool operator==(const Elem &rhs) const
Definition elem.C:696
void set_neighbor(const unsigned int i, Elem *n)
Assigns n as the neighbor.
Definition elem.h:2756
SideIter _last_side()
Definition elem.h:3616
static ElemType complete_order_equivalent_type(const ElemType et)
Definition elem.C:3755
virtual bool on_reference_element(const Point &p, const Real eps=TOLERANCE) const =0
void hack_p_level(const unsigned int p)
Sets the value of the p-refinement level for the element without altering the p-level of its ancestor...
Definition elem.h:3402
void active_family_tree_by_topological_neighbor(std::vector< const Elem * > &family, const Elem *neighbor, const MeshBase &mesh, const PointLocatorBase &point_locator, const PeriodicBoundaries *pb, bool reset=true) const
Same as the active_family_tree_by_neighbor() member, but the neighbor here may be a topological (e....
Definition elem.C:2408
std::unique_ptr< Elem > simple_build_side_ptr(const unsigned int i)
An implementation for simple (all sides equal) elements.
Definition elem.h:2910
virtual unsigned int n_permutations() const =0
Returns the number of independent permutations of element nodes - e.g.
const Elem * child_ptr(unsigned int i) const
Definition elem.h:3301
virtual const std::vector< std::pair< dof_id_type, dof_id_type > > bracketing_nodes(unsigned int c, unsigned int n) const
Definition elem.C:2786
bool positive_edge_orientation(const unsigned int i) const
Definition elem.C:4037
virtual void side_ptr(std::unique_ptr< Elem > &side, const unsigned int i)=0
Resets the loose element side, which may currently point to a different side than i or even a differe...
void family_tree_by_neighbor(std::vector< const Elem * > &family, const Elem *neighbor, bool reset=true) const
Same as the family_tree() member, but only adds elements which are next to neighbor.
Definition elem.C:2314
void swap3neighbors(unsigned int n1, unsigned int n2, unsigned int n3)
Swaps three neighbor_ptrs, "rotating" them.
Definition elem.h:2263
bool has_topological_neighbor(const Elem *elem, const MeshBase &mesh, const PointLocatorBase &point_locator, const PeriodicBoundaries *pb) const
Definition elem.C:1264
bool ancestor() const
Definition elem.C:2121
unsigned int which_neighbor_am_i(const Elem *e) const
This function tells you which neighbor e is.
Definition elem.h:3057
virtual void connectivity(const unsigned int sc, const IOPackage iop, std::vector< dof_id_type > &conn) const =0
SideIter _first_side()
Side iterator helper functions.
Definition elem.h:3608
virtual dof_id_type low_order_key(const unsigned int s) const =0
void total_family_tree_by_neighbor(std::vector< const Elem * > &family, const Elem *neighbor, bool reset=true) const
Same as the family_tree_by_neighbor() member, but also adds any subactive descendants.
Definition elem.C:2332
bool point_test(const Point &p, Real box_tol, Real map_tol) const
Shared private implementation used by the contains_point() and close_to_point() routines.
Definition elem.C:2923
virtual bool is_flipped() const =0
unsigned int n_neighbors() const
Definition elem.h:812
virtual bool is_mid_infinite_edge_node(const unsigned int) const
Definition elem.h:2035
SimpleRange< NodeRefIter > node_ref_range()
Returns a range with all nodes of an element, usable in range-based for loops.
Definition elem.h:2803
virtual unsigned int opposite_node(const unsigned int n, const unsigned int s) const
Definition elem.C:3967
Node ** _nodes
Pointers to the nodes we are connected to.
Definition elem.h:2375
virtual bool is_vertex_on_parent(unsigned int c, unsigned int n) const
Definition elem.C:3935
RefinementState
Enumeration of possible element refinement states.
Definition elem.h:1567
@ COARSEN_INACTIVE
Definition elem.h:1573
@ INVALID_REFINEMENTSTATE
Definition elem.h:1574
@ JUST_COARSENED
Definition elem.h:1571
virtual Order default_order() const =0
static std::unique_ptr< Elem > build(const ElemType type, Elem *p=nullptr)
Definition elem.C:382
virtual void build_side_ptr(std::unique_ptr< Elem > &side, const unsigned int i)=0
Resets the loose element side, which may currently point to a different side than i or even a differe...
void swap2neighbors(unsigned int n1, unsigned int n2)
Swaps two neighbor_ptrs.
Definition elem.h:2232
virtual std::vector< unsigned int > nodes_on_side(const unsigned int) const =0
virtual Order supported_nodal_order() const
Definition elem.h:1103
void set_interior_parent(Elem *p)
Sets the pointer to the element's interior_parent.
Definition elem.C:1162
static ElemType first_order_equivalent_type(const ElemType et)
Definition elem.C:3201
void remove_links_to_me()
Resets this element's neighbors' appropriate neighbor pointers and its parent's and children's approp...
Definition elem.C:1588
bool positive_face_orientation(const unsigned int i) const
Definition elem.C:4046
virtual unsigned int n_second_order_adjacent_vertices(const unsigned int n) const
Definition elem.C:3175
void total_family_tree(std::vector< const Elem * > &family, bool reset=true) const
Same as the family_tree() member, but also adds any subactive descendants.
Definition elem.C:2228
side_iterator boundary_sides_end()
Definition elem.C:3856
virtual bool is_face(const unsigned int i) const =0
const Elem *const * ConstNeighborPtrIter
Definition elem.h:335
void find_point_neighbors(const Point &p, std::set< const Elem * > &neighbor_set) const
This function finds all active elements (including this one) which are in the same manifold as this e...
Definition elem.C:907
side_iterator boundary_sides_begin()
Iterator accessor functions.
Definition elem.C:3847
void nullify_neighbors()
Replaces this element with nullptr for all of its neighbors.
Definition elem.C:3149
virtual bool has_invertible_map(Real tol=TOLERANCE *TOLERANCE) const
Definition elem.C:3016
virtual ~Elem()=default
Destructor.
std::unique_ptr< Elem *[]> _children
unique_ptr to array of this element's children.
Definition elem.h:2391
unsigned int min_new_p_level_by_neighbor(const Elem *neighbor, unsigned int current_min) const
Definition elem.C:2481
unsigned int local_node(const dof_id_type i) const
Definition elem.h:2617
static constexpr subdomain_id_type invalid_subdomain_id
A static integral constant representing an invalid subdomain id.
Definition elem.h:246
void find_interior_neighbors(std::set< const Elem * > &neighbor_set) const
This function finds all active elements (not including this one) in the parent manifold of this eleme...
Definition elem.C:1086
void swap2boundarysides(unsigned short s1, unsigned short s2, BoundaryInfo *boundary_info) const
Swaps two sides in boundary_info, if it is non-null.
Definition elem.C:3982
unsigned char _map_data
Mapping function data; currently used when needed to store the RATIONAL_BERNSTEIN nodal weight data i...
Definition elem.h:2433
virtual Real embedding_matrix(const unsigned int child_num, const unsigned int child_node_num, const unsigned int parent_node_num) const =0
virtual bool is_singular_node(unsigned int) const
Definition elem.h:1968
bool contains_vertex_of(const Elem *e, bool mesh_connection=false) const
Definition elem.C:848
unsigned int which_child_am_i(const Elem *e) const
Definition elem.h:3330
virtual Real hmin() const
Definition elem.C:623
static ElemType second_order_equivalent_type(const ElemType et, const bool full_ordered=true)
Definition elem.C:3571
static constexpr bool infinite()
Definition elem.h:2048
bool is_semilocal(const processor_id_type my_pid) const
Definition elem.C:780
void libmesh_assert_valid_neighbors() const
Checks for consistent neighbor links on this element.
Definition elem.C:1297
subdomain_id_type _sbd_id
The subdomain to which this element belongs.
Definition elem.h:2397
virtual std::vector< unsigned int > nodes_on_edge(const unsigned int) const =0
void orient(BoundaryInfo *boundary_info)
Flips the element (by swapping node and neighbor pointers) to have a mapping Jacobian of opposite sig...
Definition elem.h:3424
virtual bool contains_point(const Point &p, Real tol=TOLERANCE) const
Definition elem.C:2886
virtual unsigned short dim() const =0
virtual Real quality(const ElemQuality q) const
Definition elem.C:1723
void find_edge_neighbors(const Point &p1, const Point &p2, std::set< const Elem * > &neighbor_set) const
This function finds all active elements in the same manifold as this element which touch the current ...
Definition elem.C:997
virtual void flip(BoundaryInfo *boundary_info)=0
Flips the element (by swapping node and neighbor pointers) to have a mapping Jacobian of opposite sig...
virtual bool is_vertex_on_child(unsigned int, unsigned int n) const
Definition elem.h:872
virtual void permute(unsigned int perm_num)=0
Permutes the element (by swapping node and neighbor pointers) according to the specified index.
void libmesh_assert_valid_node_pointers() const
Checks for a valid id and pointers to nodes with valid ids on this element.
Definition elem.C:1285
virtual unsigned int local_edge_node(unsigned int edge, unsigned int edge_node) const =0
Similar to Elem::local_side_node(), but instead of a side id, takes an edge id and a node id on that ...
subdomain_id_type subdomain_id() const
Definition elem.h:2712
virtual unsigned int n_sub_elem() const =0
static const unsigned int type_to_dim_map[INVALID_ELEM]
This array maps the integer representation of the ElemType enum to the geometric dimension of the ele...
Definition elem.h:649
SimpleRange< ChildRefIter > child_ref_range()
Returns a range with all children of a parent element, usable in range-based for loops.
Definition elem.h:2476
static const unsigned int type_to_n_sides_map[INVALID_ELEM]
This array maps the integer representation of the ElemType enum to the number of sides on the element...
Definition elem.h:759
void make_links_to_me_remote()
Resets this element's neighbors' appropriate neighbor pointers and its parent's and children's approp...
Definition elem.C:1482
virtual bool is_edge(const unsigned int i) const =0
virtual dof_id_type key() const
Definition elem.C:678
Elem ** _elemlinks
Pointers to this element's parent and neighbors, and for lower-dimensional elements' interior_parent.
Definition elem.h:2381
Predicates::multi_predicate Predicate
Useful iterator typedefs.
Definition elem.h:1996
unsigned int level() const
Definition elem.h:3212
virtual Real hmax() const
Definition elem.C:647
unsigned char _map_type
Mapping function type; currently either 0 (LAGRANGE) or 1 (RATIONAL_BERNSTEIN).
Definition elem.h:2427
ElemMappingType mapping_type() const
Definition elem.h:3258
virtual bool is_remote() const
Definition elem.h:617
virtual bool runtime_topology() const
Definition elem.h:254
static const unsigned int max_n_nodes
The maximum number of nodes any element can contain.
Definition elem.h:735
static constexpr unsigned int type_to_n_nodes_map[INVALID_ELEM]
This array maps the integer representation of the ElemType enum to the number of nodes in the element...
Definition elem.h:664
std::vector< unsigned int > oriented_face_vertices(const unsigned int i) const
Definition elem.C:4078
void set_parent(Elem *p)
Sets the pointer to the element's parent.
Definition elem.h:3184
unsigned int min_p_level_by_neighbor(const Elem *neighbor, unsigned int current_min) const
Definition elem.C:2452
bool on_boundary() const
Definition elem.h:3047
std::string get_info() const
Prints relevant information about the element to a string.
Definition elem.C:3058
virtual Point side_vertex_average_normal(const unsigned int s) const
Definition elem.C:3922
virtual std::vector< std::vector< std::vector< signed char > > > & _get_parent_indices_cache() const
Elem subclasses which don't do their own child-to-parent node calculations will need to supply a stat...
Definition elem.h:2353
virtual unsigned int n_faces() const =0
virtual Order default_side_order() const
Definition elem.h:1110
static dof_id_type compute_key(dof_id_type n0)
Definition elem.h:3432
bool contains_edge_of(const Elem *e) const
Definition elem.C:886
virtual unsigned int opposite_side(const unsigned int s) const
Definition elem.C:3959
const Node * node_ptr(const unsigned int i) const
Definition elem.h:2637
void add_child(Elem *elem)
Adds a child pointer to the array of children of this element.
Definition elem.C:2155
void replace_child(Elem *elem, unsigned int c)
Replaces the child pointer at the specified index in the child array.
Definition elem.C:2201
unsigned char _p_level
p refinement level - the difference between the polynomial degree on this element and the minimum pol...
Definition elem.h:2420
virtual unsigned int as_parent_node(unsigned int c, unsigned int n) const
Definition elem.C:2515
virtual dof_id_type key(const unsigned int s) const =0
static const Order type_to_default_order_map[INVALID_ELEM]
This array maps the integer representation of the ElemType enum to the default approximation order of...
Definition elem.h:1089
void active_family_tree(std::vector< const Elem * > &active_family, bool reset=true) const
Same as the family_tree() member, but only adds the active children.
Definition elem.C:2244
virtual std::vector< unsigned int > sides_on_edge(const unsigned int) const =0
const Elem * reference_elem() const
Definition elem.C:508
bool is_internal(const unsigned int i) const
Definition elem.C:4014
void swap3nodes(unsigned int n1, unsigned int n2, unsigned int n3)
Swaps three node_ptrs, "rotating" them.
Definition elem.h:2254
virtual std::unique_ptr< Elem > build_edge_ptr(const unsigned int i)=0
const Node *const * get_nodes() const
Definition elem.h:2629
IntRange< unsigned short > edge_index_range() const
Definition elem.h:2830
Real length(const unsigned int n1, const unsigned int n2) const
Definition elem.C:667
unsigned int which_side_am_i(const Elem *e) const
This function tells you which side the boundary element e is.
Definition elem.C:795
void coarsen()
Coarsen the element.
virtual Real volume() const
Definition elem.C:3865
virtual bool is_vertex(const unsigned int i) const =0
std::unique_ptr< Elem > simple_build_edge_ptr(const unsigned int i)
An implementation for simple (all edges equal) elements.
Definition elem.h:3004
virtual std::unique_ptr< Elem > build_side_ptr(const unsigned int i, bool proxy)
Definition elem.h:1025
virtual unsigned int n_children() const =0
virtual unsigned int embedding_matrix_version() const
Definition elem.h:2181
unsigned int get_node_index(const Node *node_ptr) const
Definition elem.h:2675
void swap2boundaryedges(unsigned short e1, unsigned short e2, BoundaryInfo *boundary_info) const
Swaps two edges in boundary_info, if it is non-null.
Definition elem.C:3998
unsigned int max_descendant_p_level() const
Definition elem.h:3384
void write_connectivity(std::ostream &out, const IOPackage iop) const
Writes the element connectivity for various IO packages to the passed ostream "out".
Definition elem.C:1680
virtual void build_edge_ptr(std::unique_ptr< Elem > &edge, const unsigned int i)=0
Resets the loose element edge, which may currently point to a different edge than i or even a differe...
virtual ElemType type() const =0
IntRange< unsigned short > node_index_range() const
Definition elem.h:2821
virtual Point master_point(const unsigned int i) const =0
const Elem * interior_parent() const
Definition elem.C:1100
unsigned char _pflag
p refinement flag.
Definition elem.h:2410
void simple_side_ptr(std::unique_ptr< Elem > &side, const unsigned int i, ElemType sidetype)
An implementation for simple (all sides equal) elements.
Definition elem.h:2954
Elem *const * NeighborPtrIter
Nested "classes" for use iterating over all neighbors of an element.
Definition elem.h:334
void set_mapping_type(const ElemMappingType type)
Sets the value of the mapping type for the element.
Definition elem.h:3266
virtual bool is_node_on_edge(const unsigned int n, const unsigned int e) const =0
virtual bool is_linear() const
Definition elem.h:1328
bool relative_edge_face_order(const unsigned int e, const unsigned int s) const
Definition elem.C:4096
void set_refinement_flag(const RefinementState rflag)
Sets the value of the refinement flag for the element.
Definition elem.h:3356
virtual unsigned int n_edges() const =0
virtual ElemType side_type(const unsigned int s) const =0
virtual unsigned int n_sides() const =0
dof_id_type node_id(const unsigned int i) const
Definition elem.h:2605
bool subactive() const
Definition elem.h:3097
unsigned int p_level() const
Definition elem.h:3246
IntRange< unsigned short > face_index_range() const
Definition elem.h:2839
void active_family_tree_by_neighbor(std::vector< const Elem * > &family, const Elem *neighbor, bool reset=true) const
Same as the active_family_tree() member, but only adds elements which are next to neighbor.
Definition elem.C:2390
const Elem * topological_neighbor(const unsigned int i, const MeshBase &mesh, const PointLocatorBase &point_locator, const PeriodicBoundaries *pb) const
Definition elem.C:1227
void swap4neighbors(unsigned int n1, unsigned int n2, unsigned int n3, unsigned int n4)
Swaps four neighbor_ptrs, "rotating" them.
Definition elem.h:2283
Elem(const unsigned int n_nodes, const unsigned int n_sides, Elem *parent, Elem **elemlinkdata, Node **nodelinkdata)
Constructor.
Definition elem.h:2508
virtual bool has_affine_map() const
Definition elem.h:1312
void set_mapping_data(const unsigned char data)
Sets the value of the mapping data for the element.
Definition elem.h:3282
RefinementState p_refinement_flag() const
Definition elem.h:3364
virtual unsigned int local_singular_node(const Point &, const Real=TOLERANCE *TOLERANCE) const
Definition elem.h:1961
virtual unsigned short int second_order_adjacent_vertex(const unsigned int n, const unsigned int v) const
Definition elem.C:3183
virtual bool close_to_point(const Point &p, Real tol) const
Definition elem.C:2911
virtual bool is_edge_on_side(const unsigned int e, const unsigned int s) const =0
void set_p_level(const unsigned int p)
Sets the value of the p-refinement level for the element.
const Elem * neighbor_ptr(unsigned int i) const
Definition elem.h:2736
virtual bool infinite() const =0
void family_tree_by_side(std::vector< const Elem * > &family, unsigned int side, bool reset=true) const
Same as the family_tree() member, but only adds elements which are next to side.
Definition elem.C:2260
Point vertex_average() const
Definition elem.C:609
IntRange< unsigned short > side_index_range() const
Definition elem.h:2848
void inherit_data_from(const Elem &src)
A helper function for copying generic element data (mapping, subdomain, processor) from an element to...
Definition elem.h:3477
virtual std::vector< unsigned int > edges_adjacent_to_node(const unsigned int) const =0
unsigned int face_orientation(const unsigned int i) const
Definition elem.C:4053
const Elem * top_parent() const
Definition elem.h:3194
virtual std::unique_ptr< Elem > build_side_ptr(const unsigned int i)=0
The IntRange templated class is intended to make it easy to loop over integers which are indices of a...
Definition int_range.h:54
This is the MeshBase class.
Definition mesh_base.h:81
Implements (adaptive) mesh refinement algorithms for a MeshBase.
A Node is like a Point, but with more information.
Definition node.h:55
We're using a class instead of a typedef to allow forward declarations and future flexibility.
This is the base class for point locators.
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition point.h:41
The PointerToPointerIter templated class is intended to wrap pointer-to-pointer iterators in an inter...
This class implements reference counting.
The SimpleRange templated class is intended to make it easy to construct ranges from pairs of iterato...
Original Authors: Corwin Joy * Michael Gradman [email protected] * Michael.Gradman@caminus....
MeshBase & mesh
uint32_t hashword2(const uint32_t &first, const uint32_t &second, uint32_t initval=0)
This is a hard-coded version of hashword for hashing exactly 2 numbers.
Definition hashword.h:215
uint32_t hashword(const uint32_t *k, size_t length, uint32_t initval=0)
The hashword function takes an array of uint32_t's of length 'length' and computes a single key from ...
Definition hashword.h:158
The libMesh namespace provides an interface to certain functionality in the library.
IOPackage
libMesh interfaces with several different software packages for the purposes of creating,...
ElemType
Defines an enum for geometric element types.
ElemMappingType
Enumeration of possible element master->physical mapping types.
libmesh_assert(ctx)
std::ostream & operator<<(std::ostream &os, const OrderWrapper &order)
Overload stream operators.
Definition fe_type.h:182
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
Definition libmesh.h:303
OStreamProxy out
ElemQuality
Defines an enum for element quality metrics.
static constexpr Real TOLERANCE
uint8_t dof_id_type
Definition id_types.h:67
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
uint8_t processor_id_type
Definition id_types.h:104
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition int_range.h:176
The definition of the struct used for iterating over sides.
Definition elem.h:3629
side_iterator(const IterType &d, const IterType &e, const PredType &p)
Definition elem.h:3632