Reference documentation for deal.II version Git f09805cc1d 2021-10-18 06:49:49 +0200
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
fe_collection.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2003 - 2021 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.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_fe_collection_h
17 #define dealii_fe_collection_h
18 
19 #include <deal.II/base/config.h>
20 
22 #include <deal.II/fe/fe.h>
24 
25 #include <deal.II/hp/collection.h>
26 
27 #include <memory>
28 
30 
31 namespace hp
32 {
52  template <int dim, int spacedim = dim>
53  class FECollection : public Collection<FiniteElement<dim, spacedim>>
54  {
55  public:
66  {
73  static unsigned int
74  next_index(const typename hp::FECollection<dim, spacedim> &fe_collection,
75  const unsigned int fe_index)
76  {
77  return ((fe_index + 1) < fe_collection.size()) ? fe_index + 1 :
78  fe_index;
79  }
80 
87  static unsigned int
89  const typename hp::FECollection<dim, spacedim> &fe_collection,
90  const unsigned int fe_index)
91  {
92  (void)fe_collection;
93  return (fe_index > 0) ? fe_index - 1 : fe_index;
94  }
95  };
96 
102  FECollection();
103 
110  explicit FECollection(const FiniteElement<dim, spacedim> &fe);
111 
118  template <class... FETypes>
119  explicit FECollection(const FETypes &...fes);
120 
128  FECollection(const std::vector<const FiniteElement<dim, spacedim> *> &fes);
129 
133  FECollection(const FECollection<dim, spacedim> &) = default;
134 
145  std::is_nothrow_move_constructible<
146  std::vector<std::shared_ptr<const FiniteElement<dim, spacedim>>>>::value
147  &&std::is_nothrow_move_constructible<std::function<
148  unsigned int(const typename hp::FECollection<dim, spacedim> &,
149  const unsigned int)>>::value) = default;
150 
155  operator=(FECollection<dim, spacedim> &&) = default; // NOLINT
156 
161  bool
162  operator==(const FECollection<dim, spacedim> &fe_collection) const;
163 
168  bool
169  operator!=(const FECollection<dim, spacedim> &fe_collection) const;
170 
180  void
182 
200  unsigned int
201  n_components() const;
202 
219  unsigned int
220  n_blocks() const;
221 
226  unsigned int
227  max_degree() const;
228 
233  unsigned int
234  max_dofs_per_vertex() const;
235 
240  unsigned int
241  max_dofs_per_line() const;
242 
247  unsigned int
248  max_dofs_per_quad() const;
249 
254  unsigned int
255  max_dofs_per_hex() const;
256 
261  unsigned int
262  max_dofs_per_face() const;
263 
268  unsigned int
269  max_dofs_per_cell() const;
270 
300  bool
302 
324  std::vector<std::map<unsigned int, unsigned int>>
325  hp_vertex_dof_identities(const std::set<unsigned int> &fes) const;
326 
331  std::vector<std::map<unsigned int, unsigned int>>
332  hp_line_dof_identities(const std::set<unsigned int> &fes) const;
333 
338  std::vector<std::map<unsigned int, unsigned int>>
339  hp_quad_dof_identities(const std::set<unsigned int> &fes,
340  const unsigned int face_no = 0) const;
341 
342 
364  std::set<unsigned int>
365  find_common_fes(const std::set<unsigned int> &fes,
366  const unsigned int codim = 0) const;
367 
389  std::set<unsigned int>
390  find_enclosing_fes(const std::set<unsigned int> &fes,
391  const unsigned int codim = 0) const;
392 
425  unsigned int
426  find_dominating_fe(const std::set<unsigned int> &fes,
427  const unsigned int codim = 0) const;
428 
461  unsigned int
462  find_dominated_fe(const std::set<unsigned int> &fes,
463  const unsigned int codim = 0) const;
464 
488  unsigned int
489  find_dominating_fe_extended(const std::set<unsigned int> &fes,
490  const unsigned int codim = 0) const;
491 
514  unsigned int
515  find_dominated_fe_extended(const std::set<unsigned int> &fes,
516  const unsigned int codim = 0) const;
517 
542  void
543  set_hierarchy(const std::function<unsigned int(
544  const typename hp::FECollection<dim, spacedim> &,
545  const unsigned int)> &next,
546  const std::function<unsigned int(
547  const typename hp::FECollection<dim, spacedim> &,
548  const unsigned int)> &prev);
549 
557  void
559 
579  std::vector<unsigned int>
580  get_hierarchy_sequence(const unsigned int fe_index = 0) const;
581 
591  unsigned int
592  next_in_hierarchy(const unsigned int fe_index) const;
593 
603  unsigned int
604  previous_in_hierarchy(const unsigned int fe_index) const;
605 
635  component_mask(const FEValuesExtractors::Scalar &scalar) const;
636 
654  component_mask(const FEValuesExtractors::Vector &vector) const;
655 
675  const FEValuesExtractors::SymmetricTensor<2> &sym_tensor) const;
676 
698  component_mask(const BlockMask &block_mask) const;
699 
726  BlockMask
727  block_mask(const FEValuesExtractors::Scalar &scalar) const;
728 
751  BlockMask
752  block_mask(const FEValuesExtractors::Vector &vector) const;
753 
777  BlockMask
778  block_mask(const FEValuesExtractors::SymmetricTensor<2> &sym_tensor) const;
779 
808  BlockMask
809  block_mask(const ComponentMask &component_mask) const;
810 
826 
831  private:
836  std::function<unsigned int(const typename hp::FECollection<dim, spacedim> &,
837  const unsigned int)>
839 
844  std::function<unsigned int(const typename hp::FECollection<dim, spacedim> &,
845  const unsigned int)>
847  };
848 
849 
850 
851  /* --------------- inline functions ------------------- */
852 
853  template <int dim, int spacedim>
854  template <class... FETypes>
856  {
857  static_assert(
858  is_base_of_all<FiniteElement<dim, spacedim>, FETypes...>::value,
859  "Not all of the input arguments of this function "
860  "are derived from FiniteElement<dim,spacedim>!");
861 
862  // loop over all of the given arguments and add the finite elements to
863  // this collection. Inlining the definition of fe_pointers causes internal
864  // compiler errors on GCC 7.1.1 so we define it separately:
865  const auto fe_pointers = {
866  (static_cast<const FiniteElement<dim, spacedim> *>(&fes))...};
867  for (const auto p : fe_pointers)
868  push_back(*p);
869  }
870 
871 
872 
873  template <int dim, int spacedim>
874  inline unsigned int
876  {
877  Assert(this->size() > 0, ExcNoFiniteElements());
878 
879  // note that there is no need
880  // here to enforce that indeed
881  // all elements have the same
882  // number of components since we
883  // have already done this when
884  // adding a new element to the
885  // collection.
886 
887  return this->operator[](0).n_components();
888  }
889 
890 
891 
892  template <int dim, int spacedim>
893  inline bool
895  const FECollection<dim, spacedim> &fe_collection) const
896  {
897  const unsigned int n_elements = this->size();
898  if (n_elements != fe_collection.size())
899  return false;
900 
901  for (unsigned int i = 0; i < n_elements; ++i)
902  if (!(this->operator[](i) == fe_collection[i]))
903  return false;
904 
905  return true;
906  }
907 
908 
909 
910  template <int dim, int spacedim>
911  inline bool
913  const FECollection<dim, spacedim> &fe_collection) const
914  {
915  return !(*this == fe_collection);
916  }
917 
918 
919 
920  template <int dim, int spacedim>
921  unsigned int
923  {
924  Assert(this->size() > 0, ExcNoFiniteElements());
925 
926  unsigned int max = 0;
927  for (unsigned int i = 0; i < this->size(); ++i)
928  max = std::max(max, this->operator[](i).degree);
929 
930  return max;
931  }
932 
933 
934 
935  template <int dim, int spacedim>
936  unsigned int
938  {
939  Assert(this->size() > 0, ExcNoFiniteElements());
940 
941  unsigned int max = 0;
942  for (unsigned int i = 0; i < this->size(); ++i)
943  max = std::max(max, this->operator[](i).n_dofs_per_vertex());
944 
945  return max;
946  }
947 
948 
949 
950  template <int dim, int spacedim>
951  unsigned int
953  {
954  Assert(this->size() > 0, ExcNoFiniteElements());
955 
956  unsigned int max = 0;
957  for (unsigned int i = 0; i < this->size(); ++i)
958  max = std::max(max, this->operator[](i).n_dofs_per_line());
959 
960  return max;
961  }
962 
963 
964 
965  template <int dim, int spacedim>
966  unsigned int
968  {
969  Assert(this->size() > 0, ExcNoFiniteElements());
970 
971  unsigned int max = 0;
972  for (unsigned int i = 0; i < this->size(); ++i)
973  max = std::max(max, this->operator[](i).max_dofs_per_quad());
974 
975  return max;
976  }
977 
978 
979 
980  template <int dim, int spacedim>
981  unsigned int
983  {
984  Assert(this->size() > 0, ExcNoFiniteElements());
985 
986  unsigned int max = 0;
987  for (unsigned int i = 0; i < this->size(); ++i)
988  max = std::max(max, this->operator[](i).n_dofs_per_hex());
989 
990  return max;
991  }
992 
993 
994 
995  template <int dim, int spacedim>
996  unsigned int
998  {
999  Assert(this->size() > 0, ExcNoFiniteElements());
1000 
1001  unsigned int max = 0;
1002  for (unsigned int i = 0; i < this->size(); ++i)
1003  max = std::max(max, this->operator[](i).max_dofs_per_face());
1004 
1005  return max;
1006  }
1007 
1008 
1009 
1010  template <int dim, int spacedim>
1011  unsigned int
1013  {
1014  Assert(this->size() > 0, ExcNoFiniteElements());
1015 
1016  unsigned int max = 0;
1017  for (unsigned int i = 0; i < this->size(); ++i)
1018  max = std::max(max, this->operator[](i).n_dofs_per_cell());
1019 
1020  return max;
1021  }
1022 
1023 
1024  template <int dim, int spacedim>
1025  bool
1027  {
1028  Assert(this->size() > 0, ExcNoFiniteElements());
1029 
1030  for (unsigned int i = 0; i < this->size(); ++i)
1031  if (this->operator[](i).hp_constraints_are_implemented() == false)
1032  return false;
1033 
1034  return true;
1035  }
1036 
1037 
1038 } // namespace hp
1039 
1041 
1042 #endif
std::function< unsigned int(const typename hp::FECollection< dim, spacedim > &, const unsigned int)> hierarchy_prev
unsigned int find_dominated_fe_extended(const std::set< unsigned int > &fes, const unsigned int codim=0) const
static unsigned int next_index(const typename hp::FECollection< dim, spacedim > &fe_collection, const unsigned int fe_index)
Definition: fe_collection.h:74
ComponentMask component_mask(const FEValuesExtractors::Scalar &scalar) const
std::vector< std::map< unsigned int, unsigned int > > hp_quad_dof_identities(const std::set< unsigned int > &fes, const unsigned int face_no=0) const
unsigned int find_dominating_fe(const std::set< unsigned int > &fes, const unsigned int codim=0) const
bool operator!=(const FECollection< dim, spacedim > &fe_collection) const
bool operator==(const FECollection< dim, spacedim > &fe_collection) const
const FiniteElement< dim, spacedim > & operator[](const unsigned int index) const
Definition: collection.h:119
unsigned int next_in_hierarchy(const unsigned int fe_index) const
unsigned int find_dominating_fe_extended(const std::set< unsigned int > &fes, const unsigned int codim=0) const
std::function< unsigned int(const typename hp::FECollection< dim, spacedim > &, const unsigned int)> hierarchy_next
unsigned int n_blocks() const
BlockMask block_mask(const FEValuesExtractors::Scalar &scalar) const
unsigned int max_dofs_per_cell() const
void push_back(const FiniteElement< dim, spacedim > &new_fe)
bool hp_constraints_are_implemented() const
static ::ExceptionBase & ExcNoFiniteElements()
unsigned int max_dofs_per_hex() const
FECollection< dim, spacedim > & operator=(FECollection< dim, spacedim > &&)=default
#define Assert(cond, exc)
Definition: exceptions.h:1461
unsigned int max_degree() const
#define DeclException0(Exception0)
Definition: exceptions.h:464
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:401
unsigned int max_dofs_per_line() const
void set_hierarchy(const std::function< unsigned int(const typename hp::FECollection< dim, spacedim > &, const unsigned int)> &next, const std::function< unsigned int(const typename hp::FECollection< dim, spacedim > &, const unsigned int)> &prev)
Definition: hp.h:117
static unsigned int previous_index(const typename hp::FECollection< dim, spacedim > &fe_collection, const unsigned int fe_index)
Definition: fe_collection.h:88
unsigned int max_dofs_per_face() const
std::vector< unsigned int > get_hierarchy_sequence(const unsigned int fe_index=0) const
unsigned int max_dofs_per_vertex() const
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:400
std::set< unsigned int > find_common_fes(const std::set< unsigned int > &fes, const unsigned int codim=0) const
void set_default_hierarchy()
std::set< unsigned int > find_enclosing_fes(const std::set< unsigned int > &fes, const unsigned int codim=0) const
std::vector< std::map< unsigned int, unsigned int > > hp_vertex_dof_identities(const std::set< unsigned int > &fes) const
unsigned int find_dominated_fe(const std::set< unsigned int > &fes, const unsigned int codim=0) const
unsigned int n_components() const
unsigned int max_dofs_per_quad() const
unsigned int previous_in_hierarchy(const unsigned int fe_index) const
std::vector< std::map< unsigned int, unsigned int > > hp_line_dof_identities(const std::set< unsigned int > &fes) const