include/deal.II/fe/fe_tools.h

00001 //---------------------------------------------------------------------------
00002 //    @f$Id: fe_tools.h 25345 2012-03-31 08:37:04Z bangerth @f$
00003 //
00004 //    Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 by the deal.II authors
00005 //
00006 //    This file is subject to QPL and may not be  distributed
00007 //    without copyright and license information. Please refer
00008 //    to the file deal.II/doc/license.html for the  text  and
00009 //    further information on this license.
00010 //
00011 //---------------------------------------------------------------------------
00012 #ifndef __deal2__fe_tools_H
00013 #define __deal2__fe_tools_H
00014 
00015 
00016 
00017 #include <deal.II/base/config.h>
00018 #include <deal.II/base/exceptions.h>
00019 #include <deal.II/base/geometry_info.h>
00020 #include <deal.II/base/tensor.h>
00021 #include <deal.II/base/symmetric_tensor.h>
00022 
00023 #include <vector>
00024 
00025 DEAL_II_NAMESPACE_OPEN
00026 
00027 template <typename number> class FullMatrix;
00028 template <typename number> class Vector;
00029 template <int dim> class Quadrature;
00030 template <int dim, int spacedim> class FiniteElement;
00031 template <int dim, int spacedim> class DoFHandler;
00032 namespace hp
00033 {
00034   template <int dim, int spacedim> class DoFHandler;
00035 }
00036 template <int dim> class FiniteElementData;
00037 class ConstraintMatrix;
00038 namespace PETScWrappers
00039 {
00040   namespace MPI
00041   {
00042     class Vector;
00043   }
00044 }
00045 
00046 
00047 #include <deal.II/base/config.h>
00048 #include <deal.II/base/exceptions.h>
00049 #include <vector>
00050 #include <string>
00051 
00054 
00055 
00073 namespace FETools
00074 {
00092   template <int dim, int spacedim=dim>
00093   class FEFactoryBase
00094   {
00095     public:
00100       virtual FiniteElement<dim,spacedim>*
00101       get (const unsigned int degree) const = 0;
00102 
00110       virtual FiniteElement<dim,spacedim>*
00111       get (const Quadrature<1> &quad) const = 0;
00117       virtual ~FEFactoryBase();
00118   };
00119 
00136   template <class FE>
00137   class FEFactory : public FEFactoryBase<FE::dimension,FE::dimension>
00138   {
00139     public:
00144       virtual FiniteElement<FE::dimension,FE::dimension>*
00145       get (const unsigned int degree) const;
00146 
00153       virtual FiniteElement<FE::dimension,FE::dimension>*
00154       get (const Quadrature<1> &quad) const;
00155   };
00156 
00182   template<int dim, int spacedim>
00183   void compute_component_wise(
00184     const FiniteElement<dim,spacedim>&                fe,
00185     std::vector<unsigned int>&               renumbering,
00186     std::vector<std::vector<unsigned int> >& start_indices);
00187 
00206   template<int dim, int spacedim>
00207   void compute_block_renumbering (
00208     const FiniteElement<dim,spacedim>&  fe,
00209     std::vector<unsigned int>& renumbering,
00210     std::vector<unsigned int>& block_data,
00211     bool return_start_indices = true);
00212 
00231   template <int dim, typename number, int spacedim>
00232   void
00233   get_interpolation_matrix(const FiniteElement<dim,spacedim> &fe1,
00234                            const FiniteElement<dim,spacedim> &fe2,
00235                            FullMatrix<number> &interpolation_matrix);
00236 
00255   template <int dim, typename number, int spacedim>
00256   void
00257   get_back_interpolation_matrix(const FiniteElement<dim,spacedim> &fe1,
00258                                 const FiniteElement<dim,spacedim> &fe2,
00259                                 FullMatrix<number> &interpolation_matrix);
00260 
00278   template <int dim, typename number, int spacedim>
00279   void
00280   get_interpolation_difference_matrix(const FiniteElement<dim,spacedim> &fe1,
00281                                       const FiniteElement<dim,spacedim> &fe2,
00282                                       FullMatrix<number> &difference_matrix);
00283 
00289   template <int dim, typename number, int spacedim>
00290   void get_projection_matrix(const FiniteElement<dim,spacedim> &fe1,
00291                              const FiniteElement<dim,spacedim> &fe2,
00292                              FullMatrix<number> &matrix);
00293 
00337   template <int dim, int spacedim>
00338   void compute_node_matrix(FullMatrix<double>& M,
00339                            const FiniteElement<dim,spacedim>& fe);
00340 
00413   template <int dim, typename number, int spacedim>
00414   void compute_embedding_matrices(const FiniteElement<dim,spacedim> &fe,
00415                                   std::vector<std::vector<FullMatrix<number> > >& matrices,
00416                                   const bool isotropic_only = false);
00417 
00445   template <int dim, typename number, int spacedim>
00446   void
00447   compute_face_embedding_matrices(const FiniteElement<dim,spacedim>& fe,
00448                                   FullMatrix<number> (&matrices)[GeometryInfo<dim>::max_children_per_face],
00449                                   const unsigned int face_coarse,
00450                                   const unsigned int face_fine);
00451 
00505   template <int dim, typename number, int spacedim>
00506   void compute_projection_matrices(
00507     const FiniteElement<dim,spacedim> &fe,
00508     std::vector<std::vector<FullMatrix<number> > >& matrices,
00509     const bool isotropic_only = false);
00510 
00672   template <int dim, int spacedim>
00673   void
00674   compute_projection_from_quadrature_points_matrix (const FiniteElement<dim,spacedim> &fe,
00675                                                     const Quadrature<dim>    &lhs_quadrature,
00676                                                     const Quadrature<dim>    &rhs_quadrature,
00677                                                     FullMatrix<double>       &X);
00678 
00690   template <int dim, int spacedim>
00691   void
00692   compute_interpolation_to_quadrature_points_matrix (const FiniteElement<dim,spacedim> &fe,
00693                                                      const Quadrature<dim>    &quadrature,
00694                                                      FullMatrix<double>       &I_q);
00695 
00722   template <int dim>
00723   void
00724   compute_projection_from_quadrature_points(
00725     const FullMatrix<double>    &projection_matrix,
00726     const std::vector< Tensor<1, dim > >    &vector_of_tensors_at_qp,
00727     std::vector< Tensor<1, dim > >          &vector_of_tensors_at_nodes);
00728 
00729 
00730 
00735   template <int dim>
00736   void
00737   compute_projection_from_quadrature_points(
00738     const FullMatrix<double>    &projection_matrix,
00739     const std::vector< SymmetricTensor<2, dim > >   &vector_of_tensors_at_qp,
00740     std::vector< SymmetricTensor<2, dim > >         &vector_of_tensors_at_nodes);
00741 
00742 
00743 
00744 
00756   template <int dim, int spacedim>
00757   void
00758   compute_projection_from_face_quadrature_points_matrix (const FiniteElement<dim, spacedim> &fe,
00759                                                          const Quadrature<dim-1>    &lhs_quadrature,
00760                                                          const Quadrature<dim-1>    &rhs_quadrature,
00761                                                          const typename DoFHandler<dim, spacedim>::active_cell_iterator & cell,
00762                                                          unsigned int face,
00763                                                          FullMatrix<double>       &X);
00764 
00765 
00766 
00768 
00829   template <int dim, int spacedim,
00830             template <int,int> class DH1,
00831             template <int,int> class DH2,
00832             class InVector, class OutVector>
00833   void
00834   interpolate (const DH1<dim,spacedim> &dof1,
00835                const InVector          &u1,
00836                const DH2<dim,spacedim> &dof2,
00837                OutVector               &u2);
00838 
00872   template <int dim, int spacedim,
00873             template <int, int> class DH1,
00874             template <int, int> class DH2,
00875             class InVector, class OutVector>
00876   void interpolate (const DH1<dim,spacedim>  &dof1,
00877                     const InVector           &u1,
00878                     const DH2<dim,spacedim>  &dof2,
00879                     const ConstraintMatrix   &constraints,
00880                     OutVector&                u2);
00881 
00908   template <int dim, class InVector, class OutVector, int spacedim>
00909   void back_interpolate (const DoFHandler<dim,spacedim>    &dof1,
00910                          const InVector           &u1,
00911                          const FiniteElement<dim,spacedim> &fe2,
00912                          OutVector                &u1_interpolated);
00913 
00920   template <int dim,
00921             template <int> class DH,
00922             class InVector, class OutVector, int spacedim>
00923   void back_interpolate (const DH<dim>            &dof1,
00924                          const InVector           &u1,
00925                          const FiniteElement<dim,spacedim> &fe2,
00926                          OutVector                &u1_interpolated);
00927 
00955   template <int dim, class InVector, class OutVector, int spacedim>
00956   void back_interpolate (const DoFHandler<dim,spacedim>&  dof1,
00957                          const ConstraintMatrix& constraints1,
00958                          const InVector&         u1,
00959                          const DoFHandler<dim,spacedim>&  dof2,
00960                          const ConstraintMatrix& constraints2,
00961                          OutVector&              u1_interpolated);
00962 
00979   template <int dim, class InVector, class OutVector, int spacedim>
00980   void interpolation_difference(const DoFHandler<dim,spacedim> &dof1,
00981                                 const InVector &z1,
00982                                 const FiniteElement<dim,spacedim> &fe2,
00983                                 OutVector &z1_difference);
00984 
01002   template <int dim, class InVector, class OutVector, int spacedim>
01003   void interpolation_difference(const DoFHandler<dim,spacedim>&  dof1,
01004                                 const ConstraintMatrix& constraints1,
01005                                 const InVector&         z1,
01006                                 const DoFHandler<dim,spacedim>&  dof2,
01007                                 const ConstraintMatrix& constraints2,
01008                                 OutVector&              z1_difference);
01009 
01010 
01011 
01026   template <int dim, class InVector, class OutVector, int spacedim>
01027   void project_dg (const DoFHandler<dim,spacedim>& dof1,
01028                    const InVector&        u1,
01029                    const DoFHandler<dim,spacedim>& dof2,
01030                    OutVector&             u2);
01031 
01067   template <int dim, class InVector, class OutVector, int spacedim>
01068   void extrapolate (const DoFHandler<dim,spacedim>& dof1,
01069                     const InVector&        z1,
01070                     const DoFHandler<dim,spacedim>& dof2,
01071                     OutVector&             z2);
01072 
01093   template <int dim, class InVector, class OutVector, int spacedim>
01094   void extrapolate (const DoFHandler<dim,spacedim>&  dof1,
01095                     const InVector&         z1,
01096                     const DoFHandler<dim,spacedim>&  dof2,
01097                     const ConstraintMatrix& constraints,
01098                     OutVector&              z2);
01100 
01151   template <int dim>
01152   void
01153   hierarchic_to_lexicographic_numbering (const FiniteElementData<dim> &fe_data,
01154                                          std::vector<unsigned int>    &h2l);
01155 
01162   template <int dim>
01163   std::vector<unsigned int>
01164   hierarchic_to_lexicographic_numbering (const FiniteElementData<dim> &fe_data);
01165 
01175   template <int dim>
01176   void
01177   lexicographic_to_hierarchic_numbering (const FiniteElementData<dim> &fe_data,
01178                                          std::vector<unsigned int>    &l2h);
01179 
01186   template <int dim>
01187   std::vector<unsigned int>
01188   lexicographic_to_hierarchic_numbering (const FiniteElementData<dim> &fe_data);
01189 
01251   template <int dim>
01252   FiniteElement<dim, dim> *
01253   get_fe_from_name (const std::string &name);
01254 
01255 
01338   template <int dim, int spacedim>
01339   void add_fe_name (const std::string& name,
01340                     const FEFactoryBase<dim,spacedim>* factory);
01341 
01356   DeclException1 (ExcInvalidFEName,
01357                   std::string,
01358                   << "Can't re-generate a finite element from the string '"
01359                   << arg1 << "'.");
01360 
01380   DeclException2 (ExcInvalidFEDimension,
01381                   char, int,
01382                   << "The dimension " << arg1
01383                   << " in the finite element string must match "
01384                   << "the space dimension "
01385                   << arg2 << ".");
01386 
01392   DeclException0 (ExcInvalidFE);
01393 
01400   DeclException0 (ExcFENotPrimitive);
01406   DeclException0 (ExcTriangulationMismatch);
01407 
01416   DeclException1 (ExcHangingNodesNotAllowed,
01417                   int,
01418                   << "You are using continuous elements on a grid with "
01419                   << "hanging nodes but without providing hanging node "
01420                   << "constraints. Use the respective function with "
01421                   << "additional ConstraintMatrix argument(s), instead.");
01427   DeclException0 (ExcGridNotRefinedAtLeastOnce);
01435   DeclException4 (ExcMatrixDimensionMismatch,
01436                   int, int, int, int,
01437                   << "This is a " << arg1 << "x" << arg2 << " matrix, "
01438                   << "but should be a " << arg3 << "x" << arg4 << " matrix.");
01439 
01447   DeclException1(ExcLeastSquaresError, double,
01448                  << "Least squares fit leaves a gap of " << arg1);
01449 
01456   DeclException2 (ExcNotGreaterThan,
01457                   int,  int,
01458                   << arg1 << " must be greater than " << arg2);
01459 }
01460 
01461 
01462 #ifndef DOXYGEN
01463 
01464 namespace FETools
01465 {
01466   template <class FE>
01467   FiniteElement<FE::dimension, FE::dimension>*
01468   FEFactory<FE>::get (const unsigned int degree) const
01469   {
01470     return new FE(degree);
01471   }
01472 }
01473 
01474 #endif
01475 
01478 DEAL_II_NAMESPACE_CLOSE
01479 
01480 /*----------------------------   fe_tools.h     ---------------------------*/
01481 /* end of #ifndef __deal2__fe_tools_H */
01482 #endif
01483 /*----------------------------   fe_tools.h     ---------------------------*/
01484 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

deal.II documentation generated on Tue May 22 2012 12:06:08 by doxygen 1.7.3