libMesh
Loading...
Searching...
No Matches
quadrature_grid_2D.C
Go to the documentation of this file.
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
24namespace libMesh
25{
26
28{
29#if LIBMESH_DIM > 1
30
31 switch (_type)
32 {
33
34
35 //---------------------------------------------
36 // Quadrilateral quadrature rules
37 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 QGrid q1D(1, _order);
52 return;
53 }
54
55
56 //---------------------------------------------
57 // Triangle quadrature rules
58 case TRI3:
59 case TRISHELL3:
60 case TRI3SUBDIVISION:
61 case TRI6:
62 case TRI7:
63 {
64 const unsigned int np = (_order + 1)*(_order + 2)/2;
65 const Real weight = Real(0.5)/np;
66 const Real dx = Real(1)/static_cast<int>(_order+1);
67 _points.resize(np);
68 _weights.resize(np);
69
70 unsigned int pt = 0;
71 for (int i = 0; i != _order + 1; ++i)
72 {
73 for (int j = 0; j != _order + 1 - i; ++j)
74 {
75 _points[pt](0) = (i+0.5)*dx;
76 _points[pt](1) = (j+0.5)*dx;
77 _weights[pt] = weight;
78 pt++;
79 }
80 }
81 return;
82 }
83
84 //---------------------------------------------
85 // Unsupported type
86 default:
87 libmesh_error_msg("Element type not supported!:" << Utility::enum_to_string(_type));
88 }
89#endif
90}
91
92} // namespace libMesh
std::vector< Point > _points
The locations of the quadrature points in reference element space.
Definition quadrature.h:409
ElemType _type
The type of element for which the current values have been computed.
Definition quadrature.h:391
void tensor_product_quad(const QBase &q1D)
Constructs a 2D rule from the tensor product of q1D with itself.
Definition quadrature.C:256
std::vector< Real > _weights
The quadrature weights.
Definition quadrature.h:415
Order _order
The polynomial order which the quadrature rule is capable of integrating exactly.
Definition quadrature.h:385
This class creates quadrature points on a uniform grid, with order+1 points on an edge.
virtual void init_2D() override
Initializes the 2D quadrature rule by filling the points and weights vectors with the appropriate val...
std::string enum_to_string(const T e)
The libMesh namespace provides an interface to certain functionality in the library.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real