libMesh
quadrature_grid_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_grid.h"
22 #include "libmesh/enum_to_string.h"
23 
24 namespace libMesh
25 {
26 
27 
28 void QGrid::init_3D(const ElemType, unsigned int)
29 {
30 #if LIBMESH_DIM == 3
31 
32  switch (_type)
33  {
34  //---------------------------------------------
35  // Hex quadrature rules
36  case HEX8:
37  case HEX20:
38  case HEX27:
39  {
40  // We compute the 3D quadrature rule as a tensor
41  // product of the 1D quadrature rule.
42  QGrid q1D(1,_order);
43  q1D.init(EDGE2);
44 
45  tensor_product_hex( q1D );
46 
47  return;
48  }
49 
50 
51 
52  //---------------------------------------------
53  // Tetrahedral quadrature rules
54  case TET4:
55  case TET10:
56  {
57  const unsigned int np = (_order+1)*(_order+2)*(_order+3)/6;
58  // Master tet has 1x1 triangle base, height 1, so volume = 1/6
59  const Real weight = Real(1)/Real(6)/np;
60  const Real dx = Real(1)/(_order+1);
61  _points.resize(np);
62  _weights.resize(np);
63 
64  unsigned int pt = 0;
65  for (int i = 0; i != _order + 1; ++i)
66  {
67  for (int j = 0; j != _order + 1 - i; ++j)
68  {
69  for (int k = 0; k != _order + 1 - i - j; ++k)
70  {
71  _points[pt](0) = (i+0.5)*dx;
72  _points[pt](1) = (j+0.5)*dx;
73  _points[pt](2) = (k+0.5)*dx;
74  _weights[pt] = weight;
75  pt++;
76  }
77  }
78  }
79  return;
80  }
81 
82 
83  // Prism quadrature rules
84  case PRISM6:
85  case PRISM15:
86  case PRISM18:
87  {
88  // We compute the 3D quadrature rule as a tensor
89  // product of the 1D quadrature rule and a 2D
90  // triangle quadrature rule
91 
92  QGrid q1D(1,_order);
93  QGrid q2D(2,_order);
94 
95  // Initialize
96  q1D.init(EDGE2);
97  q2D.init(TRI3);
98 
99  tensor_product_prism(q1D, q2D);
100 
101  return;
102  }
103 
104 
105 
106  //---------------------------------------------
107  // Pyramid
108  case PYRAMID5:
109  case PYRAMID13:
110  case PYRAMID14:
111  {
112  const unsigned int np = (_order+1)*(_order+2)*(_order+3)/6;
113  _points.resize(np);
114  _weights.resize(np);
115  // Master pyramid has 2x2 base, height 1, so volume = 4/3
116  const Real weight = Real(4)/Real(3)/np;
117  const Real dx = Real(2)/(_order+1);
118  const Real dz = Real(1)/(_order+1);
119 
120  unsigned int pt = 0;
121  for (int k = 0; k != _order + 1; ++k)
122  {
123  for (int i = 0; i != _order + 1 - k; ++i)
124  {
125  for (int j = 0; j != _order + 1 - k; ++j)
126  {
127  _points[pt](0) = (i+0.5)*dx-1.0 +
128  (k+0.5)*dz;
129  _points[pt](1) = (j+0.5)*dx-1.0 +
130  (k+0.5)*dz;
131  _points[pt](2) = (k+0.5)*dz;
132  _weights[pt] = weight;
133  pt++;
134  }
135  }
136  }
137  return;
138  }
139 
140 
141 
142  //---------------------------------------------
143  // Unsupported type
144  default:
145  libmesh_error_msg("ERROR: Unsupported type: " << Utility::enum_to_string(_type));
146  }
147 #endif
148 }
149 
150 } // namespace libMesh
libMesh::HEX20
Definition: enum_elem_type.h:48
libMesh::PRISM6
Definition: enum_elem_type.h:50
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::QBase::_order
Order _order
The polynomial order which the quadrature rule is capable of integrating exactly.
Definition: quadrature.h:345
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::QGrid::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_grid_3D.C:28
libMesh::Utility::enum_to_string
std::string enum_to_string(const T e)
libMesh::QGrid
This class creates quadrature points on a uniform grid, with order+1 points on an edge.
Definition: quadrature_grid.h:47
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::PYRAMID5
Definition: enum_elem_type.h:53
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::MeshTools::weight
dof_id_type weight(const MeshBase &mesh, const processor_id_type pid)
Definition: mesh_tools.C:236
libMesh::QBase::_points
std::vector< Point > _points
The locations of the quadrature points in reference element space.
Definition: quadrature.h:363
libMesh::PYRAMID13
Definition: enum_elem_type.h:54
libMesh::PYRAMID14
Definition: enum_elem_type.h:55
libMesh::EDGE2
Definition: enum_elem_type.h:35
libMesh::ElemType
ElemType
Defines an enum for geometric element types.
Definition: enum_elem_type.h:33