libMesh
quadrature_nodal_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_nodal.h"
22 #include "libmesh/quadrature_trap.h"
23 #include "libmesh/quadrature_simpson.h"
24 #include "libmesh/enum_to_string.h"
25 
26 namespace libMesh
27 {
28 
29 void QNodal::init_2D(const ElemType, unsigned int)
30 {
31 #if LIBMESH_DIM > 1
32 
33  switch (_type)
34  {
35 
36  case QUAD4:
37  case QUADSHELL4:
38  case TRI3:
39  case TRISHELL3:
40  {
41  QTrap rule(/*dim=*/2, /*ignored*/_order);
42  rule.init(_type, /*ignored*/_p_level);
43  _points.swap (rule.get_points());
44  _weights.swap(rule.get_weights());
45  return;
46  }
47 
48  case QUAD8:
49  case QUADSHELL8:
50  {
51  // A rule with 8 points which is exact for linears, and
52  // naturally produces a lumped approximation to the mass
53  // matrix. The quadrature points are numbered the same way as
54  // the reference element nodes.
55  _points =
56  {
57  Point(-1,-1), Point(+1,-1), Point(+1,+1), Point(-1,+1),
58  Point(0.,-1), Point(+1,0.), Point(0.,+1), Point(-1,0.)
59  };
60 
61  // The weights for the Quad8 nodal quadrature rule are
62  // obtained from the following specific steps. Other
63  // "serendipity" type rules are obtained similarly.
64  //
65  // 1.) Due to the symmetry of the bi-unit square domain, we
66  // first note that there are only two "classes" of node in the
67  // Quad8: vertices (with associated weight wv) and edges (with
68  // associated weight we).
69  //
70  // 2.) In order for such a nodal quadrature rule to be exact
71  // for constants, the weights must sum to the area of the
72  // reference element, and therefore we must have:
73  // 4*wv + 4*we = 4 --> wv + we = 1
74  //
75  // 3.) Due to symmetry (once again), such a rule is then
76  // automatically exact for the linear polynomials "x" and "y",
77  // regardless of the values of wv and we.
78  //
79  // 4.) We therefore still have two unknowns and one equation.
80  // Attempting to additionally make the nodal quadrature rule
81  // exact for the quadratic polynomials "x^2" and "y^2" leads
82  // to a rule with negative weights, namely:
83  // wv = -1/3
84  // we = 4/3
85  // Note: these are the same values one obtains by integrating
86  // the corresponding Quad8 Lagrange basis functions over the
87  // reference element.
88  //
89  // Since the weights appear on the diagonal of the nodal
90  // quadrature rule's approximation to the mass matrix, rules
91  // with negative weights yield an indefinite mass matrix,
92  // i.e. one with both positive and negative eigenvalues. Rules
93  // with negative weights can also produce a negative integral
94  // approximation to a strictly positive integrand, which may
95  // be unacceptable in some situations.
96  //
97  // 5.) Requiring all positive weights therefore restricts the
98  // nodal quadrature rule to only be exact for linears. But
99  // there is still one free parameter remaining, and thus we
100  // need some other criterion in order to complete the
101  // description of the rule.
102  //
103  // Here, we have decided to choose the quadrature weights in
104  // such a way that the resulting nodal quadrature mass matrix
105  // approximation is "proportional" to the true mass matrix's
106  // diagonal entries for the reference element. We therefore
107  // pose the following constrained optimization problem:
108  //
109  // { min_{wv, we} |diag(M) - C*diag(W)|^2
110  // (O) {
111  // { subject to wv + we = 1
112  //
113  // where:
114  // * M is the true mass matrix
115  // * W is the nodal quadrature approximation to the mass
116  // matrix. In this particular case:
117  // diag(W) = [wv,wv,wv,wv,we,we,we,we]
118  // * C = tr(M) / vol(E) is the ratio between the trace of the
119  // true mass matrix and the volume of the reference
120  // element. For all Lagrange finite elements, we have C<1.
121  //
122  // 6.) The optimization problem (O) is solved directly by
123  // substituting the algebraic constraint into the functional
124  // which is to be minimized, then setting the derivative with
125  // respect to the remaining parameter equal to zero and
126  // solving. In the Quad8 and Hex20 cases, there is only one
127  // free parameter, while in the Prism15 case there are two
128  // free parameters, so a 2x2 system of linear equations must
129  // be solved.
130  Real wv = Real(12) / 79;
131  Real we = Real(67) / 79;
132 
133  _weights = {wv, wv, wv, wv, we, we, we, we};
134 
135  return;
136  }
137 
138  case QUAD9:
139  case TRI6:
140  {
141  QSimpson rule(/*dim=*/2, /*ignored*/_order);
142  rule.init(_type, /*ignored*/_p_level);
143  _points.swap (rule.get_points());
144  _weights.swap(rule.get_weights());
145  return;
146  }
147 
148  default:
149  libmesh_error_msg("Element type not supported!:" << Utility::enum_to_string(_type));
150  }
151 #endif
152 }
153 
154 } // namespace libMesh
libMesh::QSimpson
This class implements Simpson quadrature.
Definition: quadrature_simpson.h:38
libMesh::QBase::_p_level
unsigned int _p_level
The p-level of the element for which the current values have been computed.
Definition: quadrature.h:357
libMesh
The libMesh namespace provides an interface to certain functionality in the library.
Definition: factoryfunction.C:55
libMesh::QNodal::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_nodal_2D.C:29
libMesh::QTrap
This class implements trapezoidal quadrature.
Definition: quadrature_trap.h:38
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::QBase::_order
Order _order
The polynomial order which the quadrature rule is capable of integrating exactly.
Definition: quadrature.h:345
libMesh::QBase::get_points
const std::vector< Point > & get_points() const
Definition: quadrature.h:141
libMesh::QUAD4
Definition: enum_elem_type.h:41
libMesh::Point
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
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::get_weights
const std::vector< Real > & get_weights() const
Definition: quadrature.h:153
libMesh::QBase::_weights
std::vector< Real > _weights
The quadrature weights.
Definition: quadrature.h:369
libMesh::TRI6
Definition: enum_elem_type.h:40
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::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::QUAD8
Definition: enum_elem_type.h:42
libMesh::ElemType
ElemType
Defines an enum for geometric element types.
Definition: enum_elem_type.h:33