$extrastylesheet
00001 // The libMesh Finite Element Library. 00002 // Copyright (C) 2002-2014 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/cell_pyramid.h" 00023 #include "libmesh/cell_pyramid5.h" 00024 #include "libmesh/face_tri3.h" 00025 #include "libmesh/face_quad4.h" 00026 00027 namespace libMesh 00028 { 00029 00030 00031 // ------------------------------------------------------------ 00032 // Pyramid class member functions 00033 dof_id_type Pyramid::key (const unsigned int s) const 00034 { 00035 libmesh_assert_less (s, this->n_sides()); 00036 00037 switch (s) 00038 { 00039 case 0: // triangular face 1 00040 00041 return 00042 this->compute_key (this->node(0), 00043 this->node(1), 00044 this->node(4)); 00045 00046 case 1: // triangular face 2 00047 00048 return 00049 this->compute_key (this->node(1), 00050 this->node(2), 00051 this->node(4)); 00052 00053 case 2: // triangular face 3 00054 00055 return 00056 this->compute_key (this->node(2), 00057 this->node(3), 00058 this->node(4)); 00059 00060 case 3: // triangular face 4 00061 00062 return 00063 this->compute_key (this->node(3), 00064 this->node(0), 00065 this->node(4)); 00066 00067 case 4: // the quad face at z=0 00068 00069 return 00070 this->compute_key (this->node(0), 00071 this->node(3), 00072 this->node(2), 00073 this->node(1)); 00074 00075 default: 00076 libmesh_error_msg("Invalid side s = " << s); 00077 } 00078 00079 libmesh_error_msg("We'll never get here!"); 00080 return 0; 00081 } 00082 00083 00084 00085 UniquePtr<Elem> Pyramid::side (const unsigned int i) const 00086 { 00087 libmesh_assert_less (i, this->n_sides()); 00088 00089 // To be returned wrapped in an UniquePtr 00090 Elem* face = NULL; 00091 00092 switch (i) 00093 { 00094 case 0: // triangular face 1 00095 { 00096 face = new Tri3; 00097 00098 face->set_node(0) = this->get_node(0); 00099 face->set_node(1) = this->get_node(1); 00100 face->set_node(2) = this->get_node(4); 00101 00102 break; 00103 } 00104 case 1: // triangular face 2 00105 { 00106 face = new Tri3; 00107 00108 face->set_node(0) = this->get_node(1); 00109 face->set_node(1) = this->get_node(2); 00110 face->set_node(2) = this->get_node(4); 00111 00112 break; 00113 } 00114 case 2: // triangular face 3 00115 { 00116 face = new Tri3; 00117 00118 face->set_node(0) = this->get_node(2); 00119 face->set_node(1) = this->get_node(3); 00120 face->set_node(2) = this->get_node(4); 00121 00122 break; 00123 } 00124 case 3: // triangular face 4 00125 { 00126 face = new Tri3; 00127 00128 face->set_node(0) = this->get_node(3); 00129 face->set_node(1) = this->get_node(0); 00130 face->set_node(2) = this->get_node(4); 00131 00132 break; 00133 } 00134 case 4: // the quad face at z=0 00135 { 00136 face = new Quad4; 00137 00138 face->set_node(0) = this->get_node(0); 00139 face->set_node(1) = this->get_node(3); 00140 face->set_node(2) = this->get_node(2); 00141 face->set_node(3) = this->get_node(1); 00142 00143 break; 00144 } 00145 default: 00146 libmesh_error_msg("Invalid side i = " << i); 00147 } 00148 00149 return UniquePtr<Elem>(face); 00150 } 00151 00152 00153 00154 bool Pyramid::is_child_on_side(const unsigned int c, 00155 const unsigned int s) const 00156 { 00157 libmesh_assert_less (c, this->n_children()); 00158 libmesh_assert_less (s, this->n_sides()); 00159 00160 for (unsigned int i = 0; i != 4; ++i) 00161 if (Pyramid5::side_nodes_map[s][i] == c) 00162 return true; 00163 return false; 00164 } 00165 00166 00167 00168 bool Pyramid::is_edge_on_side(const unsigned int e, 00169 const unsigned int s) const 00170 { 00171 libmesh_assert_less (e, this->n_edges()); 00172 libmesh_assert_less (s, this->n_sides()); 00173 00174 return (is_node_on_side(Pyramid5::edge_nodes_map[e][0],s) && 00175 is_node_on_side(Pyramid5::edge_nodes_map[e][1],s)); 00176 } 00177 00178 00179 00180 } // namespace libMesh