libMesh
quadrature_grid_2D.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2024 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 void QGrid::init_2D(const ElemType, unsigned int)
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  {
43  // We compute the 2D quadrature rule as a tensor
44  // product of the 1D quadrature rule.
45  QGrid q1D(1, _order);
46  q1D.init(EDGE2);
47  tensor_product_quad( q1D );
48  return;
49  }
50 
51 
52  //---------------------------------------------
53  // Triangle quadrature rules
54  case TRI3:
55  case TRISHELL3:
56  case TRI3SUBDIVISION:
57  case TRI6:
58  case TRI7:
59  {
60  const unsigned int np = (_order + 1)*(_order + 2)/2;
61  const Real weight = Real(0.5)/np;
62  const Real dx = Real(1)/(_order+1);
63  _points.resize(np);
64  _weights.resize(np);
65 
66  unsigned int pt = 0;
67  for (int i = 0; i != _order + 1; ++i)
68  {
69  for (int j = 0; j != _order + 1 - i; ++j)
70  {
71  _points[pt](0) = (i+0.5)*dx;
72  _points[pt](1) = (j+0.5)*dx;
73  _weights[pt] = weight;
74  pt++;
75  }
76  }
77  return;
78  }
79 
80  //---------------------------------------------
81  // Unsupported type
82  default:
83  libmesh_error_msg("Element type not supported!:" << Utility::enum_to_string(_type));
84  }
85 #endif
86 }
87 
88 } // namespace libMesh
virtual void init(const ElemType type=INVALID_ELEM, unsigned int p_level=0)
Initializes the data structures for a quadrature rule for an element of type type.
Definition: quadrature.C:64
ElemType
Defines an enum for geometric element types.
virtual void init_2D(const ElemType, unsigned int) override
Initializes the 2D quadrature rule by filling the points and weights vectors with the appropriate val...
ElemType _type
The type of element for which the current values have been computed.
Definition: quadrature.h:371
The libMesh namespace provides an interface to certain functionality in the library.
std::vector< Point > _points
The locations of the quadrature points in reference element space.
Definition: quadrature.h:383
std::vector< Real > _weights
The quadrature weights.
Definition: quadrature.h:389
dof_id_type weight(const MeshBase &mesh, const processor_id_type pid)
Definition: mesh_tools.C:436
This class creates quadrature points on a uniform grid, with order+1 points on an edge...
std::string enum_to_string(const T e)
Order _order
The polynomial order which the quadrature rule is capable of integrating exactly. ...
Definition: quadrature.h:365
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
void tensor_product_quad(const QBase &q1D)
Constructs a 2D rule from the tensor product of q1D with itself.
Definition: quadrature.C:176