$extrastylesheet
cell_pyramid13.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_pyramid13.h"
00024 #include "libmesh/edge_edge3.h"
00025 #include "libmesh/face_tri6.h"
00026 #include "libmesh/face_quad8.h"
00027 
00028 namespace libMesh
00029 {
00030 
00031 
00032 
00033 
00034 // ------------------------------------------------------------
00035 // Pyramid13 class static member initializations
00036 const unsigned int Pyramid13::side_nodes_map[5][8] =
00037   {
00038     {0, 1, 4, 5, 10,  9, 99, 99}, // Side 0 (front)
00039     {1, 2, 4, 6, 11, 10, 99, 99}, // Side 1 (right)
00040     {2, 3, 4, 7, 12, 11, 99, 99}, // Side 2 (back)
00041     {3, 0, 4, 8,  9, 12, 99, 99}, // Side 3 (left)
00042     {0, 3, 2, 1,  8,  7,  6,  5}  // Side 4 (base)
00043   };
00044 
00045 const unsigned int Pyramid13::edge_nodes_map[8][3] =
00046   {
00047     {0, 1,  5}, // Edge 0
00048     {1, 2,  6}, // Edge 1
00049     {2, 3,  7}, // Edge 2
00050     {0, 3,  8}, // Edge 3
00051     {0, 4,  9}, // Edge 4
00052     {1, 4, 10}, // Edge 5
00053     {2, 4, 11}, // Edge 6
00054     {3, 4, 12}  // Edge 7
00055   };
00056 
00057 
00058 
00059 // ------------------------------------------------------------
00060 // Pyramid13 class member functions
00061 
00062 bool Pyramid13::is_vertex(const unsigned int i) const
00063 {
00064   if (i < 5)
00065     return true;
00066   return false;
00067 }
00068 
00069 
00070 
00071 bool Pyramid13::is_edge(const unsigned int i) const
00072 {
00073   if (i < 5)
00074     return false;
00075   return true;
00076 }
00077 
00078 
00079 
00080 bool Pyramid13::is_face(const unsigned int) const
00081 {
00082   return false;
00083 }
00084 
00085 
00086 
00087 bool Pyramid13::is_node_on_side(const unsigned int n,
00088                                 const unsigned int s) const
00089 {
00090   libmesh_assert_less (s, n_sides());
00091   for (unsigned int i = 0; i != 8; ++i)
00092     if (side_nodes_map[s][i] == n)
00093       return true;
00094   return false;
00095 }
00096 
00097 bool Pyramid13::is_node_on_edge(const unsigned int n,
00098                                 const unsigned int e) const
00099 {
00100   libmesh_assert_less (e, n_edges());
00101   for (unsigned int i = 0; i != 3; ++i)
00102     if (edge_nodes_map[e][i] == n)
00103       return true;
00104   return false;
00105 }
00106 
00107 
00108 
00109 bool Pyramid13::has_affine_map() const
00110 {
00111   // TODO: If the base is a parallelogram and all the triangular faces are planar,
00112   // the map should be linear, but I need to test this theory...
00113   return false;
00114 }
00115 
00116 
00117 
00118 UniquePtr<Elem> Pyramid13::build_side (const unsigned int i, bool proxy) const
00119 {
00120   libmesh_assert_less (i, this->n_sides());
00121 
00122   if (proxy)
00123     {
00124       switch (i)
00125         {
00126         case 0:
00127         case 1:
00128         case 2:
00129         case 3:
00130           return UniquePtr<Elem>(new Side<Tri6,Pyramid13>(this,i));
00131 
00132         case 4:
00133           return UniquePtr<Elem>(new Side<Quad8,Pyramid13>(this,i));
00134 
00135         default:
00136           libmesh_error_msg("Invalid side i = " << i);
00137         }
00138     }
00139 
00140   else
00141     {
00142       // Create NULL pointer to be initialized, returned later.
00143       Elem* face = NULL;
00144 
00145       switch (i)
00146         {
00147         case 0:  // triangular face 1
00148           {
00149             face = new Tri6;
00150 
00151             face->set_node(0) = this->get_node(0);
00152             face->set_node(1) = this->get_node(1);
00153             face->set_node(2) = this->get_node(4);
00154             face->set_node(3) = this->get_node(5);
00155             face->set_node(4) = this->get_node(10);
00156             face->set_node(5) = this->get_node(9);
00157 
00158             break;
00159           }
00160         case 1:  // triangular face 2
00161           {
00162             face = new Tri6;
00163 
00164             face->set_node(0) = this->get_node(1);
00165             face->set_node(1) = this->get_node(2);
00166             face->set_node(2) = this->get_node(4);
00167             face->set_node(3) = this->get_node(6);
00168             face->set_node(4) = this->get_node(11);
00169             face->set_node(5) = this->get_node(10);
00170 
00171             break;
00172           }
00173         case 2:  // triangular face 3
00174           {
00175             face = new Tri6;
00176 
00177             face->set_node(0) = this->get_node(2);
00178             face->set_node(1) = this->get_node(3);
00179             face->set_node(2) = this->get_node(4);
00180             face->set_node(3) = this->get_node(7);
00181             face->set_node(4) = this->get_node(12);
00182             face->set_node(5) = this->get_node(11);
00183 
00184             break;
00185           }
00186         case 3:  // triangular face 4
00187           {
00188             face = new Tri6;
00189 
00190             face->set_node(0) = this->get_node(3);
00191             face->set_node(1) = this->get_node(0);
00192             face->set_node(2) = this->get_node(4);
00193             face->set_node(3) = this->get_node(8);
00194             face->set_node(4) = this->get_node(9);
00195             face->set_node(5) = this->get_node(12);
00196 
00197             break;
00198           }
00199         case 4:  // the quad face at z=0
00200           {
00201             face = new Quad8;
00202 
00203             face->set_node(0) = this->get_node(0);
00204             face->set_node(1) = this->get_node(3);
00205             face->set_node(2) = this->get_node(2);
00206             face->set_node(3) = this->get_node(1);
00207             face->set_node(4) = this->get_node(8);
00208             face->set_node(5) = this->get_node(7);
00209             face->set_node(6) = this->get_node(6);
00210             face->set_node(7) = this->get_node(5);
00211 
00212             break;
00213           }
00214         default:
00215           libmesh_error_msg("Invalid side i = " << i);
00216         }
00217 
00218       face->subdomain_id() = this->subdomain_id();
00219       return UniquePtr<Elem>(face);
00220     }
00221 
00222   libmesh_error_msg("We'll never get here!");
00223   return UniquePtr<Elem>();
00224 }
00225 
00226 
00227 
00228 UniquePtr<Elem> Pyramid13::build_edge (const unsigned int i) const
00229 {
00230   libmesh_assert_less (i, this->n_edges());
00231 
00232   return UniquePtr<Elem>(new SideEdge<Edge3,Pyramid13>(this,i));
00233 }
00234 
00235 
00236 
00237 void Pyramid13::connectivity(const unsigned int libmesh_dbg_var(sc),
00238                              const IOPackage iop,
00239                              std::vector<dof_id_type>& /*conn*/) const
00240 {
00241   libmesh_assert(_nodes);
00242   libmesh_assert_less (sc, this->n_sub_elem());
00243   libmesh_assert_not_equal_to (iop, INVALID_IO_PACKAGE);
00244 
00245   switch (iop)
00246     {
00247     case TECPLOT:
00248       {
00249         // TODO
00250         libmesh_not_implemented();
00251       }
00252 
00253     case VTK:
00254       {
00255         // TODO
00256         libmesh_not_implemented();
00257       }
00258 
00259     default:
00260       libmesh_error_msg("Unsupported IO package " << iop);
00261     }
00262 }
00263 
00264 
00265 
00266 unsigned int Pyramid13::n_second_order_adjacent_vertices (const unsigned int n) const
00267 {
00268   switch (n)
00269     {
00270     case 5:
00271     case 6:
00272     case 7:
00273     case 8:
00274     case 9:
00275     case 10:
00276     case 11:
00277     case 12:
00278       return 2;
00279 
00280     default:
00281       libmesh_error_msg("Invalid node n = " << n);
00282     }
00283 
00284   libmesh_error_msg("We'll never get here!");
00285   return libMesh::invalid_uint;
00286 }
00287 
00288 
00289 unsigned short int Pyramid13::second_order_adjacent_vertex (const unsigned int n,
00290                                                             const unsigned int v) const
00291 {
00292   libmesh_assert_greater_equal (n, this->n_vertices());
00293   libmesh_assert_less (n, this->n_nodes());
00294 
00295   switch (n)
00296     {
00297     case 5:
00298     case 6:
00299     case 7:
00300     case 8:
00301     case 9:
00302     case 10:
00303     case 11:
00304     case 12:
00305       {
00306         libmesh_assert_less (v, 2);
00307 
00308         // This is the analog of the static, const arrays
00309         // {Hex,Prism,Tet10}::_second_order_adjacent_vertices
00310         // defined in the respective source files...
00311         unsigned short node_list[8][2] =
00312           {
00313             {0,1},
00314             {1,2},
00315             {2,3},
00316             {0,3},
00317             {0,4},
00318             {1,4},
00319             {2,4},
00320             {3,4}
00321           };
00322 
00323         return node_list[n-5][v];
00324       }
00325 
00326     default:
00327       libmesh_error_msg("Invalid n = " << n);
00328 
00329     }
00330 
00331   libmesh_error_msg("We'll never get here!");
00332   return static_cast<unsigned short int>(-1);
00333 }
00334 
00335 } // namespace libMesh