cell_pyramid14.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/side.h"
23 #include "libmesh/cell_pyramid14.h"
24 #include "libmesh/edge_edge3.h"
25 #include "libmesh/face_tri6.h"
26 #include "libmesh/face_quad9.h"
27 
28 namespace libMesh
29 {
30 
31 
32 
33 
34 // ------------------------------------------------------------
35 // Pyramid14 class static member initializations
36 const unsigned int Pyramid14::side_nodes_map[5][9] =
37 {
38  {0, 1, 4, 5, 10, 9, 99, 99, 99}, // Side 0 (front)
39  {1, 2, 4, 6, 11, 10, 99, 99, 99}, // Side 1 (right)
40  {2, 3, 4, 7, 12, 11, 99, 99, 99}, // Side 2 (back)
41  {3, 0, 4, 8, 9, 12, 99, 99, 99}, // Side 3 (left)
42  {0, 3, 2, 1, 8, 7, 6, 5, 13} // Side 4 (base)
43 };
44 
45 const unsigned int Pyramid14::edge_nodes_map[8][3] =
46 {
47  {0, 1, 5}, // Edge 0
48  {1, 2, 6}, // Edge 1
49  {2, 3, 7}, // Edge 2
50  {0, 3, 8}, // Edge 3
51  {0, 4, 9}, // Edge 4
52  {1, 4, 10}, // Edge 5
53  {2, 4, 11}, // Edge 6
54  {3, 4, 12} // Edge 7
55 };
56 
57 
58 
59 // ------------------------------------------------------------
60 // Pyramid14 class member functions
61 
62 bool Pyramid14::is_vertex(const unsigned int i) const
63 {
64  if (i < 5)
65  return true;
66  return false;
67 }
68 
69 
70 
71 bool Pyramid14::is_edge(const unsigned int i) const
72 {
73  if (i < 5)
74  return false;
75  if (i == 13)
76  return false;
77  return true;
78 }
79 
80 
81 
82 bool Pyramid14::is_face(const unsigned int i) const
83 {
84  if (i == 13)
85  return true;
86  return false;
87 }
88 
89 
90 
91 bool Pyramid14::is_node_on_side(const unsigned int n,
92  const unsigned int s) const
93 {
94  libmesh_assert_less (s, n_sides());
95  for (unsigned int i = 0; i != 9; ++i)
96  if (side_nodes_map[s][i] == n)
97  return true;
98  return false;
99 }
100 
101 bool Pyramid14::is_node_on_edge(const unsigned int n,
102  const unsigned int e) const
103 {
104  libmesh_assert_less (e, n_edges());
105  for (unsigned int i = 0; i != 3; ++i)
106  if (edge_nodes_map[e][i] == n)
107  return true;
108  return false;
109 }
110 
111 
112 
114 {
115  // TODO: If the base is a parallelogram and all the triangular faces are planar,
116  // the map should be linear, but I need to test this theory...
117  return false;
118 }
119 
120 
121 
122 AutoPtr<Elem> Pyramid14::build_side (const unsigned int i, bool proxy) const
123 {
124  libmesh_assert_less (i, this->n_sides());
125 
126  if (proxy)
127  {
128  switch (i)
129  {
130  case 0:
131  case 1:
132  case 2:
133  case 3:
134  {
135  AutoPtr<Elem> face(new Side<Tri6,Pyramid14>(this,i));
136  return face;
137  }
138 
139  case 4:
140  {
141  AutoPtr<Elem> face(new Side<Quad9,Pyramid14>(this,i));
142  return face;
143  }
144 
145  default:
146  {
147  libmesh_error();
148  }
149  }
150  }
151 
152  else
153  {
154  // Create NULL pointer to be initialized, returned later.
155  AutoPtr<Elem> face(NULL);
156 
157  switch (i)
158  {
159  case 0: // triangular face 1
160  {
161  face.reset(new Tri6);
162 
163  face->set_node(0) = this->get_node(0);
164  face->set_node(1) = this->get_node(1);
165  face->set_node(2) = this->get_node(4);
166  face->set_node(3) = this->get_node(5);
167  face->set_node(4) = this->get_node(10);
168  face->set_node(5) = this->get_node(9);
169 
170  break;
171  }
172  case 1: // triangular face 2
173  {
174  face.reset(new Tri6);
175 
176  face->set_node(0) = this->get_node(1);
177  face->set_node(1) = this->get_node(2);
178  face->set_node(2) = this->get_node(4);
179  face->set_node(3) = this->get_node(6);
180  face->set_node(4) = this->get_node(11);
181  face->set_node(5) = this->get_node(10);
182 
183  break;
184  }
185  case 2: // triangular face 3
186  {
187  face.reset(new Tri6);
188 
189  face->set_node(0) = this->get_node(2);
190  face->set_node(1) = this->get_node(3);
191  face->set_node(2) = this->get_node(4);
192  face->set_node(3) = this->get_node(7);
193  face->set_node(4) = this->get_node(12);
194  face->set_node(5) = this->get_node(11);
195 
196  break;
197  }
198  case 3: // triangular face 4
199  {
200  face.reset(new Tri6);
201 
202  face->set_node(0) = this->get_node(3);
203  face->set_node(1) = this->get_node(0);
204  face->set_node(2) = this->get_node(4);
205  face->set_node(3) = this->get_node(8);
206  face->set_node(4) = this->get_node(9);
207  face->set_node(5) = this->get_node(12);
208 
209  break;
210  }
211  case 4: // the quad face at z=0
212  {
213  face.reset(new Quad9);
214 
215  face->set_node(0) = this->get_node(0);
216  face->set_node(1) = this->get_node(3);
217  face->set_node(2) = this->get_node(2);
218  face->set_node(3) = this->get_node(1);
219  face->set_node(4) = this->get_node(8);
220  face->set_node(5) = this->get_node(7);
221  face->set_node(6) = this->get_node(6);
222  face->set_node(7) = this->get_node(5);
223  face->set_node(8) = this->get_node(13);
224 
225  break;
226  }
227  default:
228  {
229  libmesh_error();
230  }
231  }
232 
233  face->subdomain_id() = this->subdomain_id();
234  return face;
235  }
236 
237 
238  // We'll never get here.
239  libmesh_error();
240  AutoPtr<Elem> ap(NULL); return ap;
241 }
242 
243 
244 
245 AutoPtr<Elem> Pyramid14::build_edge (const unsigned int i) const
246 {
247  libmesh_assert_less (i, this->n_edges());
248 
249  return AutoPtr<Elem>(new SideEdge<Edge3,Pyramid14>(this,i));
250 }
251 
252 
253 
254 void Pyramid14::connectivity(const unsigned int libmesh_dbg_var(sc),
255  const IOPackage iop,
256  std::vector<dof_id_type>& conn) const
257 {
259  libmesh_assert_less (sc, this->n_sub_elem());
260  libmesh_assert_not_equal_to (iop, INVALID_IO_PACKAGE);
261 
262  switch (iop)
263  {
264  case TECPLOT:
265  {
266  // FIXME
267  conn.resize(8);
268  conn[0] = this->node(0)+1;
269  conn[1] = this->node(1)+1;
270  conn[2] = this->node(2)+1;
271  conn[3] = this->node(3)+1;
272  conn[4] = this->node(4)+1;
273  conn[5] = this->node(4)+1;
274  conn[6] = this->node(4)+1;
275  conn[7] = this->node(4)+1;
276  return;
277  }
278 
279  case VTK:
280  {
281  // FIXME
282  conn.resize(5);
283  conn[0] = this->node(3);
284  conn[1] = this->node(2);
285  conn[2] = this->node(1);
286  conn[3] = this->node(0);
287  conn[4] = this->node(4);
288  return;
289  }
290 
291  default:
292  libmesh_error();
293  }
294 
295  libmesh_error();
296 }
297 
298 
299 
300  unsigned int Pyramid14::n_second_order_adjacent_vertices (const unsigned int n) const
301  {
302  switch (n)
303  {
304  case 5:
305  case 6:
306  case 7:
307  case 8:
308  case 9:
309  case 10:
310  case 11:
311  case 12:
312  return 2;
313 
314  case 13:
315  return 4;
316 
317  default:
318  libmesh_error();
319  }
320 
321  // We'll never get here
322  libmesh_error();
323  return static_cast<unsigned int>(-1);
324  }
325 
326 
327  unsigned short int Pyramid14::second_order_adjacent_vertex (const unsigned int n,
328  const unsigned int v) const
329  {
330  libmesh_assert_greater_equal (n, this->n_vertices());
331  libmesh_assert_less (n, this->n_nodes());
332 
333  switch (n)
334  {
335  case 5:
336  case 6:
337  case 7:
338  case 8:
339  case 9:
340  case 10:
341  case 11:
342  case 12:
343  {
344  libmesh_assert_less (v, 2);
345 
346  // This is the analog of the static, const arrays
347  // {Hex,Prism,Tet10}::_second_order_adjacent_vertices
348  // defined in the respective source files... possibly treat
349  // this similarly once the Pyramid13 has been added?
350  unsigned short node_list[8][2] =
351  {
352  {0,1},
353  {1,2},
354  {2,3},
355  {0,3},
356  {0,4},
357  {1,4},
358  {2,4},
359  {3,4}
360  };
361 
362  return node_list[n-5][v];
363  }
364 
365  // mid-face node on bottom
366  case 13:
367  {
368  libmesh_assert_less (v, 4);
369 
370  // The vertex nodes surrounding node 13 are 0, 1, 2, and 3.
371  // Thus, the v'th node is simply = v.
372  return v;
373  }
374 
375  default:
376  {
377  // We can't handle this n, throw an error!
378  libmesh_error();
379  }
380 
381  }
382 
383  // We'll never get here
384  libmesh_error();
385  return static_cast<unsigned short int>(-1);
386  }
387 
388 } // namespace libMesh

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

Hosted By:
SourceForge.net Logo