libMesh
cell_prism.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 // C++ includes
20 
21 // Local includes
22 #include "libmesh/cell_prism.h"
23 #include "libmesh/cell_prism6.h"
24 #include "libmesh/face_quad4.h"
25 #include "libmesh/face_tri3.h"
26 
27 namespace libMesh
28 {
29 
30 
31 // ------------------------------------------------------------
32 // Prism class static member initializations
33 
34 
35 // We need to require C++11...
36 const Real Prism::_master_points[18][3] =
37  {
38  {0, 0, -1},
39  {1, 0, -1},
40  {0, 1, -1},
41  {0, 0, 1},
42  {1, 0, 1},
43  {0, 1, 1},
44  {0.5, 0, -1},
45  {0.5, 0.5, -1},
46  {0, 0.5, -1},
47  {0, 0, 0},
48  {1, 0, 0},
49  {0, 1, 0},
50  {0.5, 0, 1},
51  {0.5, 0.5, 1},
52  {0, 0.5, 1},
53  {0.5, 0, 0},
54  {0.5, 0.5, 0},
55  {0, 0.5, 0}
56  };
57 
58 
59 
60 
61 // ------------------------------------------------------------
62 // Prism class member functions
63 dof_id_type Prism::key (const unsigned int s) const
64 {
65  libmesh_assert_less (s, this->n_sides());
66 
67  switch (s)
68  {
69  case 0: // the triangular face at z=0
70  case 4: // the triangular face at z=1
71  return this->compute_key (this->node_id(Prism6::side_nodes_map[s][0]),
72  this->node_id(Prism6::side_nodes_map[s][1]),
73  this->node_id(Prism6::side_nodes_map[s][2]));
74 
75  case 1: // the quad face at y=0
76  case 2: // the other quad face
77  case 3: // the quad face at x=0
78  return this->compute_key (this->node_id(Prism6::side_nodes_map[s][0]),
79  this->node_id(Prism6::side_nodes_map[s][1]),
80  this->node_id(Prism6::side_nodes_map[s][2]),
81  this->node_id(Prism6::side_nodes_map[s][3]));
82 
83  default:
84  libmesh_error_msg("Invalid side " << s);
85  }
86 
87  libmesh_error_msg("We'll never get here!");
88  return 0;
89 }
90 
91 
92 
93 unsigned int Prism::which_node_am_i(unsigned int side,
94  unsigned int side_node) const
95 {
96  libmesh_assert_less (side, this->n_sides());
97 
98  // Never more than 4 nodes per side.
99  libmesh_assert_less(side_node, 4);
100 
101  // Some sides have 3 nodes.
102  libmesh_assert(!(side==0 || side==4) || side_node < 3);
103 
104  return Prism6::side_nodes_map[side][side_node];
105 }
106 
107 
108 
109 UniquePtr<Elem> Prism::side_ptr (const unsigned int i)
110 {
111  libmesh_assert_less (i, this->n_sides());
112 
113  Elem * face = libmesh_nullptr;
114 
115  // Set up the type of element
116  switch (i)
117  {
118  case 0: // the triangular face at z=0
119  case 4: // the triangular face at z=1
120  {
121  face = new Tri3;
122  break;
123  }
124  case 1: // the quad face at y=0
125  case 2: // the other quad face
126  case 3: // the quad face at x=0
127  {
128  face = new Quad4;
129  break;
130  }
131  default:
132  libmesh_error_msg("Invalid side i = " << i);
133  }
134 
135  // Set the nodes
136  for (unsigned n=0; n<face->n_nodes(); ++n)
137  face->set_node(n) = this->node_ptr(Prism6::side_nodes_map[i][n]);
138 
139  return UniquePtr<Elem>(face);
140 }
141 
142 
143 
144 bool Prism::is_child_on_side(const unsigned int c,
145  const unsigned int s) const
146 {
147  libmesh_assert_less (c, this->n_children());
148  libmesh_assert_less (s, this->n_sides());
149 
150  for (unsigned int i = 0; i != 4; ++i)
151  if (Prism6::side_elems_map[s][i] == c)
152  return true;
153  return false;
154 }
155 
156 
157 
158 bool Prism::is_edge_on_side(const unsigned int e,
159  const unsigned int s) const
160 {
161  libmesh_assert_less (e, this->n_edges());
162  libmesh_assert_less (s, this->n_sides());
163 
164  return (is_node_on_side(Prism6::edge_nodes_map[e][0],s) &&
165  is_node_on_side(Prism6::edge_nodes_map[e][1],s));
166 }
167 
168 
169 
170 const unsigned short int Prism::_second_order_vertex_child_number[18] =
171  {
172  99,99,99,99,99,99, // Vertices
173  0,1,0,0,1,2,3,4,3, // Edges
174  0,1,0 // Faces
175  };
176 
177 
178 
179 const unsigned short int Prism::_second_order_vertex_child_index[18] =
180  {
181  99,99,99,99,99,99, // Vertices
182  1,2,2,3,4,5,4,5,5, // Edges
183  4,5,5 // Faces
184  };
185 
186 
187 const unsigned short int Prism::_second_order_adjacent_vertices[9][2] =
188  {
189  { 0, 1}, // vertices adjacent to node 6
190  { 1, 2}, // vertices adjacent to node 7
191  { 0, 2}, // vertices adjacent to node 8
192 
193  { 0, 3}, // vertices adjacent to node 9
194  { 1, 4}, // vertices adjacent to node 10
195  { 2, 5}, // vertices adjacent to node 11
196 
197  { 3, 4}, // vertices adjacent to node 12
198  { 4, 5}, // vertices adjacent to node 13
199  { 3, 5} // vertices adjacent to node 14
200  };
201 
202 } // namespace libMesh
virtual bool is_node_on_side(const unsigned int n, const unsigned int s) const =0
The Tri3 is an element in 2D composed of 3 nodes.
Definition: face_tri3.h:54
virtual Node *& set_node(const unsigned int i)
Definition: elem.h:1941
virtual unsigned int which_node_am_i(unsigned int side, unsigned int side_node) const libmesh_override
Definition: cell_prism.C:93
The QUAD4 is an element in 2D composed of 4 nodes.
Definition: face_quad4.h:49
virtual UniquePtr< Elem > side_ptr(const unsigned int i) libmesh_override
Definition: cell_prism.C:109
UniquePtr< Elem > side(const unsigned int i) const
Definition: elem.h:2105
This is the base class from which all geometric element types are derived.
Definition: elem.h:89
const class libmesh_nullptr_t libmesh_nullptr
The libMesh namespace provides an interface to certain functionality in the library.
libmesh_assert(j)
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
virtual unsigned int n_nodes() const =0
static const unsigned short int _second_order_adjacent_vertices[9][2]
Matrix that tells which vertices define the location of mid-side (or second-order) nodes...
Definition: cell_prism.h:145
static const Real _master_points[18][3]
Master element node locations.
Definition: cell_prism.h:160
virtual dof_id_type key() const
Definition: elem.C:503
const Node * node_ptr(const unsigned int i) const
Definition: elem.h:1874
static const unsigned short int _second_order_vertex_child_index[18]
Vector that names the child vertex index for each second order node.
Definition: cell_prism.h:155
virtual unsigned int n_children() const libmesh_override
Definition: cell_prism.h:93
static const unsigned short int _second_order_vertex_child_number[18]
Vector that names a child sharing each second order node.
Definition: cell_prism.h:150
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual bool is_child_on_side(const unsigned int c, const unsigned int s) const libmesh_override
Definition: cell_prism.C:144
virtual unsigned int n_sides() const libmesh_override
Definition: cell_prism.h:73
dof_id_type node_id(const unsigned int i) const
Definition: elem.h:1831
virtual unsigned int n_edges() const libmesh_override
Definition: cell_prism.h:83
static dof_id_type compute_key(dof_id_type n0)
Definition: elem.h:2621
virtual bool is_edge_on_side(const unsigned int e, const unsigned int s) const libmesh_override
Definition: cell_prism.C:158
uint8_t dof_id_type
Definition: id_types.h:64