libMesh
quadrature_simpson_2D.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2019 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 void QSimpson::init_2D(const ElemType, unsigned int)
28 {
29 #if LIBMESH_DIM > 1
30 
31  //-----------------------------------------------------------------------
32  // 2D quadrature rules
33  switch (_type)
34  {
35 
36 
37  //---------------------------------------------
38  // Quadrilateral quadrature rules
39  case QUAD4:
40  case QUADSHELL4:
41  case QUAD8:
42  case QUADSHELL8:
43  case QUAD9:
44  {
45  // We compute the 2D quadrature rule as a tensor
46  // product of the 1D quadrature rule.
47  QSimpson q1D(1);
48  q1D.init(EDGE2);
49  tensor_product_quad( q1D );
50  return;
51  }
52 
53 
54  //---------------------------------------------
55  // Triangle quadrature rules
56  case TRI3:
57  case TRISHELL3:
58  case TRI3SUBDIVISION:
59  case TRI6:
60  {
61  // I'm not sure if you would call this Simpson's
62  // rule for triangles. What it *Really* is is
63  // four trapezoidal rules combined to give a six
64  // point rule. The points lie at the nodal locations
65  // of the TRI6, so you can get diagonal element
66  // stiffness matrix entries for quadratic elements.
67  // This rule should be able to integrate a little
68  // better than linears exactly.
69 
70  _points.resize(6);
71  _weights.resize(6);
72 
73  _points[0](0) = 0.;
74  _points[0](1) = 0.;
75 
76  _points[1](0) = 1.;
77  _points[1](1) = 0.;
78 
79  _points[2](0) = 0.;
80  _points[2](1) = 1.;
81 
82  _points[3](0) = 0.5;
83  _points[3](1) = 0.;
84 
85  _points[4](0) = 0.;
86  _points[4](1) = 0.5;
87 
88  _points[5](0) = 0.5;
89  _points[5](1) = 0.5;
90 
91  _weights[0] = Real(1)/24;
92  _weights[1] = Real(1)/24;
93  _weights[2] = Real(1)/24;
94  _weights[3] = 0.125; // 1./8.
95  _weights[4] = 0.125; // 1./8.
96  _weights[5] = 0.125; // 1./8.
97 
98  return;
99  }
100 
101 
102  //---------------------------------------------
103  // Unsupported type
104  default:
105  libmesh_error_msg("Element type not supported!:" << Utility::enum_to_string(_type));
106  }
107 #endif
108 }
109 
110 } // namespace libMesh
libMesh::QSimpson
This class implements Simpson quadrature.
Definition: quadrature_simpson.h:38
libMesh::QSimpson::init_2D
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...
Definition: quadrature_simpson_2D.C:27
libMesh
The libMesh namespace provides an interface to certain functionality in the library.
Definition: factoryfunction.C:55
libMesh::QBase::init
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:59
libMesh::QUAD4
Definition: enum_elem_type.h:41
libMesh::QBase::_type
ElemType _type
The type of element for which the current values have been computed.
Definition: quadrature.h:351
libMesh::TRI3
Definition: enum_elem_type.h:39
libMesh::Utility::enum_to_string
std::string enum_to_string(const T e)
libMesh::QBase::_weights
std::vector< Real > _weights
The quadrature weights.
Definition: quadrature.h:369
libMesh::TRI6
Definition: enum_elem_type.h:40
libMesh::QBase::tensor_product_quad
void tensor_product_quad(const QBase &q1D)
Constructs a 2D rule from the tensor product of q1D with itself.
Definition: quadrature.C:171
libMesh::QUADSHELL8
Definition: enum_elem_type.h:73
libMesh::QUADSHELL4
Definition: enum_elem_type.h:72
libMesh::QUAD9
Definition: enum_elem_type.h:43
libMesh::TRI3SUBDIVISION
Definition: enum_elem_type.h:69
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: libmesh_common.h:121
libMesh::TRISHELL3
Definition: enum_elem_type.h:71
libMesh::QBase::_points
std::vector< Point > _points
The locations of the quadrature points in reference element space.
Definition: quadrature.h:363
libMesh::EDGE2
Definition: enum_elem_type.h:35
libMesh::QUAD8
Definition: enum_elem_type.h:42
libMesh::ElemType
ElemType
Defines an enum for geometric element types.
Definition: enum_elem_type.h:33