cell_inf_hex8.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 // Local includes
19 #include "libmesh/libmesh_config.h"
20 
21 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
22 
23 // Local includes cont'd
24 #include "libmesh/cell_inf_hex8.h"
25 #include "libmesh/edge_edge2.h"
26 #include "libmesh/edge_inf_edge2.h"
27 #include "libmesh/face_quad4.h"
28 #include "libmesh/face_inf_quad4.h"
29 #include "libmesh/side.h"
31 #include "libmesh/enum_order.h"
32 
33 namespace libMesh
34 {
35 
36 
37 // ------------------------------------------------------------
38 // InfHex8 class static member initializations
39 const int InfHex8::num_nodes;
40 const int InfHex8::num_sides;
41 const int InfHex8::num_edges;
42 const int InfHex8::num_children;
43 const int InfHex8::nodes_per_side;
44 const int InfHex8::nodes_per_edge;
45 
47  {
48  { 0, 1, 2, 3}, // Side 0
49  { 0, 1, 4, 5}, // Side 1
50  { 1, 2, 5, 6}, // Side 2
51  { 2, 3, 6, 7}, // Side 3
52  { 3, 0, 7, 4} // Side 4
53  };
54 
56  {
57  {0, 1}, // Edge 0
58  {1, 2}, // Edge 1
59  {2, 3}, // Edge 2
60  {0, 3}, // Edge 3
61  {0, 4}, // Edge 4
62  {1, 5}, // Edge 5
63  {2, 6}, // Edge 6
64  {3, 7} // Edge 7
65  };
66 
67 
68 // ------------------------------------------------------------
69 // InfHex8 class member functions
70 
71 bool InfHex8::is_vertex(const unsigned int i) const
72 {
73  if (i < 4)
74  return true;
75  return false;
76 }
77 
78 bool InfHex8::is_edge(const unsigned int i) const
79 {
80  if (i < 4)
81  return false;
82  return true;
83 }
84 
85 bool InfHex8::is_face(const unsigned int) const
86 {
87  return false;
88 }
89 
90 bool InfHex8::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 InfHex8::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 InfHex8::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 
115 
116 
118 {
119  return FIRST;
120 }
121 
122 
123 
124 std::unique_ptr<Elem> InfHex8::build_side_ptr (const unsigned int i,
125  bool proxy)
126 {
127  libmesh_assert_less (i, this->n_sides());
128 
129  if (proxy)
130  {
131  switch (i)
132  {
133  // base
134  case 0:
135  return libmesh_make_unique<Side<Quad4,InfHex8>>(this,i);
136 
137  // ifem sides
138  case 1:
139  case 2:
140  case 3:
141  case 4:
142  return libmesh_make_unique<Side<InfQuad4,InfHex8>>(this,i);
143 
144  default:
145  libmesh_error_msg("Invalid side i = " << i);
146  }
147  }
148 
149  else
150  {
151  // Return value
152  std::unique_ptr<Elem> face;
153 
154  // Think of a unit cube: (-1,1) x (-1,1) x (1,1)
155  switch (i)
156  {
157  case 0: // the base face
158  {
159  face = libmesh_make_unique<Quad4>();
160  break;
161  }
162 
163  // connecting to another infinite element
164  case 1:
165  case 2:
166  case 3:
167  case 4:
168  {
169  face = libmesh_make_unique<InfQuad4>();
170  break;
171  }
172 
173  default:
174  libmesh_error_msg("Invalid side i = " << i);
175  }
176 
177  face->subdomain_id() = this->subdomain_id();
178 
179  // Set the nodes
180  for (unsigned n=0; n<face->n_nodes(); ++n)
181  face->set_node(n) = this->node_ptr(InfHex8::side_nodes_map[i][n]);
182 
183  return face;
184  }
185 }
186 
187 
188 void InfHex8::build_side_ptr (std::unique_ptr<Elem> & side,
189  const unsigned int i)
190 {
191  this->side_ptr(side, i);
192 }
193 
194 
195 
196 std::unique_ptr<Elem> InfHex8::build_edge_ptr (const unsigned int i)
197 {
198  libmesh_assert_less (i, this->n_edges());
199 
200  if (i < 4) // base edges
201  return libmesh_make_unique<SideEdge<Edge2,InfHex8>>(this,i);
202 
203  // infinite edges
204  return libmesh_make_unique<SideEdge<InfEdge2,InfHex8>>(this,i);
205 }
206 
207 
208 void InfHex8::connectivity(const unsigned int libmesh_dbg_var(sc),
209  const IOPackage iop,
210  std::vector<dof_id_type> & conn) const
211 {
212  libmesh_assert(_nodes);
213  libmesh_assert_less (sc, this->n_sub_elem());
214  libmesh_assert_not_equal_to (iop, INVALID_IO_PACKAGE);
215 
216  switch (iop)
217  {
218  case TECPLOT:
219  {
220  conn.resize(8);
221  conn[0] = this->node_id(0)+1;
222  conn[1] = this->node_id(1)+1;
223  conn[2] = this->node_id(2)+1;
224  conn[3] = this->node_id(3)+1;
225  conn[4] = this->node_id(4)+1;
226  conn[5] = this->node_id(5)+1;
227  conn[6] = this->node_id(6)+1;
228  conn[7] = this->node_id(7)+1;
229  return;
230  }
231 
232  default:
233  libmesh_error_msg("Unsupported IO package " << iop);
234  }
235 }
236 
237 
238 
239 #ifdef LIBMESH_ENABLE_AMR
240 
242  {
243  // embedding matrix for child 0
244  {
245  // 0 1 2 3 4 5 6 7 th parent N.(ode)
246  { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 0th child N.
247  { 0.5, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 1
248  { 0.25, 0.25, 0.25, 0.25, 0.0, 0.0, 0.0, 0.0}, // 2
249  { 0.5, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0}, // 3
250  { 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0}, // 4
251  { 0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0}, // 5
252  { 0.0, 0.0, 0.0, 0.0, 0.25, 0.25, 0.25, 0.25}, // 6
253  { 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.5} // 7
254  },
255 
256  // embedding matrix for child 1
257  {
258  // 0 1 2 3 4 5 6 7 th parent N.(ode)
259  { 0.5, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 0th child N.
260  { 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 1
261  { 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0}, // 2
262  { 0.25, 0.25, 0.25, 0.25, 0.0, 0.0, 0.0, 0.0}, // 3
263  { 0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0, 0.0}, // 4
264  { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0}, // 5
265  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0}, // 6
266  { 0.0, 0.0, 0.0, 0.0, 0.25, 0.25, 0.25, 0.25} // 7
267  },
268 
269  // embedding matrix for child 2
270  {
271  // 0 1 2 3 4 5 6 7 th parent N.(ode)
272  { 0.5, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0}, // 0th child N.
273  { 0.25, 0.25, 0.25, 0.25, 0.0, 0.0, 0.0, 0.0}, // 1
274  { 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 0.0}, // 2
275  { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0}, // 3
276  { 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.5}, // 4
277  { 0.0, 0.0, 0.0, 0.0, 0.25, 0.25, 0.25, 0.25}, // 5
278  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5}, // 6
279  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0} // 7
280  },
281 
282  // embedding matrix for child 3
283  {
284  // 0 1 2 3 4 5 6 7 th parent N.(ode)
285  { 0.25, 0.25, 0.25, 0.25, 0.0, 0.0, 0.0, 0.0}, // 0th child N.
286  { 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 0.0, 0.0}, // 1
287  { 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 2
288  { 0.0, 0.0, 0.5, 0.5, 0.0, 0.0, 0.0, 0.0}, // 3
289  { 0.0, 0.0, 0.0, 0.0, 0.25, 0.25, 0.25, 0.25}, // 4
290  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5, 0.0}, // 5
291  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0}, // 6
292  { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.5, 0.5} // 7
293  }
294  };
295 
296 
297 
298 #endif
299 
300 } // namespace libMesh
301 
302 #endif // ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
virtual bool is_node_on_edge(const unsigned int n, const unsigned int e) const override
Node ** _nodes
Definition: elem.h:1695
static const float _embedding_matrix[num_children][num_nodes][num_nodes]
virtual unsigned int n_sub_elem() const override
Definition: cell_inf_hex8.h:86
unsigned short int side
Definition: xdr_io.C:50
IterBase * end
static const int nodes_per_side
virtual bool is_edge(const unsigned int i) const override
Definition: cell_inf_hex8.C:78
virtual std::unique_ptr< Elem > build_edge_ptr(const unsigned int i) override
virtual std::unique_ptr< Elem > side_ptr(const unsigned int i) override final
Definition: cell_inf_hex.C:100
virtual Order default_order() const override
virtual bool is_face(const unsigned int i) const override
Definition: cell_inf_hex8.C:85
virtual void connectivity(const unsigned int sc, const IOPackage iop, std::vector< dof_id_type > &conn) const override
static const int num_children
virtual std::unique_ptr< Elem > build_side_ptr(const unsigned int i, bool proxy) override
virtual std::vector< unsigned int > nodes_on_side(const unsigned int s) const override
static const unsigned int side_nodes_map[num_sides][nodes_per_side]
static const int num_sides
subdomain_id_type subdomain_id() const
Definition: elem.h:2034
const Node * node_ptr(const unsigned int i) const
Definition: elem.h:1957
static const unsigned int edge_nodes_map[num_edges][nodes_per_edge]
virtual unsigned int n_edges() const override final
Definition: cell_inf_hex.h:104
static const int num_edges
virtual bool is_vertex(const unsigned int i) const override
Definition: cell_inf_hex8.C:71
static const int num_nodes
dof_id_type node_id(const unsigned int i) const
Definition: elem.h:1914
static const int nodes_per_edge
virtual unsigned int n_sides() const override final
Definition: cell_inf_hex.h:85
virtual bool is_node_on_side(const unsigned int n, const unsigned int s) const override
Definition: cell_inf_hex8.C:90