libMesh
edge.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2024 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 // Local includes
21 #include "libmesh/edge.h"
22 #include "libmesh/node_elem.h"
23 
24 namespace libMesh
25 {
26 
27 unsigned int Edge::local_side_node(unsigned int side,
28  unsigned int /*side_node*/) const
29 {
30  libmesh_assert_less (side, this->n_sides());
31  return side;
32 }
33 
34 
35 
36 unsigned int Edge::local_edge_node(unsigned int /*edge*/,
37  unsigned int /*edge_node*/) const
38 {
39  libmesh_error_msg("Calling Edge::local_edge_node() does not make sense.");
40  return 0;
41 }
42 
43 
44 
45 std::unique_ptr<Elem> Edge::side_ptr (const unsigned int i)
46 {
47  libmesh_assert_less (i, 2);
48  std::unique_ptr<Elem> nodeelem = std::make_unique<NodeElem>(this);
49  nodeelem->set_node(0) = this->node_ptr(i);
50  return nodeelem;
51 }
52 
53 
54 void Edge::side_ptr (std::unique_ptr<Elem> & side,
55  const unsigned int i)
56 {
57  libmesh_assert_less (i, this->n_sides());
58 
59  if (!side.get() || side->type() != NODEELEM)
60  side = this->build_side_ptr(i, false);
61  else
62  {
63  side->subdomain_id() = this->subdomain_id();
64  side->set_mapping_type(this->mapping_type());
65 
66  side->set_node(0) = this->node_ptr(i);
67  }
68 }
69 
70 
71 
72 
73 std::unique_ptr<Elem> Edge::build_side_ptr (const unsigned int i, bool)
74 {
75  libmesh_assert_less (i, 2);
76  std::unique_ptr<Elem> nodeelem = std::make_unique<NodeElem>(this);
77  nodeelem->set_node(0) = this->node_ptr(i);
78 
79 #ifndef LIBMESH_ENABLE_DEPRECATED
80  nodeelem->set_parent(nullptr);
81 #endif
82  nodeelem->set_interior_parent(this);
83 
84  return nodeelem;
85 }
86 
87 
88 void Edge::build_side_ptr (std::unique_ptr<Elem> & side,
89  const unsigned int i)
90 {
91  this->side_ptr(side, i);
92 }
93 
94 
95 
96 
97 bool Edge::is_child_on_side(const unsigned int c,
98  const unsigned int s) const
99 {
100  libmesh_assert_less (c, this->n_children());
101  libmesh_assert_less (s, this->n_sides());
102 
103  return (c == s);
104 }
105 
106 
107 
108 unsigned int Edge::opposite_side(const unsigned int side_in) const
109 {
110  libmesh_assert_less (side_in, 2);
111  return 1 - side_in;
112 }
113 
114 
115 
116 unsigned int Edge::opposite_node(const unsigned int node_in,
117  const unsigned int libmesh_dbg_var(side_in)) const
118 {
119  libmesh_assert_less (node_in, 2);
120  libmesh_assert_less (side_in, this->n_sides());
121  libmesh_assert(this->is_node_on_side(node_in, side_in));
122 
123  return 1 - node_in;
124 }
125 
126 std::vector<unsigned>
127 Edge::nodes_on_side(const unsigned int s) const
128 {
129  libmesh_assert_less(s, 2);
130  return {s};
131 }
132 
133 std::vector<unsigned>
134 Edge::nodes_on_edge(const unsigned int e) const
135 {
136  return nodes_on_side(e);
137 }
138 
139 unsigned int Edge::center_node_on_side(const unsigned short side) const
140 {
141  libmesh_assert_less (side, this->n_sides());
142  return side;
143 }
144 
145 ElemType Edge::side_type (const unsigned int libmesh_dbg_var(s)) const
146 {
147  libmesh_assert_less (s, 2);
148  return NODEELEM;
149 }
150 
151 
152 bool
154 {
155  // Don't trigger on 1D elements embedded in 2D/3D
156  return (
157 #if LIBMESH_DIM > 2
158  !this->point(0)(2) && !this->point(1)(2) &&
159 #endif
160 #if LIBMESH_DIM > 1
161  !this->point(0)(1) && !this->point(1)(1) &&
162 #endif
163  this->point(0)(0) > this->point(1)(0));
164 }
165 
166 
167 } // namespace libMesh
ElemType
Defines an enum for geometric element types.
virtual unsigned int local_edge_node(unsigned int edge, unsigned int edge_node) const override final
Throws an error.
Definition: edge.C:36
virtual std::vector< unsigned int > nodes_on_side(const unsigned int s) const override
Definition: edge.C:127
virtual unsigned int local_side_node(unsigned int side, unsigned int) const override final
Definition: edge.C:27
virtual bool is_flipped() const override final
Definition: edge.C:153
virtual bool is_node_on_side(const unsigned int n, const unsigned int s) const =0
The libMesh namespace provides an interface to certain functionality in the library.
ElemMappingType mapping_type() const
Definition: elem.h:2957
virtual std::unique_ptr< Elem > build_side_ptr(const unsigned int i, bool proxy=false) override final
Definition: edge.C:73
virtual unsigned int opposite_side(const unsigned int s) const override final
Definition: edge.C:108
libmesh_assert(ctx)
virtual std::unique_ptr< Elem > side_ptr(const unsigned int i) override final
Definition: edge.C:45
virtual unsigned int n_children() const override final
Definition: edge.h:94
subdomain_id_type subdomain_id() const
Definition: elem.h:2391
const Node * node_ptr(const unsigned int i) const
Definition: elem.h:2331
unsigned int center_node_on_side(const unsigned short side) const override final
Definition: edge.C:139
ElemType side_type(const unsigned int s) const override final
Definition: edge.C:145
virtual unsigned int opposite_node(const unsigned int n, const unsigned int s) const override final
Definition: edge.C:116
const Point & point(const unsigned int i) const
Definition: elem.h:2277
virtual std::vector< unsigned int > nodes_on_edge(const unsigned int e) const override
Definition: edge.C:134
virtual bool is_child_on_side(const unsigned int c, const unsigned int s) const override final
Definition: edge.C:97
virtual unsigned int n_sides() const override final
Definition: edge.h:74