face_tri6.C
Go to the documentation of this file.00001 // The libMesh Finite Element Library. 00002 // Copyright (C) 2002-2012 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner 00003 00004 // This library is free software; you can redistribute it and/or 00005 // modify it under the terms of the GNU Lesser General Public 00006 // License as published by the Free Software Foundation; either 00007 // version 2.1 of the License, or (at your option) any later version. 00008 00009 // This library is distributed in the hope that it will be useful, 00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 // Lesser General Public License for more details. 00013 00014 // You should have received a copy of the GNU Lesser General Public 00015 // License along with this library; if not, write to the Free Software 00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 00018 // C++ includes 00019 00020 // Local includes 00021 #include "libmesh/side.h" 00022 #include "libmesh/edge_edge3.h" 00023 #include "libmesh/face_tri6.h" 00024 00025 namespace libMesh 00026 { 00027 00028 00029 00030 00031 // ------------------------------------------------------------ 00032 // Tri6 class static member initializations 00033 const unsigned int Tri6::side_nodes_map[3][3] = 00034 { 00035 {0, 1, 3}, // Side 0 00036 {1, 2, 4}, // Side 1 00037 {2, 0, 5} // Side 2 00038 }; 00039 00040 00041 #ifdef LIBMESH_ENABLE_AMR 00042 00043 const float Tri6::_embedding_matrix[4][6][6] = 00044 { 00045 // embedding matrix for child 0 00046 { 00047 // 0 1 2 3 4 5 00048 { 1.0, 0.0, 0.0, 0.0, 0.0, 0.0}, // 0 00049 { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0}, // 1 00050 { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}, // 2 00051 {.375, -.125, 0.0, .75, 0.0, 0.0}, // 3 00052 { 0.0, -.125, -.125, 0.5, .25, 0.5}, // 4 00053 {.375, 0.0, -.125, 0.0, 0.0, .75} // 5 00054 }, 00055 00056 // embedding matrix for child 1 00057 { 00058 // 0 1 2 3 4 5 00059 { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0}, // 0 00060 { 0.0, 1.0, 0.0, 0.0, 0.0, 0.0}, // 1 00061 { 0.0, 0.0, 0.0, 0.0, 1.0, 0.0}, // 2 00062 {-.125, .375, 0.0, .75, 0.0, 0.0}, // 3 00063 { 0.0, .375, -.125, 0.0, .75, 0.0}, // 4 00064 {-.125, 0.0, -.125, 0.5, 0.5, .25} // 5 00065 }, 00066 00067 // embedding matrix for child 2 00068 { 00069 // 0 1 2 3 4 5 00070 { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}, // 0 00071 { 0.0, 0.0, 0.0, 0.0, 1.0, 0.0}, // 1 00072 { 0.0, 0.0, 1.0, 0.0, 0.0, 0.0}, // 2 00073 {-.125, -.125, 0.0, .25, 0.5, 0.5}, // 3 00074 { 0.0, -.125, .375, 0.0, .75, 0.0}, // 4 00075 {-.125, 0.0, .375, 0.0, 0.0, .75} // 5 00076 }, 00077 00078 // embedding matrix for child 3 00079 { 00080 // 0 1 2 3 4 5 00081 { 0.0, 0.0, 0.0, 1.0, 0.0, 0.0}, // 0 00082 { 0.0, 0.0, 0.0, 0.0, 1.0, 0.0}, // 1 00083 { 0.0, 0.0, 0.0, 0.0, 0.0, 1.0}, // 2 00084 {-.125, 0.0, -.125, 0.5, 0.5, .25}, // 3 00085 {-.125, -.125, 0.0, .25, 0.5, 0.5}, // 4 00086 { 0.0, -.125, -.125, 0.5, .25, 0.5} // 5 00087 } 00088 }; 00089 00090 #endif 00091 00092 00093 00094 // ------------------------------------------------------------ 00095 // Tri6 class member functions 00096 00097 bool Tri6::is_vertex(const unsigned int i) const 00098 { 00099 if (i < 3) 00100 return true; 00101 return false; 00102 } 00103 00104 bool Tri6::is_edge(const unsigned int i) const 00105 { 00106 if (i < 3) 00107 return false; 00108 return true; 00109 } 00110 00111 bool Tri6::is_face(const unsigned int) const 00112 { 00113 return false; 00114 } 00115 00116 bool Tri6::is_node_on_side(const unsigned int n, 00117 const unsigned int s) const 00118 { 00119 libmesh_assert_less (s, n_sides()); 00120 for (unsigned int i = 0; i != 3; ++i) 00121 if (side_nodes_map[s][i] == n) 00122 return true; 00123 return false; 00124 } 00125 00126 00127 00128 bool Tri6::has_affine_map() const 00129 { 00130 // Make sure edges are straight 00131 if (!this->point(3).relative_fuzzy_equals 00132 ((this->point(0) + this->point(1))/2.)) 00133 return false; 00134 if (!this->point(4).relative_fuzzy_equals 00135 ((this->point(1) + this->point(2))/2.)) 00136 return false; 00137 if (!this->point(5).relative_fuzzy_equals 00138 ((this->point(2) + this->point(0))/2.)) 00139 return false; 00140 00141 return true; 00142 } 00143 00144 00145 00146 dof_id_type Tri6::key (const unsigned int s) const 00147 { 00148 libmesh_assert_less (s, this->n_sides()); 00149 00150 switch (s) 00151 { 00152 case 0: 00153 00154 return 00155 this->compute_key (this->node(3)); 00156 00157 case 1: 00158 00159 return 00160 this->compute_key (this->node(4)); 00161 00162 case 2: 00163 00164 return 00165 this->compute_key (this->node(5)); 00166 } 00167 00168 00169 // We will never get here... Look at the code above. 00170 libmesh_error(); 00171 return 0; 00172 } 00173 00174 00175 00176 AutoPtr<Elem> Tri6::build_side (const unsigned int i, 00177 bool proxy) const 00178 { 00179 libmesh_assert_less (i, this->n_sides()); 00180 00181 if (proxy) 00182 { 00183 AutoPtr<Elem> ap(new Side<Edge3,Tri6>(this,i)); 00184 return ap; 00185 } 00186 00187 else 00188 { 00189 Edge3* edge = new Edge3; 00190 00191 switch (i) 00192 { 00193 case 0: 00194 { 00195 edge->set_node(0) = this->get_node(0); 00196 edge->set_node(1) = this->get_node(1); 00197 edge->set_node(2) = this->get_node(3); 00198 00199 AutoPtr<Elem> ap(edge); return ap; 00200 } 00201 case 1: 00202 { 00203 edge->set_node(0) = this->get_node(1); 00204 edge->set_node(1) = this->get_node(2); 00205 edge->set_node(2) = this->get_node(4); 00206 00207 AutoPtr<Elem> ap(edge); return ap; 00208 } 00209 case 2: 00210 { 00211 edge->set_node(0) = this->get_node(2); 00212 edge->set_node(1) = this->get_node(0); 00213 edge->set_node(2) = this->get_node(5); 00214 00215 AutoPtr<Elem> ap(edge); return ap; 00216 } 00217 default: 00218 { 00219 libmesh_error(); 00220 } 00221 } 00222 } 00223 00224 // We will never get here... Look at the code above. 00225 AutoPtr<Elem> ap(NULL); return ap; 00226 } 00227 00228 00229 void Tri6::connectivity(const unsigned int sf, 00230 const IOPackage iop, 00231 std::vector<dof_id_type>& conn) const 00232 { 00233 libmesh_assert_less (sf, this->n_sub_elem()); 00234 libmesh_assert_not_equal_to (iop, INVALID_IO_PACKAGE); 00235 00236 switch (iop) 00237 { 00238 case TECPLOT: 00239 { 00240 conn.resize(4); 00241 switch(sf) 00242 { 00243 case 0: 00244 // linear sub-triangle 0 00245 conn[0] = this->node(0)+1; 00246 conn[1] = this->node(3)+1; 00247 conn[2] = this->node(5)+1; 00248 conn[3] = this->node(5)+1; 00249 00250 return; 00251 00252 case 1: 00253 // linear sub-triangle 1 00254 conn[0] = this->node(3)+1; 00255 conn[1] = this->node(1)+1; 00256 conn[2] = this->node(4)+1; 00257 conn[3] = this->node(4)+1; 00258 00259 return; 00260 00261 case 2: 00262 // linear sub-triangle 2 00263 conn[0] = this->node(5)+1; 00264 conn[1] = this->node(4)+1; 00265 conn[2] = this->node(2)+1; 00266 conn[3] = this->node(2)+1; 00267 00268 return; 00269 00270 case 3: 00271 // linear sub-triangle 3 00272 conn[0] = this->node(3)+1; 00273 conn[1] = this->node(4)+1; 00274 conn[2] = this->node(5)+1; 00275 conn[3] = this->node(5)+1; 00276 00277 return; 00278 00279 default: 00280 libmesh_error(); 00281 } 00282 } 00283 00284 case VTK: 00285 { 00286 // VTK_QUADRATIC_TRIANGLE has same numbering as libmesh TRI6 00287 conn.resize(6); 00288 conn[0] = this->node(0); 00289 conn[1] = this->node(1); 00290 conn[2] = this->node(2); 00291 conn[3] = this->node(3); 00292 conn[4] = this->node(4); 00293 conn[5] = this->node(5); 00294 return; 00295 00296 // Used to write out linear sub-triangles for VTK... 00297 /* 00298 conn.resize(3); 00299 switch(sf) 00300 { 00301 case 0: 00302 // linear sub-triangle 0 00303 conn[0] = this->node(0); 00304 conn[1] = this->node(3); 00305 conn[2] = this->node(5); 00306 00307 return; 00308 00309 case 1: 00310 // linear sub-triangle 1 00311 conn[0] = this->node(3); 00312 conn[1] = this->node(1); 00313 conn[2] = this->node(4); 00314 00315 return; 00316 00317 case 2: 00318 // linear sub-triangle 2 00319 conn[0] = this->node(5); 00320 conn[1] = this->node(4); 00321 conn[2] = this->node(2); 00322 00323 return; 00324 00325 case 3: 00326 // linear sub-triangle 3 00327 conn[0] = this->node(3); 00328 conn[1] = this->node(4); 00329 conn[2] = this->node(5); 00330 00331 return; 00332 00333 default: 00334 libmesh_error(); 00335 } 00336 */ 00337 } 00338 00339 default: 00340 libmesh_error(); 00341 } 00342 00343 libmesh_error(); 00344 } 00345 00346 00347 00348 00349 00350 unsigned short int Tri6::second_order_adjacent_vertex (const unsigned int n, 00351 const unsigned int v) const 00352 { 00353 libmesh_assert_greater_equal (n, this->n_vertices()); 00354 libmesh_assert_less (n, this->n_nodes()); 00355 libmesh_assert_less (v, 2); 00356 return _second_order_adjacent_vertices[n-this->n_vertices()][v]; 00357 } 00358 00359 00360 00361 const unsigned short int Tri6::_second_order_adjacent_vertices[3][2] = 00362 { 00363 {0, 1}, // vertices adjacent to node 3 00364 {1, 2}, // vertices adjacent to node 4 00365 {0, 2} // vertices adjacent to node 5 00366 }; 00367 00368 00369 00370 std::pair<unsigned short int, unsigned short int> 00371 Tri6::second_order_child_vertex (const unsigned int n) const 00372 { 00373 libmesh_assert_greater_equal (n, this->n_vertices()); 00374 libmesh_assert_less (n, this->n_nodes()); 00375 return std::pair<unsigned short int, unsigned short int> 00376 (_second_order_vertex_child_number[n], 00377 _second_order_vertex_child_index[n]); 00378 } 00379 00380 00381 00382 const unsigned short int Tri6::_second_order_vertex_child_number[6] = 00383 { 00384 99,99,99, // Vertices 00385 0,1,0 // Edges 00386 }; 00387 00388 00389 00390 const unsigned short int Tri6::_second_order_vertex_child_index[6] = 00391 { 00392 99,99,99, // Vertices 00393 1,2,2 // Edges 00394 }; 00395 00396 } // namespace libMesh
Site Created By: libMesh Developers
Last modified: February 05 2013 19:54:46 UTC
Hosted By: