cell_inf_hex16.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 // Local includes
19 #include "libmesh/libmesh_config.h"
20 
21 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
22 
23 // C++ includes
24 
25 // Local includes cont'd
26 #include "libmesh/cell_inf_hex16.h"
27 #include "libmesh/edge_edge3.h"
28 #include "libmesh/edge_inf_edge2.h"
29 #include "libmesh/face_quad8.h"
30 #include "libmesh/face_inf_quad6.h"
31 #include "libmesh/side.h"
32 
33 namespace libMesh
34 {
35 
36 
37 // ------------------------------------------------------------
38 // InfHex16 class static member initializations
39 const unsigned int InfHex16::side_nodes_map[5][8] =
40 {
41  { 0, 1, 2, 3, 8, 9, 10, 11}, // Side 0
42  { 0, 1, 4, 5, 8, 12, 99, 99}, // Side 1
43  { 1, 2, 5, 6, 9, 13, 99, 99}, // Side 2
44  { 2, 3, 6, 7, 10, 14, 99, 99}, // Side 3
45  { 3, 0, 7, 4, 11, 15, 99, 99} // Side 4
46 };
47 
48 const unsigned int InfHex16::edge_nodes_map[8][3] =
49 {
50  { 0, 1, 8}, // Side 0
51  { 1, 2, 9}, // Side 1
52  { 2, 3, 10}, // Side 2
53  { 0, 3, 11}, // Side 3
54  { 0, 4, 99}, // Side 4
55  { 1, 5, 99}, // Side 5
56  { 2, 6, 99}, // Side 6
57  { 3, 7, 99} // Side 7
58 };
59 
60 
61 // ------------------------------------------------------------
62 // InfHex16 class member functions
63 
64 bool InfHex16::is_vertex(const unsigned int i) const
65 {
66  if (i < 4)
67  return true;
68  return false;
69 }
70 
71 bool InfHex16::is_edge(const unsigned int i) const
72 {
73  if (i < 4)
74  return false;
75  if (i > 11)
76  return false;
77  return true;
78 }
79 
80 bool InfHex16::is_face(const unsigned int i) const
81 {
82  if (i > 11)
83  return true;
84  return false;
85 }
86 
87 bool InfHex16::is_node_on_side(const unsigned int n,
88  const unsigned int s) const
89 {
90  libmesh_assert_less (s, n_sides());
91  for (unsigned int i = 0; i != 8; ++i)
92  if (side_nodes_map[s][i] == n)
93  return true;
94  return false;
95 }
96 
97 bool InfHex16::is_node_on_edge(const unsigned int n,
98  const unsigned int e) const
99 {
100  libmesh_assert_less (e, n_edges());
101  for (unsigned int i = 0; i != 3; ++i)
102  if (edge_nodes_map[e][i] == n)
103  return true;
104  return false;
105 }
106 
107 AutoPtr<Elem> InfHex16::build_side (const unsigned int i,
108  bool proxy) const
109 {
110  libmesh_assert_less (i, this->n_sides());
111 
112  if (proxy)
113  {
114  switch (i)
115  {
116  // base
117  case 0:
118  {
119  AutoPtr<Elem> ap(new Side<Quad8,InfHex16>(this,i));
120  return ap;
121  }
122  // ifem sides
123  case 1:
124  case 2:
125  case 3:
126  case 4:
127  {
128  AutoPtr<Elem> ap(new Side<InfQuad6,InfHex16>(this,i));
129  return ap;
130  }
131  default:
132  libmesh_error();
133  }
134  }
135 
136  else
137  {
138  // Create NULL pointer to be initialized, returned later.
139  AutoPtr<Elem> face(NULL);
140 
141  // Think of a unit cube: (-1,1) x (-1,1) x (1,1)
142  switch (i)
143  {
144  case 0: // the base face
145  {
146  face.reset(new Quad8);
147 
148  // Only here, the face element's normal points inward
149  face->set_node(0) = this->get_node(0);
150  face->set_node(1) = this->get_node(1);
151  face->set_node(2) = this->get_node(2);
152  face->set_node(3) = this->get_node(3);
153  face->set_node(4) = this->get_node(8);
154  face->set_node(5) = this->get_node(9);
155  face->set_node(6) = this->get_node(10);
156  face->set_node(7) = this->get_node(11);
157 
158  break;
159  }
160 
161  case 1: // connecting to another infinite element
162  {
163  face.reset(new InfQuad6);
164 
165  face->set_node(0) = this->get_node(0);
166  face->set_node(1) = this->get_node(1);
167  face->set_node(2) = this->get_node(4);
168  face->set_node(3) = this->get_node(5);
169  face->set_node(4) = this->get_node(8);
170  face->set_node(5) = this->get_node(12);
171 
172  break;
173  }
174 
175  case 2: // connecting to another infinite element
176  {
177  face.reset(new InfQuad6);
178 
179  face->set_node(0) = this->get_node(1);
180  face->set_node(1) = this->get_node(2);
181  face->set_node(2) = this->get_node(5);
182  face->set_node(3) = this->get_node(6);
183  face->set_node(4) = this->get_node(9);
184  face->set_node(5) = this->get_node(13);
185 
186  break;
187  }
188 
189  case 3: // connecting to another infinite element
190  {
191  face.reset(new InfQuad6);
192 
193  face->set_node(0) = this->get_node(2);
194  face->set_node(1) = this->get_node(3);
195  face->set_node(2) = this->get_node(6);
196  face->set_node(3) = this->get_node(7);
197  face->set_node(4) = this->get_node(10);
198  face->set_node(5) = this->get_node(14);
199 
200  break;
201  }
202 
203  case 4: // connecting to another infinite element
204  {
205  face.reset(new InfQuad6);
206 
207  face->set_node(0) = this->get_node(3);
208  face->set_node(1) = this->get_node(0);
209  face->set_node(2) = this->get_node(7);
210  face->set_node(3) = this->get_node(4);
211  face->set_node(4) = this->get_node(11);
212  face->set_node(5) = this->get_node(15);
213 
214  break;
215  }
216 
217  default:
218  {
219  libmesh_error();
220  }
221  }
222 
223  face->subdomain_id() = this->subdomain_id();
224  return face;
225  }
226 
227 
228  // We'll never get here.
229  libmesh_error();
230  AutoPtr<Elem> ap(NULL); return ap;
231 }
232 
233 AutoPtr<Elem> InfHex16::build_edge (const unsigned int i) const
234 {
235  libmesh_assert_less (i, this->n_edges());
236 
237  if (i < 4) // base edges
238  return AutoPtr<Elem>(new SideEdge<Edge3,InfHex16>(this,i));
239  // infinite edges
240  return AutoPtr<Elem>(new SideEdge<InfEdge2,InfHex16>(this,i));
241 }
242 
243 
244 void InfHex16::connectivity(const unsigned int sc,
245  const IOPackage iop,
246  std::vector<dof_id_type>& conn) const
247 {
249  libmesh_assert_less (sc, this->n_sub_elem());
250  libmesh_assert_not_equal_to (iop, INVALID_IO_PACKAGE);
251 
252  switch (iop)
253  {
254  case TECPLOT:
255  {
256  switch (sc)
257  {
258  case 0:
259 
260  conn[0] = this->node(0)+1;
261  conn[1] = this->node(1)+1;
262  conn[2] = this->node(2)+1;
263  conn[3] = this->node(3)+1;
264  conn[4] = this->node(4)+1;
265  conn[5] = this->node(5)+1;
266  conn[6] = this->node(6)+1;
267  conn[7] = this->node(7)+1;
268  return;
269 
270  default:
271  libmesh_error();
272 
273  }
274  }
275 
276  default:
277  libmesh_error();
278  }
279 
280  libmesh_error();
281 }
282 
283 
284 
285 
286 unsigned short int InfHex16::second_order_adjacent_vertex (const unsigned int n,
287  const unsigned int v) const
288 {
289  libmesh_assert_greater_equal (n, this->n_vertices());
290  libmesh_assert_less (n, this->n_nodes());
291  libmesh_assert_less (v, 2);
292  // note that the _second_order_adjacent_vertices matrix is
293  // stored in \p InfHex
294  return _second_order_adjacent_vertices[n-this->n_vertices()][v];
295 }
296 
297 
298 
299 std::pair<unsigned short int, unsigned short int>
300 InfHex16::second_order_child_vertex (const unsigned int n) const
301 {
302  libmesh_assert_greater_equal (n, this->n_vertices());
303  libmesh_assert_less (n, this->n_nodes());
304  /*
305  * the _second_order_vertex_child_* vectors are
306  * stored in cell_inf_hex.C, since they are identical
307  * for InfHex16 and InfHex18
308  */
309  return std::pair<unsigned short int, unsigned short int>
312 }
313 
314 
315 
316 
317 
318 #ifdef LIBMESH_ENABLE_AMR
319 
320 const float InfHex16::_embedding_matrix[4][16][16] =
321 {
322  // embedding matrix for child 0
323  {
324  // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 th parent Node
325  { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 0th child N.
326  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 1
327  { -0.25, -0.25, -0.25, -0.25, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.5, 0.0, 0.0, 0.0, 0.0}, // 2
328  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0}, // 3
329  { 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 4
330  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0}, // 5
331  { 0.0, 0.0, 0.0, 0.0, -0.25, -0.25, -0.25, -0.25, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.5}, // 6
332  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}, // 7
333  { 0.375, -0.125, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.75, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 8
334  { -0.1875, -0.1875, -0.1875, -0.1875, 0.0, 0.0, 0.0, 0.0, 0.75, 0.375, 0.25, 0.375, 0.0, 0.0, 0.0, 0.0}, // 9
335  { -0.1875, -0.1875, -0.1875, -0.1875, 0.0, 0.0, 0.0, 0.0, 0.375, 0.25, 0.375, 0.75, 0.0, 0.0, 0.0, 0.0}, // 10
336  { 0.375, 0.0, 0.0, -0.125, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.75, 0.0, 0.0, 0.0, 0.0}, // 11
337  { 0.0, 0.0, 0.0, 0.0, 0.375, -0.125, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.75, 0.0, 0.0, 0.0}, // 12
338  { 0.0, 0.0, 0.0, 0.0, -0.1875, -0.1875, -0.1875, -0.1875, 0.0, 0.0, 0.0, 0.0, 0.75, 0.375, 0.25, 0.375}, // 13
339  { 0.0, 0.0, 0.0, 0.0, -0.1875, -0.1875, -0.1875, -0.1875, 0.0, 0.0, 0.0, 0.0, 0.375, 0.25, 0.375, 0.75}, // 14
340  { 0.0, 0.0, 0.0, 0.0, 0.375, 0.0, 0.0, -0.125, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.75} // 15
341  },
342 
343  // embedding matrix for child 1
344  {
345  // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 th parent Node
346  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 0th child N.
347  { 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 1
348  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 2
349  { -0.25, -0.25, -0.25, -0.25, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.5, 0.0, 0.0, 0.0, 0.0}, // 3
350  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0}, // 4
351  { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 5
352  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0}, // 6
353  { 0.0, 0.0, 0.0, 0.0, -0.25, -0.25, -0.25, -0.25, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.5}, // 7
354  { -0.125, 0.375, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.75, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 8
355  { 0.0, 0.375, -0.125, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.75, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 9
356  { -0.1875, -0.1875, -0.1875, -0.1875, 0.0, 0.0, 0.0, 0.0, 0.375, 0.75, 0.375, 0.25, 0.0, 0.0, 0.0, 0.0}, // 10
357  { -0.1875, -0.1875, -0.1875, -0.1875, 0.0, 0.0, 0.0, 0.0, 0.75, 0.375, 0.25, 0.375, 0.0, 0.0, 0.0, 0.0}, // 11
358  { 0.0, 0.0, 0.0, 0.0, -0.125, 0.375, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.75, 0.0, 0.0, 0.0}, // 12
359  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.375, -0.125, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.75, 0.0, 0.0}, // 13
360  { 0.0, 0.0, 0.0, 0.0, -0.1875, -0.1875, -0.1875, -0.1875, 0.0, 0.0, 0.0, 0.0, 0.375, 0.75, 0.375, 0.25}, // 14
361  { 0.0, 0.0, 0.0, 0.0, -0.1875, -0.1875, -0.1875, -0.1875, 0.0, 0.0, 0.0, 0.0, 0.75, 0.375, 0.25, 0.375} // 15
362  },
363 
364  // embedding matrix for child 2
365  {
366  // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 th parent Node
367  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0}, // 0th child N.
368  { -0.25, -0.25, -0.25, -0.25, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.5, 0.0, 0.0, 0.0, 0.0}, // 1
369  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 2
370  { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 3
371  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}, // 4
372  { 0.0, 0.0, 0.0, 0.0, -0.25, -0.25, -0.25, -0.25, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.5}, // 5
373  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0}, // 6
374  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 7
375  { -0.1875, -0.1875, -0.1875, -0.1875, 0.0, 0.0, 0.0, 0.0, 0.375, 0.25, 0.375, 0.75, 0.0, 0.0, 0.0, 0.0}, // 8
376  { -0.1875, -0.1875, -0.1875, -0.1875, 0.0, 0.0, 0.0, 0.0, 0.25, 0.375, 0.75, 0.375, 0.0, 0.0, 0.0, 0.0}, // 9
377  { 0.0, 0.0, -0.125, 0.375, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.75, 0.0, 0.0, 0.0, 0.0, 0.0}, // 10
378  { -0.125, 0.0, 0.0, 0.375, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.75, 0.0, 0.0, 0.0, 0.0}, // 11
379  { 0.0, 0.0, 0.0, 0.0, -0.1875, -0.1875, -0.1875, -0.1875, 0.0, 0.0, 0.0, 0.0, 0.375, 0.25, 0.375, 0.75}, // 12
380  { 0.0, 0.0, 0.0, 0.0, -0.1875, -0.1875, -0.1875, -0.1875, 0.0, 0.0, 0.0, 0.0, 0.25, 0.375, 0.75, 0.375}, // 13
381  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, -0.125, 0.375, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.75, 0.0}, // 14
382  { 0.0, 0.0, 0.0, 0.0, -0.125, 0.0, 0.0, 0.375, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.75} // 15
383  },
384 
385  // embedding matrix for child 3
386  {
387  // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 th parent Node
388  { -0.25, -0.25, -0.25, -0.25, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.5, 0.0, 0.0, 0.0, 0.0}, // 0th child N.
389  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 1
390  { 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 2
391  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 3
392  { 0.0, 0.0, 0.0, 0.0, -0.25, -0.25, -0.25, -0.25, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.5, 0.5}, // 4
393  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0}, // 5
394  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 6
395  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0}, // 7
396  { -0.1875, -0.1875, -0.1875, -0.1875, 0.0, 0.0, 0.0, 0.0, 0.375, 0.75, 0.375, 0.25, 0.0, 0.0, 0.0, 0.0}, // 8
397  { 0.0, -0.125, 0.375, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.75, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 9
398  { 0.0, 0.0, 0.375, -0.125, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.75, 0.0, 0.0, 0.0, 0.0, 0.0}, // 10
399  { -0.1875, -0.1875, -0.1875, -0.1875, 0.0, 0.0, 0.0, 0.0, 0.25, 0.375, 0.75, 0.375, 0.0, 0.0, 0.0, 0.0}, // 11
400  { 0.0, 0.0, 0.0, 0.0, -0.1875, -0.1875, -0.1875, -0.1875, 0.0, 0.0, 0.0, 0.0, 0.375, 0.75, 0.375, 0.25}, // 12
401  { 0.0, 0.0, 0.0, 0.0, 0.0, -0.125, 0.375, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.75, 0.0, 0.0}, // 13
402  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.375, -0.125, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.75, 0.0}, // 14
403  { 0.0, 0.0, 0.0, 0.0, -0.1875, -0.1875, -0.1875, -0.1875, 0.0, 0.0, 0.0, 0.0, 0.25, 0.375, 0.75, 0.375} // 15
404  }
405 };
406 
407 
408 
409 #endif
410 
411 } // namespace libMesh
412 
413 #endif // ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS

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

Hosted By:
SourceForge.net Logo