cell_prism15.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 00019 // C++ includes 00020 00021 // Local includes 00022 #include "libmesh/side.h" 00023 #include "libmesh/cell_prism15.h" 00024 #include "libmesh/edge_edge3.h" 00025 #include "libmesh/face_quad8.h" 00026 #include "libmesh/face_tri6.h" 00027 00028 namespace libMesh 00029 { 00030 00031 00032 00033 // ------------------------------------------------------------ 00034 // Prism15 class static member initializations 00035 const unsigned int Prism15::side_nodes_map[5][8] = 00036 { 00037 {0, 2, 1, 8, 7, 6, 99, 99}, // Side 0 00038 {0, 1, 4, 3, 6, 10, 12, 9}, // Side 1 00039 {1, 2, 5, 4, 7, 11, 13, 10}, // Side 2 00040 {2, 0, 3, 5, 8, 9, 14, 11}, // Side 3 00041 {3, 4, 5, 12, 13, 14, 99, 99} // Side 4 00042 }; 00043 00044 const unsigned int Prism15::edge_nodes_map[9][3] = 00045 { 00046 {0, 1, 6}, // Side 0 00047 {1, 2, 7}, // Side 1 00048 {0, 2, 8}, // Side 2 00049 {0, 3, 9}, // Side 3 00050 {1, 4, 10}, // Side 4 00051 {2, 5, 11}, // Side 5 00052 {3, 4, 12}, // Side 6 00053 {4, 5, 13}, // Side 7 00054 {3, 5, 14} // Side 8 00055 }; 00056 00057 00058 // ------------------------------------------------------------ 00059 // Prism15 class member functions 00060 00061 bool Prism15::is_vertex(const unsigned int i) const 00062 { 00063 if (i < 6) 00064 return true; 00065 return false; 00066 } 00067 00068 bool Prism15::is_edge(const unsigned int i) const 00069 { 00070 if (i < 6) 00071 return false; 00072 return true; 00073 } 00074 00075 bool Prism15::is_face(const unsigned int) const 00076 { 00077 return false; 00078 } 00079 00080 bool Prism15::is_node_on_side(const unsigned int n, 00081 const unsigned int s) const 00082 { 00083 libmesh_assert_less (s, n_sides()); 00084 for (unsigned int i = 0; i != 8; ++i) 00085 if (side_nodes_map[s][i] == n) 00086 return true; 00087 return false; 00088 } 00089 00090 bool Prism15::is_node_on_edge(const unsigned int n, 00091 const unsigned int e) const 00092 { 00093 libmesh_assert_less (e, n_edges()); 00094 for (unsigned int i = 0; i != 3; ++i) 00095 if (edge_nodes_map[e][i] == n) 00096 return true; 00097 return false; 00098 } 00099 00100 00101 00102 bool Prism15::has_affine_map() const 00103 { 00104 // Make sure z edges are affine 00105 Point v = this->point(3) - this->point(0); 00106 if (!v.relative_fuzzy_equals(this->point(4) - this->point(1)) || 00107 !v.relative_fuzzy_equals(this->point(5) - this->point(2))) 00108 return false; 00109 // Make sure edges are straight 00110 v /= 2; 00111 if (!v.relative_fuzzy_equals(this->point(9) - this->point(0)) || 00112 !v.relative_fuzzy_equals(this->point(10) - this->point(1)) || 00113 !v.relative_fuzzy_equals(this->point(11) - this->point(2))) 00114 return false; 00115 v = (this->point(1) - this->point(0))/2; 00116 if (!v.relative_fuzzy_equals(this->point(6) - this->point(0)) || 00117 !v.relative_fuzzy_equals(this->point(12) - this->point(3))) 00118 return false; 00119 v = (this->point(2) - this->point(0))/2; 00120 if (!v.relative_fuzzy_equals(this->point(8) - this->point(0)) || 00121 !v.relative_fuzzy_equals(this->point(14) - this->point(3))) 00122 return false; 00123 v = (this->point(2) - this->point(1))/2; 00124 if (!v.relative_fuzzy_equals(this->point(7) - this->point(1)) || 00125 !v.relative_fuzzy_equals(this->point(13) - this->point(4))) 00126 return false; 00127 return true; 00128 } 00129 00130 00131 00132 AutoPtr<Elem> Prism15::build_side (const unsigned int i, 00133 bool proxy) const 00134 { 00135 libmesh_assert_less (i, this->n_sides()); 00136 00137 if (proxy) 00138 { 00139 switch (i) 00140 { 00141 case 0: // the triangular face at z=-1 00142 case 4: 00143 { 00144 AutoPtr<Elem> face(new Side<Tri6,Prism15>(this,i)); 00145 return face; 00146 } 00147 00148 case 1: 00149 case 2: 00150 case 3: 00151 { 00152 AutoPtr<Elem> face(new Side<Quad8,Prism15>(this,i)); 00153 return face; 00154 } 00155 00156 default: 00157 { 00158 libmesh_error(); 00159 } 00160 } 00161 } 00162 00163 else 00164 { 00165 switch (i) 00166 { 00167 case 0: // the triangular face at z=-1 00168 { 00169 AutoPtr<Elem> face(new Tri6); 00170 00171 face->set_node(0) = this->get_node(0); 00172 face->set_node(1) = this->get_node(2); 00173 face->set_node(2) = this->get_node(1); 00174 face->set_node(3) = this->get_node(8); 00175 face->set_node(4) = this->get_node(7); 00176 face->set_node(5) = this->get_node(6); 00177 00178 return face; 00179 } 00180 case 1: // the quad face at y=0 00181 { 00182 AutoPtr<Elem> face(new Quad8); 00183 00184 face->set_node(0) = this->get_node(0); 00185 face->set_node(1) = this->get_node(1); 00186 face->set_node(2) = this->get_node(4); 00187 face->set_node(3) = this->get_node(3); 00188 face->set_node(4) = this->get_node(6); 00189 face->set_node(5) = this->get_node(10); 00190 face->set_node(6) = this->get_node(12); 00191 face->set_node(7) = this->get_node(9); 00192 00193 return face; 00194 } 00195 case 2: // the other quad face 00196 { 00197 AutoPtr<Elem> face(new Quad8); 00198 00199 face->set_node(0) = this->get_node(1); 00200 face->set_node(1) = this->get_node(2); 00201 face->set_node(2) = this->get_node(5); 00202 face->set_node(3) = this->get_node(4); 00203 face->set_node(4) = this->get_node(7); 00204 face->set_node(5) = this->get_node(11); 00205 face->set_node(6) = this->get_node(13); 00206 face->set_node(7) = this->get_node(10); 00207 00208 return face; 00209 } 00210 case 3: // the quad face at x=0 00211 { 00212 AutoPtr<Elem> face(new Quad8); 00213 00214 face->set_node(0) = this->get_node(2); 00215 face->set_node(1) = this->get_node(0); 00216 face->set_node(2) = this->get_node(3); 00217 face->set_node(3) = this->get_node(5); 00218 face->set_node(4) = this->get_node(8); 00219 face->set_node(5) = this->get_node(9); 00220 face->set_node(6) = this->get_node(14); 00221 face->set_node(7) = this->get_node(11); 00222 00223 return face; 00224 } 00225 case 4: // the triangular face at z=1 00226 { 00227 AutoPtr<Elem> face(new Tri6); 00228 00229 face->set_node(0) = this->get_node(3); 00230 face->set_node(1) = this->get_node(4); 00231 face->set_node(2) = this->get_node(5); 00232 face->set_node(3) = this->get_node(12); 00233 face->set_node(4) = this->get_node(13); 00234 face->set_node(5) = this->get_node(14); 00235 00236 return face; 00237 } 00238 default: 00239 { 00240 libmesh_error(); 00241 } 00242 } 00243 } 00244 00245 // We'll never get here. 00246 libmesh_error(); 00247 AutoPtr<Elem> ap(NULL); return ap; 00248 } 00249 00250 00251 AutoPtr<Elem> Prism15::build_edge (const unsigned int i) const 00252 { 00253 libmesh_assert_less (i, this->n_edges()); 00254 00255 return AutoPtr<Elem>(new SideEdge<Edge3,Prism15>(this,i)); 00256 } 00257 00258 00259 void Prism15::connectivity(const unsigned int libmesh_dbg_var(sc), 00260 const IOPackage iop, 00261 std::vector<dof_id_type>& conn) const 00262 { 00263 libmesh_assert(_nodes); 00264 libmesh_assert_less (sc, this->n_sub_elem()); 00265 libmesh_assert_not_equal_to (iop, INVALID_IO_PACKAGE); 00266 00267 switch (iop) 00268 { 00269 case TECPLOT: 00270 { 00271 conn.resize(8); 00272 conn[0] = this->node(0)+1; 00273 conn[1] = this->node(1)+1; 00274 conn[2] = this->node(2)+1; 00275 conn[3] = this->node(2)+1; 00276 conn[4] = this->node(3)+1; 00277 conn[5] = this->node(4)+1; 00278 conn[6] = this->node(5)+1; 00279 conn[7] = this->node(5)+1; 00280 return; 00281 } 00282 00283 case VTK: 00284 { 00285 /* 00286 conn.resize(6); 00287 conn[0] = this->node(0); 00288 conn[1] = this->node(2); 00289 conn[2] = this->node(1); 00290 conn[3] = this->node(3); 00291 conn[4] = this->node(5); 00292 conn[5] = this->node(4); 00293 */ 00294 00295 // VTK's VTK_QUADRATIC_WEDGE first 9 nodes match, then their 00296 // middle and top layers of mid-edge nodes are reversed from 00297 // LibMesh's. 00298 conn.resize(15); 00299 for (unsigned i=0; i<9; ++i) 00300 conn[i] = this->node(i); 00301 00302 // top "ring" of mid-edge nodes 00303 conn[9] = this->node(12); 00304 conn[10] = this->node(13); 00305 conn[11] = this->node(14); 00306 00307 // middle "ring" of mid-edge nodes 00308 conn[12] = this->node(9); 00309 conn[13] = this->node(10); 00310 conn[14] = this->node(11); 00311 00312 00313 return; 00314 } 00315 00316 default: 00317 libmesh_error(); 00318 } 00319 00320 libmesh_error(); 00321 00322 } 00323 00324 00325 00326 00327 unsigned short int Prism15::second_order_adjacent_vertex (const unsigned int n, 00328 const unsigned int v) const 00329 { 00330 libmesh_assert_greater_equal (n, this->n_vertices()); 00331 libmesh_assert_less (n, this->n_nodes()); 00332 libmesh_assert_less (v, 2); 00333 return _second_order_adjacent_vertices[n-this->n_vertices()][v]; 00334 } 00335 00336 00337 00338 std::pair<unsigned short int, unsigned short int> 00339 Prism15::second_order_child_vertex (const unsigned int n) const 00340 { 00341 libmesh_assert_greater_equal (n, this->n_vertices()); 00342 libmesh_assert_less (n, this->n_nodes()); 00343 00344 return std::pair<unsigned short int, unsigned short int> 00345 (_second_order_vertex_child_number[n], 00346 _second_order_vertex_child_index[n]); 00347 } 00348 00349 } // namespace libMesh 00350 00351 00352 00353 00354
Site Created By: libMesh Developers
Last modified: February 05 2013 19:54:45 UTC
Hosted By: