side.h
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 #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 
70  Side (Side &&) = delete;
71  Side (const Side &) = delete;
72  Side & operator= (const Side &) = delete;
73  Side & operator= (Side &&) = delete;
74  virtual ~Side() = default;
75 
79  virtual Node * & set_node (const unsigned int i) override
80  {
81  libmesh_assert_less (i, this->n_nodes());
82  return this->parent()->set_node (ParentType::side_nodes_map[_side_number][i]);
83  }
84 
85 private:
86 
90  const unsigned int _side_number;
91 };
92 
93 
94 
105 template <class EdgeType, class ParentType>
106 class SideEdge : public EdgeType
107 {
108 public:
109 
113  SideEdge (const Elem * my_parent,
114  const unsigned int my_edge) :
115  EdgeType(const_cast<Elem *>(my_parent)),
116  _edge_number(my_edge)
117  {
118  libmesh_assert(my_parent);
119  libmesh_assert_less (_edge_number, this->parent()->n_edges());
120  libmesh_assert_equal_to (this->dim(), 1);
121 
122  for (auto n : this->node_index_range())
123  this->_nodes[n] = this->parent()->node_ptr
124  (ParentType::edge_nodes_map[_edge_number][n]);
125  }
126 
130  virtual Node * & set_node (const unsigned int i) override
131  {
132  libmesh_assert_less (i, this->n_nodes());
133  return this->parent()->set_node (ParentType::edge_nodes_map[_edge_number][i]);
134  }
135 
136 private:
137 
141  const unsigned int _edge_number;
142 };
143 
144 
145 } // namespace libMesh
146 
147 #endif // LIBMESH_SIDE_H
A geometric point in (x,y,z) space associated with a DOF.
Definition: node.h:52
The base class for all geometric element types.
Definition: elem.h:100
const unsigned int _edge_number
Definition: side.h:141
virtual ~Side()=default
SideEdge(const Elem *my_parent, const unsigned int my_edge)
Definition: side.h:113
const dof_id_type n_nodes
Definition: tecplot_io.C:68
const unsigned int _side_number
Definition: side.h:90
virtual Node *& set_node(const unsigned int i) override
Definition: side.h:130
Proxy class for efficiently representing an Elem&#39;s side.
Definition: side.h:48
Side & operator=(const Side &)=delete
Side(const Elem *parent_in, const unsigned int side_in)
Definition: side.h:55
virtual Node *& set_node(const unsigned int i) override
Definition: side.h:79