fe_type.h
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 #ifndef LIBMESH_FE_TYPE_H
21 #define LIBMESH_FE_TYPE_H
22 
23 // Local includes
24 #include "libmesh/auto_ptr.h" // deprecated
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" // LAGRANGE
29 #include "libmesh/enum_inf_map_type.h" // CARTESIAN
30 
31 // C++ includes
32 #include <memory>
33 
34 namespace libMesh
35 {
36 
37 // Forward declarations
38 class QBase;
39 
47 {
48 public:
49 
55  _order(static_cast<int>(order))
56  {}
57 
62  OrderWrapper(int order) :
63  _order(order)
64  {}
65 
70  operator Order() const
71  {
72  return static_cast<Order>(_order);
73  }
74 
78  int get_order() const
79  {
80  return _order;
81  }
82 
83 private:
84 
88  int _order;
89 
90 };
91 
95 inline bool operator==(const OrderWrapper & lhs, const OrderWrapper & rhs){ return lhs.get_order() == rhs.get_order(); }
96 inline bool operator!=(const OrderWrapper & lhs, const OrderWrapper & rhs){ return !(lhs == rhs); }
97 inline bool operator< (const OrderWrapper & lhs, const OrderWrapper & rhs){ return lhs.get_order() < rhs.get_order(); }
98 inline bool operator> (const OrderWrapper & lhs, const OrderWrapper & rhs){ return rhs < lhs; }
99 inline bool operator<=(const OrderWrapper & lhs, const OrderWrapper & rhs){ return !(lhs > rhs); }
100 inline bool operator>=(const OrderWrapper & lhs, const OrderWrapper & rhs){ return !(lhs < rhs); }
101 
102 // First disambiguate everything that would be ambiguated by the
103 // subsequent disambiguations
104 #define OrderWrapperOperators(comparisontype) \
105  inline bool operator==(comparisontype lhs, Order rhs) \
106  { return lhs == static_cast<comparisontype>(rhs); } \
107  inline bool operator==(Order lhs, comparisontype rhs) \
108  { return static_cast<comparisontype>(lhs) == rhs; } \
109  inline bool operator!=(comparisontype lhs, Order rhs) \
110  { return !(lhs == rhs); } \
111  inline bool operator!=(Order lhs, comparisontype rhs) \
112  { return !(lhs == rhs); } \
113  inline bool operator< (comparisontype lhs, Order rhs) \
114  { return lhs < static_cast<comparisontype>(rhs); } \
115  inline bool operator< (Order lhs, comparisontype rhs) \
116  { return static_cast<comparisontype>(lhs) < rhs; } \
117  inline bool operator> (comparisontype lhs, Order rhs) \
118  { return rhs < lhs; } \
119  inline bool operator> (Order lhs, comparisontype rhs) \
120  { return rhs < lhs; } \
121  inline bool operator<=(comparisontype lhs, Order rhs) \
122  { return !(lhs > rhs); } \
123  inline bool operator<=(Order lhs, comparisontype rhs) \
124  { return !(lhs > rhs); } \
125  inline bool operator>=(comparisontype lhs, Order rhs) \
126  { return !(lhs < rhs); } \
127  inline bool operator>=(Order lhs, comparisontype rhs) \
128  { return !(lhs < rhs); }
129 
131 OrderWrapperOperators(unsigned int)
132 #if LIBMESH_SIZEOF_SIZE_T != LIBMESH_SIZEOF_UNSIGNED_INT
133 OrderWrapperOperators(std::size_t)
134 #endif
135 
136 // Now disambiguate all the things
137 inline bool operator==(int lhs, const OrderWrapper & rhs){ return lhs == rhs.get_order(); }
138 inline bool operator==(const OrderWrapper & lhs, int rhs){ return lhs.get_order() == rhs; }
139 inline bool operator==(Order lhs, const OrderWrapper & rhs){ return lhs == rhs.get_order(); }
140 inline bool operator==(const OrderWrapper & lhs, Order rhs){ return lhs.get_order() == rhs; }
141 inline bool operator!=(int lhs, const OrderWrapper & rhs){ return !(lhs == rhs); }
142 inline bool operator!=(const OrderWrapper & lhs, int rhs){ return !(lhs == rhs); }
143 inline bool operator!=(Order lhs, const OrderWrapper & rhs){ return !(lhs == rhs); }
144 inline bool operator!=(const OrderWrapper & lhs, Order rhs){ return !(lhs == rhs); }
145 inline bool operator< (int lhs, const OrderWrapper & rhs){ return lhs < rhs.get_order(); }
146 inline bool operator< (const OrderWrapper & lhs, int rhs){ return lhs.get_order() < rhs; }
147 inline bool operator< (Order lhs, const OrderWrapper & rhs){ return lhs < rhs.get_order(); }
148 inline bool operator< (const OrderWrapper & lhs, Order rhs){ return lhs.get_order() < rhs; }
149 inline bool operator> (int lhs, const OrderWrapper & rhs){ return rhs < lhs; }
150 inline bool operator> (const OrderWrapper & lhs, int rhs){ return rhs < lhs; }
151 inline bool operator> (Order lhs, const OrderWrapper & rhs){ return rhs < lhs; }
152 inline bool operator> (const OrderWrapper & lhs, Order rhs){ return rhs < lhs; }
153 inline bool operator<=(int lhs, const OrderWrapper & rhs){ return !(lhs > rhs); }
154 inline bool operator<=(const OrderWrapper & lhs, int rhs){ return !(lhs > rhs); }
155 inline bool operator<=(Order lhs, const OrderWrapper & rhs){ return !(lhs > rhs); }
156 inline bool operator<=(const OrderWrapper & lhs, Order rhs){ return !(lhs > rhs); }
157 inline bool operator>=(int lhs, const OrderWrapper & rhs){ return !(lhs < rhs); }
158 inline bool operator>=(const OrderWrapper & lhs, int rhs){ return !(lhs < rhs); }
159 inline bool operator>=(Order lhs, const OrderWrapper & rhs){ return !(lhs < rhs); }
160 inline bool operator>=(const OrderWrapper & lhs, Order rhs){ return !(lhs < rhs); }
161 
165 inline std::ostream & operator << (std::ostream & os, const OrderWrapper & order)
166 {
167  os << order.get_order();
168  return os;
169 }
170 
179 class FEType
180 {
181 public:
182 
183 #ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
184 
189  FEType(const int o = 1,
190  const FEFamily f = LAGRANGE) :
191  order(o),
192  family(f)
193  {}
194 
199 
205 
206 #else
207 
217  FEType(const int o = 1,
218  const FEFamily f = LAGRANGE,
219  const int ro = THIRD,
220  const FEFamily rf = JACOBI_20_00,
221  const InfMapType im = CARTESIAN) :
222  order(o),
223  radial_order(ro),
224  family(f),
225  radial_family(rf),
226  inf_map(im)
227  {}
228 
233 
238 
244 
251 
259 
260 #endif // ifndef LIBMESH_ENABLE_INFINITE_ELEMENTS
261 
265  bool operator== (const FEType & f2) const
266  {
267  return (order == f2.order
268  && family == f2.family
269 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
270  && radial_order == f2.radial_order
272  && inf_map == f2.inf_map
273 #endif // ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
274  );
275  }
276 
280  bool operator!= (const FEType & f2) const
281  {
282  return !(*this == f2);
283  }
284 
288  bool operator< (const FEType & f2) const
289  {
290  if (order != f2.order)
291  return (order < f2.order);
292  if (family != f2.family)
293  return (family < f2.family);
294 
295 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
296  if (radial_order != f2.radial_order)
297  return (radial_order < f2.radial_order);
298  if (radial_family != f2.radial_family)
299  return (radial_family < f2.radial_family);
300  if (inf_map != f2.inf_map)
301  return (inf_map < f2.inf_map);
302 #endif // ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
303  return false;
304  }
305 
313 
320  std::unique_ptr<QBase> default_quadrature_rule (const unsigned int dim,
321  const int extraorder=0) const;
322 
323 
324 private:
325 
326 };
327 
328 
329 
330 //-------------------------------------------------------------------
331 // FEType inline methods
332 inline
334 {
335  return static_cast<Order>(2*static_cast<unsigned int>(order.get_order()) + 1);
336 }
337 
338 } // namespace libMesh
339 
340 
341 #endif // LIBMESH_FE_TYPE_H
Manages the family, order, etc. parameters for a given FE.
Definition: fe_type.h:179
FEFamily family
Definition: fe_type.h:204
bool operator==(const FEType &f2) const
Definition: fe_type.h:265
OrderWrapper(int order)
Definition: fe_type.h:62
OrderWrapperOperators(int) OrderWrapperOperators(unsigned int) OrderWrapperOperators(std
Definition: fe_type.h:130
bool operator<(const OrderWrapper &lhs, const OrderWrapper &rhs)
Definition: fe_type.h:97
OrderWrapper radial_order
Definition: fe_type.h:237
Order default_quadrature_order() const
Definition: fe_type.h:333
OrderWrapper order
Definition: fe_type.h:198
bool operator>=(const OrderWrapper &lhs, const OrderWrapper &rhs)
Definition: fe_type.h:100
bool operator!=(const OrderWrapper &lhs, const OrderWrapper &rhs)
Definition: fe_type.h:96
bool operator<=(const OrderWrapper &lhs, const OrderWrapper &rhs)
Definition: fe_type.h:99
bool operator!=(const FEType &f2) const
Definition: fe_type.h:280
std::unique_ptr< QBase > default_quadrature_rule(const unsigned int dim, const int extraorder=0) const
Definition: fe_type.C:31
bool operator>(const OrderWrapper &lhs, const OrderWrapper &rhs)
Definition: fe_type.h:98
FEType(const int o=1, const FEFamily f=LAGRANGE)
Definition: fe_type.h:189
InfMapType inf_map
Definition: fe_type.h:258
bool operator==(const OrderWrapper &lhs, const OrderWrapper &rhs)
Definition: fe_type.h:95
bool operator<(const FEType &f2) const
Definition: fe_type.h:288
FEFamily radial_family
Definition: fe_type.h:250
int get_order() const
Definition: fe_type.h:78
FEType(const int o=1, const FEFamily f=LAGRANGE, const int ro=THIRD, const FEFamily rf=JACOBI_20_00, const InfMapType im=CARTESIAN)
Definition: fe_type.h:217
std::ostream & operator<<(std::ostream &os, const FEAbstract &fe)
Definition: fe_abstract.C:809
OrderWrapper(Order order)
Definition: fe_type.h:54