libMesh
edge.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 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 UniquePtr<Elem> Edge::side_ptr (const unsigned int i)
37 {
38  libmesh_assert_less (i, 2);
39  const Elem * the_parent = this;
40  Elem * nodeelem = new NodeElem(const_cast<Elem *>(the_parent));
41  nodeelem->set_node(0) = this->node_ptr(i);
42  return UniquePtr<Elem>(nodeelem);
43 }
44 
45 
46 UniquePtr<Elem> Edge::build_side_ptr (const unsigned int i, bool)
47 {
48  libmesh_assert_less (i, 2);
49  const Elem * the_parent = this;
50  Elem * nodeelem = new NodeElem(const_cast<Elem *>(the_parent));
51  nodeelem->set_node(0) = this->node_ptr(i);
52  return UniquePtr<Elem>(nodeelem);
53 }
54 
55 
56 bool Edge::is_child_on_side(const unsigned int c,
57  const unsigned int s) const
58 {
59  libmesh_assert_less (c, this->n_children());
60  libmesh_assert_less (s, this->n_sides());
61 
62  return (c == s);
63 }
64 
65 
66 
67 unsigned int Edge::opposite_side(const unsigned int side_in) const
68 {
69  libmesh_assert_less (side_in, 2);
70  return 1 - side_in;
71 }
72 
73 
74 
75 unsigned int Edge::opposite_node(const unsigned int node_in,
76  const unsigned int libmesh_dbg_var(side_in)) const
77 {
78  libmesh_assert_less (node_in, 2);
79  libmesh_assert_less (side_in, this->n_sides());
80  libmesh_assert(this->is_node_on_side(node_in, side_in));
81 
82  return 1 - node_in;
83 }
84 
85 
86 
87 } // namespace libMesh
virtual bool is_node_on_side(const unsigned int n, const unsigned int s) const =0
virtual unsigned int n_children() const libmesh_override
Definition: edge.h:88
virtual Node *& set_node(const unsigned int i)
Definition: elem.h:1941
UniquePtr< Elem > side(const unsigned int i) const
Definition: elem.h:2105
unsigned short int side
Definition: xdr_io.C:49
This is the base class from which all geometric element types are derived.
Definition: elem.h:89
virtual UniquePtr< Elem > side_ptr(const unsigned int i) libmesh_override
Definition: edge.C:36
virtual unsigned int n_sides() const libmesh_override
Definition: edge.h:68
The libMesh namespace provides an interface to certain functionality in the library.
virtual unsigned int which_node_am_i(unsigned int side, unsigned int) const libmesh_override
Definition: edge.C:27
libmesh_assert(j)
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
virtual unsigned int opposite_node(const unsigned int n, const unsigned int s) const libmesh_override
Definition: edge.C:75
const Node * node_ptr(const unsigned int i) const
Definition: elem.h:1874
PetscErrorCode Vec Mat libmesh_dbg_var(j)
The NodeElem is a point element, generally used as a side of a 1D element.
Definition: node_elem.h:37
virtual UniquePtr< Elem > build_side_ptr(const unsigned int i, bool proxy) libmesh_override
Definition: edge.C:46
virtual unsigned int opposite_side(const unsigned int s) const libmesh_override
Definition: edge.C:67
virtual bool is_child_on_side(const unsigned int c, const unsigned int s) const libmesh_override
Definition: edge.C:56