quadrature_gm_3D.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 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_gm.h"
22 
23 namespace libMesh
24 {
25 
26 
27 
29  unsigned int p)
30 {
31  // Nearly all GM rules contain negative weights, so if you are not
32  // allowing rules with negative weights, we cannot continue!
34  libmesh_error_msg("You requested a Grundmann-Moller rule but\n" \
35  << "are not allowing rules with negative weights!\n" \
36  << "Either select a different quadrature class or\n" \
37  << "set allow_rules_with_negative_weights==true.");
38 
39  switch (type_in)
40  {
41  case TET4:
42  case TET10:
43  {
44  switch(_order + 2*p)
45  {
46  // We hard-code the first few orders based on output from
47  // the mp-quadrature library:
48  //
49  // https://code.google.com/p/mp-quadrature
50  //
51  // The points are ordered in such a way that the amount of
52  // round-off error in the quadrature calculations is
53  // (hopefully) minimized. These orderings were obtained
54  // via a simple permutation optimization strategy designed
55  // to produce the smallest overall average error while
56  // integrating all polynomials of degree <= d.
57  case CONSTANT:
58  case FIRST:
59  {
60  _points.resize(1);
61  _weights.resize(1);
62 
63  _points[0](0) = Real(1)/4;
64  _points[0](1) = Real(1)/4;
65  _points[0](2) = Real(1)/4;
66 
67  _weights[0] = Real(1)/6;
68  return;
69  }
70 
71  case SECOND:
72  case THIRD:
73  {
74  _points.resize(5);
75  _weights.resize(5);
76 
77  _points[0](0) = Real(1)/6; _points[0](1) = Real(1)/6; _points[0](2) = Real(1)/2; _weights[0] = Real(3)/40;
78  _points[1](0) = Real(1)/6; _points[1](1) = Real(1)/6; _points[1](2) = Real(1)/6; _weights[1] = Real(3)/40;
79  _points[2](0) = Real(1)/4; _points[2](1) = Real(1)/4; _points[2](2) = Real(1)/4; _weights[2] = -Real(2)/15;
80  _points[3](0) = Real(1)/2; _points[3](1) = Real(1)/6; _points[3](2) = Real(1)/6; _weights[3] = Real(3)/40;
81  _points[4](0) = Real(1)/6; _points[4](1) = Real(1)/2; _points[4](2) = Real(1)/6; _weights[4] = Real(3)/40;
82  return;
83  }
84 
85  case FOURTH:
86  case FIFTH:
87  {
88  _points.resize(15);
89  _weights.resize(15);
90 
91  _points[ 0](0) = Real(1)/8; _points[ 0](1) = Real(3)/8; _points[ 0](2) = Real(1)/8; _weights[ 0] = Real(16)/315;
92  _points[ 1](0) = Real(1)/8; _points[ 1](1) = Real(1)/8; _points[ 1](2) = Real(5)/8; _weights[ 1] = Real(16)/315;
93  _points[ 2](0) = Real(3)/8; _points[ 2](1) = Real(1)/8; _points[ 2](2) = Real(1)/8; _weights[ 2] = Real(16)/315;
94  _points[ 3](0) = Real(1)/6; _points[ 3](1) = Real(1)/2; _points[ 3](2) = Real(1)/6; _weights[ 3] = -Real(27)/280;
95  _points[ 4](0) = Real(3)/8; _points[ 4](1) = Real(1)/8; _points[ 4](2) = Real(3)/8; _weights[ 4] = Real(16)/315;
96  _points[ 5](0) = Real(1)/8; _points[ 5](1) = Real(3)/8; _points[ 5](2) = Real(3)/8; _weights[ 5] = Real(16)/315;
97  _points[ 6](0) = Real(1)/6; _points[ 6](1) = Real(1)/6; _points[ 6](2) = Real(1)/6; _weights[ 6] = -Real(27)/280;
98  _points[ 7](0) = Real(1)/6; _points[ 7](1) = Real(1)/6; _points[ 7](2) = Real(1)/2; _weights[ 7] = -Real(27)/280;
99  _points[ 8](0) = Real(1)/8; _points[ 8](1) = Real(1)/8; _points[ 8](2) = Real(1)/8; _weights[ 8] = Real(16)/315;
100  _points[ 9](0) = Real(1)/4; _points[ 9](1) = Real(1)/4; _points[ 9](2) = Real(1)/4; _weights[ 9] = Real(2)/45;
101  _points[10](0) = Real(1)/8; _points[10](1) = Real(5)/8; _points[10](2) = Real(1)/8; _weights[10] = Real(16)/315;
102  _points[11](0) = Real(1)/2; _points[11](1) = Real(1)/6; _points[11](2) = Real(1)/6; _weights[11] = -Real(27)/280;
103  _points[12](0) = Real(1)/8; _points[12](1) = Real(1)/8; _points[12](2) = Real(3)/8; _weights[12] = Real(16)/315;
104  _points[13](0) = Real(5)/8; _points[13](1) = Real(1)/8; _points[13](2) = Real(1)/8; _weights[13] = Real(16)/315;
105  _points[14](0) = Real(3)/8; _points[14](1) = Real(3)/8; _points[14](2) = Real(1)/8; _weights[14] = Real(16)/315;
106  return;
107  }
108 
109  case SIXTH:
110  case SEVENTH:
111  {
112  _points.resize(35);
113  _weights.resize(35);
114 
115  _points[ 0](0) = Real(3)/10; _points[ 0](1) = Real(1)/10; _points[ 0](2) = Real(3)/10; _weights[ 0] = Real(3125)/72576;
116  _points[ 1](0) = Real(1)/6; _points[ 1](1) = Real(1)/2; _points[ 1](2) = Real(1)/6; _weights[ 1] = Real(243)/4480;
117  _points[ 2](0) = Real(1)/6; _points[ 2](1) = Real(1)/6; _points[ 2](2) = Real(1)/2; _weights[ 2] = Real(243)/4480;
118  _points[ 3](0) = Real(1)/2; _points[ 3](1) = Real(1)/10; _points[ 3](2) = Real(1)/10; _weights[ 3] = Real(3125)/72576;
119  _points[ 4](0) = Real(3)/10; _points[ 4](1) = Real(1)/10; _points[ 4](2) = Real(1)/10; _weights[ 4] = Real(3125)/72576;
120  _points[ 5](0) = Real(3)/10; _points[ 5](1) = Real(3)/10; _points[ 5](2) = Real(1)/10; _weights[ 5] = Real(3125)/72576;
121  _points[ 6](0) = Real(1)/2; _points[ 6](1) = Real(1)/6; _points[ 6](2) = Real(1)/6; _weights[ 6] = Real(243)/4480;
122  _points[ 7](0) = Real(3)/10; _points[ 7](1) = Real(1)/10; _points[ 7](2) = Real(1)/2; _weights[ 7] = Real(3125)/72576;
123  _points[ 8](0) = Real(7)/10; _points[ 8](1) = Real(1)/10; _points[ 8](2) = Real(1)/10; _weights[ 8] = Real(3125)/72576;
124  _points[ 9](0) = Real(3)/8; _points[ 9](1) = Real(1)/8; _points[ 9](2) = Real(1)/8; _weights[ 9] = -Real(256)/2835;
125  _points[10](0) = Real(3)/10; _points[10](1) = Real(3)/10; _points[10](2) = Real(3)/10; _weights[10] = Real(3125)/72576;
126  _points[11](0) = Real(1)/10; _points[11](1) = Real(1)/2; _points[11](2) = Real(3)/10; _weights[11] = Real(3125)/72576;
127  _points[12](0) = Real(1)/10; _points[12](1) = Real(1)/10; _points[12](2) = Real(7)/10; _weights[12] = Real(3125)/72576;
128  _points[13](0) = Real(1)/2; _points[13](1) = Real(1)/10; _points[13](2) = Real(3)/10; _weights[13] = Real(3125)/72576;
129  _points[14](0) = Real(1)/10; _points[14](1) = Real(7)/10; _points[14](2) = Real(1)/10; _weights[14] = Real(3125)/72576;
130  _points[15](0) = Real(1)/10; _points[15](1) = Real(1)/2; _points[15](2) = Real(1)/10; _weights[15] = Real(3125)/72576;
131  _points[16](0) = Real(1)/6; _points[16](1) = Real(1)/6; _points[16](2) = Real(1)/6; _weights[16] = Real(243)/4480;
132  _points[17](0) = Real(3)/8; _points[17](1) = Real(1)/8; _points[17](2) = Real(3)/8; _weights[17] = -Real(256)/2835;
133  _points[18](0) = Real(1)/8; _points[18](1) = Real(1)/8; _points[18](2) = Real(5)/8; _weights[18] = -Real(256)/2835;
134  _points[19](0) = Real(1)/10; _points[19](1) = Real(1)/10; _points[19](2) = Real(3)/10; _weights[19] = Real(3125)/72576;
135  _points[20](0) = Real(1)/8; _points[20](1) = Real(3)/8; _points[20](2) = Real(3)/8; _weights[20] = -Real(256)/2835;
136  _points[21](0) = Real(5)/8; _points[21](1) = Real(1)/8; _points[21](2) = Real(1)/8; _weights[21] = -Real(256)/2835;
137  _points[22](0) = Real(1)/8; _points[22](1) = Real(5)/8; _points[22](2) = Real(1)/8; _weights[22] = -Real(256)/2835;
138  _points[23](0) = Real(1)/10; _points[23](1) = Real(3)/10; _points[23](2) = Real(1)/10; _weights[23] = Real(3125)/72576;
139  _points[24](0) = Real(1)/4; _points[24](1) = Real(1)/4; _points[24](2) = Real(1)/4; _weights[24] = -Real(8)/945;
140  _points[25](0) = Real(1)/8; _points[25](1) = Real(1)/8; _points[25](2) = Real(3)/8; _weights[25] = -Real(256)/2835;
141  _points[26](0) = Real(3)/8; _points[26](1) = Real(3)/8; _points[26](2) = Real(1)/8; _weights[26] = -Real(256)/2835;
142  _points[27](0) = Real(1)/8; _points[27](1) = Real(3)/8; _points[27](2) = Real(1)/8; _weights[27] = -Real(256)/2835;
143  _points[28](0) = Real(1)/10; _points[28](1) = Real(3)/10; _points[28](2) = Real(1)/2; _weights[28] = Real(3125)/72576;
144  _points[29](0) = Real(3)/10; _points[29](1) = Real(1)/2; _points[29](2) = Real(1)/10; _weights[29] = Real(3125)/72576;
145  _points[30](0) = Real(1)/10; _points[30](1) = Real(1)/10; _points[30](2) = Real(1)/2; _weights[30] = Real(3125)/72576;
146  _points[31](0) = Real(1)/2; _points[31](1) = Real(3)/10; _points[31](2) = Real(1)/10; _weights[31] = Real(3125)/72576;
147  _points[32](0) = Real(1)/8; _points[32](1) = Real(1)/8; _points[32](2) = Real(1)/8; _weights[32] = -Real(256)/2835;
148  _points[33](0) = Real(1)/10; _points[33](1) = Real(3)/10; _points[33](2) = Real(3)/10; _weights[33] = Real(3125)/72576;
149  _points[34](0) = Real(1)/10; _points[34](1) = Real(1)/10; _points[34](2) = Real(1)/10; _weights[34] = Real(3125)/72576;
150  return;
151  }
152 
153  default:
154  {
155  // Untested above _order=23 but should work...
156  gm_rule((_order + 2*p)/2, /*dim=*/3);
157  return;
158  }
159  } // end switch (order)
160  } // end case TET4, TET10
161 
162  default:
163  libmesh_error_msg("ERROR: Unsupported element type: " << type_in);
164  } // end switch (type_in)
165 }
166 
167 } // namespace libMesh
bool allow_rules_with_negative_weights
Definition: quadrature.h:246
virtual void init_3D(const ElemType _type=INVALID_ELEM, unsigned int p_level=0) override
std::vector< Point > _points
Definition: quadrature.h:349
std::vector< Real > _weights
Definition: quadrature.h:355
void gm_rule(unsigned int s, unsigned int dim)
Definition: quadrature_gm.C:52
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real