Reference documentation for deal.II version 8.5.1
fe_tools.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2000 - 2017 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 #include <deal.II/distributed/tria.h>
28 #include <deal.II/fe/component_mask.h>
29 #include <deal.II/lac/parallel_vector.h>
30 
31 
32 
33 #include <vector>
34 #include <string>
35 
36 
37 DEAL_II_NAMESPACE_OPEN
38 
39 template <typename number> class FullMatrix;
40 template <int dim> class Quadrature;
41 template <int dim, int spacedim> class FiniteElement;
42 template <int dim, int spacedim> class DoFHandler;
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>
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 
301  template <int dim, int spacedim>
304 
311  template <int dim, int spacedim>
312  void
314  const FiniteElement<dim,spacedim> &fe) DEAL_II_DEPRECATED;
315 
354  template <int dim, typename number, int spacedim>
356  std::vector<std::vector<FullMatrix<number> > > &matrices,
357  const bool isotropic_only = false,
358  const double threshold = 1.e-12);
359 
381  template <int dim, typename number, int spacedim>
382  void
385  const unsigned int face_coarse,
386  const unsigned int face_fine,
387  const double threshold = 1.e-12);
388 
416  template <int dim, typename number, int spacedim>
418  const FiniteElement<dim,spacedim> &fe,
419  std::vector<std::vector<FullMatrix<number> > > &matrices,
420  const bool isotropic_only = false);
421 
507  template <int dim, int spacedim>
508  void
510  const Quadrature<dim> &lhs_quadrature,
511  const Quadrature<dim> &rhs_quadrature,
512  FullMatrix<double> &X);
513 
521  template <int dim, int spacedim>
522  void
524  const Quadrature<dim> &quadrature,
525  FullMatrix<double> &I_q);
526 
540  template <int dim>
541  void
543  const FullMatrix<double> &projection_matrix,
544  const std::vector< Tensor<1, dim > > &vector_of_tensors_at_qp,
545  std::vector< Tensor<1, dim > > &vector_of_tensors_at_nodes);
546 
547 
548 
552  template <int dim>
553  void
555  const FullMatrix<double> &projection_matrix,
556  const std::vector< SymmetricTensor<2, dim > > &vector_of_tensors_at_qp,
557  std::vector< SymmetricTensor<2, dim > > &vector_of_tensors_at_nodes);
558 
559 
560 
561 
571  template <int dim, int spacedim>
572  void
574  const Quadrature<dim-1> &lhs_quadrature,
575  const Quadrature<dim-1> &rhs_quadrature,
577  const unsigned int face,
578  FullMatrix<double> &X);
579 
580 
581 
583 
615  template <int dim, int spacedim,
616  template <int, int> class DoFHandlerType1,
617  template <int, int> class DoFHandlerType2,
618  class InVector, class OutVector>
619  void
620  interpolate (const DoFHandlerType1<dim,spacedim> &dof1,
621  const InVector &u1,
622  const DoFHandlerType2<dim,spacedim> &dof2,
623  OutVector &u2);
624 
641  template <int dim, int spacedim,
642  template <int, int> class DoFHandlerType1,
643  template <int, int> class DoFHandlerType2,
644  class InVector, class OutVector>
645  void interpolate (const DoFHandlerType1<dim,spacedim> &dof1,
646  const InVector &u1,
647  const DoFHandlerType2<dim,spacedim> &dof2,
648  const ConstraintMatrix &constraints,
649  OutVector &u2);
650 
666  template <int dim,
667  template <int,int> class DoFHandlerType,
668  class InVector, class OutVector, int spacedim>
669  void back_interpolate (const DoFHandlerType<dim,spacedim> &dof1,
670  const InVector &u1,
671  const FiniteElement<dim,spacedim> &fe2,
672  OutVector &u1_interpolated);
673 
686  template <int dim, class InVector, class OutVector, int spacedim>
687  void back_interpolate (const DoFHandler<dim,spacedim> &dof1,
688  const ConstraintMatrix &constraints1,
689  const InVector &u1,
690  const DoFHandler<dim,spacedim> &dof2,
691  const ConstraintMatrix &constraints2,
692  OutVector &u1_interpolated);
693 
703  template <int dim, class InVector, class OutVector, int spacedim>
705  const InVector &z1,
706  const FiniteElement<dim,spacedim> &fe2,
707  OutVector &z1_difference);
708 
721  template <int dim, class InVector, class OutVector, int spacedim>
723  const ConstraintMatrix &constraints1,
724  const InVector &z1,
725  const DoFHandler<dim,spacedim> &dof2,
726  const ConstraintMatrix &constraints2,
727  OutVector &z1_difference);
728 
729 
730 
739  template <int dim, class InVector, class OutVector, int spacedim>
740  void project_dg (const DoFHandler<dim,spacedim> &dof1,
741  const InVector &u1,
742  const DoFHandler<dim,spacedim> &dof2,
743  OutVector &u2);
744 
804  template <int dim, class InVector, class OutVector, int spacedim>
805  void extrapolate (const DoFHandler<dim,spacedim> &dof1,
806  const InVector &z1,
807  const DoFHandler<dim,spacedim> &dof2,
808  OutVector &z2);
809 
822  template <int dim, class InVector, class OutVector, int spacedim>
823  void extrapolate (const DoFHandler<dim,spacedim> &dof1,
824  const InVector &z1,
825  const DoFHandler<dim,spacedim> &dof2,
826  const ConstraintMatrix &constraints,
827  OutVector &z2);
828 
830 
855  template <int dim>
856  void
857  hierarchic_to_lexicographic_numbering (unsigned int degree,
858  std::vector<unsigned int> &h2l);
859 
860  template <int dim>
861  void
863  std::vector<unsigned int> &h2l);
864 
869  template <int dim>
870  std::vector<unsigned int>
872 
878  template <int dim>
879  void
881  std::vector<unsigned int> &l2h);
882 
887  template <int dim>
888  std::vector<unsigned int>
890 
891 
965  namespace Compositing
966  {
967 
984  template <int dim, int spacedim>
986  multiply_dof_numbers (const std::vector<const FiniteElement<dim,spacedim>*> &fes,
987  const std::vector<unsigned int> &multiplicities,
988  const bool do_tensor_product = true);
989 
993  template <int dim, int spacedim>
996  const unsigned int N1,
997  const FiniteElement<dim,spacedim> *fe2=NULL,
998  const unsigned int N2=0,
999  const FiniteElement<dim,spacedim> *fe3=NULL,
1000  const unsigned int N3=0,
1001  const FiniteElement<dim,spacedim> *fe4=NULL,
1002  const unsigned int N4=0,
1003  const FiniteElement<dim,spacedim> *fe5=NULL,
1004  const unsigned int N5=0);
1005 
1018  template <int dim, int spacedim>
1019  std::vector<bool>
1021  const std::vector<unsigned int> &multiplicities);
1022 
1037  template <int dim, int spacedim>
1038  std::vector<bool>
1040  const unsigned int N1,
1041  const FiniteElement<dim,spacedim> *fe2=NULL,
1042  const unsigned int N2=0,
1043  const FiniteElement<dim,spacedim> *fe3=NULL,
1044  const unsigned int N3=0,
1045  const FiniteElement<dim,spacedim> *fe4=NULL,
1046  const unsigned int N4=0,
1047  const FiniteElement<dim,spacedim> *fe5=NULL,
1048  const unsigned int N5=0);
1049 
1066  template <int dim, int spacedim>
1067  std::vector<ComponentMask>
1068  compute_nonzero_components (const std::vector<const FiniteElement<dim,spacedim>*> &fes,
1069  const std::vector<unsigned int> &multiplicities,
1070  const bool do_tensor_product = true);
1071 
1090  template <int dim, int spacedim>
1091  std::vector<ComponentMask>
1093  const unsigned int N1,
1094  const FiniteElement<dim,spacedim> *fe2=NULL,
1095  const unsigned int N2=0,
1096  const FiniteElement<dim,spacedim> *fe3=NULL,
1097  const unsigned int N3=0,
1098  const FiniteElement<dim,spacedim> *fe4=NULL,
1099  const unsigned int N4=0,
1100  const FiniteElement<dim,spacedim> *fe5=NULL,
1101  const unsigned int N5=0,
1102  const bool do_tensor_product = true);
1103 
1120  template <int dim, int spacedim>
1121  void
1122  build_cell_tables(std::vector< std::pair< std::pair< unsigned int, unsigned int >, unsigned int > > &system_to_base_table,
1123  std::vector< std::pair< unsigned int, unsigned int > > &system_to_component_table,
1124  std::vector< std::pair< std::pair< unsigned int, unsigned int >, unsigned int > > &component_to_base_table,
1125  const FiniteElement<dim,spacedim> &finite_element,
1126  const bool do_tensor_product = true);
1127 
1143  template <int dim, int spacedim>
1144  void
1145  build_face_tables(std::vector< std::pair< std::pair< unsigned int, unsigned int >, unsigned int > > &face_system_to_base_table,
1146  std::vector< std::pair< unsigned int, unsigned int > > &face_system_to_component_table,
1147  const FiniteElement<dim,spacedim> &finite_element,
1148  const bool do_tensor_product = true);
1149 
1150  }
1151 
1152 
1187  template <int dim, int spacedim
1188 #ifdef DEAL_II_WITH_CXX11
1189  =dim
1190 #endif
1191  >
1193  get_fe_by_name (const std::string &name);
1194 
1195 
1199  template <int dim>
1201  get_fe_from_name (const std::string &name) DEAL_II_DEPRECATED;
1202 
1203 
1246  template <int dim, int spacedim>
1247  void add_fe_name (const std::string &name,
1248  const FEFactoryBase<dim,spacedim> *factory);
1249 
1260  std::string,
1261  << "Can't re-generate a finite element from the string '"
1262  << arg1 << "'.");
1263 
1276  char, int,
1277  << "The dimension " << arg1
1278  << " in the finite element string must match "
1279  << "the space dimension "
1280  << arg2 << ".");
1281 
1288 
1302 
1310  int,
1311  << "You are using continuous elements on a grid with "
1312  << "hanging nodes but without providing hanging node "
1313  << "constraints. Use the respective function with "
1314  << "additional ConstraintMatrix argument(s), instead."
1315  << (arg1?"":""));
1328  int, int, int, int,
1329  << "This is a " << arg1 << "x" << arg2 << " matrix, "
1330  << "but should be a " << arg3 << "x" << arg4 << " matrix.");
1331 
1338  << "Least squares fit leaves a gap of " << arg1);
1339 
1346  int, int,
1347  << arg1 << " must be greater than " << arg2);
1348 }
1349 
1350 
1351 #ifndef DOXYGEN
1352 
1353 namespace FETools
1354 {
1355  template <class FE>
1357  FEFactory<FE>::get (const unsigned int degree) const
1358  {
1359  return new FE(degree);
1360  }
1361 }
1362 
1363 #endif
1364 
1367 DEAL_II_NAMESPACE_CLOSE
1368 
1369 /*---------------------------- fe_tools.h ---------------------------*/
1370 /* end of #ifndef dealii__fe_tools_H */
1371 #endif
1372 /*---------------------------- fe_tools.h ---------------------------*/
Definition: tria.h:67
void project_dg(const DoFHandler< dim, spacedim > &dof1, const InVector &u1, const DoFHandler< dim, spacedim > &dof2, OutVector &u2)
static ::ExceptionBase & ExcLeastSquaresError(double arg1)
void compute_interpolation_to_quadrature_points_matrix(const FiniteElement< dim, spacedim > &fe, const Quadrature< dim > &quadrature, FullMatrix< double > &I_q)
Definition: fe_tools.cc:2719
#define DeclException2(Exception2, type1, type2, outsequence)
Definition: exceptions.h:576
static ::ExceptionBase & ExcGridNotRefinedAtLeastOnce()
void compute_component_wise(const FiniteElement< dim, spacedim > &fe, std::vector< unsigned int > &renumbering, std::vector< std::vector< unsigned int > > &start_indices)
Definition: fe_tools.cc:1325
static ::ExceptionBase & ExcHangingNodesNotAllowed(int arg1)
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:1367
FiniteElement< dim, dim > * get_fe_from_name(const std::string &name) 1
Definition: fe_tools.cc:2580
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:1920
void interpolation_difference(const DoFHandler< dim, spacedim > &dof1, const InVector &z1, const FiniteElement< dim, spacedim > &fe2, OutVector &z1_difference)
void build_face_tables(std::vector< std::pair< std::pair< unsigned int, unsigned int >, unsigned int > > &face_system_to_base_table, std::vector< std::pair< unsigned int, unsigned int > > &face_system_to_component_table, const FiniteElement< dim, spacedim > &finite_element, const bool do_tensor_product=true)
Definition: fe_tools.cc:776
void hierarchic_to_lexicographic_numbering(unsigned int degree, std::vector< unsigned int > &h2l)
Definition: fe_tools.cc:2928
std::vector< ComponentMask > compute_nonzero_components(const std::vector< const FiniteElement< dim, spacedim > *> &fes, const std::vector< unsigned int > &multiplicities, const bool do_tensor_product=true)
Definition: fe_tools.cc:351
ActiveSelector::active_cell_iterator active_cell_iterator
Definition: dof_handler.h:228
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:1897
void extrapolate(const DoFHandler< dim, spacedim > &dof1, const InVector &z1, const DoFHandler< dim, spacedim > &dof2, OutVector &z2)
static ::ExceptionBase & ExcFENotPrimitive()
void get_projection_matrix(const FiniteElement< dim, spacedim > &fe1, const FiniteElement< dim, spacedim > &fe2, FullMatrix< number > &matrix)
Definition: fe_tools.cc:1531
static ::ExceptionBase & ExcMatrixDimensionMismatch(int arg1, int arg2, int arg3, int arg4)
#define DeclException1(Exception1, type1, outsequence)
Definition: exceptions.h:564
void get_interpolation_matrix(const FiniteElement< dim, spacedim > &fe1, const FiniteElement< dim, spacedim > &fe2, FullMatrix< number > &interpolation_matrix)
Definition: fe_tools.cc:1415
static ::ExceptionBase & ExcNotGreaterThan(int arg1, int arg2)
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:2868
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:2679
#define DeclException0(Exception0)
Definition: exceptions.h:541
void get_back_interpolation_matrix(const FiniteElement< dim, spacedim > &fe1, const FiniteElement< dim, spacedim > &fe2, FullMatrix< number > &interpolation_matrix)
Definition: fe_tools.cc:1479
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:2737
virtual ~FEFactoryBase()
Definition: fe_tools.cc:1319
FiniteElementData< dim > multiply_dof_numbers(const std::vector< const FiniteElement< dim, spacedim > *> &fes, const std::vector< unsigned int > &multiplicities, const bool do_tensor_product=true)
Definition: fe_tools.cc:73
virtual FiniteElement< FE::dimension, FE::space_dimension > * get(const unsigned int degree) const
std::vector< bool > compute_restriction_is_additive_flags(const std::vector< const FiniteElement< dim, spacedim > *> &fes, const std::vector< unsigned int > &multiplicities)
Definition: fe_tools.cc:189
static ::ExceptionBase & ExcInvalidFEDimension(char arg1, int arg2)
void lexicographic_to_hierarchic_numbering(const FiniteElementData< dim > &fe_data, std::vector< unsigned int > &l2h)
Definition: fe_tools.cc:3120
static ::ExceptionBase & ExcInvalidFE()
FullMatrix< double > compute_node_matrix(const FiniteElement< dim, spacedim > &fe)
Definition: fe_tools.cc:1616
void add_fe_name(const std::string &name, const FEFactoryBase< dim, spacedim > *factory)
Definition: fe_tools.cc:2283
void build_cell_tables(std::vector< std::pair< std::pair< unsigned int, unsigned int >, unsigned int > > &system_to_base_table, std::vector< std::pair< unsigned int, unsigned int > > &system_to_component_table, std::vector< std::pair< std::pair< unsigned int, unsigned int >, unsigned int > > &component_to_base_table, const FiniteElement< dim, spacedim > &finite_element, const bool do_tensor_product=true)
Definition: fe_tools.cc:581
void get_interpolation_difference_matrix(const FiniteElement< dim, spacedim > &fe1, const FiniteElement< dim, spacedim > &fe2, FullMatrix< number > &difference_matrix)
Definition: fe_tools.cc:1505
#define DeclException4(Exception4, type1, type2, type3, type4, outsequence)
Definition: exceptions.h:600
static ::ExceptionBase & ExcInvalidFEName(std::string arg1)
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:2123
FiniteElement< dim, spacedim > * get_fe_by_name(const std::string &name)
Definition: fe_tools.cc:2589
static ::ExceptionBase & ExcTriangulationMismatch()
void back_interpolate(const DoFHandlerType< dim, spacedim > &dof1, const InVector &u1, const FiniteElement< dim, spacedim > &fe2, OutVector &u1_interpolated)
void interpolate(const DoFHandlerType1< dim, spacedim > &dof1, const InVector &u1, const DoFHandlerType2< dim, spacedim > &dof2, OutVector &u2)