libMesh
side.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2019 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
libMesh::Side::Side
Side(const Elem *parent_in, const unsigned int side_in)
Constructor.
Definition: side.h:55
libMesh::Side::set_node
virtual Node *& set_node(const unsigned int i) override
Setting a side node changes the node on the parent.
Definition: side.h:79
libMesh::SideEdge::SideEdge
SideEdge(const Elem *my_parent, const unsigned int my_edge)
Constructor.
Definition: side.h:113
libMesh
The libMesh namespace provides an interface to certain functionality in the library.
Definition: factoryfunction.C:55
libMesh::SideEdge::set_node
virtual Node *& set_node(const unsigned int i) override
Setting an edge node changes the node on the parent.
Definition: side.h:130
dim
unsigned int dim
Definition: adaptivity_ex3.C:113
libMesh::SideEdge::_edge_number
const unsigned int _edge_number
The side on the parent element.
Definition: side.h:141
libMesh::libmesh_assert
libmesh_assert(ctx)
libMesh::Side
This defines the Side class.
Definition: side.h:48
libMesh::Node
A Node is like a Point, but with more information.
Definition: node.h:52
n_nodes
const dof_id_type n_nodes
Definition: tecplot_io.C:68
libMesh::Side::_side_number
const unsigned int _side_number
The side on the parent element.
Definition: side.h:90
libMesh::SideEdge
This defines the SideEdge class.
Definition: side.h:106
libMesh::Elem
This is the base class from which all geometric element types are derived.
Definition: elem.h:100
libMesh::Side::~Side
virtual ~Side()=default
libMesh::Side::operator=
Side & operator=(const Side &)=delete