LCOV - code coverage report
Current view: top level - include/geom - face_tri3.h (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4229 (6a9aeb) with base 727f46 Lines: 12 12 100.0 %
Date: 2025-08-19 19:27:09 Functions: 11 11 100.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_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  2584790127 :   Tri3 (Elem * p=nullptr) :
      70  2584790127 :     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  2357198775 :   virtual ~Tri3() = default;
      77             : 
      78             :   /**
      79             :    * \returns \p TRI3.
      80             :    */
      81  2082583483 :   virtual ElemType type () const override { return TRI3; }
      82             : 
      83             :   /**
      84             :    * \returns 1.
      85             :    */
      86     1496222 :   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      571080 :   virtual bool is_node_on_edge(const unsigned int n,
     119             :                                const unsigned int e) const override
     120      571080 :   { 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    10041751 :   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     3271614 :   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 const unsigned int side_nodes_map[num_sides][nodes_per_side];
     170             : 
     171             :   /**
     172             :    * The centroid of a 3-node triangle is simply given by the
     173             :    * average of its vertex positions.
     174             :    */
     175             :   virtual Point true_centroid () const override;
     176             : 
     177             :   /**
     178             :    * An optimized method for computing the area of a 3-node triangle.
     179             :    */
     180             :   virtual Real volume () const override;
     181             : 
     182             :   /**
     183             :    * \returns The minimum and maximum angles for the triangle
     184             :    * (in radians) in a std::pair.  The first entry in the pair
     185             :    * is the minimum angle, the second entry is the max angle.
     186             :    */
     187             :   std::pair<Real, Real> min_and_max_angle() const;
     188             : 
     189             :   /**
     190             :    * Specialization for tri3 elements. These elements are guaranteed to be planar
     191             :    * so a simple linear geometric test can be used.
     192             :    */
     193             :   virtual bool contains_point (const Point & p, Real tol) const override;
     194             : 
     195             :   /**
     196             :    * Builds a bounding box out of the nodal positions
     197             :    */
     198             :   virtual BoundingBox loose_bounding_box () const override;
     199             : 
     200             :   virtual void permute(unsigned int perm_num) override final;
     201             : 
     202             :   virtual void flip(BoundaryInfo *) override final;
     203             : 
     204             :   ElemType side_type (const unsigned int s) const override final;
     205             : 
     206             : protected:
     207             : 
     208             :   /**
     209             :    * Data for links to nodes.
     210             :    */
     211             :   Node * _nodelinks_data[num_nodes];
     212             : 
     213             : 
     214             : 
     215             : #ifdef LIBMESH_ENABLE_AMR
     216             : 
     217             :   /**
     218             :    * Matrix used to create the elements children.
     219             :    */
     220     9019473 :   virtual Real embedding_matrix (const unsigned int i,
     221             :                                  const unsigned int j,
     222             :                                  const unsigned int k) const override
     223     9019473 :   { return _embedding_matrix[i][j][k]; }
     224             : 
     225             :   /**
     226             :    * Matrix that computes new nodal locations/solution values
     227             :    * from current nodes/solution.
     228             :    */
     229             :   static const Real _embedding_matrix[num_children][num_nodes][num_nodes];
     230             : 
     231    30147315 :   LIBMESH_ENABLE_TOPOLOGY_CACHES;
     232             : 
     233             : #endif // LIBMESH_ENABLE_AMR
     234             : 
     235             : };
     236             : 
     237             : } // namespace libMesh
     238             : 
     239             : #endif // LIBMESH_FACE_TRI3_H

Generated by: LCOV version 1.14