Line data Source code
1 : // The libMesh Finite Element Library. 2 : // Copyright (C) 2002-2026 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 : 19 : 20 : #ifndef LIBMESH_FACE_TRI6_H 21 : #define LIBMESH_FACE_TRI6_H 22 : 23 : // Local includes 24 : #include "libmesh/libmesh_common.h" 25 : #include "libmesh/face_tri.h" 26 : #include "libmesh/face_tri3.h" 27 : #include "libmesh/fe_reference_element_traits.h" 28 : 29 : namespace libMesh 30 : { 31 : 32 : /** 33 : * The \p Tri6 is an element in 2D composed of 6 nodes. It is 34 : * numbered like this: 35 : * 36 : * \verbatim 37 : * TRI6: 38 : * 2 39 : * o 40 : * |\ 41 : * | \ 42 : * | \ eta 43 : * | \ ^ 44 : * | \ | 45 : * 5 o o 4 | 46 : * | \ o---> xi 47 : * | \ 48 : * | \ 49 : * o----o----o 50 : * 0 3 1 51 : * \endverbatim 52 : * 53 : * (xi, eta): { 0 <= xi <= 1 54 : * { 0 <= eta <= 1 55 : * { xi + eta <= 1 56 : * are the reference element coordinates associated with the given 57 : * numbering. 58 : * 59 : * \author Benjamin S. Kirk 60 : * \date 2002 61 : * \brief A 2D triangular element with 6 nodes. 62 : */ 63 : class Tri6 : public Tri 64 : { 65 : public: 66 : 67 : /** 68 : * Constructor. By default this element has no parent. 69 : */ 70 : explicit 71 5399652 : Tri6 (Elem * p=nullptr) : 72 5399652 : Tri(num_nodes, p, _nodelinks_data) {} 73 : 74 : Tri6 (Tri6 &&) = delete; 75 : Tri6 (const Tri6 &) = delete; 76 : Tri6 & operator= (const Tri6 &) = delete; 77 : Tri6 & operator= (Tri6 &&) = delete; 78 5571983 : virtual ~Tri6() = default; 79 : 80 : /** 81 : * \returns \p TRI6. 82 : */ 83 14992031954 : virtual ElemType type () const override { return TRI6; } 84 : 85 : /** 86 : * \returns 6. 87 : */ 88 2082778912 : virtual unsigned int n_nodes() const override { return num_nodes; } 89 : 90 : /** 91 : * \returns 4. 92 : */ 93 0 : virtual unsigned int n_sub_elem() const override { return 4; } 94 : 95 : /** 96 : * \returns \p true if the specified (local) node number is a vertex. 97 : */ 98 : virtual bool is_vertex(const unsigned int i) const override; 99 : 100 : /** 101 : * \returns \p true if the specified (local) node number is an edge. 102 : */ 103 : virtual bool is_edge(const unsigned int i) const override; 104 : 105 : /** 106 : * \returns \p true if the specified (local) node number is a face. 107 : */ 108 : virtual bool is_face(const unsigned int i) const override; 109 : 110 : /** 111 : * \returns \p true if the specified (local) node number is on the 112 : * specified side. 113 : */ 114 : virtual bool is_node_on_side(const unsigned int n, 115 : const unsigned int s) const override; 116 : 117 : virtual std::vector<unsigned int> nodes_on_side(const unsigned int s) const override; 118 : 119 : virtual std::vector<unsigned int> nodes_on_edge(const unsigned int e) const override; 120 : 121 : /** 122 : * \returns \p true if the specified (local) node number is on the 123 : * specified edge (== is_node_on_side in 2D). 124 : */ 125 48379 : virtual bool is_node_on_edge(const unsigned int n, 126 : const unsigned int e) const override 127 48379 : { return this->is_node_on_side(n,e); } 128 : 129 : /** 130 : * \returns \p true if the element map is definitely affine within 131 : * numerical tolerances. 132 : */ 133 : virtual bool has_affine_map () const override; 134 : 135 : /** 136 : * \returns SECOND. 137 : */ 138 : virtual Order default_order() const override; 139 : 140 : /** 141 : * Don't hide Elem::key() defined in the base class. 142 : */ 143 : using Elem::key; 144 : 145 : /** 146 : * \returns An id associated with the \p s side of this element. 147 : * The id is not necessarily unique, but should be close. 148 : * 149 : * We reimplement this method here for the \p Tri6 since we can 150 : * use the center node of each edge to provide a perfect (unique) 151 : * key. 152 : */ 153 : virtual dof_id_type key (const unsigned int s) const override; 154 : 155 : /** 156 : * \returns \p Tri6::side_nodes_map[side][side_node] after doing some range checking. 157 : */ 158 : virtual unsigned int local_side_node(unsigned int side, 159 : unsigned int side_node) const override; 160 : 161 : virtual std::unique_ptr<Elem> build_side_ptr (const unsigned int i) override; 162 : 163 : /** 164 : * Rebuilds an EDGE2 coincident with face i. 165 : */ 166 : virtual void build_side_ptr (std::unique_ptr<Elem> & elem, 167 : const unsigned int i) override; 168 : 169 : // Avoid hiding deprecated version with different signature 170 : using Elem::build_side_ptr; 171 : 172 : virtual void connectivity(const unsigned int sf, 173 : const IOPackage iop, 174 : std::vector<dof_id_type> & conn) const override; 175 : 176 : /** 177 : * \returns 2 for all \p n. 178 : */ 179 45382 : virtual unsigned int n_second_order_adjacent_vertices (const unsigned int) const override 180 45382 : { return 2; } 181 : 182 : /** 183 : * \returns The element-local number of the \f$ v^{th} \f$ vertex 184 : * that defines the \f$ n^{th} \f$ second-order node. 185 : * 186 : * \note \p n is counted as depicted above, \f$ 3 \le n < 6 \f$. 187 : */ 188 : virtual unsigned short int second_order_adjacent_vertex (const unsigned int n, 189 : const unsigned int v) const override; 190 : 191 : /** 192 : * \returns The child number \p c and element-local index \p v of the 193 : * \f$ n^{th} \f$ second-order node on the parent element. See 194 : * elem.h for further details. 195 : */ 196 : virtual std::pair<unsigned short int, unsigned short int> 197 : second_order_child_vertex (const unsigned int n) const override; 198 : 199 : /** 200 : * Geometric constants for Tri6. 201 : */ 202 : static const int num_nodes = 6; 203 : static const int nodes_per_side = 3; 204 : 205 : /** 206 : * This maps the \f$ j^{th} \f$ node of the \f$ i^{th} \f$ side to 207 : * element node numbers. It is derived from the first-order 208 : * Tri3 tables; see fe_reference_element_traits.h. 209 : */ 210 : static constexpr NodeMapTable<num_sides, nodes_per_side> 211 : _side_nodes = derived_side_nodes<Tri3, num_sides>(); 212 : static constexpr const unsigned int (&side_nodes_map)[num_sides][nodes_per_side] = _side_nodes.values; 213 : 214 : /** 215 : * An optimized method for approximating the area of a 216 : * TRI6 using quadrature. 217 : */ 218 : virtual Real volume () const override; 219 : 220 : /** 221 : * \returns A bounding box (not necessarily the minimal bounding box) 222 : * containing the geometric element. 223 : */ 224 : virtual BoundingBox loose_bounding_box () const override; 225 : 226 : virtual void permute(unsigned int perm_num) override final; 227 : 228 : virtual void flip(BoundaryInfo *) override final; 229 : 230 : unsigned int center_node_on_side(const unsigned short side) const override final; 231 : 232 : ElemType side_type (const unsigned int s) const override final; 233 : 234 : protected: 235 : 236 : /** 237 : * Data for links to nodes. 238 : */ 239 : Node * _nodelinks_data[num_nodes]; 240 : 241 : 242 : 243 : #ifdef LIBMESH_ENABLE_AMR 244 : 245 : /** 246 : * Matrix used to create the elements children. 247 : */ 248 6560786 : virtual Real embedding_matrix (const unsigned int i, 249 : const unsigned int j, 250 : const unsigned int k) const override 251 6560786 : { return _embedding_matrix[i][j][k]; } 252 : 253 : /** 254 : * Matrix that computes new nodal locations/solution values 255 : * from current nodes/solution. 256 : */ 257 : static const Real _embedding_matrix[num_children][num_nodes][num_nodes]; 258 : 259 10483728 : LIBMESH_ENABLE_TOPOLOGY_CACHES; 260 : 261 : #endif // LIBMESH_ENABLE_AMR 262 : 263 : private: 264 : 265 : /** 266 : * Matrix that tells which vertices define the location 267 : * of mid-side (or second-order) nodes 268 : */ 269 : static const unsigned short int _second_order_adjacent_vertices[num_sides][2]; 270 : 271 : /** 272 : * Vector that names a child sharing each second order node. 273 : */ 274 : static const unsigned short int _second_order_vertex_child_number[num_nodes]; 275 : 276 : /** 277 : * Vector that names the child vertex index for each second order node. 278 : */ 279 : static const unsigned short int _second_order_vertex_child_index[num_nodes]; 280 : }; 281 : 282 : 283 : } // namespace libMesh 284 : 285 : #endif // LIBMESH_FACE_TRI6_H