edge.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 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::which_node_am_i(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 std::unique_ptr<Elem> Edge::side_ptr (const unsigned int i)
37 {
38  libmesh_assert_less (i, 2);
39  std::unique_ptr<Elem> nodeelem = libmesh_make_unique<NodeElem>(this);
40  nodeelem->set_node(0) = this->node_ptr(i);
41  return nodeelem;
42 }
43 
44 
45 void Edge::side_ptr (std::unique_ptr<Elem> & side,
46  const unsigned int i)
47 {
48  libmesh_assert_less (i, this->n_sides());
49 
50  if (!side.get() || side->type() != NODEELEM)
51  side = this->build_side_ptr(i, false);
52  else
53  {
54  side->subdomain_id() = this->subdomain_id();
55 
56  side->set_node(0) = this->node_ptr(i);
57  }
58 }
59 
60 
61 
62 
63 std::unique_ptr<Elem> Edge::build_side_ptr (const unsigned int i, bool)
64 {
65  libmesh_assert_less (i, 2);
66  std::unique_ptr<Elem> nodeelem = libmesh_make_unique<NodeElem>(this);
67  nodeelem->set_node(0) = this->node_ptr(i);
68  return nodeelem;
69 }
70 
71 
72 void Edge::build_side_ptr (std::unique_ptr<Elem> & side,
73  const unsigned int i)
74 {
75  this->side_ptr(side, i);
76 }
77 
78 
79 
80 
81 bool Edge::is_child_on_side(const unsigned int c,
82  const unsigned int s) const
83 {
84  libmesh_assert_less (c, this->n_children());
85  libmesh_assert_less (s, this->n_sides());
86 
87  return (c == s);
88 }
89 
90 
91 
92 unsigned int Edge::opposite_side(const unsigned int side_in) const
93 {
94  libmesh_assert_less (side_in, 2);
95  return 1 - side_in;
96 }
97 
98 
99 
100 unsigned int Edge::opposite_node(const unsigned int node_in,
101  const unsigned int libmesh_dbg_var(side_in)) const
102 {
103  libmesh_assert_less (node_in, 2);
104  libmesh_assert_less (side_in, this->n_sides());
105  libmesh_assert(this->is_node_on_side(node_in, side_in));
106 
107  return 1 - node_in;
108 }
109 
110 std::vector<unsigned>
111 Edge::nodes_on_side(const unsigned int s) const
112 {
113  libmesh_assert_less(s, 2);
114  return {s};
115 }
116 
117 } // namespace libMesh
virtual unsigned int which_node_am_i(unsigned int side, unsigned int) const override final
Definition: edge.C:27
virtual std::vector< unsigned int > nodes_on_side(const unsigned int s) const override
Definition: edge.C:111
unsigned short int side
Definition: xdr_io.C:50
virtual bool is_node_on_side(const unsigned int n, const unsigned int s) const =0
virtual unsigned int opposite_side(const unsigned int s) const override final
Definition: edge.C:92
virtual std::unique_ptr< Elem > side_ptr(const unsigned int i) override final
Definition: edge.C:36
virtual std::unique_ptr< Elem > build_side_ptr(const unsigned int i, bool proxy) override final
Definition: edge.C:63
virtual unsigned int n_children() const override final
Definition: edge.h:94
subdomain_id_type subdomain_id() const
Definition: elem.h:2034
const Node * node_ptr(const unsigned int i) const
Definition: elem.h:1957
virtual unsigned int opposite_node(const unsigned int n, const unsigned int s) const override final
Definition: edge.C:100
std::unique_ptr< Elem > side(const unsigned int i) const
Definition: elem.h:2202
virtual bool is_child_on_side(const unsigned int c, const unsigned int s) const override final
Definition: edge.C:81
virtual unsigned int n_sides() const override final
Definition: edge.h:74