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