libMesh
fe_type.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 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 #ifndef LIBMESH_FE_TYPE_H
21 #define LIBMESH_FE_TYPE_H
22 
23 // Local includes
24 #include "libmesh/auto_ptr.h"
25 #include "libmesh/compare_types.h"
26 #include "libmesh/libmesh_config.h"
27 #include "libmesh/enum_order.h"
28 #include "libmesh/enum_fe_family.h"
29 #include "libmesh/enum_inf_map_type.h"
30 
31 // C++ includes
32 
33 namespace libMesh
34 {
35 
36 // Forward declarations
37 class QBase;
38 
46 {
47 public:
48 
54  _order(static_cast<int>(order))
55  {}
56 
61  OrderWrapper(int order) :
62  _order(order)
63  {}
64 
69  operator Order() const
70  {
71  return static_cast<Order>(_order);
72  }
73 
77  int get_order() const
78  {
79  return _order;
80  }
81 
82 private:
83 
87  int _order;
88 
89 };
90 
94 inline bool operator==(const OrderWrapper & lhs, const OrderWrapper & rhs){ return lhs.get_order() == rhs.get_order(); }
95 inline bool operator!=(const OrderWrapper & lhs, const OrderWrapper & rhs){ return !(lhs == rhs); }
96 inline bool operator< (const OrderWrapper & lhs, const OrderWrapper & rhs){ return lhs.get_order() < rhs.get_order(); }
97 inline bool operator> (const OrderWrapper & lhs, const OrderWrapper & rhs){ return rhs < lhs; }
98 inline bool operator<=(const OrderWrapper & lhs, const OrderWrapper & rhs){ return !(lhs > rhs); }
99 inline bool operator>=(const OrderWrapper & lhs, const OrderWrapper & rhs){ return !(lhs < rhs); }
100 
101 // First disambiguate everything that would be ambiguated by the
102 // subsequent disambiguations
103 #define OrderWrapperOperators(comparisontype) \
104  inline bool operator==(comparisontype lhs, Order rhs) \
105  { return lhs == static_cast<comparisontype>(rhs); } \
106  inline bool operator==(Order lhs, comparisontype rhs) \
107  { return static_cast<comparisontype>(lhs) == rhs; } \
108  inline bool operator!=(comparisontype lhs, Order rhs) \
109  { return !(lhs == rhs); } \
110  inline bool operator!=(Order lhs, comparisontype rhs) \
111  { return !(lhs == rhs); } \
112  inline bool operator< (comparisontype lhs, Order rhs) \
113  { return lhs < static_cast<comparisontype>(rhs); } \
114  inline bool operator< (Order lhs, comparisontype rhs) \
115  { return static_cast<comparisontype>(lhs) < rhs; } \
116  inline bool operator> (comparisontype lhs, Order rhs) \
117  { return rhs < lhs; } \
118  inline bool operator> (Order lhs, comparisontype rhs) \
119  { return rhs < lhs; } \
120  inline bool operator<=(comparisontype lhs, Order rhs) \
121  { return !(lhs > rhs); } \
122  inline bool operator<=(Order lhs, comparisontype rhs) \
123  { return !(lhs > rhs); } \
124  inline bool operator>=(comparisontype lhs, Order rhs) \
125  { return !(lhs < rhs); } \
126  inline bool operator>=(Order lhs, comparisontype rhs) \
127  { return !(lhs < rhs); }
128 
130 OrderWrapperOperators(unsigned int)
131 #if LIBMESH_SIZEOF_SIZE_T != LIBMESH_SIZEOF_UNSIGNED_INT
132 OrderWrapperOperators(std::size_t)
133 #endif
134 
135 // Now disambiguate all the things
136 inline bool operator==(int lhs, const OrderWrapper & rhs){ return lhs == rhs.get_order(); }
137 inline bool operator==(const OrderWrapper & lhs, int rhs){ return lhs.get_order() == rhs; }
138 inline bool operator==(Order lhs, const OrderWrapper & rhs){ return lhs == rhs.get_order(); }
139 inline bool operator==(const OrderWrapper & lhs, Order rhs){ return lhs.get_order() == rhs; }
140 inline bool operator!=(int lhs, const OrderWrapper & rhs){ return !(lhs == rhs); }
141 inline bool operator!=(const OrderWrapper & lhs, int rhs){ return !(lhs == rhs); }
142 inline bool operator!=(Order lhs, const OrderWrapper & rhs){ return !(lhs == rhs); }
143 inline bool operator!=(const OrderWrapper & lhs, Order rhs){ return !(lhs == rhs); }
144 inline bool operator< (int lhs, const OrderWrapper & rhs){ return lhs < rhs.get_order(); }
145 inline bool operator< (const OrderWrapper & lhs, int rhs){ return lhs.get_order() < rhs; }
146 inline bool operator< (Order lhs, const OrderWrapper & rhs){ return lhs < rhs.get_order(); }
147 inline bool operator< (const OrderWrapper & lhs, Order rhs){ return lhs.get_order() < rhs; }
148 inline bool operator> (int lhs, const OrderWrapper & rhs){ return rhs < lhs; }
149 inline bool operator> (const OrderWrapper & lhs, int rhs){ return rhs < lhs; }
150 inline bool operator> (Order lhs, const OrderWrapper & rhs){ return rhs < lhs; }
151 inline bool operator> (const OrderWrapper & lhs, Order rhs){ return rhs < lhs; }
152 inline bool operator<=(int lhs, const OrderWrapper & rhs){ return !(lhs > rhs); }
153 inline bool operator<=(const OrderWrapper & lhs, int rhs){ return !(lhs > rhs); }
154 inline bool operator<=(Order lhs, const OrderWrapper & rhs){ return !(lhs > rhs); }
155 inline bool operator<=(const OrderWrapper & lhs, Order rhs){ return !(lhs > rhs); }
156 inline bool operator>=(int lhs, const OrderWrapper & rhs){ return !(lhs < rhs); }
157 inline bool operator>=(const OrderWrapper & lhs, int rhs){ return !(lhs < rhs); }
158 inline bool operator>=(Order lhs, const OrderWrapper & rhs){ return !(lhs < rhs); }
159 inline bool operator>=(const OrderWrapper & lhs, Order rhs){ return !(lhs < rhs); }
160 
164 inline std::ostream & operator << (std::ostream & os, const OrderWrapper & order)
165 {
166  os << order.get_order();
167  return os;
168 }
169 
178 class FEType
179 {
180 public:
181 
182 #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
183 
188  FEType(const int o = 1,
189  const FEFamily f = LAGRANGE) :
190  order(o),
191  family(f)
192  {}
193 
198 
204 
205 #else
206 
216  FEType(const int o = 1,
217  const FEFamily f = LAGRANGE,
218  const int ro = THIRD,
219  const FEFamily rf = JACOBI_20_00,
220  const InfMapType im = CARTESIAN) :
221  order(o),
222  radial_order(ro),
223  family(f),
224  radial_family(rf),
225  inf_map(im)
226  {}
227 
231  OrderWrapper order;
232 
237 
242  FEFamily family;
243 
250 
258 
259 #endif // ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
260 
264  bool operator== (const FEType & f2) const
265  {
266  return (order == f2.order
267  && family == f2.family
268 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
269  && radial_order == f2.radial_order
270  && radial_family == f2.radial_family
271  && inf_map == f2.inf_map
272 #endif // ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
273  );
274  }
275 
279  bool operator!= (const FEType & f2) const
280  {
281  return !(*this == f2);
282  }
283 
287  bool operator< (const FEType & f2) const
288  {
289  if (order != f2.order)
290  return (order < f2.order);
291  if (family != f2.family)
292  return (family < f2.family);
293 
294 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
295  if (radial_order != f2.radial_order)
296  return (radial_order < f2.radial_order);
297  if (radial_family != f2.radial_family)
298  return (radial_family < f2.radial_family);
299  if (inf_map != f2.inf_map)
300  return (inf_map < f2.inf_map);
301 #endif // ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
302  return false;
303  }
304 
311  Order default_quadrature_order () const;
312 
319  UniquePtr<QBase> default_quadrature_rule (const unsigned int dim,
320  const int extraorder=0) const;
321 
322 
323 private:
324 
325 };
326 
327 
328 
329 //-------------------------------------------------------------------
330 // FEType inline methods
331 inline
333 {
334  return static_cast<Order>(2*static_cast<unsigned int>(order.get_order()) + 1);
335 }
336 
337 } // namespace libMesh
338 
339 
340 #endif // LIBMESH_FE_TYPE_H
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Definition: fe_type.h:178
FEFamily family
The type of finite element.
Definition: fe_type.h:203
int get_order() const
Explicitly request the order as an int.
Definition: fe_type.h:77
OrderWrapper(int order)
Constructor.
Definition: fe_type.h:61
OrderWrapperOperators(int) OrderWrapperOperators(unsigned int) OrderWrapperOperators(std
Definition: fe_type.h:129
bool operator<(const OrderWrapper &lhs, const OrderWrapper &rhs)
Definition: fe_type.h:96
unsigned int dim
OrderWrapper radial_order
The approximation order in the base of the infinite element.
Definition: fe_type.h:236
std::ostream & operator<<(std::ostream &os, const OrderWrapper &order)
Overload stream operators.
Definition: fe_type.h:164
OrderWrapper order
The approximation order of the element.
Definition: fe_type.h:197
bool operator>=(const OrderWrapper &lhs, const OrderWrapper &rhs)
Definition: fe_type.h:99
The libMesh namespace provides an interface to certain functionality in the library.
bool operator!=(const OrderWrapper &lhs, const OrderWrapper &rhs)
Definition: fe_type.h:95
InfMapType
defines an enum for the types of coordinate mappings available in infinite elements.
bool operator<=(const OrderWrapper &lhs, const OrderWrapper &rhs)
Definition: fe_type.h:98
std::unique_ptr< T > UniquePtr
Definition: auto_ptr.h:46
FEFamily
defines an enum for finite element families.
int _order
The approximation order of the element.
Definition: fe_type.h:87
bool operator>(const OrderWrapper &lhs, const OrderWrapper &rhs)
Definition: fe_type.h:97
Order default_quadrature_order() const
Definition: fe_type.h:332
FEType(const int o=1, const FEFamily f=LAGRANGE)
Constructor.
Definition: fe_type.h:188
This provides a shim class that wraps the Order enum.
Definition: fe_type.h:45
InfMapType inf_map
The coordinate mapping type of the infinite element.
Definition: fe_type.h:257
bool operator==(const OrderWrapper &lhs, const OrderWrapper &rhs)
Overload comparison operators for OrderWrapper.
Definition: fe_type.h:94
FEFamily radial_family
For InfFE, family contains the radial shape family, while base_family contains the approximation type...
Definition: fe_type.h:249
Order
defines an enum for polynomial orders.
Definition: enum_order.h:32
FEType(const int o=1, const FEFamily f=LAGRANGE, const int ro=THIRD, const FEFamily rf=JACOBI_20_00, const InfMapType im=CARTESIAN)
Constructor.
Definition: fe_type.h:216
OrderWrapper(Order order)
Constructor.
Definition: fe_type.h:53
void ErrorVector unsigned int
Definition: adjoints_ex3.C:360