LCOV - code coverage report
Current view: top level - include/geom - face_tri.h (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4229 (6a9aeb) with base 727f46 Lines: 17 17 100.0 %
Date: 2025-08-19 19:27:09 Functions: 9 10 90.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // The libMesh Finite Element Library.
       2             : // Copyright (C) 2002-2025 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_TRI_H
      21             : #define LIBMESH_FACE_TRI_H
      22             : 
      23             : // Local includes
      24             : #include "libmesh/libmesh_common.h"
      25             : #include "libmesh/face.h"
      26             : 
      27             : namespace libMesh
      28             : {
      29             : 
      30             : /**
      31             :  * The \p Tri is an element in 2D composed of 3 sides.
      32             :  * It looks like this:
      33             :  * \verbatim
      34             :  *          ^
      35             :  *         / \
      36             :  *        /   \
      37             :  *       /     \
      38             :  *      /       \
      39             :  *     /         \
      40             :  *     -----------
      41             :  * \endverbatim
      42             :  *
      43             :  * \author Benjamin S. Kirk
      44             :  * \date 2002
      45             :  * \brief The base class for all triangular element types.
      46             :  */
      47             : class Tri : public Face
      48             : {
      49             : public:
      50             : 
      51             :   /**
      52             :    * Default triangular element, takes number of nodes and
      53             :    * parent. Derived classes implement 'true' elements.
      54             :    */
      55  2609507661 :   Tri (const unsigned int nn,
      56             :        Elem * p,
      57  2609507661 :        Node ** nodelinkdata) :
      58  2609507661 :     Face(nn, num_sides, p, _elemlinks_data, nodelinkdata)
      59             :   {
      60             :     // Make sure the interior parent isn't undefined
      61             :     if (LIBMESH_DIM > 2)
      62  2609507661 :       this->set_interior_parent(nullptr);
      63  2609507661 :   }
      64             : 
      65             :   Tri (Tri &&) = delete;
      66             :   Tri (const Tri &) = delete;
      67             :   Tri & operator= (const Tri &) = delete;
      68             :   Tri & operator= (Tri &&) = delete;
      69    13038293 :   virtual ~Tri() = default;
      70             : 
      71             :   /**
      72             :    * \returns The \p Point associated with local \p Node \p i,
      73             :    * in master element rather than physical coordinates.
      74             :    */
      75      158039 :   virtual Point master_point (const unsigned int i) const override final
      76             :   {
      77        5184 :     libmesh_assert_less(i, this->n_nodes());
      78      158039 :     return Point(_master_points[i][0],
      79      158039 :                  _master_points[i][1],
      80      163223 :                  _master_points[i][2]);
      81             :   }
      82             : 
      83             :   /**
      84             :    * Geometric constants for all Tris
      85             :    */
      86             :   static const int num_sides = 3;
      87             :   static const int num_children = 4;
      88             : 
      89             :   /**
      90             :    * \returns 3.  All tri-derivatives are guaranteed to have at
      91             :    * least 3 nodes.
      92             :    */
      93   693390954 :   virtual unsigned int n_nodes() const override { return 3; }
      94             : 
      95             :   /**
      96             :    * \returns 3.
      97             :    */
      98   348066504 :   virtual unsigned int n_sides() const override final { return 3; }
      99             : 
     100             :   /**
     101             :    * \returns 3.  All triangles have 3 vertices.
     102             :    */
     103    93146506 :   virtual unsigned int n_vertices() const override final { return 3; }
     104             : 
     105             :   /**
     106             :    * \returns 3.  All triangles have 3 edges.
     107             :    */
     108    70269606 :   virtual unsigned int n_edges() const override final { return 3; }
     109             : 
     110             :   /**
     111             :    * \returns 4.
     112             :    */
     113    80488318 :   virtual unsigned int n_children() const override final { return 4; }
     114             : 
     115             :   /**
     116             :    * \returns \p true if the specified child is on the
     117             :    * specified side.
     118             :    */
     119             :   virtual bool is_child_on_side(const unsigned int c,
     120             :                                 const unsigned int s) const override final;
     121             : 
     122             :   /**
     123             :    * Don't hide Elem::key() defined in the base class.
     124             :    */
     125             :   using Elem::key;
     126             : 
     127             :   /**
     128             :    * \returns An id associated with the global node ids of this
     129             :    * element.  The id is not necessarily unique, but should be
     130             :    * close.
     131             :    */
     132             :   virtual dof_id_type key () const override final;
     133             : 
     134             :   /**
     135             :    * \returns An id associated with the \p s side of this element.
     136             :    * The id is not necessarily unique, but should be close.
     137             :    */
     138             :   virtual dof_id_type key (const unsigned int s) const override;
     139             : 
     140             :   /**
     141             :    * \returns An id associated with the \p s side of this element, as
     142             :    * defined solely by element vertices.  The id is not necessarily
     143             :    * unique, but should be close.  This is particularly useful in the
     144             :    * \p MeshBase::find_neighbors() routine.
     145             :    */
     146             :   virtual dof_id_type low_order_key (const unsigned int s) const override;
     147             : 
     148             :   /**
     149             :    * \returns \p Tri3::side_nodes_map[side][side_node] after doing some range checking.
     150             :    */
     151             :   virtual unsigned int local_side_node(unsigned int side,
     152             :                                        unsigned int side_node) const override;
     153             : 
     154             :   /**
     155             :    * Calls local_side_node(edge, edge_node). For 2D elements, there is an implied
     156             :    * equivalence between edges and sides, e.g. n_edges() == n_sides(), so we treat
     157             :    * these two functions the same.
     158             :    */
     159             :   virtual unsigned int local_edge_node(unsigned int edge,
     160             :                                        unsigned int edge_node) const override;
     161             : 
     162             :   /**
     163             :    * \returns A primitive (2-noded) edge for edge i.
     164             :    */
     165             :   virtual std::unique_ptr<Elem> side_ptr (const unsigned int i) override final;
     166             : 
     167             :   /**
     168             :    * Rebuilds an EDGE2 coincident with face i.
     169             :    */
     170             :   virtual void side_ptr (std::unique_ptr<Elem> & elem,
     171             :                          const unsigned int i) override final;
     172             : 
     173             :   /**
     174             :    * \returns A quantitative assessment of element quality based on
     175             :    * the quality metric \p q specified by the user.
     176             :    */
     177             :   virtual Real quality (const ElemQuality q) const override;
     178             : 
     179             :   /**
     180             :    * \returns The suggested quality bounds for the hex based on quality
     181             :    * measure \p q.  These are the values suggested by the CUBIT User's
     182             :    * Manual.
     183             :    */
     184             :   virtual std::pair<Real, Real> qual_bounds (const ElemQuality q) const override;
     185             : 
     186             :   /**
     187             :    * Three sides, one orientation each.
     188             :    */
     189      294545 :   virtual unsigned int n_permutations() const override final { return 3; }
     190             : 
     191             :   virtual bool is_flipped() const override final;
     192             : 
     193             :   virtual std::vector<unsigned int> edges_adjacent_to_node(const unsigned int n) const override;
     194             : 
     195             :   virtual bool on_reference_element(const Point & p,
     196             :                                     const Real eps = TOLERANCE) const override final;
     197             : 
     198             : protected:
     199             : 
     200             :   /**
     201             :    * Data for links to parent/neighbor/interior_parent elements.
     202             :    */
     203             :   Elem * _elemlinks_data[4+(LIBMESH_DIM>2)];
     204             : 
     205             :   /**
     206             :    * Master element node locations
     207             :    */
     208             :   static const Real _master_points[6][3];
     209             : 
     210             :   /**
     211             :    * This maps the \f$ j^{th} \f$ node to the (in this case) 2 side
     212             :    * ids adjacent to the node. The side numbering matches the one used
     213             :    * in the derived classes' side_nodes_map. This data structure
     214             :    * is used in the Tri::edges_adjacent_to_node() override and is
     215             :    * shared by all the derived Tri types.
     216             :    */
     217             :   static const unsigned int adjacent_sides_map[/*num_vertices*/3][/*n_adjacent_sides*/2];
     218             : };
     219             : 
     220             : } // namespace libMesh
     221             : 
     222             : #endif // LIBMESH_FACE_TRI_H

Generated by: LCOV version 1.14