fe.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_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 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 override;
264 
269  virtual bool is_hierarchic() const 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 = nullptr,
334  const std::vector<Real> * const weights = nullptr) 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 = nullptr,
349  const std::vector<Real> * const weights = nullptr) 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 = nullptr,
364  const std::vector<Real> * const weights = nullptr) 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) override;
375 
381  virtual void attach_quadrature_rule (QBase * q) override;
382 
388  virtual unsigned int n_quadrature_points () const 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 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) 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 <>
558 Real FE<2,SUBDIVISION>::shape_deriv(const Elem * elem,
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 = nullptr,
595  const std::vector<Real> * const weights = nullptr) override;
596 
601  virtual void reinit (const Elem *,
602  const unsigned int,
603  const Real = TOLERANCE,
604  const std::vector<Point> * const = nullptr,
605  const std::vector<Real> * const = nullptr) override
606  { libmesh_not_implemented(); }
607 
613  virtual void attach_quadrature_rule (QBase * q) override;
614 
622  virtual void init_shape_functions(const std::vector<Point> & qp,
623  const Elem * elem) 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 
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 
842  virtual void reinit (const Elem * elem,
843  const std::vector<Point> * const pts = nullptr,
844  const std::vector<Real> * const weights = nullptr) override
845  { FE<Dim,XYZ>::reinit (elem, pts, weights); }
846 
851  virtual void reinit (const Elem * elem,
852  const unsigned int side,
853  const Real tolerance = TOLERANCE,
854  const std::vector<Point> * const pts = nullptr,
855  const std::vector<Real> * const weights = nullptr) override;
856 
857 
858 protected:
859 
867  virtual void init_shape_functions(const std::vector<Point> & qp,
868  const Elem * e) override;
869 
880  virtual void compute_shape_functions(const Elem * elem, const std::vector<Point> & qp) override;
881 
885  void compute_face_values (const Elem * elem,
886  const Elem * side,
887  const std::vector<Real> & weights);
888 };
889 
890 
891 
899 template <unsigned int Dim>
900 class FELagrangeVec : public FE<Dim,LAGRANGE_VEC>
901 {
902 public:
903 
908  explicit
909  FELagrangeVec(const FEType & fet) :
910  FE<Dim,LAGRANGE_VEC> (fet)
911  {}
912 };
913 
914 
915 
923 template <unsigned int Dim>
924 class FENedelecOne : public FE<Dim,NEDELEC_ONE>
925 {
926 public:
931  explicit
932  FENedelecOne(const FEType & fet) :
933  FE<Dim,NEDELEC_ONE> (fet)
934  {}
935 };
936 
937 
938 
939 
943 namespace FiniteElements
944 {
950 
956 
962 
968 
969 
975 
981 
987 
988 
994 
1000 
1006 
1007 
1013 
1019 
1025 
1026 
1032 
1038 
1044 
1045 }
1046 
1047 } // namespace libMesh
1048 
1049 #endif // LIBMESH_FE_H
Manages the family, order, etc. parameters for a given FE.
Definition: fe_type.h:179
FELagrange(const FEType &fet)
Definition: fe.h:746
FESubdivision(const FEType &fet)
FEMonomial(const FEType &fet)
Definition: fe.h:788
static unsigned int n_dofs(const ElemType t, const Order o)
static Real regular_shape(const unsigned int i, const Real v, const Real w)
Base class for all the infinite geometric element types.
Definition: fe.h:40
static Point map_zeta(const Elem *elem, const Point &reference_point)
Definition: fe_map.C:2068
virtual void side_map(const Elem *elem, const Elem *side, const unsigned int s, const std::vector< Point > &reference_side_points, std::vector< Point > &reference_points) override
Definition: fe_boundary.C:353
unsigned int last_edge
Definition: fe.h:482
static OutputShape shape(const ElemType t, const Order o, const unsigned int i, const Point &p)
FE< 1, MONOMIAL > FEMonomial1D
Definition: fe.h:1031
FE< 2, L2_HIERARCHIC > FEL2Hierarchic2D
Definition: fe.h:980
virtual void attach_quadrature_rule(QBase *q) override
Definition: fe.C:58
FE< 3, L2_HIERARCHIC > FEL2Hierarchic3D
Definition: fe.h:986
static void init_subdivision_matrix(DenseMatrix< Real > &A, unsigned int valence)
void compute_face_values(const Elem *elem, const Elem *side, const std::vector< Real > &weights)
FEClough(const FEType &fet)
Definition: fe.h:504
static Point map_xi(const Elem *elem, const Point &reference_point)
Definition: fe_map.C:2012
static void loop_subdivision_mask(std::vector< Real > &weights, const unsigned int valence)
FE< 1, L2_LAGRANGE > FEL2Lagrange1D
Definition: fe.h:1012
unsigned short int side
Definition: xdr_io.C:50
The base class for all geometric element types.
Definition: elem.h:100
FEGenericBase< typename FEOutputType< T >::type >::OutputShape OutputShape
Definition: fe.h:101
FE(const FEType &fet)
Definition: fe.C:37
static unsigned int n_dofs_at_node(const ElemType t, const Order o, const unsigned int n)
static OutputShape shape_deriv(const ElemType t, const Order o, const unsigned int i, const unsigned int j, const Point &p)
static void dofs_on_side(const Elem *const elem, const Order o, unsigned int s, std::vector< unsigned int > &di)
Definition: fe.C:77
FE< 3, L2_LAGRANGE > FEL2Lagrange3D
Definition: fe.h:1024
static const Real TOLERANCE
virtual bool shapes_need_reinit() const override
FE< 1, HIERARCHIC > FEHierarchic1D
Definition: fe.h:955
static Real hermite_raw_shape_second_deriv(const unsigned int basis_num, const Real xi)
virtual void init_shape_functions(const std::vector< Point > &qp, const Elem *e) override
Definition: fe_xyz.C:598
FEXYZ(const FEType &fet)
Definition: fe.h:833
FE< 2, LAGRANGE > FELagrange2D
Definition: fe.h:999
FELagrangeVec(const FEType &fet)
Definition: fe.h:909
static Real hermite_raw_shape(const unsigned int basis_num, const Real xi)
virtual void attach_quadrature_rule(QBase *q) override
FE< 3, LAGRANGE > FELagrange3D
Definition: fe.h:1005
FEClough< 2 > FEClough2D
Definition: fe.h:949
FEL2Lagrange(const FEType &fet)
Definition: fe.h:765
virtual bool is_hierarchic() const override
Manages the degrees of freedom (DOFs) in a simulation.
Definition: dof_map.h:176
FEHierarchic(const FEType &fet)
Definition: fe.h:698
virtual void reinit(const Elem *elem, const std::vector< Point > *const pts=nullptr, const std::vector< Real > *const weights=nullptr) override
Definition: fe.C:129
virtual unsigned int n_shape_functions() const override
Definition: fe.C:50
Template class which generates the different FE families and orders.
Definition: fe.h:89
static Point map(const Elem *elem, const Point &reference_point)
Definition: fe_map.C:1985
static Real regular_shape_second_deriv(const unsigned int i, const unsigned int j, const Real v, const Real w)
FEHermite(const FEType &fet)
Definition: fe.h:528
FE< 3, HIERARCHIC > FEHierarchic3D
Definition: fe.h:967
FEL2Hierarchic(const FEType &fet)
Definition: fe.h:722
FE< 2, MONOMIAL > FEMonomial2D
Definition: fe.h:1037
static Real regular_shape_deriv(const unsigned int i, const unsigned int j, const Real v, const Real w)
static unsigned int n_dofs_per_elem(const ElemType t, const Order o)
virtual FEContinuity get_continuity() const override
FENedelecOne(const FEType &fet)
Definition: fe.h:932
virtual unsigned int n_quadrature_points() const override
Definition: fe.C:69
static void compute_constraints(DofConstraints &constraints, DofMap &dof_map, const unsigned int variable_number, const Elem *elem)
static Point map_eta(const Elem *elem, const Point &reference_point)
Definition: fe_map.C:2040
static unsigned int n_shape_functions(const ElemType t, const Order o)
Definition: fe.h:228
static void dofs_on_edge(const Elem *const elem, const Order o, unsigned int e, std::vector< unsigned int > &di)
Definition: fe.C:103
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
FE< 2, HIERARCHIC > FEHierarchic2D
Definition: fe.h:961
virtual void compute_shape_functions(const Elem *elem, const std::vector< Point > &qp) override
Definition: fe_xyz.C:709
static PetscErrorCode Mat * A
static void nodal_soln(const Elem *elem, const Order o, const std::vector< Number > &elem_soln, std::vector< Number > &nodal_soln)
FE< 3, MONOMIAL > FEMonomial3D
Definition: fe.h:1043
virtual void init_shape_functions(const std::vector< Point > &qp, const Elem *e)
Definition: fe.C:294
static Real hermite_raw_shape_deriv(const unsigned int basis_num, const Real xi)
FE< 2, L2_LAGRANGE > FEL2Lagrange2D
Definition: fe.h:1018
FE< 1, LAGRANGE > FELagrange1D
Definition: fe.h:993
FEScalar(const FEType &fet)
Definition: fe.h:809
FE< 1, L2_HIERARCHIC > FEL2Hierarchic1D
Definition: fe.h:974
std::vector< Point > cached_nodes
Definition: fe.h:475
virtual void init_shape_functions(const std::vector< Point > &qp, const Elem *elem) override
ElemType last_side
Definition: fe.h:480
A matrix object used for finite element assembly and numerics.
Definition: dense_matrix.h:54
virtual void edge_reinit(const Elem *elem, const unsigned int edge, const Real tolerance=TOLERANCE, const std::vector< Point > *const pts=nullptr, const std::vector< Real > *const weights=nullptr) override
Definition: fe_boundary.C:260
A geometric point in (x,y,z) space.
Definition: point.h:38
virtual void reinit(const Elem *elem, const std::vector< Point > *const pts=nullptr, const std::vector< Real > *const weights=nullptr) override
virtual void reinit(const Elem *elem, const std::vector< Point > *const pts=nullptr, const std::vector< Real > *const weights=nullptr) override
Definition: fe.h:842
Base class for all quadrature families and orders.
Definition: quadrature.h:62
static OutputShape shape_second_deriv(const ElemType t, const Order o, const unsigned int i, const unsigned int j, const Point &p)
static Point inverse_map(const Elem *elem, const Point &p, const Real tolerance=TOLERANCE, const bool secure=true)
Definition: fe_map.C:1576
virtual void init_base_shape_functions(const std::vector< Point > &qp, const Elem *e) override
Definition: fe.C:550
virtual void reinit(const Elem *, const unsigned int, const Real=TOLERANCE, const std::vector< Point > *const =nullptr, const std::vector< Real > *const =nullptr) override
Definition: fe.h:601