Reference documentation for deal.II version GIT 5dd0dfed0b 2022-12-08 21:45:02+00:00
\(\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 - 2022 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 // Forward declarations
32 namespace hp
33 {
34  template <int dim, int spacedim>
35  class MappingCollection;
36 }
37 
38 
39 namespace hp
40 {
60  template <int dim, int spacedim = dim>
61  class FECollection : public Collection<FiniteElement<dim, spacedim>>
62  {
63  public:
74  {
81  static unsigned int
82  next_index(const typename hp::FECollection<dim, spacedim> &fe_collection,
83  const unsigned int fe_index)
84  {
85  return ((fe_index + 1) < fe_collection.size()) ? fe_index + 1 :
86  fe_index;
87  }
88 
95  static unsigned int
97  const typename hp::FECollection<dim, spacedim> &fe_collection,
98  const unsigned int fe_index)
99  {
100  (void)fe_collection;
101  return (fe_index > 0) ? fe_index - 1 : fe_index;
102  }
103  };
104 
110  FECollection();
111 
118  explicit FECollection(const FiniteElement<dim, spacedim> &fe);
119 
126  template <class... FETypes>
127  explicit FECollection(const FETypes &...fes);
128 
136  FECollection(const std::vector<const FiniteElement<dim, spacedim> *> &fes);
137 
142 
153  std::is_nothrow_move_constructible<
154  std::vector<std::shared_ptr<const FiniteElement<dim, spacedim>>>>::value
155  &&std::is_nothrow_move_constructible<std::function<
156  unsigned int(const typename hp::FECollection<dim, spacedim> &,
157  const unsigned int)>>::value) = default;
158 
162  FECollection<dim, spacedim> &
163  operator=(FECollection<dim, spacedim> &&) = default; // NOLINT
164 
169  bool
170  operator==(const FECollection<dim, spacedim> &fe_collection) const;
171 
176  bool
177  operator!=(const FECollection<dim, spacedim> &fe_collection) const;
178 
188  void
189  push_back(const FiniteElement<dim, spacedim> &new_fe);
190 
208  unsigned int
209  n_components() const;
210 
227  unsigned int
228  n_blocks() const;
229 
234  unsigned int
235  max_degree() const;
236 
241  unsigned int
243 
248  unsigned int
250 
255  unsigned int
257 
262  unsigned int
264 
269  unsigned int
271 
276  unsigned int
278 
287  const MappingCollection<dim, spacedim> &
289 
319  bool
321 
343  std::vector<std::map<unsigned int, unsigned int>>
344  hp_vertex_dof_identities(const std::set<unsigned int> &fes) const;
345 
350  std::vector<std::map<unsigned int, unsigned int>>
351  hp_line_dof_identities(const std::set<unsigned int> &fes) const;
352 
357  std::vector<std::map<unsigned int, unsigned int>>
358  hp_quad_dof_identities(const std::set<unsigned int> &fes,
359  const unsigned int face_no = 0) const;
360 
361 
383  std::set<unsigned int>
384  find_common_fes(const std::set<unsigned int> &fes,
385  const unsigned int codim = 0) const;
386 
408  std::set<unsigned int>
409  find_enclosing_fes(const std::set<unsigned int> &fes,
410  const unsigned int codim = 0) const;
411 
444  unsigned int
445  find_dominating_fe(const std::set<unsigned int> &fes,
446  const unsigned int codim = 0) const;
447 
480  unsigned int
481  find_dominated_fe(const std::set<unsigned int> &fes,
482  const unsigned int codim = 0) const;
483 
507  unsigned int
508  find_dominating_fe_extended(const std::set<unsigned int> &fes,
509  const unsigned int codim = 0) const;
510 
533  unsigned int
534  find_dominated_fe_extended(const std::set<unsigned int> &fes,
535  const unsigned int codim = 0) const;
536 
561  void
562  set_hierarchy(const std::function<unsigned int(
563  const typename hp::FECollection<dim, spacedim> &,
564  const unsigned int)> &next,
565  const std::function<unsigned int(
566  const typename hp::FECollection<dim, spacedim> &,
567  const unsigned int)> &prev);
568 
576  void
578 
598  std::vector<unsigned int>
599  get_hierarchy_sequence(const unsigned int fe_index = 0) const;
600 
610  unsigned int
611  next_in_hierarchy(const unsigned int fe_index) const;
612 
622  unsigned int
623  previous_in_hierarchy(const unsigned int fe_index) const;
624 
654  component_mask(const FEValuesExtractors::Scalar &scalar) const;
655 
673  component_mask(const FEValuesExtractors::Vector &vector) const;
674 
694  const FEValuesExtractors::SymmetricTensor<2> &sym_tensor) const;
695 
717  component_mask(const BlockMask &block_mask) const;
718 
745  BlockMask
746  block_mask(const FEValuesExtractors::Scalar &scalar) const;
747 
770  BlockMask
771  block_mask(const FEValuesExtractors::Vector &vector) const;
772 
796  BlockMask
797  block_mask(const FEValuesExtractors::SymmetricTensor<2> &sym_tensor) const;
798 
827  BlockMask
829 
845 
850  private:
855  std::shared_ptr<MappingCollection<dim, spacedim>>
857 
862  std::function<unsigned int(const typename hp::FECollection<dim, spacedim> &,
863  const unsigned int)>
865 
870  std::function<unsigned int(const typename hp::FECollection<dim, spacedim> &,
871  const unsigned int)>
873  };
874 
875 
876 
877  /* --------------- inline functions ------------------- */
878 
879  template <int dim, int spacedim>
880  template <class... FETypes>
881  FECollection<dim, spacedim>::FECollection(const FETypes &...fes)
882  {
883  static_assert(
884  is_base_of_all<FiniteElement<dim, spacedim>, FETypes...>::value,
885  "Not all of the input arguments of this function "
886  "are derived from FiniteElement<dim,spacedim>!");
887 
888  // loop over all of the given arguments and add the finite elements to
889  // this collection. Inlining the definition of fe_pointers causes internal
890  // compiler errors on GCC 7.1.1 so we define it separately:
891  const auto fe_pointers = {
892  (static_cast<const FiniteElement<dim, spacedim> *>(&fes))...};
893  for (const auto p : fe_pointers)
894  push_back(*p);
895  }
896 
897 
898 
899  template <int dim, int spacedim>
900  inline unsigned int
902  {
903  Assert(this->size() > 0, ExcNoFiniteElements());
904 
905  // note that there is no need
906  // here to enforce that indeed
907  // all elements have the same
908  // number of components since we
909  // have already done this when
910  // adding a new element to the
911  // collection.
912 
913  return this->operator[](0).n_components();
914  }
915 
916 
917 
918  template <int dim, int spacedim>
919  inline bool
921  const FECollection<dim, spacedim> &fe_collection) const
922  {
923  const unsigned int n_elements = this->size();
924  if (n_elements != fe_collection.size())
925  return false;
926 
927  for (unsigned int i = 0; i < n_elements; ++i)
928  if (!(this->operator[](i) == fe_collection[i]))
929  return false;
930 
931  return true;
932  }
933 
934 
935 
936  template <int dim, int spacedim>
937  inline bool
939  const FECollection<dim, spacedim> &fe_collection) const
940  {
941  return !(*this == fe_collection);
942  }
943 
944 
945 
946  template <int dim, int spacedim>
947  unsigned int
949  {
950  Assert(this->size() > 0, ExcNoFiniteElements());
951 
952  unsigned int max = 0;
953  for (unsigned int i = 0; i < this->size(); ++i)
954  max = std::max(max, this->operator[](i).degree);
955 
956  return max;
957  }
958 
959 
960 
961  template <int dim, int spacedim>
962  unsigned int
964  {
965  Assert(this->size() > 0, ExcNoFiniteElements());
966 
967  unsigned int max = 0;
968  for (unsigned int i = 0; i < this->size(); ++i)
969  max = std::max(max, this->operator[](i).n_dofs_per_vertex());
970 
971  return max;
972  }
973 
974 
975 
976  template <int dim, int spacedim>
977  unsigned int
979  {
980  Assert(this->size() > 0, ExcNoFiniteElements());
981 
982  unsigned int max = 0;
983  for (unsigned int i = 0; i < this->size(); ++i)
984  max = std::max(max, this->operator[](i).n_dofs_per_line());
985 
986  return max;
987  }
988 
989 
990 
991  template <int dim, int spacedim>
992  unsigned int
994  {
995  Assert(this->size() > 0, ExcNoFiniteElements());
996 
997  unsigned int max = 0;
998  for (unsigned int i = 0; i < this->size(); ++i)
999  max = std::max(max, this->operator[](i).max_dofs_per_quad());
1000 
1001  return max;
1002  }
1003 
1004 
1005 
1006  template <int dim, int spacedim>
1007  unsigned int
1009  {
1010  Assert(this->size() > 0, ExcNoFiniteElements());
1011 
1012  unsigned int max = 0;
1013  for (unsigned int i = 0; i < this->size(); ++i)
1014  max = std::max(max, this->operator[](i).n_dofs_per_hex());
1015 
1016  return max;
1017  }
1018 
1019 
1020 
1021  template <int dim, int spacedim>
1022  unsigned int
1024  {
1025  Assert(this->size() > 0, ExcNoFiniteElements());
1026 
1027  unsigned int max = 0;
1028  for (unsigned int i = 0; i < this->size(); ++i)
1029  max = std::max(max, this->operator[](i).max_dofs_per_face());
1030 
1031  return max;
1032  }
1033 
1034 
1035 
1036  template <int dim, int spacedim>
1037  unsigned int
1039  {
1040  Assert(this->size() > 0, ExcNoFiniteElements());
1041 
1042  unsigned int max = 0;
1043  for (unsigned int i = 0; i < this->size(); ++i)
1044  max = std::max(max, this->operator[](i).n_dofs_per_cell());
1045 
1046  return max;
1047  }
1048 
1049 
1050  template <int dim, int spacedim>
1051  bool
1053  {
1054  Assert(this->size() > 0, ExcNoFiniteElements());
1055 
1056  for (unsigned int i = 0; i < this->size(); ++i)
1057  if (this->operator[](i).hp_constraints_are_implemented() == false)
1058  return false;
1059 
1060  return true;
1061  }
1062 
1063 
1064 } // namespace hp
1065 
1067 
1068 #endif
unsigned int n_components() const
Definition: vector.h:109
unsigned int size() const
Definition: collection.h:264
const FiniteElement< dim, dim > & operator[](const unsigned int index) const
Definition: collection.h:273
std::vector< std::map< unsigned int, unsigned int > > hp_vertex_dof_identities(const std::set< unsigned int > &fes) const
unsigned int previous_in_hierarchy(const unsigned int fe_index) const
unsigned int max_dofs_per_line() const
unsigned int max_dofs_per_hex() const
std::vector< unsigned int > get_hierarchy_sequence(const unsigned int fe_index=0) const
unsigned int max_dofs_per_vertex() const
unsigned int find_dominating_fe_extended(const std::set< unsigned int > &fes, const unsigned int codim=0) const
FECollection(FECollection< dim, spacedim > &&) noexcept(std::is_nothrow_move_constructible< std::vector< std::shared_ptr< const FiniteElement< dim, spacedim >>>>::value &&std::is_nothrow_move_constructible< std::function< unsigned int(const typename hp::FECollection< dim, spacedim > &, const unsigned int)>>::value)=default
bool hp_constraints_are_implemented() const
bool operator==(const FECollection< dim, spacedim > &fe_collection) const
std::function< unsigned int(const typename hp::FECollection< dim, spacedim > &, const unsigned int)> hierarchy_next
const MappingCollection< dim, spacedim > & get_reference_cell_default_linear_mapping() const
std::set< unsigned int > find_common_fes(const std::set< unsigned int > &fes, const unsigned int codim=0) const
FECollection(const FETypes &...fes)
void push_back(const FiniteElement< dim, spacedim > &new_fe)
unsigned int next_in_hierarchy(const unsigned int fe_index) const
void set_default_hierarchy()
std::shared_ptr< MappingCollection< dim, spacedim > > reference_cell_default_linear_mapping
unsigned int max_degree() const
unsigned int find_dominating_fe(const std::set< unsigned int > &fes, const unsigned int codim=0) const
std::set< unsigned int > find_enclosing_fes(const std::set< unsigned int > &fes, const unsigned int codim=0) const
unsigned int find_dominated_fe(const std::set< unsigned int > &fes, const unsigned int codim=0) const
unsigned int max_dofs_per_face() const
ComponentMask component_mask(const FEValuesExtractors::Scalar &scalar) const
bool operator!=(const FECollection< dim, spacedim > &fe_collection) const
std::vector< std::map< unsigned int, unsigned int > > hp_line_dof_identities(const std::set< unsigned int > &fes) 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)
unsigned int max_dofs_per_quad() const
unsigned int find_dominated_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_prev
unsigned int n_blocks() const
FECollection(const FECollection< dim, spacedim > &)=default
unsigned int n_components() 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 max_dofs_per_cell() const
BlockMask block_mask(const FEValuesExtractors::Scalar &scalar) const
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:458
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:459
__global__ void set(Number *val, const Number s, const size_type N)
#define DeclException0(Exception0)
Definition: exceptions.h:464
#define Assert(cond, exc)
Definition: exceptions.h:1501
static ::ExceptionBase & ExcNoFiniteElements()
Definition: hp.h:118
unsigned short int fe_index
Definition: types.h:59
static unsigned int next_index(const typename hp::FECollection< dim, spacedim > &fe_collection, const unsigned int fe_index)
Definition: fe_collection.h:82
static unsigned int previous_index(const typename hp::FECollection< dim, spacedim > &fe_collection, const unsigned int fe_index)
Definition: fe_collection.h:96