cell_inf_prism12.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 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 #include "libmesh/libmesh_config.h"
19 
20 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
21 
22 // Local includes
24 #include "libmesh/edge_edge3.h"
25 #include "libmesh/edge_inf_edge2.h"
26 #include "libmesh/face_tri6.h"
27 #include "libmesh/face_inf_quad6.h"
28 #include "libmesh/side.h"
30 #include "libmesh/enum_order.h"
31 
32 namespace libMesh
33 {
34 
35 
36 // ------------------------------------------------------------
37 // InfPrism12 class static member initializations
38 const int InfPrism12::num_nodes;
39 const int InfPrism12::num_sides;
40 const int InfPrism12::num_edges;
41 const int InfPrism12::num_children;
44 
46  {
47  { 0, 1, 2, 6, 7, 8}, // Side 0
48  { 0, 1, 3, 4, 6, 9}, // Side 1
49  { 1, 2, 4, 5, 7, 10}, // Side 2
50  { 2, 0, 5, 3, 8, 11} // Side 3
51  };
52 
54  {
55  {0, 1, 6}, // Side 0
56  {1, 2, 7}, // Side 1
57  {0, 2, 8}, // Side 2
58  {0, 3, 99}, // Side 3
59  {1, 4, 99}, // Side 4
60  {2, 5, 99} // Side 5
61  };
62 
63 
64 // ------------------------------------------------------------
65 // InfPrism12 class member functions
66 
67 bool InfPrism12::is_vertex(const unsigned int i) const
68 {
69  if (i < 3)
70  return true;
71  return false;
72 }
73 
74 bool InfPrism12::is_edge(const unsigned int i) const
75 {
76  if (i < 3)
77  return false;
78  if (i > 8)
79  return false;
80  return true;
81 }
82 
83 bool InfPrism12::is_face(const unsigned int i) const
84 {
85  if (i > 8)
86  return true;
87  return false;
88 }
89 
90 bool InfPrism12::is_node_on_side(const unsigned int n,
91  const unsigned int s) const
92 {
93  libmesh_assert_less (s, n_sides());
94  return std::find(std::begin(side_nodes_map[s]),
96  n) != std::end(side_nodes_map[s]);
97 }
98 
99 std::vector<unsigned>
100 InfPrism12::nodes_on_side(const unsigned int s) const
101 {
102  libmesh_assert_less(s, n_sides());
103  return {std::begin(side_nodes_map[s]), std::end(side_nodes_map[s])};
104 }
105 
106 bool InfPrism12::is_node_on_edge(const unsigned int n,
107  const unsigned int e) const
108 {
109  libmesh_assert_less (e, n_edges());
110  return std::find(std::begin(edge_nodes_map[e]),
112  n) != std::end(edge_nodes_map[e]);
113 }
114 
116 {
117  return SECOND;
118 }
119 
120 unsigned int InfPrism12::which_node_am_i(unsigned int side,
121  unsigned int side_node) const
122 {
123  libmesh_assert_less (side, this->n_sides());
124 
125  // Never more than 6 nodes per side.
126  libmesh_assert_less(side_node, 6);
127 
128  return InfPrism12::side_nodes_map[side][side_node];
129 }
130 
131 
132 
133 std::unique_ptr<Elem> InfPrism12::build_side_ptr (const unsigned int i,
134  bool proxy)
135 {
136  libmesh_assert_less (i, this->n_sides());
137 
138  if (proxy)
139  {
140  switch (i)
141  {
142  // base
143  case 0:
144  return libmesh_make_unique<Side<Tri6,InfPrism12>>(this,i);
145 
146  // ifem sides
147  case 1:
148  case 2:
149  case 3:
150  return libmesh_make_unique<Side<InfQuad6,InfPrism12>>(this,i);
151 
152  default:
153  libmesh_error_msg("Invalid side i = " << i);
154  }
155  }
156 
157  else
158  {
159  // Return value
160  std::unique_ptr<Elem> face;
161 
162  switch (i)
163  {
164  case 0: // the triangular face at z=-1, base face
165  {
166  face = libmesh_make_unique<Tri6>();
167  break;
168  }
169 
170  case 1: // the quad face at y=0
171  case 2: // the other quad face
172  case 3: // the quad face at x=0
173  {
174  face = libmesh_make_unique<InfQuad6>();
175  break;
176  }
177 
178  default:
179  libmesh_error_msg("Invalid side i = " << i);
180  }
181 
182  face->subdomain_id() = this->subdomain_id();
183 
184  // Set the nodes
185  for (unsigned n=0; n<face->n_nodes(); ++n)
186  face->set_node(n) = this->node_ptr(InfPrism12::side_nodes_map[i][n]);
187 
188  return face;
189  }
190 }
191 
192 
193 void InfPrism12::build_side_ptr (std::unique_ptr<Elem> & side,
194  const unsigned int i)
195 {
196  libmesh_assert_less (i, this->n_sides());
197 
198  switch (i)
199  {
200  case 0: // the triangular face at z=-1, base face
201  {
202  if (!side.get() || side->type() != TRI6)
203  {
204  side = this->build_side_ptr(i, false);
205  return;
206  }
207  break;
208  }
209 
210  case 1: // the quad face at y=0
211  case 2: // the other quad face
212  case 3: // the quad face at x=0
213  {
214  if (!side.get() || side->type() != INFQUAD6)
215  {
216  side = this->build_side_ptr(i, false);
217  return;
218  }
219  break;
220  }
221 
222  default:
223  libmesh_error_msg("Invalid side i = " << i);
224  }
225 
226  side->subdomain_id() = this->subdomain_id();
227 
228  // Set the nodes
229  for (auto n : side->node_index_range())
230  side->set_node(n) = this->node_ptr(InfPrism12::side_nodes_map[i][n]);
231 }
232 
233 
234 std::unique_ptr<Elem> InfPrism12::build_edge_ptr (const unsigned int i)
235 {
236  libmesh_assert_less (i, this->n_edges());
237 
238  if (i < 3) // base edges
239  return libmesh_make_unique<SideEdge<Edge3,InfPrism12>>(this,i);
240 
241  // infinite edges
242  return libmesh_make_unique<SideEdge<InfEdge2,InfPrism12>>(this,i);
243 }
244 
245 
246 void InfPrism12::connectivity(const unsigned int sc,
247  const IOPackage iop,
248  std::vector<dof_id_type> & conn) const
249 {
250  libmesh_assert(_nodes);
251  libmesh_assert_less (sc, this->n_sub_elem());
252  libmesh_assert_not_equal_to (iop, INVALID_IO_PACKAGE);
253 
254  switch (iop)
255  {
256  case TECPLOT:
257  {
258  conn.resize(8);
259  switch (sc)
260  {
261  case 0:
262 
263  // guess this is a collapsed hex8
264  conn[0] = this->node_id(0)+1;
265  conn[1] = this->node_id(6)+1;
266  conn[2] = this->node_id(8)+1;
267  conn[3] = this->node_id(8)+1;
268  conn[4] = this->node_id(3)+1;
269  conn[5] = this->node_id(9)+1;
270  conn[6] = this->node_id(11)+1;
271  conn[7] = this->node_id(11)+1;
272 
273  return;
274 
275  case 1:
276 
277  conn[0] = this->node_id(6)+1;
278  conn[1] = this->node_id(7)+1;
279  conn[2] = this->node_id(8)+1;
280  conn[3] = this->node_id(8)+1;
281  conn[4] = this->node_id(9)+1;
282  conn[5] = this->node_id(10)+1;
283  conn[6] = this->node_id(11)+1;
284  conn[7] = this->node_id(11)+1;
285 
286  return;
287 
288  case 2:
289 
290  conn[0] = this->node_id(6)+1;
291  conn[1] = this->node_id(1)+1;
292  conn[2] = this->node_id(7)+1;
293  conn[3] = this->node_id(7)+1;
294  conn[4] = this->node_id(9)+1;
295  conn[5] = this->node_id(4)+1;
296  conn[6] = this->node_id(10)+1;
297  conn[7] = this->node_id(10)+1;
298 
299  return;
300 
301  case 3:
302 
303  conn[0] = this->node_id(8)+1;
304  conn[1] = this->node_id(7)+1;
305  conn[2] = this->node_id(2)+1;
306  conn[3] = this->node_id(2)+1;
307  conn[4] = this->node_id(11)+1;
308  conn[5] = this->node_id(10)+1;
309  conn[6] = this->node_id(5)+1;
310  conn[7] = this->node_id(5)+1;
311 
312  return;
313 
314  default:
315  libmesh_error_msg("Invalid sc = " << sc);
316  }
317  }
318 
319  default:
320  libmesh_error_msg("Unsupported IO package " << iop);
321  }
322 }
323 
324 
325 
326 
327 
328 unsigned short int InfPrism12::second_order_adjacent_vertex (const unsigned int n,
329  const unsigned int v) const
330 {
331  libmesh_assert_greater_equal (n, this->n_vertices());
332  libmesh_assert_less (n, this->n_nodes());
333  libmesh_assert_less (v, 2);
334  return _second_order_adjacent_vertices[n-this->n_vertices()][v];
335 }
336 
337 
338 
340  {
341  { 0, 1}, // vertices adjacent to node 6
342  { 1, 2}, // vertices adjacent to node 7
343  { 0, 2}, // vertices adjacent to node 8
344 
345  { 3, 4}, // vertices adjacent to node 9
346  { 4, 5}, // vertices adjacent to node 10
347  { 3, 5} // vertices adjacent to node 11
348  };
349 
350 
351 
352 std::pair<unsigned short int, unsigned short int>
353 InfPrism12::second_order_child_vertex (const unsigned int n) const
354 {
355  libmesh_assert_greater_equal (n, this->n_vertices());
356  libmesh_assert_less (n, this->n_nodes());
357 
358  return std::pair<unsigned short int, unsigned short int>
361 }
362 
363 
364 
366  {
367  99,99,99,99,99,99, // Vertices
368  0,1,0, // Edges
369  0,1,0 // Faces
370  };
371 
372 
373 
375  {
376  99,99,99,99,99,99, // Vertices
377  1,2,2, // Edges
378  4,5,5 // Faces
379  };
380 
381 
382 
383 #ifdef LIBMESH_ENABLE_AMR
384 
386  {
387  // embedding matrix for child 0
388  {
389  // 0 1 2 3 4 5 6 7 8 9 10 11 th parent Node
390  { 1.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.
391  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 1
392  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0}, // 2
393  { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 3
394  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0}, // 4
395  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}, // 5
396  { 0.375, -0.125, 0.0, 0.0, 0.0, 0.0, 0.75, 0.0, 0.0, 0.0, 0.0, 0.0}, // 6
397  { 0.0, -0.125, -0.125, 0.0, 0.0, 0.0, 0.5, 0.25, 0.5, 0.0, 0.0, 0.0}, // 7
398  { 0.375, 0.0, -0.125, 0.0, 0.0, 0.0, 0.0, 0.0, 0.75, 0.0, 0.0, 0.0}, // 8
399  { 0.0, 0.0, 0.0, 0.375, -0.125, 0.0, 0.0, 0.0, 0.0, 0.75, 0.0, 0.0}, // 9
400  { 0.0, 0.0, 0.0, 0.0, -0.125, -0.125, 0.0, 0.0, 0.0, 0.5, 0.25, 0.5}, // 10
401  { 0.0, 0.0, 0.0, 0.375, 0.0, -0.125, 0.0, 0.0, 0.0, 0.0, 0.0, 0.75} // 11
402  },
403 
404  // embedding matrix for child 1
405  {
406  // 0 1 2 3 4 5 6 7 8 9 10 11 th parent Node
407  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 0th child N.
408  { 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 1
409  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0}, // 2
410  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0}, // 3
411  { 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 4
412  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0}, // 5
413  { -0.125, 0.375, 0.0, 0.0, 0.0, 0.0, 0.75, 0.0, 0.0, 0.0, 0.0, 0.0}, // 6
414  { 0.0, 0.375, -0.125, 0.0, 0.0, 0.0, 0.0, 0.75, 0.0, 0.0, 0.0, 0.0}, // 7
415  { -0.125, 0.0, -0.125, 0.0, 0.0, 0.0, 0.5, 0.5, 0.25, 0.0, 0.0, 0.0}, // 8
416  { 0.0, 0.0, 0.0, -0.125, 0.375, 0.0, 0.0, 0.0, 0.0, 0.75, 0.0, 0.0}, // 9
417  { 0.0, 0.0, 0.0, 0.0, 0.375, -0.125, 0.0, 0.0, 0.0, 0.0, 0.75, 0.0}, // 10
418  { 0.0, 0.0, 0.0, -0.125, 0.0, -0.125, 0.0, 0.0, 0.0, 0.5, 0.5, 0.25} // 11
419  },
420 
421  // embedding matrix for child 2
422  {
423  // 0 1 2 3 4 5 6 7 8 9 10 11 th parent Node
424  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0}, // 0th child N.
425  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0}, // 1
426  { 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 2
427  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}, // 3
428  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0}, // 4
429  { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 5
430  { -0.125, -0.125, 0.0, 0.0, 0.0, 0.0, 0.25, 0.5, 0.5, 0.0, 0.0, 0.0}, // 6
431  { 0.0, -0.125, 0.375, 0.0, 0.0, 0.0, 0.0, 0.75, 0.0, 0.0, 0.0, 0.0}, // 7
432  { -0.125, 0.0, 0.375, 0.0, 0.0, 0.0, 0.0, 0.0, 0.75, 0.0, 0.0, 0.0}, // 8
433  { 0.0, 0.0, 0.0, -0.125, -0.125, 0.0, 0.0, 0.0, 0.0, 0.25, 0.5, 0.5}, // 9
434  { 0.0, 0.0, 0.0, 0.0, -0.125, 0.375, 0.0, 0.0, 0.0, 0.0, 0.75, 0.0}, // 10
435  { 0.0, 0.0, 0.0, -0.125, 0.0, 0.375, 0.0, 0.0, 0.0, 0.0, 0.0, 0.75} // 11
436  },
437 
438  // embedding matrix for child 3
439  {
440  // 0 1 2 3 4 5 6 7 8 9 10 11 th parent Node
441  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 0th child N.
442  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0}, // 1
443  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0}, // 2
444  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0}, // 3
445  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0}, // 4
446  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}, // 5
447  { -0.125, 0.0, -0.125, 0.0, 0.0, 0.0, 0.5, 0.5, 0.25, 0.0, 0.0, 0.0}, // 6
448  { -0.125, -0.125, 0.0, 0.0, 0.0, 0.0, 0.25, 0.5, 0.5, 0.0, 0.0, 0.0}, // 7
449  { 0.0, -0.125, -0.125, 0.0, 0.0, 0.0, 0.5, 0.25, 0.5, 0.0, 0.0, 0.0}, // 8
450  { 0.0, 0.0, 0.0, -0.125, 0.0, -0.125, 0.0, 0.0, 0.0, 0.5, 0.5, 0.25}, // 9
451  { 0.0, 0.0, 0.0, -0.125, -0.125, 0.0, 0.0, 0.0, 0.0, 0.25, 0.5, 0.5}, // 10
452  { 0.0, 0.0, 0.0, 0.0, -0.125, -0.125, 0.0, 0.0, 0.0, 0.5, 0.25, 0.5} // 11
453  }
454 
455  };
456 
457 
458 
459 
460 #endif
461 
462 } // namespace libMesh
463 
464 #endif // ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
static const int num_edges
virtual unsigned int n_vertices() const override final
Node ** _nodes
Definition: elem.h:1695
virtual bool is_edge(const unsigned int i) const override
static const unsigned int edge_nodes_map[num_edges][nodes_per_edge]
static const float _embedding_matrix[num_children][num_nodes][num_nodes]
virtual unsigned short int second_order_adjacent_vertex(const unsigned int n, const unsigned int v) const override
virtual unsigned int n_edges() const override final
unsigned short int side
Definition: xdr_io.C:50
virtual unsigned int n_nodes() const override
virtual unsigned int n_sub_elem() const override
IterBase * end
static const unsigned short int _second_order_adjacent_vertices[num_edges][2]
virtual void connectivity(const unsigned int sc, const IOPackage iop, std::vector< dof_id_type > &conn) const override
virtual std::unique_ptr< Elem > build_side_ptr(const unsigned int i, bool proxy) override
virtual bool is_vertex(const unsigned int i) const override
static const int nodes_per_edge
virtual std::unique_ptr< Elem > build_edge_ptr(const unsigned int i) override
static const unsigned short int _second_order_vertex_child_index[num_nodes]
virtual Order default_order() const override
static const int num_children
static const unsigned short int _second_order_vertex_child_number[num_nodes]
virtual std::vector< unsigned int > nodes_on_side(const unsigned int s) const override
static const int num_sides
virtual bool is_node_on_edge(const unsigned int n, const unsigned int e) const override
subdomain_id_type subdomain_id() const
Definition: elem.h:2034
static const int nodes_per_side
virtual std::pair< unsigned short int, unsigned short int > second_order_child_vertex(const unsigned int n) const override
const Node * node_ptr(const unsigned int i) const
Definition: elem.h:1957
virtual unsigned int which_node_am_i(unsigned int side, unsigned int side_node) const override
static const int num_nodes
static const unsigned int side_nodes_map[num_sides][nodes_per_side]
virtual bool is_face(const unsigned int i) const override
virtual bool is_node_on_side(const unsigned int n, const unsigned int s) const override
virtual unsigned int n_sides() const override final
dof_id_type node_id(const unsigned int i) const
Definition: elem.h:1914
std::unique_ptr< Elem > side(const unsigned int i) const
Definition: elem.h:2202