libMesh
Loading...
Searching...
No Matches
fe_type.C
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 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// Local includes
19#include "libmesh/fe_type.h"
20#include "libmesh/quadrature_clough.h"
21#include "libmesh/quadrature_gauss.h"
22#include "libmesh/quadrature_gauss_lobatto.h"
23
24// C++ Includes
25#include <memory>
26
27
28namespace libMesh
29{
30
31// ---------------------------------------
32// FEType class members
33
34std::unique_ptr<QBase>
36 const int extraorder) const
37{
38 // Clough elements have at least piecewise cubic functions
39 if (family == CLOUGH)
40 {
41 Order o = static_cast<Order>(std::max(static_cast<unsigned int>(this->default_quadrature_order()),
42 static_cast<unsigned int>(7 + extraorder)));
43 return std::make_unique<QClough>(dim, o);
44 }
45
46 if (family == SUBDIVISION)
47 return std::make_unique<QGauss>(dim, static_cast<Order>(1 + extraorder));
48
49 // The default rule for the Gauss-Lobatto nodal bases is the Gauss-Lobatto rule on the
50 // basis's own interpolation points. That collocation makes the mass matrix diagonal, and
51 // the shape function values at the quadrature points form the identity matrix. A basis of
52 // degree p has p+1 points, and a Gauss-Lobatto rule of n points is exact through degree
53 // 2n-3, so the matching order is 2p-1. A positive extraorder selects a rule with more
54 // points, which integrates more accurately but gives up collocation.
55 //
56 // p refinement preserves the pairing. QBase raises the order of a rule by twice the
57 // element's p_level, and 2p-1 also rises by two per degree, so on an element of p level l
58 // the rule has the p+l+1 points of the degree p+l basis.
60 {
61 const int p = static_cast<int>(order.get_order());
62 return std::make_unique<QGaussLobatto>(dim, static_cast<Order>(2*p - 1 + extraorder));
63 }
64
65 return std::make_unique<QGauss>(dim, static_cast<Order>(this->default_quadrature_order() + extraorder));
66}
67
68
69std::unique_ptr<QBase>
71 const int extraorder) const
72{
73 // Clough elements have at least piecewise cubic functions
74 if (family == CLOUGH)
75 {
76 Order o = static_cast<Order>(std::max(static_cast<unsigned int>(this->unweighted_quadrature_order()),
77 static_cast<unsigned int>(3 + extraorder)));
78 return std::make_unique<QClough>(dim, o);
79 }
80
81 if (family == SUBDIVISION)
82 return std::make_unique<QGauss>(dim, static_cast<Order>(1 + extraorder));
83
84 return std::make_unique<QGauss>(dim, static_cast<Order>(this->unweighted_quadrature_order() + extraorder));
85}
86
87} // namespace libMesh
unsigned int dim
std::unique_ptr< QBase > default_quadrature_rule(const unsigned int dim, const int extraorder=0) const
Definition fe_type.C:35
std::unique_ptr< QBase > unweighted_quadrature_rule(const unsigned int dim, const int extraorder=0) const
Definition fe_type.C:70
Order default_quadrature_order() const
Definition fe_type.h:415
OrderWrapper order
The approximation order of the element (at 0 p-refinement level).
Definition fe_type.h:203
FEFamily family
The type of finite element.
Definition fe_type.h:228
Order unweighted_quadrature_order() const
Definition fe_type.h:421
int get_order() const
Explicitly request the order as an int.
Definition fe_type.h:80
The libMesh namespace provides an interface to certain functionality in the library.