LCOV - code coverage report
Current view: top level - include/geom - face_c0polygon.h (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4229 (6a9aeb) with base 727f46 Lines: 6 10 60.0 %
Date: 2025-08-19 19:27:09 Functions: 6 8 75.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_C0POLYGON_H
      21             : #define LIBMESH_FACE_C0POLYGON_H
      22             : 
      23             : // Local includes
      24             : #include "libmesh/libmesh_common.h"
      25             : #include "libmesh/face_polygon.h"
      26             : 
      27             : namespace libMesh
      28             : {
      29             : 
      30             : /**
      31             :  * The \p C0Polygon is an element in 2D with an arbitrary (but fixed)
      32             :  * number of first-order (EDGE2) sides.
      33             :  *
      34             :  * In master space, side 0 of a C0Polygon has point 0 at (0,0), point 1
      35             :  * at (0,1), and subsequent sides continue in a counter-clockwise loop
      36             :  * to form a regular polygon of side length 1.  E.g. a master hexagon
      37             :  * would look like:
      38             :  *
      39             :  *    (0,2*sqrt(3))  o----o  (1,2*sqrt(3))
      40             :  *                  /      \
      41             :  *                 /        \
      42             :  * (-.5, sqrt(3)) o          o (1.5, sqrt(3))
      43             :  *                 \        /
      44             :  *                  \      /
      45             :  *            (0,0)  o----o  (1,0)
      46             :  *
      47             :  * \author Roy H. Stogner
      48             :  * \date 2025
      49             :  * \brief A 2D element with an arbitrary number of first-order sides.
      50             :  */
      51             : class C0Polygon : public Polygon
      52             : {
      53             : public:
      54             : 
      55             :   /**
      56             :    * Constructor.  Takes the number of sides as an input, and
      57             :    * allocates the same number of nodes, one node for the vertex
      58             :    * between each two sides.
      59             :    *
      60             :    * By default this element has no parent.
      61             :    *
      62             :    * We'll set up a simple default triangulation here, but if users
      63             :    * want to make a non-convex polygon they'll want to retriangulate()
      64             :    * after setting up its nodes.
      65             :    */
      66             :   explicit
      67             :   C0Polygon (const unsigned int num_sides, Elem * p=nullptr);
      68             : 
      69             :   C0Polygon (C0Polygon &&) = delete;
      70             :   C0Polygon (const C0Polygon &) = delete;
      71             :   C0Polygon & operator= (const C0Polygon &) = delete;
      72             :   C0Polygon & operator= (C0Polygon &&) = delete;
      73        1080 :   virtual ~C0Polygon() = default;
      74             : 
      75             :   /**
      76             :    * \returns \p C0POLYGON.
      77             :    */
      78     3332499 :   virtual ElemType type () const override final { return C0POLYGON; }
      79             : 
      80             :   /**
      81             :    * \returns the number of triangles to break this into for
      82             :    * visualization.
      83             :    */
      84         284 :   virtual unsigned int n_sub_elem() const override { return this->n_sides(); }
      85             : 
      86             :   /**
      87             :    * \returns The local node number for the node opposite to node n on
      88             :    * side \p opposite_side(s) (for n_sides() even), or throws an error
      89             :    * otherwise.
      90             :    */
      91             :   virtual unsigned int opposite_node(const unsigned int n,
      92             :                                      const unsigned int s) const override final;
      93             : 
      94             :   /**
      95             :    * \returns \p true if the specified (local) node number is a vertex.
      96             :    */
      97             :   virtual bool is_vertex(const unsigned int i) const override;
      98             : 
      99             :   /**
     100             :    * \returns \p true if the specified (local) node number is an edge.
     101             :    */
     102             :   virtual bool is_edge(const unsigned int i) const override;
     103             : 
     104             :   /**
     105             :    * \returns \p true if the specified (local) node number is a face.
     106             :    */
     107             :   virtual bool is_face(const unsigned int i) const override;
     108             : 
     109             :   /**
     110             :    * C0Polygon elements have only vertex nodes, two per side/edge
     111             :    */
     112         579 :   virtual unsigned int n_nodes_per_side() const override { return 2;}
     113             : 
     114             :   /**
     115             :    * \returns \p true if the specified (local) node number is on the
     116             :    * specified side.
     117             :    */
     118             :   virtual bool is_node_on_side(const unsigned int n,
     119             :                                const unsigned int s) const override;
     120             : 
     121             :   virtual std::vector<unsigned int> nodes_on_side(const unsigned int s) const override;
     122             : 
     123             :   virtual std::vector<unsigned int> nodes_on_edge(const unsigned int e) const override;
     124             : 
     125             :   /**
     126             :    * \returns \p true if the specified (local) node number is on the
     127             :    * specified edge (== is_node_on_side in 2D).
     128             :    */
     129        2818 :   virtual bool is_node_on_edge(const unsigned int n,
     130             :                                const unsigned int e) const override
     131        2818 :   { return this->is_node_on_side(n,e); }
     132             : 
     133             :   /**
     134             :    * \returns \p true if the element map is definitely affine within
     135             :    * numerical tolerances.
     136             :    */
     137             :   virtual bool has_affine_map () const override;
     138             : 
     139             :   /**
     140             :    * \returns FIRST
     141             :    */
     142             :   virtual Order default_order() const override;
     143             : 
     144             :   /**
     145             :    * Don't hide Elem::key() defined in the base class.
     146             :    */
     147             :   using Elem::key;
     148             : 
     149             :   virtual std::unique_ptr<Elem> build_side_ptr (const unsigned int i) override;
     150             : 
     151             :   /**
     152             :    * Rebuilds an EDGE2 coincident with side i.
     153             :    */
     154             :   virtual void build_side_ptr (std::unique_ptr<Elem> & elem,
     155             :                                const unsigned int i) override;
     156             : 
     157             :   // Avoid hiding deprecated version with different signature
     158             :   using Elem::build_side_ptr;
     159             : 
     160             :   virtual void connectivity(const unsigned int sf,
     161             :                             const IOPackage iop,
     162             :                             std::vector<dof_id_type> & conn) const override;
     163             : 
     164             :   /**
     165             :    * \returns 2 for all \p n.
     166             :    */
     167           0 :   virtual unsigned int n_second_order_adjacent_vertices (const unsigned int) const override
     168           0 :   { return 2; }
     169             : 
     170             :   /**
     171             :    * Element refinement is not implemented for polygons.
     172             :    */
     173             :   virtual std::pair<unsigned short int, unsigned short int>
     174             :   second_order_child_vertex (const unsigned int n) const override;
     175             : 
     176             :   /**
     177             :    * An optimized method for calculating the area of a C0Polygon.
     178             :    */
     179             :   virtual Real volume () const override;
     180             : 
     181             :   /**
     182             :    * An optimized method for calculating the centroid of a C0Polygon.
     183             :    */
     184             :   virtual Point true_centroid () const override;
     185             : 
     186             :   virtual void permute(unsigned int perm_num) override final;
     187             : 
     188             :   virtual void flip(BoundaryInfo *) override final;
     189             : 
     190             :   ElemType side_type (const unsigned int s) const override final;
     191             : 
     192             :   /**
     193             :    * Create a triangulation from the current node locations.
     194             :    */
     195             :   virtual void retriangulate() override final;
     196             : 
     197             : protected:
     198             : 
     199             : #ifdef LIBMESH_ENABLE_AMR
     200             : 
     201             :   /**
     202             :    * Matrix used to create the elements children.
     203             :    */
     204           0 :   virtual Real embedding_matrix (const unsigned int /*i*/,
     205             :                                  const unsigned int /*j*/,
     206             :                                  const unsigned int /*k*/) const override
     207           0 :   { libmesh_not_implemented(); return 0; }
     208             : 
     209             : #endif // LIBMESH_ENABLE_AMR
     210             : 
     211             : };
     212             : 
     213             : 
     214             : } // namespace libMesh
     215             : 
     216             : #endif // LIBMESH_FACE_POLYGON_H

Generated by: LCOV version 1.14