LCOV - code coverage report
Current view: top level - src/quadrature - quadrature_simpson_2D.C (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4229 (6a9aeb) with base 727f46 Lines: 28 30 93.3 %
Date: 2025-08-19 19:27:09 Functions: 1 1 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             : // Local includes
      21             : #include "libmesh/quadrature_simpson.h"
      22             : #include "libmesh/enum_to_string.h"
      23             : 
      24             : namespace libMesh
      25             : {
      26             : 
      27        2957 : void QSimpson::init_2D()
      28             : {
      29             : #if LIBMESH_DIM > 1
      30             : 
      31             :   //-----------------------------------------------------------------------
      32             :   // 2D quadrature rules
      33        2957 :   switch (_type)
      34             :     {
      35             : 
      36             : 
      37             :       //---------------------------------------------
      38             :       // Quadrilateral quadrature rules
      39         878 :     case QUAD4:
      40             :     case QUADSHELL4:
      41             :     case QUAD8:
      42             :     case QUADSHELL8:
      43             :     case QUAD9:
      44             :     case QUADSHELL9:
      45             :       {
      46             :         // We compute the 2D quadrature rule as a tensor
      47             :         // product of the 1D quadrature rule.
      48         924 :         QSimpson q1D(1);
      49         878 :         tensor_product_quad( q1D );
      50          46 :         return;
      51             :       }
      52             : 
      53             : 
      54             :       //---------------------------------------------
      55             :       // Triangle quadrature rules
      56        2079 :     case TRI3:
      57             :     case TRISHELL3:
      58             :     case TRI3SUBDIVISION:
      59             :     case TRI6:
      60             :     case TRI7:
      61             :       {
      62             :         // The integral of the vertex Lagrange basis functions of the
      63             :         // TRI6 is equal to 0, while the integral of the edge Lagrange
      64             :         // basis functions is 1/6, so attempting to derive the weights
      65             :         // of a nodal quadrature rule using this approach shows that
      66             :         // we only require three quadrature points to get a rule which
      67             :         // is exact for quadratics.
      68             :         //
      69             :         // Unfortunately, it is not possible to derive a nodal
      70             :         // quadrature rule on the TRI6 which is exact for cubics, so
      71             :         // we instead choose the weights such that they are all
      72             :         // strictly positive while still integrating linears
      73             :         // exactly. This avoids issues with this nodal quadrature rule
      74             :         // producing a singular elemental mass matrix.  We use the
      75             :         // "optimization" approach described in quadrature_nodal_2D.C
      76             :         // to choose the weights.
      77             : 
      78        2079 :         _points.resize(6);
      79        2079 :         _weights.resize(6);
      80             : 
      81        2079 :         _points[0](0) = 0.;
      82        2079 :         _points[0](1) = 0.;
      83             : 
      84        2079 :         _points[1](0) = 1.;
      85        2079 :         _points[1](1) = 0.;
      86             : 
      87        2079 :         _points[2](0) = 0.;
      88        2079 :         _points[2](1) = 1.;
      89             : 
      90        2079 :         _points[3](0) = 0.5;
      91        2079 :         _points[3](1) = 0.;
      92             : 
      93        2079 :         _points[4](0) = 0.5;
      94        2079 :         _points[4](1) = 0.5;
      95             : 
      96        2079 :         _points[5](0) = 0.;
      97        2079 :         _points[5](1) = 0.5;
      98             : 
      99        2079 :         _weights[0] = Real(1)/38; // 0.0263157894736842
     100        2079 :         _weights[1] = Real(1)/38;
     101        2079 :         _weights[2] = Real(1)/38;
     102        2079 :         _weights[3] = Real(8)/57; // 0.140350877192982
     103        2079 :         _weights[4] = Real(8)/57;
     104        2079 :         _weights[5] = Real(8)/57;
     105             : 
     106        2079 :         return;
     107             :       }
     108             : 
     109             : 
     110             :       //---------------------------------------------
     111             :       // Unsupported type
     112           0 :     default:
     113           0 :       libmesh_error_msg("Element type not supported!:" << Utility::enum_to_string(_type));
     114             :     }
     115             : #endif
     116             : }
     117             : 
     118             : } // namespace libMesh

Generated by: LCOV version 1.14