$extrastylesheet
fe.h
Go to the documentation of this file.
00001 // The libMesh Finite Element Library.
00002 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
00003 
00004 // This library is free software; you can redistribute it and/or
00005 // modify it under the terms of the GNU Lesser General Public
00006 // License as published by the Free Software Foundation; either
00007 // version 2.1 of the License, or (at your option) any later version.
00008 
00009 // This library is distributed in the hope that it will be useful,
00010 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012 // Lesser General Public License for more details.
00013 
00014 // You should have received a copy of the GNU Lesser General Public
00015 // License along with this library; if not, write to the Free Software
00016 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 
00018 
00019 
00020 #ifndef LIBMESH_FE_H
00021 #define LIBMESH_FE_H
00022 
00023 // Local includes
00024 #include "libmesh/fe_base.h"
00025 #include "libmesh/libmesh.h"
00026 
00027 // C++ includes
00028 #include <cstddef>
00029 
00030 namespace libMesh
00031 {
00032 
00033 // forward declarations
00034 class DofConstraints;
00035 class DofMap;
00036 
00037 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
00038 
00039 template <unsigned int friend_Dim, FEFamily friend_T_radial, InfMapType friend_T_map>
00040 class InfFE;
00041 
00042 #endif
00043 
00044 
00048 template <FEFamily T>
00049 struct FEOutputType
00050 {
00051   typedef Real type;
00052 };
00053 
00054 
00058 template<>
00059 struct FEOutputType<LAGRANGE_VEC>
00060 {
00061   typedef RealGradient type;
00062 };
00063 
00064 template<>
00065 struct FEOutputType<NEDELEC_ONE>
00066 {
00067   typedef RealGradient type;
00068 };
00069 
00070 
00088 //-------------------------------------------------------------
00089 // FE class definition
00090 template <unsigned int Dim, FEFamily T>
00091 class FE : public FEGenericBase<typename FEOutputType<T>::type>
00092 {
00093 public:
00094 
00098   explicit
00099   FE(const FEType& fet);
00100 
00101   typedef typename
00102   FEGenericBase<typename FEOutputType<T>::type>::OutputShape
00103   OutputShape;
00104 
00113   static OutputShape shape(const ElemType t,
00114                            const Order o,
00115                            const unsigned int i,
00116                            const Point& p);
00117 
00126   static OutputShape shape(const Elem* elem,
00127                            const Order o,
00128                            const unsigned int i,
00129                            const Point& p);
00130 
00138   static OutputShape shape_deriv(const ElemType t,
00139                                  const Order o,
00140                                  const unsigned int i,
00141                                  const unsigned int j,
00142                                  const Point& p);
00143 
00150   static OutputShape shape_deriv(const Elem* elem,
00151                                  const Order o,
00152                                  const unsigned int i,
00153                                  const unsigned int j,
00154                                  const Point& p);
00155 
00174   static OutputShape shape_second_deriv(const ElemType t,
00175                                         const Order o,
00176                                         const unsigned int i,
00177                                         const unsigned int j,
00178                                         const Point& p);
00179 
00198   static OutputShape shape_second_deriv(const Elem* elem,
00199                                         const Order o,
00200                                         const unsigned int i,
00201                                         const unsigned int j,
00202                                         const Point& p);
00203 
00210   static void nodal_soln(const Elem* elem, const Order o,
00211                          const std::vector<Number>& elem_soln,
00212                          std::vector<Number>& nodal_soln);
00213 
00218   virtual unsigned int n_shape_functions () const;
00219 
00226   static unsigned int n_shape_functions (const ElemType t,
00227                                          const Order o)
00228   { return FE<Dim,T>::n_dofs (t,o); }
00229 
00236   static unsigned int n_dofs(const ElemType t,
00237                              const Order o);
00238 
00245   static unsigned int n_dofs_at_node(const ElemType t,
00246                                      const Order o,
00247                                      const unsigned int n);
00248 
00255   static unsigned int n_dofs_per_elem(const ElemType t,
00256                                       const Order o);
00257 
00261   virtual FEContinuity get_continuity() const;
00262 
00267   virtual bool is_hierarchic() const;
00268 
00275   static void dofs_on_side(const Elem* const elem,
00276                            const Order o,
00277                            unsigned int s,
00278                            std::vector<unsigned int>& di);
00285   static void dofs_on_edge(const Elem* const elem,
00286                            const Order o,
00287                            unsigned int e,
00288                            std::vector<unsigned int>& di);
00289 
00299   static Point inverse_map (const Elem* elem,
00300                             const Point& p,
00301                             const Real tolerance = TOLERANCE,
00302                             const bool secure = true);
00303 
00314   static void inverse_map (const Elem* elem,
00315                            const std::vector<Point>& physical_points,
00316                            std::vector<Point>&       reference_points,
00317                            const Real tolerance = TOLERANCE,
00318                            const bool secure = true);
00319 
00330   virtual void reinit (const Elem* elem,
00331                        const std::vector<Point>* const pts = NULL,
00332                        const std::vector<Real>* const weights = NULL);
00333 
00343   virtual void reinit (const Elem* elem,
00344                        const unsigned int side,
00345                        const Real tolerance = TOLERANCE,
00346                        const std::vector<Point>* const pts = NULL,
00347                        const std::vector<Real>* const weights = NULL);
00348 
00358   virtual void edge_reinit (const Elem* elem,
00359                             const unsigned int edge,
00360                             const Real tolerance = TOLERANCE,
00361                             const std::vector<Point>* const pts = NULL,
00362                             const std::vector<Real>* const weights = NULL);
00363 
00368   virtual void side_map (const Elem* elem,
00369                          const Elem* side,
00370                          const unsigned int s,
00371                          const std::vector<Point>& reference_side_points,
00372                          std::vector<Point>&       reference_points);
00373 
00379   virtual void attach_quadrature_rule (QBase* q);
00380 
00386   virtual unsigned int n_quadrature_points () const;
00387 
00388 #ifdef LIBMESH_ENABLE_AMR
00389 
00395   static void compute_constraints (DofConstraints &constraints,
00396                                    DofMap &dof_map,
00397                                    const unsigned int variable_number,
00398                                    const Elem* elem);
00399 #endif // #ifdef LIBMESH_ENABLE_AMR
00400 
00407   virtual bool shapes_need_reinit() const;
00408 
00413   static Point map (const Elem* elem,
00414                     const Point& reference_point);
00415 
00420   static Point map_xi (const Elem* elem,
00421                        const Point& reference_point);
00422 
00427   static Point map_eta (const Elem* elem,
00428                         const Point& reference_point);
00429 
00434   static Point map_zeta (const Elem* elem,
00435                          const Point& reference_point);
00436 
00437 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
00438 
00442   template <unsigned int friend_Dim, FEFamily friend_T_radial, InfMapType friend_T_map>
00443   friend class InfFE;
00444 #endif
00445 
00446 protected:
00447 
00455   virtual void init_shape_functions(const std::vector<Point>& qp,
00456                                     const Elem* e);
00457 
00458 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
00459 
00464   virtual void init_base_shape_functions(const std::vector<Point>& qp,
00465                                          const Elem* e);
00466 
00467 #endif
00468 
00473   std::vector<Point> cached_nodes;
00474 
00478   ElemType last_side;
00479 
00480   unsigned int last_edge;
00481 };
00482 
00483 
00484 
00493 //-------------------------------------------------------------
00494 // FEHierarchic class definition
00495 template <unsigned int Dim>
00496 class FEClough : public FE<Dim,CLOUGH>
00497 {
00498 public:
00499 
00504   explicit
00505   FEClough(const FEType& fet);
00506 };
00507 
00508 
00509 
00518 //-------------------------------------------------------------
00519 // FEHierarchic class definition
00520 template <unsigned int Dim>
00521 class FEHermite : public FE<Dim,HERMITE>
00522 {
00523 public:
00524 
00529   explicit
00530   FEHermite(const FEType& fet);
00531 
00535   static Real hermite_raw_shape_second_deriv(const unsigned int basis_num,
00536                                              const Real xi);
00537   static Real hermite_raw_shape_deriv(const unsigned int basis_num,
00538                                       const Real xi);
00539   static Real hermite_raw_shape(const unsigned int basis_num,
00540                                 const Real xi);
00541 };
00542 
00547 //-------------------------------------------------------------
00548 // FESubdivision class definition
00549 
00550 
00551 // template specialization prototypes, needed for being able to
00552 // call them from inside FESubdivision::init_shape_functions
00553 
00554 template <>
00555 Real FE<2,SUBDIVISION>::shape(const Elem* elem,
00556                               const Order order,
00557                               const unsigned int i,
00558                               const Point& p);
00559 
00560 template <>
00561 Real FE<2,SUBDIVISION>::shape_deriv(const Elem* elem,
00562                                     const Order order,
00563                                     const unsigned int i,
00564                                     const unsigned int j,
00565                                     const Point& p);
00566 
00567 template <>
00568 Real FE<2,SUBDIVISION>::shape_second_deriv(const Elem* elem,
00569                                            const Order order,
00570                                            const unsigned int i,
00571                                            const unsigned int j,
00572                                            const Point& p);
00573 
00574 
00575 class FESubdivision : public FE<2,SUBDIVISION>
00576 {
00577 public:
00578 
00584   FESubdivision(const FEType& fet);
00585 
00596   virtual void reinit (const Elem* elem,
00597                        const std::vector<Point>* const pts = NULL,
00598                        const std::vector<Real>* const weights = NULL);
00599 
00604   virtual void reinit (const Elem*,
00605                        const unsigned int,
00606                        const Real = TOLERANCE,
00607                        const std::vector<Point>* const = NULL,
00608                        const std::vector<Real>* const = NULL)
00609   { libmesh_not_implemented(); }
00610 
00616   virtual void attach_quadrature_rule (QBase* q);
00617 
00625   virtual void init_shape_functions(const std::vector<Point>& qp,
00626                                     const Elem* elem);
00627 
00634   static Real regular_shape(const unsigned int i,
00635                             const Real v,
00636                             const Real w);
00637 
00644   static Real regular_shape_deriv(const unsigned int i,
00645                                   const unsigned int j,
00646                                   const Real v,
00647                                   const Real w);
00648 
00655   static Real regular_shape_second_deriv(const unsigned int i,
00656                                          const unsigned int j,
00657                                          const Real v,
00658                                          const Real w);
00659 
00660 
00670   static void loop_subdivision_mask(std::vector<Real> & weights,
00671                                     const unsigned int valence);
00672 
00673 
00678   static void init_subdivision_matrix(DenseMatrix<Real> &A,
00679                                       unsigned int valence);
00680 };
00681 
00682 
00683 
00692 //-------------------------------------------------------------
00693 // FEHierarchic class definition
00694 template <unsigned int Dim>
00695 class FEHierarchic : public FE<Dim,HIERARCHIC>
00696 {
00697 public:
00698 
00703   explicit
00704   FEHierarchic(const FEType& fet);
00705 };
00706 
00707 
00708 
00717 //-------------------------------------------------------------
00718 // FEL2Hierarchic class definition
00719 template <unsigned int Dim>
00720 class FEL2Hierarchic : public FE<Dim,L2_HIERARCHIC>
00721 {
00722 public:
00723 
00728   explicit
00729   FEL2Hierarchic(const FEType& fet);
00730 };
00731 
00732 
00733 
00742 //-------------------------------------------------------------
00743 // FELagrange class definition
00744 template <unsigned int Dim>
00745 class FELagrange : public FE<Dim,LAGRANGE>
00746 {
00747 public:
00748 
00753   explicit
00754   FELagrange(const FEType& fet);
00755 };
00756 
00757 
00761 //-------------------------------------------------------------
00762 // FEL2Lagrange class definition
00763 template <unsigned int Dim>
00764 class FEL2Lagrange : public FE<Dim,L2_LAGRANGE>
00765 {
00766 public:
00767 
00772   explicit
00773   FEL2Lagrange(const FEType& fet);
00774 };
00775 
00776 
00785 //-------------------------------------------------------------
00786 // FEMonomial class definition
00787 template <unsigned int Dim>
00788 class FEMonomial : public FE<Dim,MONOMIAL>
00789 {
00790 public:
00791 
00796   explicit
00797   FEMonomial(const FEType& fet);
00798 };
00799 
00800 
00801 //-------------------------------------------------------------
00802 // FEScalar class definition
00803 template <unsigned int Dim>
00804 class FEScalar : public FE<Dim,SCALAR>
00805 {
00806 public:
00807 
00814   explicit
00815   FEScalar(const FEType& fet);
00816 };
00817 
00818 
00828 //-------------------------------------------------------------
00829 // FEXYZ class definition
00830 template <unsigned int Dim>
00831 class FEXYZ : public FE<Dim,XYZ>
00832 {
00833 public:
00834 
00839   explicit
00840   FEXYZ(const FEType& fet);
00841 
00846   virtual void reinit (const Elem* elem,
00847                        const std::vector<Point>* const pts = NULL,
00848                        const std::vector<Real>* const weights = NULL)
00849   { FE<Dim,XYZ>::reinit (elem, pts, weights); }
00850 
00855   virtual void reinit (const Elem* elem,
00856                        const unsigned int side,
00857                        const Real tolerance = TOLERANCE,
00858                        const std::vector<Point>* const pts = NULL,
00859                        const std::vector<Real>* const weights = NULL);
00860 
00861 
00862 protected:
00863 
00871   virtual void init_shape_functions(const std::vector<Point>& qp,
00872                                     const Elem* e);
00873 
00884   virtual void compute_shape_functions(const Elem* elem, const std::vector<Point>& qp);
00885 
00889   void compute_face_values (const Elem* elem,
00890                             const Elem* side,
00891                             const std::vector<Real>& weights);
00892 };
00893 
00894 //-------------------------------------------------------------
00895 // FELagrangeVec class definition
00896 template <unsigned int Dim>
00897 class FELagrangeVec : public FE<Dim,LAGRANGE_VEC>
00898 {
00899 public:
00900 
00905   explicit
00906   FELagrangeVec(const FEType& fet);
00907 
00908 };
00909 
00910 //-------------------------------------------------------------
00911 // FENedelecOne class definition
00912 template <unsigned int Dim>
00913 class FENedelecOne : public FE<Dim,NEDELEC_ONE>
00914 {
00915 public:
00916 
00921   explicit
00922   FENedelecOne(const FEType& fet);
00923 
00924 };
00925 
00926 
00927 
00928 
00932 namespace FiniteElements
00933 {
00938 typedef FEClough<2> FEClough2D;
00939 
00944 typedef FE<1,HIERARCHIC> FEHierarchic1D;
00945 
00950 typedef FE<2,HIERARCHIC> FEHierarchic2D;
00951 
00956 typedef FE<3,HIERARCHIC> FEHierarchic3D;
00957 
00958 
00963 typedef FE<1,L2_HIERARCHIC> FEL2Hierarchic1D;
00964 
00969 typedef FE<2,L2_HIERARCHIC> FEL2Hierarchic2D;
00970 
00975 typedef FE<3,L2_HIERARCHIC> FEL2Hierarchic3D;
00976 
00977 
00982 typedef FE<1,LAGRANGE> FELagrange1D;
00983 
00988 typedef FE<2,LAGRANGE> FELagrange2D;
00989 
00994 typedef FE<3,LAGRANGE> FELagrange3D;
00995 
00996 
01001 typedef FE<1,L2_LAGRANGE> FEL2Lagrange1D;
01002 
01007 typedef FE<2,L2_LAGRANGE> FEL2Lagrange2D;
01008 
01013 typedef FE<3,L2_LAGRANGE> FEL2Lagrange3D;
01014 
01015 
01020 typedef FE<1,MONOMIAL> FEMonomial1D;
01021 
01026 typedef FE<2,MONOMIAL> FEMonomial2D;
01027 
01032 typedef FE<3,MONOMIAL> FEMonomial3D;
01033 
01034 }
01035 
01036 
01037 
01038 
01039 // ------------------------------------------------------------
01040 // FE class inline members
01041 template <unsigned int Dim, FEFamily T>
01042 inline
01043 FE<Dim,T>::FE (const FEType& fet) :
01044   FEGenericBase<typename FEOutputType<T>::type> (Dim,fet),
01045   last_side(INVALID_ELEM),
01046   last_edge(libMesh::invalid_uint)
01047 {
01048   // Sanity check.  Make sure the
01049   // Family specified in the template instantiation
01050   // matches the one in the FEType object
01051   libmesh_assert_equal_to (T, this->get_family());
01052 }
01053 
01054 
01055 
01056 // ------------------------------------------------------------
01057 // FEClough class inline members
01058 template <unsigned int Dim>
01059 inline
01060 FEClough<Dim>::FEClough (const FEType& fet) :
01061   FE<Dim,CLOUGH> (fet)
01062 {
01063 }
01064 
01065 
01066 
01067 // ------------------------------------------------------------
01068 // FEHermite class inline members
01069 template <unsigned int Dim>
01070 inline
01071 FEHermite<Dim>::FEHermite (const FEType& fet) :
01072   FE<Dim,HERMITE> (fet)
01073 {
01074 }
01075 
01076 
01077 
01078 // ------------------------------------------------------------
01079 // FEHierarchic class inline members
01080 template <unsigned int Dim>
01081 inline
01082 FEHierarchic<Dim>::FEHierarchic (const FEType& fet) :
01083   FE<Dim,HIERARCHIC> (fet)
01084 {
01085 }
01086 
01087 
01088 
01089 // ------------------------------------------------------------
01090 // FEL2Hierarchic class inline members
01091 template <unsigned int Dim>
01092 inline
01093 FEL2Hierarchic<Dim>::FEL2Hierarchic (const FEType& fet) :
01094   FE<Dim,L2_HIERARCHIC> (fet)
01095 {
01096 }
01097 
01098 
01099 
01100 // ------------------------------------------------------------
01101 // FELagrange class inline members
01102 template <unsigned int Dim>
01103 inline
01104 FELagrange<Dim>::FELagrange (const FEType& fet) :
01105   FE<Dim,LAGRANGE> (fet)
01106 {
01107 }
01108 
01109 // ------------------------------------------------------------
01110 // FELagrangeVec class inline members
01111 template <unsigned int Dim>
01112 inline
01113 FELagrangeVec<Dim>::FELagrangeVec (const FEType& fet) :
01114   FE<Dim,LAGRANGE_VEC> (fet)
01115 {
01116 }
01117 
01118 // ------------------------------------------------------------
01119 // FEL2Lagrange class inline members
01120 template <unsigned int Dim>
01121 inline
01122 FEL2Lagrange<Dim>::FEL2Lagrange (const FEType& fet) :
01123   FE<Dim,L2_LAGRANGE> (fet)
01124 {
01125 }
01126 
01127 
01128 
01129 // ------------------------------------------------------------
01130 // FEMonomial class inline members
01131 template <unsigned int Dim>
01132 inline
01133 FEMonomial<Dim>::FEMonomial (const FEType& fet) :
01134   FE<Dim,MONOMIAL> (fet)
01135 {
01136 }
01137 
01138 
01139 
01140 
01141 // ------------------------------------------------------------
01142 // FEXYZ class inline members
01143 template <unsigned int Dim>
01144 inline
01145 FEXYZ<Dim>::FEXYZ (const FEType& fet) :
01146   FE<Dim,XYZ> (fet)
01147 {
01148 }
01149 
01150 // ------------------------------------------------------------
01151 // FEScalar class inline members
01152 template <unsigned int Dim>
01153 inline
01154 FEScalar<Dim>::FEScalar (const FEType& fet) :
01155   FE<Dim,SCALAR> (fet)
01156 {
01157 }
01158 
01159 // ------------------------------------------------------------
01160 // FENedelecOne class inline members
01161 template <unsigned int Dim>
01162 inline
01163 FENedelecOne<Dim>::FENedelecOne (const FEType& fet) :
01164   FE<Dim,NEDELEC_ONE> (fet)
01165 {
01166 }
01167 
01168 } // namespace libMesh
01169 
01170 #endif // LIBMESH_FE_H