libMesh
cell_inf_hex8.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_hex8.h"
27 #include "libmesh/edge_edge2.h"
28 #include "libmesh/edge_inf_edge2.h"
29 #include "libmesh/face_quad4.h"
30 #include "libmesh/face_inf_quad4.h"
31 #include "libmesh/side.h"
32 
33 namespace libMesh
34 {
35 
36 
37 // ------------------------------------------------------------
38 // InfHex8 class member functions
39 const unsigned int InfHex8::side_nodes_map[5][4] =
40  {
41  { 0, 1, 2, 3}, // Side 0
42  { 0, 1, 4, 5}, // Side 1
43  { 1, 2, 5, 6}, // Side 2
44  { 2, 3, 6, 7}, // Side 3
45  { 3, 0, 7, 4} // Side 4
46  };
47 
48 const unsigned int InfHex8::edge_nodes_map[8][2] =
49  {
50  {0, 1}, // Edge 0
51  {1, 2}, // Edge 1
52  {2, 3}, // Edge 2
53  {0, 3}, // Edge 3
54  {0, 4}, // Edge 4
55  {1, 5}, // Edge 5
56  {2, 6}, // Edge 6
57  {3, 7} // Edge 7
58  };
59 
60 
61 // ------------------------------------------------------------
62 // InfHex8 class member functions
63 
64 bool InfHex8::is_vertex(const unsigned int i) const
65 {
66  if (i < 4)
67  return true;
68  return false;
69 }
70 
71 bool InfHex8::is_edge(const unsigned int i) const
72 {
73  if (i < 4)
74  return false;
75  return true;
76 }
77 
78 bool InfHex8::is_face(const unsigned int) const
79 {
80  return false;
81 }
82 
83 bool InfHex8::is_node_on_side(const unsigned int n,
84  const unsigned int s) const
85 {
86  libmesh_assert_less (s, n_sides());
87  for (unsigned int i = 0; i != 4; ++i)
88  if (side_nodes_map[s][i] == n)
89  return true;
90  return false;
91 }
92 
93 bool InfHex8::is_node_on_edge(const unsigned int n,
94  const unsigned int e) const
95 {
96  libmesh_assert_less (e, n_edges());
97  for (unsigned int i = 0; i != 2; ++i)
98  if (edge_nodes_map[e][i] == n)
99  return true;
100  return false;
101 }
102 
103 UniquePtr<Elem> InfHex8::build_side_ptr (const unsigned int i,
104  bool proxy)
105 {
106  libmesh_assert_less (i, this->n_sides());
107 
108  if (proxy)
109  {
110  switch (i)
111  {
112  // base
113  case 0:
114  return UniquePtr<Elem>(new Side<Quad4,InfHex8>(this,i));
115 
116  // ifem sides
117  case 1:
118  case 2:
119  case 3:
120  case 4:
121  return UniquePtr<Elem>(new Side<InfQuad4,InfHex8>(this,i));
122 
123  default:
124  libmesh_error_msg("Invalid side i = " << i);
125  }
126  }
127 
128  else
129  {
130  // Create NULL pointer to be initialized, returned later.
131  Elem * face = libmesh_nullptr;
132 
133  // Think of a unit cube: (-1,1) x (-1,1) x (1,1)
134  switch (i)
135  {
136  case 0: // the base face
137  {
138  face = new Quad4;
139  break;
140  }
141 
142  // connecting to another infinite element
143  case 1:
144  case 2:
145  case 3:
146  case 4:
147  {
148  face = new InfQuad4;
149  break;
150  }
151 
152  default:
153  libmesh_error_msg("Invalid side i = " << i);
154  }
155 
156  face->subdomain_id() = this->subdomain_id();
157 
158  // Set the nodes
159  for (unsigned n=0; n<face->n_nodes(); ++n)
160  face->set_node(n) = this->node_ptr(InfHex8::side_nodes_map[i][n]);
161 
162  return UniquePtr<Elem>(face);
163  }
164 
165  libmesh_error_msg("We'll never get here!");
166  return UniquePtr<Elem>();
167 }
168 
169 
170 UniquePtr<Elem> InfHex8::build_edge_ptr (const unsigned int i)
171 {
172  libmesh_assert_less (i, this->n_edges());
173 
174  if (i < 4) // base edges
175  return UniquePtr<Elem>(new SideEdge<Edge2,InfHex8>(this,i));
176  // infinite edges
177  return UniquePtr<Elem>(new SideEdge<InfEdge2,InfHex8>(this,i));
178 }
179 
180 
181 void InfHex8::connectivity(const unsigned int libmesh_dbg_var(sc),
182  const IOPackage iop,
183  std::vector<dof_id_type> & conn) const
184 {
185  libmesh_assert(_nodes);
186  libmesh_assert_less (sc, this->n_sub_elem());
187  libmesh_assert_not_equal_to (iop, INVALID_IO_PACKAGE);
188 
189  switch (iop)
190  {
191  case TECPLOT:
192  {
193  conn.resize(8);
194  conn[0] = this->node_id(0)+1;
195  conn[1] = this->node_id(1)+1;
196  conn[2] = this->node_id(2)+1;
197  conn[3] = this->node_id(3)+1;
198  conn[4] = this->node_id(4)+1;
199  conn[5] = this->node_id(5)+1;
200  conn[6] = this->node_id(6)+1;
201  conn[7] = this->node_id(7)+1;
202  return;
203  }
204 
205  default:
206  libmesh_error_msg("Unsupported IO package " << iop);
207  }
208 }
209 
210 
211 
212 #ifdef LIBMESH_ENABLE_AMR
213 
214 const float InfHex8::_embedding_matrix[4][8][8] =
215  {
216  // embedding matrix for child 0
217  {
218  // 0 1 2 3 4 5 6 7 th parent N.(ode)
219  { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 0th child N.
220  { 0.5, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 1
221  { 0.25, 0.25, 0.25, 0.25, 0.0, 0.0, 0.0, 0.0}, // 2
222  { 0.5, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0}, // 3
223  { 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0}, // 4
224  { 0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0}, // 5
225  { 0.0, 0.0, 0.0, 0.0, 0.25, 0.25, 0.25, 0.25}, // 6
226  { 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.5} // 7
227  },
228 
229  // embedding matrix for child 1
230  {
231  // 0 1 2 3 4 5 6 7 th parent N.(ode)
232  { 0.5, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 0th child N.
233  { 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 1
234  { 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0}, // 2
235  { 0.25, 0.25, 0.25, 0.25, 0.0, 0.0, 0.0, 0.0}, // 3
236  { 0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0}, // 4
237  { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0}, // 5
238  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0}, // 6
239  { 0.0, 0.0, 0.0, 0.0, 0.25, 0.25, 0.25, 0.25} // 7
240  },
241 
242  // embedding matrix for child 2
243  {
244  // 0 1 2 3 4 5 6 7 th parent N.(ode)
245  { 0.5, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0}, // 0th child N.
246  { 0.25, 0.25, 0.25, 0.25, 0.0, 0.0, 0.0, 0.0}, // 1
247  { 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 0.0}, // 2
248  { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0}, // 3
249  { 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.5}, // 4
250  { 0.0, 0.0, 0.0, 0.0, 0.25, 0.25, 0.25, 0.25}, // 5
251  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5}, // 6
252  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0} // 7
253  },
254 
255  // embedding matrix for child 3
256  {
257  // 0 1 2 3 4 5 6 7 th parent N.(ode)
258  { 0.25, 0.25, 0.25, 0.25, 0.0, 0.0, 0.0, 0.0}, // 0th child N.
259  { 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0}, // 1
260  { 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 2
261  { 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 0.0}, // 3
262  { 0.0, 0.0, 0.0, 0.0, 0.25, 0.25, 0.25, 0.25}, // 4
263  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0}, // 5
264  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0}, // 6
265  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5} // 7
266  }
267  };
268 
269 
270 
271 #endif
272 
273 } // namespace libMesh
274 
275 #endif // ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
const class libmesh_nullptr_t libmesh_nullptr
The libMesh namespace provides an interface to certain functionality in the library.
libmesh_assert(j)
PetscErrorCode Vec Mat libmesh_dbg_var(j)
IOPackage
libMesh interfaces with several different software packages for the purposes of creating, reading, and writing mesh files.