libMesh
quadrature_simpson_3D.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_3D(const ElemType, unsigned int)
28 {
29 #if LIBMESH_DIM == 3
30 
31  //-----------------------------------------------------------------------
32  // 3D quadrature rules
33  switch (_type)
34  {
35  //---------------------------------------------
36  // Hex quadrature rules
37  case HEX8:
38  case HEX20:
39  case HEX27:
40  {
41  // We compute the 3D quadrature rule as a tensor
42  // product of the 1D quadrature rule.
43  QSimpson q1D(1);
44  q1D.init(EDGE2);
45 
46  tensor_product_hex( q1D );
47 
48  return;
49  }
50 
51 
52 
53  //---------------------------------------------
54  // Tetrahedral quadrature rules
55  case TET4:
56  case TET10:
57  {
58  // This rule is created by combining 8 subtets
59  // which use the trapezoidal rule. The weights
60  // may seem a bit odd, but they are correct,
61  // and should add up to 1/6, the volume of the
62  // reference tet. The points of this rule are
63  // at the nodal points of the TET10, allowing
64  // you to generate diagonal element stiffness
65  // matrices when using quadratic elements.
66  // It should be able to integrate something
67  // better than linears, but I'm not sure how
68  // high.
69 
70  _points.resize(10);
71  _weights.resize(10);
72 
73  _points[0](0) = 0.; _points[5](0) = .5;
74  _points[0](1) = 0.; _points[5](1) = .5;
75  _points[0](2) = 0.; _points[5](2) = 0.;
76 
77  _points[1](0) = 1.; _points[6](0) = 0.;
78  _points[1](1) = 0.; _points[6](1) = .5;
79  _points[1](2) = 0.; _points[6](2) = 0.;
80 
81  _points[2](0) = 0.; _points[7](0) = 0.;
82  _points[2](1) = 1.; _points[7](1) = 0.;
83  _points[2](2) = 0.; _points[7](2) = .5;
84 
85  _points[3](0) = 0.; _points[8](0) = .5;
86  _points[3](1) = 0.; _points[8](1) = 0.;
87  _points[3](2) = 1.; _points[8](2) = .5;
88 
89  _points[4](0) = .5; _points[9](0) = 0.;
90  _points[4](1) = 0.; _points[9](1) = .5;
91  _points[4](2) = 0.; _points[9](2) = .5;
92 
93 
94  _weights[0] = Real(1)/192;
95  _weights[1] = _weights[0];
96  _weights[2] = _weights[0];
97  _weights[3] = _weights[0];
98 
99  _weights[4] = Real(14)/576;
100  _weights[5] = _weights[4];
101  _weights[6] = _weights[4];
102  _weights[7] = _weights[4];
103  _weights[8] = _weights[4];
104  _weights[9] = _weights[4];
105 
106  return;
107  }
108 
109 
110 
111  //---------------------------------------------
112  // Prism quadrature rules
113  case PRISM6:
114  case PRISM15:
115  case PRISM18:
116  {
117  // We compute the 3D quadrature rule as a tensor
118  // product of the 1D quadrature rule and a 2D
119  // triangle quadrature rule
120 
121  QSimpson q1D(1);
122  QSimpson q2D(2);
123 
124  // Initialize
125  q1D.init(EDGE2);
126  q2D.init(TRI3);
127 
128  tensor_product_prism(q1D, q2D);
129 
130  return;
131  }
132 
133 
134  //---------------------------------------------
135  // Unsupported type
136  default:
137  libmesh_error_msg("ERROR: Unsupported type: " << Utility::enum_to_string(_type));
138  }
139 #endif
140 }
141 
142 } // namespace libMesh
libMesh::HEX20
Definition: enum_elem_type.h:48
libMesh::PRISM6
Definition: enum_elem_type.h:50
libMesh::QSimpson
This class implements Simpson quadrature.
Definition: quadrature_simpson.h:38
libMesh::QBase::tensor_product_hex
void tensor_product_hex(const QBase &q1D)
Computes the tensor product quadrature rule [q1D x q1D x q1D] from the 1D rule q1D.
Definition: quadrature.C:198
libMesh::HEX8
Definition: enum_elem_type.h:47
libMesh
The libMesh namespace provides an interface to certain functionality in the library.
Definition: factoryfunction.C:55
libMesh::TET10
Definition: enum_elem_type.h:46
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::TET4
Definition: enum_elem_type.h:45
libMesh::PRISM15
Definition: enum_elem_type.h:51
libMesh::HEX27
Definition: enum_elem_type.h:49
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::tensor_product_prism
void tensor_product_prism(const QBase &q1D, const QBase &q2D)
Computes the tensor product of a 1D quadrature rule and a 2D quadrature rule.
Definition: quadrature.C:225
libMesh::QBase::_weights
std::vector< Real > _weights
The quadrature weights.
Definition: quadrature.h:369
libMesh::Real
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Definition: libmesh_common.h:121
libMesh::PRISM18
Definition: enum_elem_type.h:52
libMesh::QBase::_points
std::vector< Point > _points
The locations of the quadrature points in reference element space.
Definition: quadrature.h:363
libMesh::QSimpson::init_3D
virtual void init_3D(const ElemType, unsigned int) override
Initializes the 3D quadrature rule by filling the points and weights vectors with the appropriate val...
Definition: quadrature_simpson_3D.C:27
libMesh::EDGE2
Definition: enum_elem_type.h:35
libMesh::ElemType
ElemType
Defines an enum for geometric element types.
Definition: enum_elem_type.h:33