LCOV - code coverage report
Current view: top level - include/geom - face_quad9.h (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4554 (5a536d) with base 54e0d5 Lines: 11 11 100.0 %
Date: 2026-09-16 12:37:14 Functions: 10 10 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.14