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_TRI3_H 21 : #define LIBMESH_FACE_TRI3_H 22 : 23 : 24 : // Local includes 25 : #include "libmesh/libmesh_common.h" 26 : #include "libmesh/face_tri.h" 27 : 28 : // C++ includes 29 : #include <cstddef> 30 : 31 : namespace libMesh 32 : { 33 : 34 : /** 35 : * The \p Tri3 is an element in 2D composed of 3 nodes. It is 36 : * numbered like this: 37 : * 38 : * \verbatim 39 : * TRI3: 40 : * 2 41 : * o 42 : * |\ eta 43 : * | \ ^ 44 : * | \ | 45 : * | \ | 46 : * | \ o---> xi 47 : * o-----o 48 : * 0 1 49 : * \endverbatim 50 : * 51 : * (xi, eta): { 0 <= xi <= 1 52 : * { 0 <= eta <= 1 53 : * { xi + eta <= 1 54 : * are the reference element coordinates associated with the given 55 : * numbering. 56 : * 57 : * \author Benjamin S. Kirk 58 : * \date 2002 59 : * \brief A 2D triangular element with 3 nodes. 60 : */ 61 : class Tri3 : public Tri 62 : { 63 : public: 64 : 65 : /** 66 : * Constructor. By default this element has no parent. 67 : */ 68 : explicit 69 2592918806 : Tri3 (Elem * p=nullptr) : 70 2592918806 : Tri(num_nodes, p, _nodelinks_data) {} 71 : 72 : Tri3 (Tri3 &&) = delete; 73 : Tri3 (const Tri3 &) = delete; 74 : Tri3 & operator= (const Tri3 &) = delete; 75 : Tri3 & operator= (Tri3 &&) = delete; 76 2406416596 : virtual ~Tri3() = default; 77 : 78 : /** 79 : * \returns \p TRI3. 80 : */ 81 2212035902 : virtual ElemType type () const override { return TRI3; } 82 : 83 : /** 84 : * \returns 1. 85 : */ 86 282800 : virtual unsigned int n_sub_elem() const override { return 1; } 87 : 88 : /** 89 : * \returns \p true if the specified (local) node number is a vertex. 90 : */ 91 : virtual bool is_vertex(const unsigned int i) const override; 92 : 93 : /** 94 : * \returns \p true if the specified (local) node number is an edge. 95 : */ 96 : virtual bool is_edge(const unsigned int i) const override; 97 : 98 : /** 99 : * \returns \p true if the specified (local) node number is a face. 100 : */ 101 : virtual bool is_face(const unsigned int i) const override; 102 : 103 : /** 104 : * \returns \p true if the specified (local) node number is on the 105 : * specified side. 106 : */ 107 : virtual bool is_node_on_side(const unsigned int n, 108 : const unsigned int s) const override; 109 : 110 : virtual std::vector<unsigned int> nodes_on_side(const unsigned int s) const override; 111 : 112 : virtual std::vector<unsigned int> nodes_on_edge(const unsigned int e) const override; 113 : 114 : /** 115 : * \returns \p true if the specified (local) node number is on the 116 : * specified edge (== is_node_on_side in 2D). 117 : */ 118 713262 : virtual bool is_node_on_edge(const unsigned int n, 119 : const unsigned int e) const override 120 713262 : { return this->is_node_on_side(n,e); } 121 : 122 : /** 123 : * \returns \p true if the element map is definitely affine within 124 : * numerical tolerances. 125 : */ 126 10046822 : virtual bool has_affine_map () const override { return true; } 127 : 128 : /** 129 : * \returns \p true if the element has non-zero volume, false otherwise. 130 : */ 131 : virtual bool has_invertible_map(Real tol) const override; 132 : 133 : /** 134 : * \returns \p true if the Lagrange shape functions on this element 135 : * are linear. 136 : */ 137 3283062 : virtual bool is_linear () const override { return true; } 138 : 139 : /** 140 : * \returns FIRST. 141 : */ 142 : virtual Order default_order() const override; 143 : 144 : virtual std::unique_ptr<Elem> build_side_ptr (const unsigned int i) override; 145 : 146 : /** 147 : * Rebuilds an EDGE2 coincident with face i. 148 : */ 149 : virtual void build_side_ptr (std::unique_ptr<Elem> & elem, 150 : const unsigned int i) override; 151 : 152 : // Avoid hiding deprecated version with different signature 153 : using Elem::build_side_ptr; 154 : 155 : virtual void connectivity(const unsigned int sf, 156 : const IOPackage iop, 157 : std::vector<dof_id_type> & conn) const override; 158 : 159 : /** 160 : * Geometric constants for Tri3. 161 : */ 162 : static const int num_nodes = 3; 163 : static const int nodes_per_side = 2; 164 : 165 : /** 166 : * This maps the \f$ j^{th} \f$ node of the \f$ i^{th} \f$ side to 167 : * element node numbers. 168 : */ 169 : static constexpr unsigned int side_nodes_map[num_sides][nodes_per_side] = 170 : { 171 : {0, 1}, // Side 0 172 : {1, 2}, // Side 1 173 : {2, 0} // Side 2 174 : }; 175 : 176 : /** 177 : * The centroid of a 3-node triangle is simply given by the 178 : * average of its vertex positions. 179 : */ 180 : virtual Point true_centroid () const override; 181 : 182 : /** 183 : * An optimized method for computing the area of a 3-node triangle. 184 : */ 185 : virtual Real volume () const override; 186 : 187 : /** 188 : * \returns The minimum and maximum angles for the triangle 189 : * (in radians) in a std::pair. The first entry in the pair 190 : * is the minimum angle, the second entry is the max angle. 191 : */ 192 : std::pair<Real, Real> min_and_max_angle() const; 193 : 194 : /** 195 : * Specialization for tri3 elements. These elements are guaranteed to be planar 196 : * so a simple linear geometric test can be used. 197 : */ 198 : virtual bool contains_point (const Point & p, Real tol) const override; 199 : 200 : /** 201 : * Builds a bounding box out of the nodal positions 202 : */ 203 : virtual BoundingBox loose_bounding_box () const override; 204 : 205 : virtual void permute(unsigned int perm_num) override final; 206 : 207 : virtual void flip(BoundaryInfo *) override final; 208 : 209 : ElemType side_type (const unsigned int s) const override final; 210 : 211 : virtual Point side_vertex_average_normal(const unsigned int s) const override final; 212 : 213 : protected: 214 : 215 : /** 216 : * Data for links to nodes. 217 : */ 218 : Node * _nodelinks_data[num_nodes]; 219 : 220 : 221 : 222 : #ifdef LIBMESH_ENABLE_AMR 223 : 224 : /** 225 : * Matrix used to create the elements children. 226 : */ 227 9019473 : virtual Real embedding_matrix (const unsigned int i, 228 : const unsigned int j, 229 : const unsigned int k) const override 230 9019473 : { return _embedding_matrix[i][j][k]; } 231 : 232 : /** 233 : * Matrix that computes new nodal locations/solution values 234 : * from current nodes/solution. 235 : */ 236 : static const Real _embedding_matrix[num_children][num_nodes][num_nodes]; 237 : 238 30147315 : LIBMESH_ENABLE_TOPOLOGY_CACHES; 239 : 240 : #endif // LIBMESH_ENABLE_AMR 241 : 242 : }; 243 : 244 : } // namespace libMesh 245 : 246 : #endif // LIBMESH_FACE_TRI3_H