libMesh
fe.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_H
21 #define LIBMESH_FE_H
22 
23 // Local includes
24 #include "libmesh/fe_base.h"
25 #include "libmesh/libmesh.h"
26 
27 // C++ includes
28 #include <cstddef>
29 
30 namespace libMesh
31 {
32 
33 // forward declarations
34 class DofConstraints;
35 class DofMap;
36 
37 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
38 
39 template <unsigned int friend_Dim, FEFamily friend_T_radial, InfMapType friend_T_map>
40 class InfFE;
41 
42 #endif
43 
44 
48 template <FEFamily T>
50 {
51  typedef Real type;
52 };
53 
54 
58 template<>
60 {
61  typedef RealGradient type;
62 };
63 
64 template<>
66 {
67  typedef RealGradient type;
68 };
69 
70 
88 template <unsigned int Dim, FEFamily T>
89 class FE : public FEGenericBase<typename FEOutputType<T>::type>
90 {
91 public:
92 
96  explicit
97  FE(const FEType & fet);
98 
99  typedef typename
102 
111  static OutputShape shape(const ElemType t,
112  const Order o,
113  const unsigned int i,
114  const Point & p);
115 
124  static OutputShape shape(const Elem * elem,
125  const Order o,
126  const unsigned int i,
127  const Point & p);
128 
136  static OutputShape shape_deriv(const ElemType t,
137  const Order o,
138  const unsigned int i,
139  const unsigned int j,
140  const Point & p);
141 
148  static OutputShape shape_deriv(const Elem * elem,
149  const Order o,
150  const unsigned int i,
151  const unsigned int j,
152  const Point & p);
153 
174  static OutputShape shape_second_deriv(const ElemType t,
175  const Order o,
176  const unsigned int i,
177  const unsigned int j,
178  const Point & p);
179 
200  static OutputShape shape_second_deriv(const Elem * elem,
201  const Order o,
202  const unsigned int i,
203  const unsigned int j,
204  const Point & p);
205 
212  static void nodal_soln(const Elem * elem, const Order o,
213  const std::vector<Number> & elem_soln,
214  std::vector<Number> & nodal_soln);
215 
220  virtual unsigned int n_shape_functions () const libmesh_override;
221 
228  static unsigned int n_shape_functions (const ElemType t,
229  const Order o)
230  { return FE<Dim,T>::n_dofs (t,o); }
231 
238  static unsigned int n_dofs(const ElemType t,
239  const Order o);
240 
247  static unsigned int n_dofs_at_node(const ElemType t,
248  const Order o,
249  const unsigned int n);
250 
257  static unsigned int n_dofs_per_elem(const ElemType t,
258  const Order o);
259 
263  virtual FEContinuity get_continuity() const libmesh_override;
264 
269  virtual bool is_hierarchic() const libmesh_override;
270 
277  static void dofs_on_side(const Elem * const elem,
278  const Order o,
279  unsigned int s,
280  std::vector<unsigned int> & di);
287  static void dofs_on_edge(const Elem * const elem,
288  const Order o,
289  unsigned int e,
290  std::vector<unsigned int> & di);
291 
301  static Point inverse_map (const Elem * elem,
302  const Point & p,
303  const Real tolerance = TOLERANCE,
304  const bool secure = true);
305 
316  static void inverse_map (const Elem * elem,
317  const std::vector<Point> & physical_points,
318  std::vector<Point> & reference_points,
319  const Real tolerance = TOLERANCE,
320  const bool secure = true);
321 
332  virtual void reinit (const Elem * elem,
333  const std::vector<Point> * const pts = libmesh_nullptr,
334  const std::vector<Real> * const weights = libmesh_nullptr) libmesh_override;
335 
345  virtual void reinit (const Elem * elem,
346  const unsigned int side,
347  const Real tolerance = TOLERANCE,
348  const std::vector<Point> * const pts = libmesh_nullptr,
349  const std::vector<Real> * const weights = libmesh_nullptr) libmesh_override;
350 
360  virtual void edge_reinit (const Elem * elem,
361  const unsigned int edge,
362  const Real tolerance = TOLERANCE,
363  const std::vector<Point> * const pts = libmesh_nullptr,
364  const std::vector<Real> * const weights = libmesh_nullptr) libmesh_override;
365 
370  virtual void side_map (const Elem * elem,
371  const Elem * side,
372  const unsigned int s,
373  const std::vector<Point> & reference_side_points,
374  std::vector<Point> & reference_points) libmesh_override;
375 
381  virtual void attach_quadrature_rule (QBase * q) libmesh_override;
382 
388  virtual unsigned int n_quadrature_points () const libmesh_override;
389 
390 #ifdef LIBMESH_ENABLE_AMR
391 
397  static void compute_constraints (DofConstraints & constraints,
398  DofMap & dof_map,
399  const unsigned int variable_number,
400  const Elem * elem);
401 #endif // #ifdef LIBMESH_ENABLE_AMR
402 
409  virtual bool shapes_need_reinit() const libmesh_override;
410 
415  static Point map (const Elem * elem,
416  const Point & reference_point);
417 
422  static Point map_xi (const Elem * elem,
423  const Point & reference_point);
424 
429  static Point map_eta (const Elem * elem,
430  const Point & reference_point);
431 
436  static Point map_zeta (const Elem * elem,
437  const Point & reference_point);
438 
439 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
440 
444  template <unsigned int friend_Dim, FEFamily friend_T_radial, InfMapType friend_T_map>
445  friend class InfFE;
446 #endif
447 
448 protected:
449 
457  virtual void init_shape_functions(const std::vector<Point> & qp,
458  const Elem * e);
459 
460 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
461 
466  virtual void init_base_shape_functions(const std::vector<Point> & qp,
467  const Elem * e) libmesh_override;
468 
469 #endif
470 
475  std::vector<Point> cached_nodes;
476 
481 
482  unsigned int last_edge;
483 };
484 
485 
486 
494 template <unsigned int Dim>
495 class FEClough : public FE<Dim,CLOUGH>
496 {
497 public:
498 
503  explicit
504  FEClough(const FEType & fet) :
505  FE<Dim,CLOUGH> (fet)
506  {}
507 };
508 
509 
510 
518 template <unsigned int Dim>
519 class FEHermite : public FE<Dim,HERMITE>
520 {
521 public:
522 
527  explicit
528  FEHermite(const FEType & fet) :
529  FE<Dim,HERMITE> (fet)
530  {}
531 
535  static Real hermite_raw_shape_second_deriv(const unsigned int basis_num,
536  const Real xi);
537  static Real hermite_raw_shape_deriv(const unsigned int basis_num,
538  const Real xi);
539  static Real hermite_raw_shape(const unsigned int basis_num,
540  const Real xi);
541 };
542 
543 
544 
551 template <>
552 Real FE<2,SUBDIVISION>::shape(const Elem * elem,
553  const Order order,
554  const unsigned int i,
555  const Point & p);
556 
557 template <>
559  const Order order,
560  const unsigned int i,
561  const unsigned int j,
562  const Point & p);
563 
564 template <>
566  const Order order,
567  const unsigned int i,
568  const unsigned int j,
569  const Point & p);
570 
571 
572 class FESubdivision : public FE<2,SUBDIVISION>
573 {
574 public:
575 
581  FESubdivision(const FEType & fet);
582 
593  virtual void reinit (const Elem * elem,
594  const std::vector<Point> * const pts = libmesh_nullptr,
595  const std::vector<Real> * const weights = libmesh_nullptr) libmesh_override;
596 
601  virtual void reinit (const Elem *,
602  const unsigned int,
603  const Real = TOLERANCE,
604  const std::vector<Point> * const = libmesh_nullptr,
605  const std::vector<Real> * const = libmesh_nullptr) libmesh_override
606  { libmesh_not_implemented(); }
607 
613  virtual void attach_quadrature_rule (QBase * q) libmesh_override;
614 
622  virtual void init_shape_functions(const std::vector<Point> & qp,
623  const Elem * elem) libmesh_override;
624 
631  static Real regular_shape(const unsigned int i,
632  const Real v,
633  const Real w);
634 
641  static Real regular_shape_deriv(const unsigned int i,
642  const unsigned int j,
643  const Real v,
644  const Real w);
645 
652  static Real regular_shape_second_deriv(const unsigned int i,
653  const unsigned int j,
654  const Real v,
655  const Real w);
656 
657 
667  static void loop_subdivision_mask(std::vector<Real> & weights,
668  const unsigned int valence);
669 
670 
675  static void init_subdivision_matrix(DenseMatrix<Real> & A,
676  unsigned int valence);
677 };
678 
679 
680 
688 template <unsigned int Dim>
689 class FEHierarchic : public FE<Dim,HIERARCHIC>
690 {
691 public:
692 
697  explicit
698  FEHierarchic(const FEType & fet) :
699  FE<Dim,HIERARCHIC> (fet)
700  {}
701 };
702 
703 
704 
712 template <unsigned int Dim>
713 class FEL2Hierarchic : public FE<Dim,L2_HIERARCHIC>
714 {
715 public:
716 
721  explicit
722  FEL2Hierarchic(const FEType & fet) :
723  FE<Dim,L2_HIERARCHIC> (fet)
724  {}
725 };
726 
727 
728 
736 template <unsigned int Dim>
737 class FELagrange : public FE<Dim,LAGRANGE>
738 {
739 public:
740 
745  explicit
746  FELagrange(const FEType & fet) :
747  FE<Dim,LAGRANGE> (fet)
748  {}
749 };
750 
751 
755 template <unsigned int Dim>
756 class FEL2Lagrange : public FE<Dim,L2_LAGRANGE>
757 {
758 public:
759 
764  explicit
765  FEL2Lagrange(const FEType & fet) :
766  FE<Dim,L2_LAGRANGE> (fet)
767  {}
768 };
769 
770 
778 template <unsigned int Dim>
779 class FEMonomial : public FE<Dim,MONOMIAL>
780 {
781 public:
782 
787  explicit
788  FEMonomial(const FEType & fet) :
789  FE<Dim,MONOMIAL> (fet)
790  {}
791 };
792 
793 
797 template <unsigned int Dim>
798 class FEScalar : public FE<Dim,SCALAR>
799 {
800 public:
801 
808  explicit
809  FEScalar(const FEType & fet) :
810  FE<Dim,SCALAR> (fet)
811  {}
812 };
813 
814 
823 template <unsigned int Dim>
824 class FEXYZ : public FE<Dim,XYZ>
825 {
826 public:
827 
832  explicit
833  FEXYZ(const FEType & fet) :
834  FE<Dim,XYZ> (fet)
835  {}
836 
841  virtual void reinit (const Elem * elem,
842  const std::vector<Point> * const pts = libmesh_nullptr,
843  const std::vector<Real> * const weights = libmesh_nullptr) libmesh_override
844  { FE<Dim,XYZ>::reinit (elem, pts, weights); }
845 
850  virtual void reinit (const Elem * elem,
851  const unsigned int side,
852  const Real tolerance = TOLERANCE,
853  const std::vector<Point> * const pts = libmesh_nullptr,
854  const std::vector<Real> * const weights = libmesh_nullptr) libmesh_override;
855 
856 
857 protected:
858 
866  virtual void init_shape_functions(const std::vector<Point> & qp,
867  const Elem * e) libmesh_override;
868 
879  virtual void compute_shape_functions(const Elem * elem, const std::vector<Point> & qp) libmesh_override;
880 
884  void compute_face_values (const Elem * elem,
885  const Elem * side,
886  const std::vector<Real> & weights);
887 };
888 
889 
890 
898 template <unsigned int Dim>
899 class FELagrangeVec : public FE<Dim,LAGRANGE_VEC>
900 {
901 public:
902 
907  explicit
908  FELagrangeVec(const FEType & fet) :
909  FE<Dim,LAGRANGE_VEC> (fet)
910  {}
911 };
912 
913 
914 
922 template <unsigned int Dim>
923 class FENedelecOne : public FE<Dim,NEDELEC_ONE>
924 {
925 public:
930  explicit
931  FENedelecOne(const FEType & fet) :
932  FE<Dim,NEDELEC_ONE> (fet)
933  {}
934 };
935 
936 
937 
938 
942 namespace FiniteElements
943 {
949 
955 
961 
967 
968 
974 
980 
986 
987 
993 
999 
1005 
1006 
1012 
1018 
1024 
1025 
1031 
1037 
1043 
1044 }
1045 
1046 
1047 
1048 // ------------------------------------------------------------
1049 // FE class inline members
1050 template <unsigned int Dim, FEFamily T>
1051 inline
1052 FE<Dim,T>::FE (const FEType & fet) :
1053  FEGenericBase<typename FEOutputType<T>::type> (Dim,fet),
1054  last_side(INVALID_ELEM),
1055  last_edge(libMesh::invalid_uint)
1056 {
1057  // Sanity check. Make sure the
1058  // Family specified in the template instantiation
1059  // matches the one in the FEType object
1060  libmesh_assert_equal_to (T, this->get_family());
1061 }
1062 
1063 } // namespace libMesh
1064 
1065 #endif // LIBMESH_FE_H
FELagrangeVec objects are used for working with vector-valued finite elements.
Definition: fe.h:899
class FEType hides (possibly multiple) FEFamily and approximation orders, thereby enabling specialize...
Definition: fe_type.h:178
XYZ finite elements.
Definition: fe.h:824
FELagrange(const FEType &fet)
Constructor.
Definition: fe.h:746
FEMonomial(const FEType &fet)
Constructor.
Definition: fe.h:788
static unsigned int n_dofs(const ElemType t, const Order o)
A specific instantiation of the FEBase class.
Definition: fe.h:40
FENedelecOne objects are used for working with vector-valued Nedelec finite elements of the first kin...
Definition: fe.h:923
unsigned int last_edge
Definition: fe.h:482
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value.
Definition: libmesh.h:184
static OutputShape shape(const ElemType t, const Order o, const unsigned int i, const Point &p)
FE< 1, MONOMIAL > FEMonomial1D
Convenient definition for a 1D Monomial finite element.
Definition: fe.h:1030
FE< 2, L2_HIERARCHIC > FEL2Hierarchic2D
Convenient definition for a 2D Discontinuous Hierarchic finite element.
Definition: fe.h:979
FE< 3, L2_HIERARCHIC > FEL2Hierarchic3D
Convenient definition for a 3D Discontinuous Hierarchic finite element.
Definition: fe.h:985
Lagrange finite elements.
Definition: fe.h:737
Monomial finite elements.
Definition: fe.h:779
FEClough(const FEType &fet)
Constructor.
Definition: fe.h:504
FE< 1, L2_LAGRANGE > FEL2Lagrange1D
Convenient definition for a 1D Discontinuous Lagrange finite element.
Definition: fe.h:1011
virtual void reinit(const Elem *, const unsigned int, const Real=TOLERANCE, const std::vector< Point > *const =libmesh_nullptr, const std::vector< Real > *const =libmesh_nullptr) libmesh_override
This prevents some compilers being confused by partially overriding this virtual function.
Definition: fe.h:601
ElemType
Defines an enum for geometric element types.
unsigned short int side
Definition: xdr_io.C:49
This is the base class from which all geometric element types are derived.
Definition: elem.h:89
FEGenericBase< typename FEOutputType< T >::type >::OutputShape OutputShape
Definition: fe.h:101
const class libmesh_nullptr_t libmesh_nullptr
FE(const FEType &fet)
Constructor.
Definition: fe.h:1052
static OutputShape shape_deriv(const ElemType t, const Order o, const unsigned int i, const unsigned int j, const Point &p)
FE< 3, L2_LAGRANGE > FEL2Lagrange3D
Convenient definition for a 3D Discontinuous Lagrange finite element.
Definition: fe.h:1023
static const Real TOLERANCE
FEFamily get_family() const
Definition: fe_abstract.h:447
FE< 1, HIERARCHIC > FEHierarchic1D
Convenient definition for a 1D Hierarchic finite element.
Definition: fe.h:954
The libMesh namespace provides an interface to certain functionality in the library.
virtual void reinit(const Elem *elem, const std::vector< Point > *const pts=libmesh_nullptr, const std::vector< Real > *const weights=libmesh_nullptr) libmesh_override
Explicitly call base class method.
Definition: fe.h:841
FEXYZ(const FEType &fet)
Constructor.
Definition: fe.h:833
FE< 2, LAGRANGE > FELagrange2D
Convenient definition for a 2D Lagrange finite element.
Definition: fe.h:998
FELagrangeVec(const FEType &fet)
Constructor.
Definition: fe.h:908
FE< 3, LAGRANGE > FELagrange3D
Convenient definition for a 3D Lagrange finite element.
Definition: fe.h:1004
FEClough< 2 > FEClough2D
Convenient definition for a 2D Clough-Tocher finite element.
Definition: fe.h:948
FEL2Lagrange(const FEType &fet)
Constructor.
Definition: fe.h:765
This class handles the numbering of degrees of freedom on a mesh.
Definition: dof_map.h:167
FEHierarchic(const FEType &fet)
Constructor.
Definition: fe.h:698
A specific instantiation of the FEBase class.
Definition: fe.h:89
FEHermite(const FEType &fet)
Constructor.
Definition: fe.h:528
FE< 3, HIERARCHIC > FEHierarchic3D
Convenient definition for a 3D Hierarchic finite element.
Definition: fe.h:966
Discontinuous Hierarchic finite elements.
Definition: fe.h:713
FEL2Hierarchic(const FEType &fet)
Constructor.
Definition: fe.h:722
FE< 2, MONOMIAL > FEMonomial2D
Convenient definition for a 2D Monomial finite element.
Definition: fe.h:1036
FEOutputType< T >::type OutputShape
Convenient typedefs for gradients of output, hessians of output, and potentially-complex-valued versi...
Definition: fe_base.h:120
FENedelecOne(const FEType &fet)
Constructor.
Definition: fe.h:931
FEContinuity
defines an enum for finite element types to libmesh_assert a certain level (or type? Hcurl?) of continuity.
Discontinuous Lagrange finite elements.
Definition: fe.h:756
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
FE< 2, HIERARCHIC > FEHierarchic2D
Convenient definition for a 2D Hierarchic finite element.
Definition: fe.h:960
Hierarchic finite elements.
Definition: fe.h:689
virtual void reinit(const Elem *elem, const std::vector< Point > *const pts=libmesh_nullptr, const std::vector< Real > *const weights=libmesh_nullptr) libmesh_override
This is at the core of this class.
Definition: fe.C:115
static PetscErrorCode Mat * A
FE< 3, MONOMIAL > FEMonomial3D
Convenient definition for a 3D Monomial finite element.
Definition: fe.h:1042
Order
defines an enum for polynomial orders.
Definition: enum_order.h:32
FE< 2, L2_LAGRANGE > FEL2Lagrange2D
Convenient definition for a 2D Discontinuous Lagrange finite element.
Definition: fe.h:1017
FE< 1, LAGRANGE > FELagrange1D
Convenient definition for a 1D Lagrange finite element.
Definition: fe.h:992
The FEScalar class is used for working with SCALAR variables.
Definition: fe.h:798
FEScalar(const FEType &fet)
Constructor.
Definition: fe.h:809
Hermite finite elements.
Definition: fe.h:519
FE< 1, L2_HIERARCHIC > FEL2Hierarchic1D
Convenient definition for a 1D Discontinuous Hierarchic finite element.
Definition: fe.h:973
std::vector< Point > cached_nodes
An array of the node locations on the last element we computed on.
Definition: fe.h:475
Clough-Tocher finite elements.
Definition: fe.h:495
ElemType last_side
The last side and last edge we did a reinit on.
Definition: fe.h:480
A Point defines a location in LIBMESH_DIM dimensional Real space.
Definition: point.h:38
The constraint matrix storage format.
Definition: dof_map.h:96
The QBase class provides the basic functionality from which various quadrature rules can be derived...
Definition: quadrature.h:53
This class forms the foundation from which generic finite elements may be derived.
static OutputShape shape_second_deriv(const ElemType t, const Order o, const unsigned int i, const unsigned int j, const Point &p)
Most finite element types in libMesh are scalar-valued.
Definition: fe.h:49