Reference documentation for deal.II version GIT relicensing-245-g36f19064f7 2024-03-29 07:20: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\}}\)
Loading...
Searching...
No Matches
fe_collection.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2005 - 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_fe_collection_h
16#define dealii_fe_collection_h
17
18#include <deal.II/base/config.h>
19
21#include <deal.II/fe/fe.h>
23
25
26#include <memory>
27
29
30// Forward declarations
31namespace hp
32{
33 template <int dim, int spacedim>
34 class MappingCollection;
35}
36
37
38namespace hp
39{
59 template <int dim, int spacedim = dim>
60 class FECollection : public Collection<FiniteElement<dim, spacedim>>
61 {
62 public:
73 {
80 static unsigned int
81 next_index(const typename hp::FECollection<dim, spacedim> &fe_collection,
82 const unsigned int fe_index)
83 {
84 return ((fe_index + 1) < fe_collection.size()) ? fe_index + 1 :
85 fe_index;
86 }
87
94 static unsigned int
96 const typename hp::FECollection<dim, spacedim> &fe_collection,
97 const unsigned int fe_index)
98 {
99 (void)fe_collection;
100 return (fe_index > 0) ? fe_index - 1 : fe_index;
101 }
102 };
103
109 FECollection();
110
117 explicit FECollection(const FiniteElement<dim, spacedim> &fe);
118
125 template <class... FETypes>
126 explicit FECollection(const FETypes &...fes);
127
135 FECollection(const std::vector<const FiniteElement<dim, spacedim> *> &fes);
136
141
152 std::is_nothrow_move_constructible<
153 std::vector<std::shared_ptr<const FiniteElement<dim, spacedim>>>>::value
154 &&std::is_nothrow_move_constructible<std::function<
155 unsigned int(const typename hp::FECollection<dim, spacedim> &,
156 const unsigned int)>>::value) = default;
157
161 FECollection<dim, spacedim> &
162 operator=(FECollection<dim, spacedim> &&) = default; // NOLINT
163
168 bool
169 operator==(const FECollection<dim, spacedim> &fe_collection) const;
170
175 bool
176 operator!=(const FECollection<dim, spacedim> &fe_collection) const;
177
187 void
188 push_back(const FiniteElement<dim, spacedim> &new_fe);
189
207 unsigned int
209
226 unsigned int
227 n_blocks() const;
228
233 unsigned int
234 max_degree() const;
235
240 unsigned int
242
247 unsigned int
249
254 unsigned int
256
261 unsigned int
263
268 unsigned int
270
275 unsigned int
277
286 const MappingCollection<dim, spacedim> &
288
318 bool
320
342 std::vector<std::map<unsigned int, unsigned int>>
343 hp_vertex_dof_identities(const std::set<unsigned int> &fes) const;
344
349 std::vector<std::map<unsigned int, unsigned int>>
350 hp_line_dof_identities(const std::set<unsigned int> &fes) const;
351
356 std::vector<std::map<unsigned int, unsigned int>>
357 hp_quad_dof_identities(const std::set<unsigned int> &fes,
358 const unsigned int face_no = 0) const;
359
360
382 std::set<unsigned int>
383 find_common_fes(const std::set<unsigned int> &fes,
384 const unsigned int codim = 0) const;
385
407 std::set<unsigned int>
408 find_enclosing_fes(const std::set<unsigned int> &fes,
409 const unsigned int codim = 0) const;
410
443 unsigned int
444 find_dominating_fe(const std::set<unsigned int> &fes,
445 const unsigned int codim = 0) const;
446
479 unsigned int
480 find_dominated_fe(const std::set<unsigned int> &fes,
481 const unsigned int codim = 0) const;
482
506 unsigned int
507 find_dominating_fe_extended(const std::set<unsigned int> &fes,
508 const unsigned int codim = 0) const;
509
532 unsigned int
533 find_dominated_fe_extended(const std::set<unsigned int> &fes,
534 const unsigned int codim = 0) const;
535
560 void
561 set_hierarchy(const std::function<unsigned int(
562 const typename hp::FECollection<dim, spacedim> &,
563 const unsigned int)> &next,
564 const std::function<unsigned int(
565 const typename hp::FECollection<dim, spacedim> &,
566 const unsigned int)> &prev);
567
575 void
577
597 std::vector<unsigned int>
598 get_hierarchy_sequence(const unsigned int fe_index = 0) const;
599
609 unsigned int
610 next_in_hierarchy(const unsigned int fe_index) const;
611
621 unsigned int
622 previous_in_hierarchy(const unsigned int fe_index) const;
623
653 component_mask(const FEValuesExtractors::Scalar &scalar) const;
654
672 component_mask(const FEValuesExtractors::Vector &vector) const;
673
693 const FEValuesExtractors::SymmetricTensor<2> &sym_tensor) const;
694
716 component_mask(const BlockMask &block_mask) const;
717
745 block_mask(const FEValuesExtractors::Scalar &scalar) const;
746
770 block_mask(const FEValuesExtractors::Vector &vector) const;
771
796 block_mask(const FEValuesExtractors::SymmetricTensor<2> &sym_tensor) const;
797
828
844
849 private:
854 std::shared_ptr<MappingCollection<dim, spacedim>>
856
861 std::function<unsigned int(const typename hp::FECollection<dim, spacedim> &,
862 const unsigned int)>
864
869 std::function<unsigned int(const typename hp::FECollection<dim, spacedim> &,
870 const unsigned int)>
872 };
873
874
875
876 /* --------------- inline functions ------------------- */
877
878 template <int dim, int spacedim>
879 template <class... FETypes>
880 FECollection<dim, spacedim>::FECollection(const FETypes &...fes)
881 {
882 static_assert(
884 "Not all of the input arguments of this function "
885 "are derived from FiniteElement<dim, spacedim>!");
886
887 // loop over all of the given arguments and add the finite elements to
888 // this collection. Inlining the definition of fe_pointers causes internal
889 // compiler errors on GCC 7.1.1 so we define it separately:
890 const auto fe_pointers = {
891 (static_cast<const FiniteElement<dim, spacedim> *>(&fes))...};
892 for (const auto p : fe_pointers)
893 push_back(*p);
894 }
895
896
897
898 template <int dim, int spacedim>
899 inline unsigned int
901 {
902 Assert(this->size() > 0, ExcNoFiniteElements());
903
904 // note that there is no need
905 // here to enforce that indeed
906 // all elements have the same
907 // number of components since we
908 // have already done this when
909 // adding a new element to the
910 // collection.
911
912 return this->operator[](0).n_components();
913 }
914
915
916
917 template <int dim, int spacedim>
918 inline bool
920 const FECollection<dim, spacedim> &fe_collection) const
921 {
922 const unsigned int n_elements = this->size();
923 if (n_elements != fe_collection.size())
924 return false;
925
926 for (unsigned int i = 0; i < n_elements; ++i)
927 if (!(this->operator[](i) == fe_collection[i]))
928 return false;
929
930 return true;
931 }
932
933
934
935 template <int dim, int spacedim>
936 inline bool
938 const FECollection<dim, spacedim> &fe_collection) const
939 {
940 return !(*this == fe_collection);
941 }
942
943
944
945 template <int dim, int spacedim>
946 unsigned int
948 {
949 Assert(this->size() > 0, ExcNoFiniteElements());
950
951 unsigned int max = 0;
952 for (unsigned int i = 0; i < this->size(); ++i)
953 max = std::max(max, this->operator[](i).degree);
954
955 return max;
956 }
957
958
959
960 template <int dim, int spacedim>
961 unsigned int
963 {
964 Assert(this->size() > 0, ExcNoFiniteElements());
965
966 unsigned int max = 0;
967 for (unsigned int i = 0; i < this->size(); ++i)
968 max = std::max(max, this->operator[](i).n_dofs_per_vertex());
969
970 return max;
971 }
972
973
974
975 template <int dim, int spacedim>
976 unsigned int
978 {
979 Assert(this->size() > 0, ExcNoFiniteElements());
980
981 unsigned int max = 0;
982 for (unsigned int i = 0; i < this->size(); ++i)
983 max = std::max(max, this->operator[](i).n_dofs_per_line());
984
985 return max;
986 }
987
988
989
990 template <int dim, int spacedim>
991 unsigned int
993 {
994 Assert(this->size() > 0, ExcNoFiniteElements());
995
996 unsigned int max = 0;
997 for (unsigned int i = 0; i < this->size(); ++i)
998 max = std::max(max, this->operator[](i).max_dofs_per_quad());
999
1000 return max;
1001 }
1002
1003
1004
1005 template <int dim, int spacedim>
1006 unsigned int
1008 {
1009 Assert(this->size() > 0, ExcNoFiniteElements());
1010
1011 unsigned int max = 0;
1012 for (unsigned int i = 0; i < this->size(); ++i)
1013 max = std::max(max, this->operator[](i).n_dofs_per_hex());
1014
1015 return max;
1016 }
1017
1018
1019
1020 template <int dim, int spacedim>
1021 unsigned int
1023 {
1024 Assert(this->size() > 0, ExcNoFiniteElements());
1025
1026 unsigned int max = 0;
1027 for (unsigned int i = 0; i < this->size(); ++i)
1028 max = std::max(max, this->operator[](i).max_dofs_per_face());
1029
1030 return max;
1031 }
1032
1033
1034
1035 template <int dim, int spacedim>
1036 unsigned int
1038 {
1039 Assert(this->size() > 0, ExcNoFiniteElements());
1040
1041 unsigned int max = 0;
1042 for (unsigned int i = 0; i < this->size(); ++i)
1043 max = std::max(max, this->operator[](i).n_dofs_per_cell());
1044
1045 return max;
1046 }
1047
1048
1049 template <int dim, int spacedim>
1050 bool
1052 {
1053 Assert(this->size() > 0, ExcNoFiniteElements());
1054
1055 for (unsigned int i = 0; i < this->size(); ++i)
1056 if (this->operator[](i).hp_constraints_are_implemented() == false)
1057 return false;
1058
1059 return true;
1060 }
1061
1062
1063} // namespace hp
1064
1066
1067#endif
unsigned int size() const
Definition collection.h:264
const T & 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
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
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)
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
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:502
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:503
#define DeclException0(Exception0)
Definition exceptions.h:471
#define Assert(cond, exc)
static ::ExceptionBase & ExcNoFiniteElements()
Definition hp.h:117
STL namespace.
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
static unsigned int next_index(const typename hp::FECollection< dim, spacedim > &fe_collection, const unsigned int fe_index)
static unsigned int previous_index(const typename hp::FECollection< dim, spacedim > &fe_collection, const unsigned int fe_index)