libMesh
side.h
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 #ifndef LIBMESH_SIDE_H
21 #define LIBMESH_SIDE_H
22 
23 // Local includes
24 #include "libmesh/libmesh_common.h"
25 #include "libmesh/elem.h"
26 
27 namespace libMesh
28 {
29 
30 // Forward declarations
31 class Point;
32 class Node;
33 
47 template <class SideType, class ParentType>
48 class Side : public SideType
49 {
50 public:
51 
55  Side (const Elem * parent_in,
56  const unsigned int side_in) :
57  SideType(const_cast<Elem *>(parent_in)),
58  _side_number(side_in)
59  {
60  libmesh_assert(parent_in);
61  // may not be true when building infinite element sides
62  // libmesh_assert_less (_side_number, this->parent()->n_sides());
63  libmesh_assert_equal_to ((this->dim()+1), this->parent()->dim());
64 
65  for (auto n : this->node_index_range())
66  this->_nodes[n] = this->parent()->node_ptr
67  (ParentType::side_nodes_map[_side_number][n]);
68  }
69 
73  virtual Node * & set_node (const unsigned int i) libmesh_override
74  {
75  libmesh_assert_less (i, this->n_nodes());
76  return this->parent()->set_node (ParentType::side_nodes_map[_side_number][i]);
77  }
78 
82  virtual unsigned int n_sides () const libmesh_override
83  { return 0; }
84 
85  virtual bool is_child_on_side(const unsigned int,
86  const unsigned int) const libmesh_override
87  { libmesh_not_implemented(); return false; }
88 
89 
90 private:
91 
95  const unsigned int _side_number;
96 };
97 
98 
99 
110 template <class EdgeType, class ParentType>
111 class SideEdge : public EdgeType
112 {
113 public:
114 
118  SideEdge (const Elem * my_parent,
119  const unsigned int my_edge) :
120  EdgeType(const_cast<Elem *>(my_parent)),
121  _edge_number(my_edge)
122  {
123  libmesh_assert(my_parent);
124  libmesh_assert_less (_edge_number, this->parent()->n_edges());
125  libmesh_assert_equal_to (this->dim(), 1);
126 
127  for (auto n : this->node_index_range())
128  this->_nodes[n] = this->parent()->node_ptr
129  (ParentType::edge_nodes_map[_edge_number][n]);
130  }
131 
135  virtual Node * & set_node (const unsigned int i) libmesh_override
136  {
137  libmesh_assert_less (i, this->n_nodes());
138  return this->parent()->set_node (ParentType::edge_nodes_map[_edge_number][i]);
139  }
140 
144  virtual unsigned int n_sides () const libmesh_override { return 0; }
145 
146 private:
147 
151  const unsigned int _edge_number;
152 };
153 
154 
155 } // namespace libMesh
156 
157 #endif // LIBMESH_SIDE_H
A Node is like a Point, but with more information.
Definition: node.h:52
unsigned int dim
This is the base class from which all geometric element types are derived.
Definition: elem.h:89
const unsigned int _edge_number
The side on the parent element.
Definition: side.h:151
The libMesh namespace provides an interface to certain functionality in the library.
virtual unsigned int n_sides() const libmesh_override
Definition: side.h:144
SideEdge(const Elem *my_parent, const unsigned int my_edge)
Constructor.
Definition: side.h:118
libmesh_assert(j)
const dof_id_type n_nodes
Definition: tecplot_io.C:67
const unsigned int _side_number
The side on the parent element.
Definition: side.h:95
virtual unsigned int n_sides() const libmesh_override
Sides do not have sides.
Definition: side.h:82
This defines the Side class.
Definition: side.h:48
virtual Node *& set_node(const unsigned int i) libmesh_override
Setting an edge node changes the node on the parent.
Definition: side.h:135
This defines the SideEdge class.
Definition: side.h:111
virtual Node *& set_node(const unsigned int i) libmesh_override
Setting a side node changes the node on the parent.
Definition: side.h:73
Side(const Elem *parent_in, const unsigned int side_in)
Constructor.
Definition: side.h:55
virtual bool is_child_on_side(const unsigned int, const unsigned int) const libmesh_override
Definition: side.h:85