libMesh
face_inf_quad6.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 
19 
20 // Local includes
21 #include "libmesh/libmesh_config.h"
22 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
23 
24 
25 // Local includes cont'd
26 #include "libmesh/face_inf_quad6.h"
27 #include "libmesh/edge_edge3.h"
28 #include "libmesh/side.h"
29 #include "libmesh/edge_inf_edge2.h"
30 
31 namespace libMesh
32 {
33 
34 
35 
36 
37 // ------------------------------------------------------------
38 // InfQuad6 class static member initializations
39 const unsigned int InfQuad6::side_nodes_map[3][3] =
40  {
41  {0, 1, 4}, // Side 0
42  {1, 3, 99}, // Side 1
43  {0, 2, 99} // Side 2
44  };
45 
46 
47 // ------------------------------------------------------------
48 // InfQuad6 class member functions
49 
50 bool InfQuad6::is_vertex(const unsigned int i) const
51 {
52  if (i < 2)
53  return true;
54  return false;
55 }
56 
57 bool InfQuad6::is_edge(const unsigned int i) const
58 {
59  if (i < 2)
60  return false;
61  return true;
62 }
63 
64 bool InfQuad6::is_face(const unsigned int) const
65 {
66  return false;
67 }
68 
69 bool InfQuad6::is_node_on_side(const unsigned int n,
70  const unsigned int s) const
71 {
72  libmesh_assert_less (s, n_sides());
73  for (unsigned int i = 0; i != 3; ++i)
74  if (side_nodes_map[s][i] == n)
75  return true;
76  return false;
77 }
78 
79 #ifdef LIBMESH_ENABLE_AMR
80 
81 const float InfQuad6::_embedding_matrix[2][6][6] =
82  {
83  // embedding matrix for child 0
84  {
85  // 0 1 2 3 4 5th parent node
86  { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0 }, // 0th child node
87  { 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 }, // 1
88  { 0.0, 0.0, 1.0, 0.0, 0.0, 0.0 }, // 2
89  { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 }, // 3
90  { 0.375, -0.125, 0.0, 0.0, 0.75, 0.0 }, // 4
91  { 0.0, 0.0, 0.375, -0.125, 0.0, 0.75 } // 5
92  },
93 
94  // embedding matrix for child 1
95  {
96  // 0 1 2 3 4 5th parent node
97  { 0.0, 0.0, 0.0, 0.0, 1.0, 0.0 }, // 0th child node
98  { 0.0, 1.0, 0.0, 0.0, 0.0, 0.0 }, // 1
99  { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 }, // 2
100  { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0 }, // 3
101  { -0.125, 0.375, 0.0, 0.0, 0.75, 0.0 }, // 4
102  { 0.0, 0.0, -0.125, 0.375, 0.0, 0.75 } // 5
103  }
104  };
105 
106 #endif
107 
108 
109 
110 
111 dof_id_type InfQuad6::key (const unsigned int s) const
112 {
113  libmesh_assert_less (s, this->n_sides());
114 
115  switch (s)
116  {
117  // Edge3 side
118  case 0:
119  return this->compute_key (this->node_id(4));
120 
121  // InfEdge
122  case 1:
123  case 2:
124  return InfQuad::key(s);
125 
126  default:
127  libmesh_error_msg("Invalid side s = " << s);
128  }
129 
130  libmesh_error_msg("We'll never get here!");
131  return 0;
132 }
133 
134 
135 
136 unsigned int InfQuad6::which_node_am_i(unsigned int side,
137  unsigned int side_node) const
138 {
139  libmesh_assert_less (side, this->n_sides());
140  libmesh_assert ((side == 0 && side_node < 3) || (side_node < 2));
141 
142  return InfQuad6::side_nodes_map[side][side_node];
143 }
144 
145 
146 
148  bool proxy)
149 {
150  // libmesh_assert_less (i, this->n_sides());
151 
152  if (proxy)
153  {
154  switch (i)
155  {
156  case 0:
157  return UniquePtr<Elem>(new Side<Edge3,InfQuad6>(this,i));
158 
159  case 1:
160  case 2:
161  return UniquePtr<Elem>(new Side<InfEdge2,InfQuad6>(this,i));
162 
163  default:
164  libmesh_error_msg("Invalid side i = " << i);
165  }
166  }
167 
168  else
169  {
170  // Create NULL pointer to be initialized, returned later.
171  Elem * edge = libmesh_nullptr;
172 
173  switch (i)
174  {
175  case 0:
176  {
177  edge = new Edge3;
178  break;
179  }
180 
181  // adjacent to another infinite element
182  case 1:
183  case 2:
184  {
185  edge = new InfEdge2;
186  break;
187  }
188 
189  default:
190  libmesh_error_msg("Invalid side i = " << i);
191  }
192 
193  edge->subdomain_id() = this->subdomain_id();
194 
195  // Set the nodes
196  for (unsigned n=0; n<edge->n_nodes(); ++n)
197  edge->set_node(n) = this->node_ptr(InfQuad6::side_nodes_map[i][n]);
198 
199  return UniquePtr<Elem>(edge);
200  }
201 
202  libmesh_error_msg("We'll never get here!");
203  return UniquePtr<Elem>();
204 }
205 
206 
207 
208 
209 void InfQuad6::connectivity(const unsigned int sf,
210  const IOPackage iop,
211  std::vector<dof_id_type> & conn) const
212 {
213  libmesh_assert_less (sf, this->n_sub_elem());
214  libmesh_assert_not_equal_to (iop, INVALID_IO_PACKAGE);
215 
216  conn.resize(4);
217 
218  switch (iop)
219  {
220  case TECPLOT:
221  {
222  switch(sf)
223  {
224  case 0:
225  // linear sub-quad 0
226  conn[0] = this->node_id(0)+1;
227  conn[1] = this->node_id(4)+1;
228  conn[2] = this->node_id(5)+1;
229  conn[3] = this->node_id(2)+1;
230 
231  return;
232 
233  case 1:
234  // linear sub-quad 1
235  conn[0] = this->node_id(4)+1;
236  conn[1] = this->node_id(1)+1;
237  conn[2] = this->node_id(3)+1;
238  conn[3] = this->node_id(5)+1;
239 
240  return;
241 
242  default:
243  libmesh_error_msg("Invalid sf = " << sf);
244  }
245  }
246 
247  default:
248  libmesh_error_msg("Unsupported IO package " << iop);
249  }
250 }
251 
252 
253 
254 
255 unsigned short int InfQuad6::second_order_adjacent_vertex (const unsigned int n,
256  const unsigned int v) const
257 {
258  libmesh_assert_greater_equal (n, this->n_vertices());
259  libmesh_assert_less (n, this->n_nodes());
260  libmesh_assert_less (v, 2);
261  return _second_order_adjacent_vertices[n-this->n_vertices()][v];
262 }
263 
264 
265 
266 const unsigned short int InfQuad6::_second_order_adjacent_vertices[2][2] =
267  {
268  {0, 1}, // vertices adjacent to node 4
269  {2, 3} // vertices adjacent to node 5
270  };
271 
272 
273 
274 std::pair<unsigned short int, unsigned short int>
275 InfQuad6::second_order_child_vertex (const unsigned int n) const
276 {
277  libmesh_assert_greater_equal (n, this->n_vertices());
278  libmesh_assert_less (n, this->n_nodes());
279 
280  return std::pair<unsigned short int, unsigned short int>
281  (0, 2*n-7);
282 }
283 
284 } // namespace libMesh
285 
286 
287 
288 
289 #endif // ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
virtual Node *& set_node(const unsigned int i)
Definition: elem.h:1941
UniquePtr< Elem > side(const unsigned int i) const
Definition: elem.h:2105
static const float _embedding_matrix[2][6][6]
Matrix that computes new nodal locations/solution values from current nodes/solution.
virtual void connectivity(const unsigned int sf, const IOPackage iop, std::vector< dof_id_type > &conn) const libmesh_override
This is the base class from which all geometric element types are derived.
Definition: elem.h:89
const class libmesh_nullptr_t libmesh_nullptr
The InfEdge2 is an infinite element in 1D composed of 2 nodes.
static const unsigned int side_nodes_map[3][3]
This maps the node of the side to element node numbers.
The libMesh namespace provides an interface to certain functionality in the library.
virtual bool is_face(const unsigned int i) const libmesh_override
virtual std::pair< unsigned short int, unsigned short int > second_order_child_vertex(const unsigned int n) const libmesh_override
libmesh_assert(j)
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
virtual unsigned int n_nodes() const =0
virtual unsigned int n_nodes() const libmesh_override
virtual unsigned int which_node_am_i(unsigned int side, unsigned int side_node) const libmesh_override
virtual dof_id_type key() const
Definition: elem.C:503
const Node * node_ptr(const unsigned int i) const
Definition: elem.h:1874
virtual bool is_vertex(const unsigned int i) const libmesh_override
virtual bool is_node_on_side(const unsigned int n, const unsigned int s) const libmesh_override
subdomain_id_type subdomain_id() const
Definition: elem.h:1951
static const unsigned short int _second_order_adjacent_vertices[2][2]
Matrix that tells which vertices define the location of mid-side (or second-order) nodes...
The Edge3 is an element in 1D composed of 3 nodes.
Definition: edge_edge3.h:43
This defines the Side class.
Definition: side.h:48
virtual unsigned short int second_order_adjacent_vertex(const unsigned int n, const unsigned int v) const libmesh_override
virtual unsigned int n_sub_elem() const libmesh_override
dof_id_type node_id(const unsigned int i) const
Definition: elem.h:1831
static dof_id_type compute_key(dof_id_type n0)
Definition: elem.h:2621
IOPackage
libMesh interfaces with several different software packages for the purposes of creating, reading, and writing mesh files.
virtual unsigned int n_vertices() const libmesh_override
virtual bool is_edge(const unsigned int i) const libmesh_override
virtual UniquePtr< Elem > build_side_ptr(const unsigned int i, bool proxy) libmesh_override
virtual unsigned int n_sides() const libmesh_override
Definition: face_inf_quad.h:96
uint8_t dof_id_type
Definition: id_types.h:64