LCOV - code coverage report
Current view: top level - src/quadrature - quadrature_grid_2D.C (source / functions) Hit Total Coverage
Test: libMesh/libmesh: #4640 (c5f9f0) with base a68dd6 Lines: 26 28 92.9 %
Date: 2026-11-02 23:02:27 Functions: 1 1 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             : // Local includes
      21             : #include "libmesh/quadrature_grid.h"
      22             : #include "libmesh/enum_to_string.h"
      23             : 
      24             : namespace libMesh
      25             : {
      26             : 
      27        1411 : void QGrid::init_2D()
      28             : {
      29             : #if LIBMESH_DIM > 1
      30             : 
      31        1411 :   switch (_type)
      32             :     {
      33             : 
      34             : 
      35             :       //---------------------------------------------
      36             :       // Quadrilateral quadrature rules
      37         772 :     case QUAD4:
      38             :     case QUADSHELL4:
      39             :     case QUAD8:
      40             :     case QUADSHELL8:
      41             :     case QUAD9:
      42             :     case QUADSHELL9:
      43             :       {
      44             :         // We compute the 2D quadrature rule as a tensor
      45             :         // product of the 1D quadrature rule.
      46             :         //
      47             :         // We ignore p_level in QGrid, since the "order" here is a
      48             :         // user-requested number of grid points, nothing to do with
      49             :         // the order of exactly-integrated polynomial spaces
      50         794 :         QGrid q1D(1, _order);
      51         772 :         tensor_product_quad( q1D );
      52          22 :         return;
      53             :       }
      54             : 
      55             : 
      56             :       //---------------------------------------------
      57             :       // Triangle quadrature rules
      58         639 :     case TRI3:
      59             :     case TRISHELL3:
      60             :     case TRI3SUBDIVISION:
      61             :     case TRI6:
      62             :     case TRI7:
      63             :       {
      64             :         // This is the composite centroid rule on a uniform refinement
      65             :         // of the reference triangle with order+1 intervals per edge:
      66             :         // one point at the centroid of each of the (order+1)^2
      67             :         // congruent subtriangles, each weighted by the subtriangle
      68             :         // area.  It is exact for linears and has O(dx^2) error on
      69             :         // smooth functions, like the midpoint grid on quads.
      70         639 :         const unsigned int np = (_order + 1)*(_order + 1);
      71         639 :         const Real weight = Real(0.5)/np;
      72         639 :         const Real dx = Real(1)/static_cast<int>(_order+1);
      73         639 :         _points.resize(np);
      74         639 :         _weights.resize(np);
      75             : 
      76          18 :         unsigned int pt = 0;
      77        4491 :         for (int i = 0; i != _order + 1; ++i)
      78             :           {
      79       19383 :             for (int j = 0; j != _order + 1 - i; ++j)
      80             :               {
      81             :                 // Centroid of the subtriangle with vertices
      82             :                 // (i,j), (i+1,j), (i,j+1), scaled by dx
      83       15549 :                 _points[pt](0) = (i+Real(1)/3)*dx;
      84       15549 :                 _points[pt](1) = (j+Real(1)/3)*dx;
      85       15549 :                 _weights[pt] = weight;
      86       15549 :                 pt++;
      87             : 
      88             :                 // Centroid of the subtriangle with vertices
      89             :                 // (i+1,j), (i,j+1), (i+1,j+1), scaled by dx, which
      90             :                 // lies inside the reference triangle only if
      91             :                 // i+j < order
      92       15549 :                 if (i + j < _order)
      93             :                   {
      94       11715 :                     _points[pt](0) = (i+Real(2)/3)*dx;
      95       11715 :                     _points[pt](1) = (j+Real(2)/3)*dx;
      96       11715 :                     _weights[pt] = weight;
      97       11715 :                     pt++;
      98             :                   }
      99             :               }
     100             :           }
     101          18 :         libmesh_assert_equal_to(pt, np);
     102          18 :         return;
     103             :       }
     104             : 
     105             :       //---------------------------------------------
     106             :       // Unsupported type
     107           0 :     default:
     108           0 :       libmesh_error_msg("Element type not supported!:" << Utility::enum_to_string(_type));
     109             :     }
     110             : #endif
     111             : }
     112             : 
     113             : } // namespace libMesh

Generated by: LCOV version 1.14