Reference documentation for deal.II version 8.4.2
fe_tools.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2000 - 2016 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii__fe_tools_H
17 #define dealii__fe_tools_H
18 
19 
20 
21 #include <deal.II/base/config.h>
22 #include <deal.II/base/subscriptor.h>
23 #include <deal.II/base/exceptions.h>
24 #include <deal.II/base/geometry_info.h>
25 #include <deal.II/base/tensor.h>
26 #include <deal.II/base/symmetric_tensor.h>
27 
28 #include <vector>
29 #include <string>
30 
31 
32 DEAL_II_NAMESPACE_OPEN
33 
34 template <typename number> class FullMatrix;
35 template <typename number> class Vector;
36 template <int dim> class Quadrature;
37 template <int dim, int spacedim> class FiniteElement;
38 template <int dim, int spacedim> class DoFHandler;
39 namespace hp
40 {
41  template <int dim, int spacedim> class DoFHandler;
42 }
43 template <int dim> class FiniteElementData;
44 class ConstraintMatrix;
45 
46 
47 
50 
51 
67 namespace FETools
68 {
79  template <int dim, int spacedim=dim>
80  class FEFactoryBase : public Subscriptor
81  {
82  public:
87  get (const unsigned int degree) const = 0;
88 
95  get (const Quadrature<1> &quad) const = 0;
99  virtual ~FEFactoryBase();
100  };
101 
113  template <class FE>
114  class FEFactory : public FEFactoryBase<FE::dimension,FE::space_dimension>
115  {
116  public:
121  get (const unsigned int degree) const;
122 
128  get (const Quadrature<1> &quad) const;
129  };
130 
146  template<int dim, int spacedim>
147  void compute_component_wise(
148  const FiniteElement<dim,spacedim> &fe,
149  std::vector<unsigned int> &renumbering,
150  std::vector<std::vector<unsigned int> > &start_indices);
151 
167  template<int dim, int spacedim>
169  const FiniteElement<dim,spacedim> &fe,
170  std::vector<types::global_dof_index> &renumbering,
171  std::vector<types::global_dof_index> &block_data,
172  bool return_start_indices = true);
173 
187  template <int dim, typename number, int spacedim>
188  void
190  const FiniteElement<dim,spacedim> &fe2,
191  FullMatrix<number> &interpolation_matrix);
192 
204  template <int dim, typename number, int spacedim>
205  void
207  const FiniteElement<dim,spacedim> &fe2,
208  FullMatrix<number> &interpolation_matrix);
209 
220  template <int dim, typename number, int spacedim>
221  void
223  const FiniteElement<dim,spacedim> &fe2,
224  FullMatrix<number> &difference_matrix);
225 
229  template <int dim, typename number, int spacedim>
231  const FiniteElement<dim,spacedim> &fe2,
232  FullMatrix<number> &matrix);
233 
261  template <int dim, int spacedim>
263  const FiniteElement<dim,spacedim> &fe);
264 
303  template <int dim, typename number, int spacedim>
305  std::vector<std::vector<FullMatrix<number> > > &matrices,
306  const bool isotropic_only = false,
307  const double threshold = 1.e-12);
308 
330  template <int dim, typename number, int spacedim>
331  void
334  const unsigned int face_coarse,
335  const unsigned int face_fine,
336  const double threshold = 1.e-12);
337 
365  template <int dim, typename number, int spacedim>
367  const FiniteElement<dim,spacedim> &fe,
368  std::vector<std::vector<FullMatrix<number> > > &matrices,
369  const bool isotropic_only = false);
370 
456  template <int dim, int spacedim>
457  void
459  const Quadrature<dim> &lhs_quadrature,
460  const Quadrature<dim> &rhs_quadrature,
461  FullMatrix<double> &X);
462 
470  template <int dim, int spacedim>
471  void
473  const Quadrature<dim> &quadrature,
474  FullMatrix<double> &I_q);
475 
489  template <int dim>
490  void
492  const FullMatrix<double> &projection_matrix,
493  const std::vector< Tensor<1, dim > > &vector_of_tensors_at_qp,
494  std::vector< Tensor<1, dim > > &vector_of_tensors_at_nodes);
495 
496 
497 
501  template <int dim>
502  void
503  compute_projection_from_quadrature_points(
504  const FullMatrix<double> &projection_matrix,
505  const std::vector< SymmetricTensor<2, dim > > &vector_of_tensors_at_qp,
506  std::vector< SymmetricTensor<2, dim > > &vector_of_tensors_at_nodes);
507 
508 
509 
510 
520  template <int dim, int spacedim>
521  void
523  const Quadrature<dim-1> &lhs_quadrature,
524  const Quadrature<dim-1> &rhs_quadrature,
526  const unsigned int face,
527  FullMatrix<double> &X);
528 
529 
530 
532 
564  template <int dim, int spacedim,
565  template <int, int> class DoFHandlerType1,
566  template <int, int> class DoFHandlerType2,
567  class InVector, class OutVector>
568  void
569  interpolate (const DoFHandlerType1<dim,spacedim> &dof1,
570  const InVector &u1,
571  const DoFHandlerType2<dim,spacedim> &dof2,
572  OutVector &u2);
573 
590  template <int dim, int spacedim,
591  template <int, int> class DoFHandlerType1,
592  template <int, int> class DoFHandlerType2,
593  class InVector, class OutVector>
594  void interpolate (const DoFHandlerType1<dim,spacedim> &dof1,
595  const InVector &u1,
596  const DoFHandlerType2<dim,spacedim> &dof2,
597  const ConstraintMatrix &constraints,
598  OutVector &u2);
599 
613  template <int dim, class InVector, class OutVector, int spacedim>
614  void back_interpolate (const DoFHandler<dim,spacedim> &dof1,
615  const InVector &u1,
616  const FiniteElement<dim,spacedim> &fe2,
617  OutVector &u1_interpolated);
618 
623  template <int dim,
624  template <int> class DoFHandlerType,
625  class InVector, class OutVector, int spacedim>
626  void back_interpolate (const DoFHandlerType<dim> &dof1,
627  const InVector &u1,
628  const FiniteElement<dim,spacedim> &fe2,
629  OutVector &u1_interpolated);
630 
643  template <int dim, class InVector, class OutVector, int spacedim>
644  void back_interpolate (const DoFHandler<dim,spacedim> &dof1,
645  const ConstraintMatrix &constraints1,
646  const InVector &u1,
647  const DoFHandler<dim,spacedim> &dof2,
648  const ConstraintMatrix &constraints2,
649  OutVector &u1_interpolated);
650 
660  template <int dim, class InVector, class OutVector, int spacedim>
662  const InVector &z1,
663  const FiniteElement<dim,spacedim> &fe2,
664  OutVector &z1_difference);
665 
678  template <int dim, class InVector, class OutVector, int spacedim>
679  void interpolation_difference(const DoFHandler<dim,spacedim> &dof1,
680  const ConstraintMatrix &constraints1,
681  const InVector &z1,
682  const DoFHandler<dim,spacedim> &dof2,
683  const ConstraintMatrix &constraints2,
684  OutVector &z1_difference);
685 
686 
687 
696  template <int dim, class InVector, class OutVector, int spacedim>
697  void project_dg (const DoFHandler<dim,spacedim> &dof1,
698  const InVector &u1,
699  const DoFHandler<dim,spacedim> &dof2,
700  OutVector &u2);
701 
760  template <int dim, class InVector, class OutVector, int spacedim>
761  void extrapolate (const DoFHandler<dim,spacedim> &dof1,
762  const InVector &z1,
763  const DoFHandler<dim,spacedim> &dof2,
764  OutVector &z2);
765 
778  template <int dim, class InVector, class OutVector, int spacedim>
779  void extrapolate (const DoFHandler<dim,spacedim> &dof1,
780  const InVector &z1,
781  const DoFHandler<dim,spacedim> &dof2,
782  const ConstraintMatrix &constraints,
783  OutVector &z2);
785 
810  template <int dim>
811  void
812  hierarchic_to_lexicographic_numbering (unsigned int degree,
813  std::vector<unsigned int> &h2l);
814 
815  template <int dim>
816  void
817  hierarchic_to_lexicographic_numbering (const FiniteElementData<dim> &fe_data,
818  std::vector<unsigned int> &h2l);
819 
824  template <int dim>
825  std::vector<unsigned int>
826  hierarchic_to_lexicographic_numbering (const FiniteElementData<dim> &fe_data);
827 
833  template <int dim>
834  void
836  std::vector<unsigned int> &l2h);
837 
842  template <int dim>
843  std::vector<unsigned int>
844  lexicographic_to_hierarchic_numbering (const FiniteElementData<dim> &fe_data);
845 
880  template <int dim, int spacedim>
882  get_fe_by_name (const std::string &name);
883 
884 
888  template <int dim>
890  get_fe_from_name (const std::string &name);
891 
892 
935  template <int dim, int spacedim>
936  void add_fe_name (const std::string &name,
937  const FEFactoryBase<dim,spacedim> *factory);
938 
948  DeclException1 (ExcInvalidFEName,
949  std::string,
950  << "Can't re-generate a finite element from the string '"
951  << arg1 << "'.");
952 
964  DeclException2 (ExcInvalidFEDimension,
965  char, int,
966  << "The dimension " << arg1
967  << " in the finite element string must match "
968  << "the space dimension "
969  << arg2 << ".");
970 
976  DeclException0 (ExcInvalidFE);
977 
984  DeclException0 (ExcFENotPrimitive);
990  DeclException0 (ExcTriangulationMismatch);
991 
998  DeclException1 (ExcHangingNodesNotAllowed,
999  int,
1000  << "You are using continuous elements on a grid with "
1001  << "hanging nodes but without providing hanging node "
1002  << "constraints. Use the respective function with "
1003  << "additional ConstraintMatrix argument(s), instead."
1004  << (arg1?"":""));
1010  DeclException0 (ExcGridNotRefinedAtLeastOnce);
1016  DeclException4 (ExcMatrixDimensionMismatch,
1017  int, int, int, int,
1018  << "This is a " << arg1 << "x" << arg2 << " matrix, "
1019  << "but should be a " << arg3 << "x" << arg4 << " matrix.");
1020 
1026  DeclException1(ExcLeastSquaresError, double,
1027  << "Least squares fit leaves a gap of " << arg1);
1028 
1034  DeclException2 (ExcNotGreaterThan,
1035  int, int,
1036  << arg1 << " must be greater than " << arg2);
1037 }
1038 
1039 
1040 #ifndef DOXYGEN
1041 
1042 namespace FETools
1043 {
1044  template <class FE>
1046  FEFactory<FE>::get (const unsigned int degree) const
1047  {
1048  return new FE(degree);
1049  }
1050 }
1051 
1052 #endif
1053 
1056 DEAL_II_NAMESPACE_CLOSE
1057 
1058 /*---------------------------- fe_tools.h ---------------------------*/
1059 /* end of #ifndef dealii__fe_tools_H */
1060 #endif
1061 /*---------------------------- fe_tools.h ---------------------------*/
void project_dg(const DoFHandler< dim, spacedim > &dof1, const InVector &u1, const DoFHandler< dim, spacedim > &dof2, OutVector &u2)
void compute_interpolation_to_quadrature_points_matrix(const FiniteElement< dim, spacedim > &fe, const Quadrature< dim > &quadrature, FullMatrix< double > &I_q)
Definition: fe_tools.cc:1687
#define DeclException2(Exception2, type1, type2, outsequence)
Definition: exceptions.h:552
void compute_block_renumbering(const FiniteElement< dim, spacedim > &fe, std::vector< types::global_dof_index > &renumbering, std::vector< types::global_dof_index > &block_data, bool return_start_indices=true)
Definition: fe_tools.cc:385
void compute_face_embedding_matrices(const FiniteElement< dim, spacedim > &fe, FullMatrix< number >(&matrices)[GeometryInfo< dim >::max_children_per_face], const unsigned int face_coarse, const unsigned int face_fine, const double threshold=1.e-12)
Definition: fe_tools.cc:914
void interpolation_difference(const DoFHandler< dim, spacedim > &dof1, const InVector &z1, const FiniteElement< dim, spacedim > &fe2, OutVector &z1_difference)
void hierarchic_to_lexicographic_numbering(unsigned int degree, std::vector< unsigned int > &h2l)
Definition: fe_tools.cc:1896
ActiveSelector::active_cell_iterator active_cell_iterator
Definition: dof_handler.h:221
void compute_embedding_matrices(const FiniteElement< dim, spacedim > &fe, std::vector< std::vector< FullMatrix< number > > > &matrices, const bool isotropic_only=false, const double threshold=1.e-12)
Definition: fe_tools.cc:891
void extrapolate(const DoFHandler< dim, spacedim > &dof1, const InVector &z1, const DoFHandler< dim, spacedim > &dof2, OutVector &z2)
void get_projection_matrix(const FiniteElement< dim, spacedim > &fe1, const FiniteElement< dim, spacedim > &fe2, FullMatrix< number > &matrix)
Definition: fe_tools.cc:549
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:542
void get_interpolation_matrix(const FiniteElement< dim, spacedim > &fe1, const FiniteElement< dim, spacedim > &fe2, FullMatrix< number > &interpolation_matrix)
Definition: fe_tools.cc:433
void compute_projection_from_face_quadrature_points_matrix(const FiniteElement< dim, spacedim > &fe, const Quadrature< dim-1 > &lhs_quadrature, const Quadrature< dim-1 > &rhs_quadrature, const typename DoFHandler< dim, spacedim >::active_cell_iterator &cell, const unsigned int face, FullMatrix< double > &X)
Definition: fe_tools.cc:1836
void back_interpolate(const DoFHandler< dim, spacedim > &dof1, const InVector &u1, const FiniteElement< dim, spacedim > &fe2, OutVector &u1_interpolated)
void compute_projection_from_quadrature_points_matrix(const FiniteElement< dim, spacedim > &fe, const Quadrature< dim > &lhs_quadrature, const Quadrature< dim > &rhs_quadrature, FullMatrix< double > &X)
Definition: fe_tools.cc:1647
#define DeclException0(Exception0)
Definition: exceptions.h:522
void get_back_interpolation_matrix(const FiniteElement< dim, spacedim > &fe1, const FiniteElement< dim, spacedim > &fe2, FullMatrix< number > &interpolation_matrix)
Definition: fe_tools.cc:497
void compute_projection_from_quadrature_points(const FullMatrix< double > &projection_matrix, const std::vector< Tensor< 1, dim > > &vector_of_tensors_at_qp, std::vector< Tensor< 1, dim > > &vector_of_tensors_at_nodes)
Definition: fe_tools.cc:1705
Definition: hp.h:102
void lexicographic_to_hierarchic_numbering(const FiniteElementData< dim > &fe_data, std::vector< unsigned int > &l2h)
Definition: fe_tools.cc:2086
FiniteElement< dim, dim > * get_fe_from_name(const std::string &name)
Definition: fe_tools.cc:1638
void add_fe_name(const std::string &name, const FEFactoryBase< dim, spacedim > *factory)
Definition: fe_tools.cc:1277
void get_interpolation_difference_matrix(const FiniteElement< dim, spacedim > &fe1, const FiniteElement< dim, spacedim > &fe2, FullMatrix< number > &difference_matrix)
Definition: fe_tools.cc:523
#define DeclException4(Exception4, type1, type2, type3, type4, outsequence)
Definition: exceptions.h:572
void compute_projection_matrices(const FiniteElement< dim, spacedim > &fe, std::vector< std::vector< FullMatrix< number > > > &matrices, const bool isotropic_only=false)
Definition: fe_tools.cc:1117
FiniteElement< dim, spacedim > * get_fe_by_name(const std::string &name)
Definition: fe_tools.cc:1549
void compute_node_matrix(FullMatrix< double > &M, const FiniteElement< dim, spacedim > &fe)
Definition: fe_tools.cc:633
void interpolate(const DoFHandlerType1< dim, spacedim > &dof1, const InVector &u1, const DoFHandlerType2< dim, spacedim > &dof2, OutVector &u2)