face_tri6.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2014 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 // C++ includes
19 
20 // Local includes
21 #include "libmesh/side.h"
22 #include "libmesh/edge_edge3.h"
23 #include "libmesh/face_tri6.h"
24 
25 namespace libMesh
26 {
27 
28 
29 
30 
31 // ------------------------------------------------------------
32 // Tri6 class static member initializations
33 const unsigned int Tri6::side_nodes_map[3][3] =
34 {
35  {0, 1, 3}, // Side 0
36  {1, 2, 4}, // Side 1
37  {2, 0, 5} // Side 2
38 };
39 
40 
41 #ifdef LIBMESH_ENABLE_AMR
42 
43 const float Tri6::_embedding_matrix[4][6][6] =
44 {
45  // embedding matrix for child 0
46  {
47  // 0 1 2 3 4 5
48  { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 0
49  { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0}, // 1
50  { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}, // 2
51  {.375, -.125, 0.0, .75, 0.0, 0.0}, // 3
52  { 0.0, -.125, -.125, 0.5, .25, 0.5}, // 4
53  {.375, 0.0, -.125, 0.0, 0.0, .75} // 5
54  },
55 
56  // embedding matrix for child 1
57  {
58  // 0 1 2 3 4 5
59  { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0}, // 0
60  { 0.0, 1.0, 0.0, 0.0, 0.0, 0.0}, // 1
61  { 0.0, 0.0, 0.0, 0.0, 1.0, 0.0}, // 2
62  {-.125, .375, 0.0, .75, 0.0, 0.0}, // 3
63  { 0.0, .375, -.125, 0.0, .75, 0.0}, // 4
64  {-.125, 0.0, -.125, 0.5, 0.5, .25} // 5
65  },
66 
67  // embedding matrix for child 2
68  {
69  // 0 1 2 3 4 5
70  { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}, // 0
71  { 0.0, 0.0, 0.0, 0.0, 1.0, 0.0}, // 1
72  { 0.0, 0.0, 1.0, 0.0, 0.0, 0.0}, // 2
73  {-.125, -.125, 0.0, .25, 0.5, 0.5}, // 3
74  { 0.0, -.125, .375, 0.0, .75, 0.0}, // 4
75  {-.125, 0.0, .375, 0.0, 0.0, .75} // 5
76  },
77 
78  // embedding matrix for child 3
79  {
80  // 0 1 2 3 4 5
81  { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0}, // 0
82  { 0.0, 0.0, 0.0, 0.0, 1.0, 0.0}, // 1
83  { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}, // 2
84  {-.125, 0.0, -.125, 0.5, 0.5, .25}, // 3
85  {-.125, -.125, 0.0, .25, 0.5, 0.5}, // 4
86  { 0.0, -.125, -.125, 0.5, .25, 0.5} // 5
87  }
88 };
89 
90 #endif
91 
92 
93 
94 // ------------------------------------------------------------
95 // Tri6 class member functions
96 
97 bool Tri6::is_vertex(const unsigned int i) const
98 {
99  if (i < 3)
100  return true;
101  return false;
102 }
103 
104 bool Tri6::is_edge(const unsigned int i) const
105 {
106  if (i < 3)
107  return false;
108  return true;
109 }
110 
111 bool Tri6::is_face(const unsigned int) const
112 {
113  return false;
114 }
115 
116 bool Tri6::is_node_on_side(const unsigned int n,
117  const unsigned int s) const
118 {
119  libmesh_assert_less (s, n_sides());
120  for (unsigned int i = 0; i != 3; ++i)
121  if (side_nodes_map[s][i] == n)
122  return true;
123  return false;
124 }
125 
126 
127 
129 {
130  // Make sure edges are straight
131  if (!this->point(3).relative_fuzzy_equals
132  ((this->point(0) + this->point(1))/2.))
133  return false;
134  if (!this->point(4).relative_fuzzy_equals
135  ((this->point(1) + this->point(2))/2.))
136  return false;
137  if (!this->point(5).relative_fuzzy_equals
138  ((this->point(2) + this->point(0))/2.))
139  return false;
140 
141  return true;
142 }
143 
144 
145 
146 dof_id_type Tri6::key (const unsigned int s) const
147 {
148  libmesh_assert_less (s, this->n_sides());
149 
150  switch (s)
151  {
152  case 0:
153 
154  return
155  this->compute_key (this->node(3));
156 
157  case 1:
158 
159  return
160  this->compute_key (this->node(4));
161 
162  case 2:
163 
164  return
165  this->compute_key (this->node(5));
166  }
167 
168 
169  // We will never get here... Look at the code above.
170  libmesh_error();
171  return 0;
172 }
173 
174 
175 
176 AutoPtr<Elem> Tri6::build_side (const unsigned int i,
177  bool proxy) const
178 {
179  libmesh_assert_less (i, this->n_sides());
180 
181  if (proxy)
182  {
183  AutoPtr<Elem> ap(new Side<Edge3,Tri6>(this,i));
184  return ap;
185  }
186 
187  else
188  {
189  AutoPtr<Elem> edge(new Edge3);
190  edge->subdomain_id() = this->subdomain_id();
191 
192  switch (i)
193  {
194  case 0:
195  {
196  edge->set_node(0) = this->get_node(0);
197  edge->set_node(1) = this->get_node(1);
198  edge->set_node(2) = this->get_node(3);
199 
200  return edge;
201  }
202  case 1:
203  {
204  edge->set_node(0) = this->get_node(1);
205  edge->set_node(1) = this->get_node(2);
206  edge->set_node(2) = this->get_node(4);
207 
208  return edge;
209  }
210  case 2:
211  {
212  edge->set_node(0) = this->get_node(2);
213  edge->set_node(1) = this->get_node(0);
214  edge->set_node(2) = this->get_node(5);
215 
216  return edge;
217  }
218  default:
219  {
220  libmesh_error();
221  }
222  }
223  }
224 
225  // We will never get here... Look at the code above.
226  AutoPtr<Elem> ap(NULL); return ap;
227 }
228 
229 
230 void Tri6::connectivity(const unsigned int sf,
231  const IOPackage iop,
232  std::vector<dof_id_type>& conn) const
233 {
234  libmesh_assert_less (sf, this->n_sub_elem());
235  libmesh_assert_not_equal_to (iop, INVALID_IO_PACKAGE);
236 
237  switch (iop)
238  {
239  case TECPLOT:
240  {
241  conn.resize(4);
242  switch(sf)
243  {
244  case 0:
245  // linear sub-triangle 0
246  conn[0] = this->node(0)+1;
247  conn[1] = this->node(3)+1;
248  conn[2] = this->node(5)+1;
249  conn[3] = this->node(5)+1;
250 
251  return;
252 
253  case 1:
254  // linear sub-triangle 1
255  conn[0] = this->node(3)+1;
256  conn[1] = this->node(1)+1;
257  conn[2] = this->node(4)+1;
258  conn[3] = this->node(4)+1;
259 
260  return;
261 
262  case 2:
263  // linear sub-triangle 2
264  conn[0] = this->node(5)+1;
265  conn[1] = this->node(4)+1;
266  conn[2] = this->node(2)+1;
267  conn[3] = this->node(2)+1;
268 
269  return;
270 
271  case 3:
272  // linear sub-triangle 3
273  conn[0] = this->node(3)+1;
274  conn[1] = this->node(4)+1;
275  conn[2] = this->node(5)+1;
276  conn[3] = this->node(5)+1;
277 
278  return;
279 
280  default:
281  libmesh_error();
282  }
283  }
284 
285  case VTK:
286  {
287  // VTK_QUADRATIC_TRIANGLE has same numbering as libmesh TRI6
288  conn.resize(6);
289  conn[0] = this->node(0);
290  conn[1] = this->node(1);
291  conn[2] = this->node(2);
292  conn[3] = this->node(3);
293  conn[4] = this->node(4);
294  conn[5] = this->node(5);
295  return;
296 
297  // Used to write out linear sub-triangles for VTK...
298  /*
299  conn.resize(3);
300  switch(sf)
301  {
302  case 0:
303  // linear sub-triangle 0
304  conn[0] = this->node(0);
305  conn[1] = this->node(3);
306  conn[2] = this->node(5);
307 
308  return;
309 
310  case 1:
311  // linear sub-triangle 1
312  conn[0] = this->node(3);
313  conn[1] = this->node(1);
314  conn[2] = this->node(4);
315 
316  return;
317 
318  case 2:
319  // linear sub-triangle 2
320  conn[0] = this->node(5);
321  conn[1] = this->node(4);
322  conn[2] = this->node(2);
323 
324  return;
325 
326  case 3:
327  // linear sub-triangle 3
328  conn[0] = this->node(3);
329  conn[1] = this->node(4);
330  conn[2] = this->node(5);
331 
332  return;
333 
334  default:
335  libmesh_error();
336  }
337  */
338  }
339 
340  default:
341  libmesh_error();
342  }
343 
344  libmesh_error();
345 }
346 
347 
348 
349 
350 
351 unsigned short int Tri6::second_order_adjacent_vertex (const unsigned int n,
352  const unsigned int v) const
353 {
354  libmesh_assert_greater_equal (n, this->n_vertices());
355  libmesh_assert_less (n, this->n_nodes());
356  libmesh_assert_less (v, 2);
357  return _second_order_adjacent_vertices[n-this->n_vertices()][v];
358 }
359 
360 
361 
362 const unsigned short int Tri6::_second_order_adjacent_vertices[3][2] =
363 {
364  {0, 1}, // vertices adjacent to node 3
365  {1, 2}, // vertices adjacent to node 4
366  {0, 2} // vertices adjacent to node 5
367 };
368 
369 
370 
371 std::pair<unsigned short int, unsigned short int>
372 Tri6::second_order_child_vertex (const unsigned int n) const
373 {
374  libmesh_assert_greater_equal (n, this->n_vertices());
375  libmesh_assert_less (n, this->n_nodes());
376  return std::pair<unsigned short int, unsigned short int>
379 }
380 
381 
382 
383 const unsigned short int Tri6::_second_order_vertex_child_number[6] =
384 {
385  99,99,99, // Vertices
386  0,1,0 // Edges
387 };
388 
389 
390 
391 const unsigned short int Tri6::_second_order_vertex_child_index[6] =
392 {
393  99,99,99, // Vertices
394  1,2,2 // Edges
395 };
396 
397 } // namespace libMesh

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:04 UTC

Hosted By:
SourceForge.net Logo