libMesh
cell_inf_hex16.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 // 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}, // Edge 0
51  {1, 2, 9}, // Edge 1
52  {2, 3, 10}, // Edge 2
53  {0, 3, 11}, // Edge 3
54  {0, 4, 99}, // Edge 4
55  {1, 5, 99}, // Edge 5
56  {2, 6, 99}, // Edge 6
57  {3, 7, 99} // Edge 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 
108 
109 unsigned int InfHex16::which_node_am_i(unsigned int side,
110  unsigned int side_node) const
111 {
112  libmesh_assert_less (side, this->n_sides());
113 
114  // Never more than 8 nodes per side.
115  libmesh_assert_less (side_node, 8);
116 
117  // Some sides have 6 nodes.
118  libmesh_assert(side == 0 || side_node < 6);
119 
120  return InfHex16::side_nodes_map[side][side_node];
121 }
122 
123 
124 
125 UniquePtr<Elem> InfHex16::build_side_ptr (const unsigned int i,
126  bool proxy)
127 {
128  libmesh_assert_less (i, this->n_sides());
129 
130  if (proxy)
131  {
132  switch (i)
133  {
134  // base
135  case 0:
136  return UniquePtr<Elem>(new Side<Quad8,InfHex16>(this,i));
137 
138  // ifem sides
139  case 1:
140  case 2:
141  case 3:
142  case 4:
143  return UniquePtr<Elem>(new Side<InfQuad6,InfHex16>(this,i));
144 
145  default:
146  libmesh_error_msg("Invalid side i = " << i);
147  }
148  }
149 
150  else
151  {
152  // Create NULL pointer to be initialized, returned later.
153  Elem * face = libmesh_nullptr;
154 
155  // Think of a unit cube: (-1,1) x (-1,1) x (1,1)
156  switch (i)
157  {
158  // the base face
159  case 0:
160  {
161  face = new Quad8;
162  break;
163  }
164 
165  // connecting to another infinite element
166  case 1:
167  case 2:
168  case 3:
169  case 4:
170  {
171  face = new InfQuad6;
172  break;
173  }
174 
175  default:
176  libmesh_error_msg("Invalid side i = " << i);
177  }
178 
179  face->subdomain_id() = this->subdomain_id();
180 
181  // Set the nodes
182  for (unsigned n=0; n<face->n_nodes(); ++n)
183  face->set_node(n) = this->node_ptr(InfHex16::side_nodes_map[i][n]);
184 
185  return UniquePtr<Elem>(face);
186  }
187 
188  libmesh_error_msg("We'll never get here!");
189  return UniquePtr<Elem>();
190 }
191 
192 UniquePtr<Elem> InfHex16::build_edge_ptr (const unsigned int i)
193 {
194  libmesh_assert_less (i, this->n_edges());
195 
196  if (i < 4) // base edges
197  return UniquePtr<Elem>(new SideEdge<Edge3,InfHex16>(this,i));
198  // infinite edges
199  return UniquePtr<Elem>(new SideEdge<InfEdge2,InfHex16>(this,i));
200 }
201 
202 
203 void InfHex16::connectivity(const unsigned int sc,
204  const IOPackage iop,
205  std::vector<dof_id_type> & conn) const
206 {
207  libmesh_assert(_nodes);
208  libmesh_assert_less (sc, this->n_sub_elem());
209  libmesh_assert_not_equal_to (iop, INVALID_IO_PACKAGE);
210 
211  switch (iop)
212  {
213  case TECPLOT:
214  {
215  switch (sc)
216  {
217  case 0:
218 
219  conn[0] = this->node_id(0)+1;
220  conn[1] = this->node_id(1)+1;
221  conn[2] = this->node_id(2)+1;
222  conn[3] = this->node_id(3)+1;
223  conn[4] = this->node_id(4)+1;
224  conn[5] = this->node_id(5)+1;
225  conn[6] = this->node_id(6)+1;
226  conn[7] = this->node_id(7)+1;
227  return;
228 
229  default:
230  libmesh_error_msg("Invalid sc = " << sc);
231  }
232  }
233 
234  default:
235  libmesh_error_msg("Unsupported IO package " << iop);
236  }
237 }
238 
239 
240 
241 
242 unsigned short int InfHex16::second_order_adjacent_vertex (const unsigned int n,
243  const unsigned int v) const
244 {
245  libmesh_assert_greater_equal (n, this->n_vertices());
246  libmesh_assert_less (n, this->n_nodes());
247  libmesh_assert_less (v, 2);
248  // note that the _second_order_adjacent_vertices matrix is
249  // stored in \p InfHex
250  return _second_order_adjacent_vertices[n-this->n_vertices()][v];
251 }
252 
253 
254 
255 std::pair<unsigned short int, unsigned short int>
256 InfHex16::second_order_child_vertex (const unsigned int n) const
257 {
258  libmesh_assert_greater_equal (n, this->n_vertices());
259  libmesh_assert_less (n, this->n_nodes());
260  /*
261  * the _second_order_vertex_child_* vectors are
262  * stored in cell_inf_hex.C, since they are identical
263  * for InfHex16 and InfHex18
264  */
265  return std::pair<unsigned short int, unsigned short int>
266  (_second_order_vertex_child_number[n],
267  _second_order_vertex_child_index[n]);
268 }
269 
270 
271 
272 
273 
274 #ifdef LIBMESH_ENABLE_AMR
275 
276 const float InfHex16::_embedding_matrix[4][16][16] =
277  {
278  // embedding matrix for child 0
279  {
280  // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 th parent Node
281  { 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.
282  { 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
283  { -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
284  { 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
285  { 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
286  { 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
287  { 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
288  { 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
289  { 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
290  { -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
291  { -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
292  { 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
293  { 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
294  { 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
295  { 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
296  { 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
297  },
298 
299  // embedding matrix for child 1
300  {
301  // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 th parent Node
302  { 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.
303  { 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
304  { 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
305  { -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
306  { 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
307  { 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
308  { 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
309  { 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
310  { -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
311  { 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
312  { -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
313  { -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
314  { 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
315  { 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
316  { 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
317  { 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
318  },
319 
320  // embedding matrix for child 2
321  {
322  // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 th parent Node
323  { 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.
324  { -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
325  { 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
326  { 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
327  { 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
328  { 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
329  { 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
330  { 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
331  { -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
332  { -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
333  { 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
334  { -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
335  { 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
336  { 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
337  { 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
338  { 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
339  },
340 
341  // embedding matrix for child 3
342  {
343  // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 th parent Node
344  { -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.
345  { 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
346  { 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
347  { 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
348  { 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
349  { 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
350  { 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
351  { 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
352  { -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
353  { 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
354  { 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
355  { -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
356  { 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
357  { 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
358  { 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
359  { 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
360  }
361  };
362 
363 
364 
365 #endif
366 
367 } // namespace libMesh
368 
369 #endif // ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
unsigned short int side
Definition: xdr_io.C:49
const class libmesh_nullptr_t libmesh_nullptr
The libMesh namespace provides an interface to certain functionality in the library.
libmesh_assert(j)
const dof_id_type n_nodes
Definition: tecplot_io.C:67
IOPackage
libMesh interfaces with several different software packages for the purposes of creating, reading, and writing mesh files.