cell_pyramid.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2014 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_pyramid.h"
23 #include "libmesh/cell_pyramid5.h"
24 #include "libmesh/face_tri3.h"
25 #include "libmesh/face_quad4.h"
26 
27 namespace libMesh
28 {
29 
30 
31 // ------------------------------------------------------------
32 // Pyramid class member functions
33 dof_id_type Pyramid::key (const unsigned int s) const
34 {
35  libmesh_assert_less (s, this->n_sides());
36 
37 
38  switch (s)
39  {
40  case 0: // triangular face 1
41 
42  return
43  this->compute_key (this->node(0),
44  this->node(1),
45  this->node(4));
46 
47  case 1: // triangular face 2
48 
49  return
50  this->compute_key (this->node(1),
51  this->node(2),
52  this->node(4));
53 
54  case 2: // triangular face 3
55 
56  return
57  this->compute_key (this->node(2),
58  this->node(3),
59  this->node(4));
60 
61  case 3: // triangular face 4
62 
63  return
64  this->compute_key (this->node(3),
65  this->node(0),
66  this->node(4));
67 
68  case 4: // the quad face at z=0
69 
70  return
71  this->compute_key (this->node(0),
72  this->node(3),
73  this->node(2),
74  this->node(1));
75  }
76 
77  // We'll never get here.
78  libmesh_error();
79  return 0;
80 }
81 
82 
83 
84 AutoPtr<Elem> Pyramid::side (const unsigned int i) const
85 {
86  libmesh_assert_less (i, this->n_sides());
87 
88 
89 
90  switch (i)
91  {
92  case 0: // triangular face 1
93  {
94  Elem* face = new Tri3;
95 
96  face->set_node(0) = this->get_node(0);
97  face->set_node(1) = this->get_node(1);
98  face->set_node(2) = this->get_node(4);
99 
100  AutoPtr<Elem> ap_face(face);
101  return ap_face;
102  }
103  case 1: // triangular face 2
104  {
105  Elem* face = new Tri3;
106 
107  face->set_node(0) = this->get_node(1);
108  face->set_node(1) = this->get_node(2);
109  face->set_node(2) = this->get_node(4);
110 
111  AutoPtr<Elem> ap_face(face);
112  return ap_face;
113  }
114  case 2: // triangular face 3
115  {
116  Elem* face = new Tri3;
117 
118  face->set_node(0) = this->get_node(2);
119  face->set_node(1) = this->get_node(3);
120  face->set_node(2) = this->get_node(4);
121 
122  AutoPtr<Elem> ap_face(face);
123  return ap_face;
124  }
125  case 3: // triangular face 4
126  {
127  Elem* face = new Tri3;
128 
129  face->set_node(0) = this->get_node(3);
130  face->set_node(1) = this->get_node(0);
131  face->set_node(2) = this->get_node(4);
132 
133  AutoPtr<Elem> ap_face(face);
134  return ap_face;
135  }
136  case 4: // the quad face at z=0
137  {
138  Elem* face = new Quad4;
139 
140  face->set_node(0) = this->get_node(0);
141  face->set_node(1) = this->get_node(3);
142  face->set_node(2) = this->get_node(2);
143  face->set_node(3) = this->get_node(1);
144 
145  AutoPtr<Elem> ap_face(face);
146  return ap_face;
147  }
148  default:
149  {
150  libmesh_error();
151  AutoPtr<Elem> ap_face(NULL);
152  return ap_face;
153  }
154  }
155 
156  // We'll never get here.
157  libmesh_error();
158  AutoPtr<Elem> ap_face(NULL);
159 
160  return ap_face;
161 }
162 
163 
164 
165 bool Pyramid::is_child_on_side(const unsigned int c,
166  const unsigned int s) const
167 {
168  libmesh_assert_less (c, this->n_children());
169  libmesh_assert_less (s, this->n_sides());
170 
171  for (unsigned int i = 0; i != 4; ++i)
172  if (Pyramid5::side_nodes_map[s][i] == c)
173  return true;
174  return false;
175 }
176 
177 
178 
179 bool Pyramid::is_edge_on_side(const unsigned int e,
180  const unsigned int s) const
181 {
182  libmesh_assert_less (e, this->n_edges());
183  libmesh_assert_less (s, this->n_sides());
184 
185  return (is_node_on_side(Pyramid5::edge_nodes_map[e][0],s) &&
187 }
188 
189 
190 
191 } // namespace libMesh

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:04 UTC

Hosted By:
SourceForge.net Logo