deal.II version GIT relicensing-2645-g9d42f38b55 2025-02-15 04:20:00+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#include <set>
28
29
31
32// Forward declarations
33namespace hp
34{
35 template <int dim, int spacedim>
36 class MappingCollection;
37}
38
39
40namespace hp
41{
61 template <int dim, int spacedim = dim>
62 class FECollection : public Collection<FiniteElement<dim, spacedim>>
63 {
64 public:
75 {
82 static unsigned int
83 next_index(const typename hp::FECollection<dim, spacedim> &fe_collection,
84 const unsigned int fe_index)
85 {
86 return ((fe_index + 1) < fe_collection.size()) ? fe_index + 1 :
87 fe_index;
88 }
89
96 static unsigned int
98 const typename hp::FECollection<dim, spacedim> &fe_collection,
99 const unsigned int fe_index)
100 {
101 (void)fe_collection;
102 return (fe_index > 0) ? fe_index - 1 : fe_index;
103 }
104 };
105
111 FECollection();
112
119 explicit FECollection(const FiniteElement<dim, spacedim> &fe);
120
127 template <class... FETypes>
128 explicit FECollection(const FETypes &...fes);
129
137 FECollection(const std::vector<const FiniteElement<dim, spacedim> *> &fes);
138
143
154 std::is_nothrow_move_constructible<
155 std::vector<std::shared_ptr<const FiniteElement<dim, spacedim>>>>::value
156 &&std::is_nothrow_move_constructible<std::function<
157 unsigned int(const typename hp::FECollection<dim, spacedim> &,
158 const unsigned int)>>::value) = default;
159
163 FECollection<dim, spacedim> &
164 operator=(FECollection<dim, spacedim> &&) = default; // NOLINT
165
170 bool
171 operator==(const FECollection<dim, spacedim> &fe_collection) const;
172
177 bool
178 operator!=(const FECollection<dim, spacedim> &fe_collection) const;
179
189 void
190 push_back(const FiniteElement<dim, spacedim> &new_fe);
191
209 unsigned int
211
228 unsigned int
229 n_blocks() const;
230
235 unsigned int
236 max_degree() const;
237
242 unsigned int
244
249 unsigned int
251
256 unsigned int
258
263 unsigned int
265
270 unsigned int
272
277 unsigned int
279
288 const MappingCollection<dim, spacedim> &
290
320 bool
322
344 std::vector<std::map<unsigned int, unsigned int>>
345 hp_vertex_dof_identities(const std::set<unsigned int> &fes) const;
346
351 std::vector<std::map<unsigned int, unsigned int>>
352 hp_line_dof_identities(const std::set<unsigned int> &fes) const;
353
358 std::vector<std::map<unsigned int, unsigned int>>
359 hp_quad_dof_identities(const std::set<unsigned int> &fes,
360 const unsigned int face_no = 0) const;
361
362
384 std::set<unsigned int>
385 find_common_fes(const std::set<unsigned int> &fes,
386 const unsigned int codim = 0) const;
387
409 std::set<unsigned int>
410 find_enclosing_fes(const std::set<unsigned int> &fes,
411 const unsigned int codim = 0) const;
412
445 unsigned int
446 find_dominating_fe(const std::set<unsigned int> &fes,
447 const unsigned int codim = 0) const;
448
481 unsigned int
482 find_dominated_fe(const std::set<unsigned int> &fes,
483 const unsigned int codim = 0) const;
484
508 unsigned int
509 find_dominating_fe_extended(const std::set<unsigned int> &fes,
510 const unsigned int codim = 0) const;
511
534 unsigned int
535 find_dominated_fe_extended(const std::set<unsigned int> &fes,
536 const unsigned int codim = 0) const;
537
562 void
563 set_hierarchy(const std::function<unsigned int(
564 const typename hp::FECollection<dim, spacedim> &,
565 const unsigned int)> &next,
566 const std::function<unsigned int(
567 const typename hp::FECollection<dim, spacedim> &,
568 const unsigned int)> &prev);
569
577 void
579
599 std::vector<unsigned int>
600 get_hierarchy_sequence(const unsigned int fe_index = 0) const;
601
611 unsigned int
612 next_in_hierarchy(const unsigned int fe_index) const;
613
623 unsigned int
624 previous_in_hierarchy(const unsigned int fe_index) const;
625
655 component_mask(const FEValuesExtractors::Scalar &scalar) const;
656
674 component_mask(const FEValuesExtractors::Vector &vector) const;
675
695 const FEValuesExtractors::SymmetricTensor<2> &sym_tensor) const;
696
718 component_mask(const BlockMask &block_mask) const;
719
747 block_mask(const FEValuesExtractors::Scalar &scalar) const;
748
772 block_mask(const FEValuesExtractors::Vector &vector) const;
773
798 block_mask(const FEValuesExtractors::SymmetricTensor<2> &sym_tensor) const;
799
830
846
851 private:
856 std::shared_ptr<MappingCollection<dim, spacedim>>
858
863 std::function<unsigned int(const typename hp::FECollection<dim, spacedim> &,
864 const unsigned int)>
866
871 std::function<unsigned int(const typename hp::FECollection<dim, spacedim> &,
872 const unsigned int)>
874 };
875
876
877
878 /* --------------- inline functions ------------------- */
879
880 template <int dim, int spacedim>
881 template <class... FETypes>
882 FECollection<dim, spacedim>::FECollection(const FETypes &...fes)
883 {
884 static_assert(
886 "Not all of the input arguments of this function "
887 "are derived from FiniteElement<dim, spacedim>!");
888
889 // loop over all of the given arguments and add the finite elements to
890 // this collection. Inlining the definition of fe_pointers causes internal
891 // compiler errors on GCC 7.1.1 so we define it separately:
892 const auto fe_pointers = {
893 (static_cast<const FiniteElement<dim, spacedim> *>(&fes))...};
894 for (const auto p : fe_pointers)
895 push_back(*p);
896 }
897
898
899
900 template <int dim, int spacedim>
901 inline unsigned int
903 {
904 Assert(this->size() > 0, ExcNoFiniteElements());
905
906 // note that there is no need
907 // here to enforce that indeed
908 // all elements have the same
909 // number of components since we
910 // have already done this when
911 // adding a new element to the
912 // collection.
913
914 return this->operator[](0).n_components();
915 }
916
917
918
919 template <int dim, int spacedim>
920 inline bool
922 const FECollection<dim, spacedim> &fe_collection) const
923 {
924 const unsigned int n_elements = this->size();
925 if (n_elements != fe_collection.size())
926 return false;
927
928 for (unsigned int i = 0; i < n_elements; ++i)
929 if (!(this->operator[](i) == fe_collection[i]))
930 return false;
931
932 return true;
933 }
934
935
936
937 template <int dim, int spacedim>
938 inline bool
940 const FECollection<dim, spacedim> &fe_collection) const
941 {
942 return !(*this == fe_collection);
943 }
944
945
946
947 template <int dim, int spacedim>
948 unsigned int
950 {
951 Assert(this->size() > 0, ExcNoFiniteElements());
952
953 unsigned int max = 0;
954 for (unsigned int i = 0; i < this->size(); ++i)
955 max = std::max(max, this->operator[](i).degree);
956
957 return max;
958 }
959
960
961
962 template <int dim, int spacedim>
963 unsigned int
965 {
966 Assert(this->size() > 0, ExcNoFiniteElements());
967
968 unsigned int max = 0;
969 for (unsigned int i = 0; i < this->size(); ++i)
970 max = std::max(max, this->operator[](i).n_dofs_per_vertex());
971
972 return max;
973 }
974
975
976
977 template <int dim, int spacedim>
978 unsigned int
980 {
981 Assert(this->size() > 0, ExcNoFiniteElements());
982
983 unsigned int max = 0;
984 for (unsigned int i = 0; i < this->size(); ++i)
985 max = std::max(max, this->operator[](i).n_dofs_per_line());
986
987 return max;
988 }
989
990
991
992 template <int dim, int spacedim>
993 unsigned int
995 {
996 Assert(this->size() > 0, ExcNoFiniteElements());
997
998 unsigned int max = 0;
999 for (unsigned int i = 0; i < this->size(); ++i)
1000 max = std::max(max, this->operator[](i).max_dofs_per_quad());
1001
1002 return max;
1003 }
1004
1005
1006
1007 template <int dim, int spacedim>
1008 unsigned int
1010 {
1011 Assert(this->size() > 0, ExcNoFiniteElements());
1012
1013 unsigned int max = 0;
1014 for (unsigned int i = 0; i < this->size(); ++i)
1015 max = std::max(max, this->operator[](i).n_dofs_per_hex());
1016
1017 return max;
1018 }
1019
1020
1021
1022 template <int dim, int spacedim>
1023 unsigned int
1025 {
1026 Assert(this->size() > 0, ExcNoFiniteElements());
1027
1028 unsigned int max = 0;
1029 for (unsigned int i = 0; i < this->size(); ++i)
1030 max = std::max(max, this->operator[](i).max_dofs_per_face());
1031
1032 return max;
1033 }
1034
1035
1036
1037 template <int dim, int spacedim>
1038 unsigned int
1040 {
1041 Assert(this->size() > 0, ExcNoFiniteElements());
1042
1043 unsigned int max = 0;
1044 for (unsigned int i = 0; i < this->size(); ++i)
1045 max = std::max(max, this->operator[](i).n_dofs_per_cell());
1046
1047 return max;
1048 }
1049
1050
1051 template <int dim, int spacedim>
1052 bool
1054 {
1055 Assert(this->size() > 0, ExcNoFiniteElements());
1056
1057 for (unsigned int i = 0; i < this->size(); ++i)
1058 if (this->operator[](i).hp_constraints_are_implemented() == false)
1059 return false;
1060
1061 return true;
1062 }
1063
1064
1065} // namespace hp
1066
1068
1069#endif
unsigned int size() const
Definition collection.h:316
const T & operator[](const unsigned int index) const
Definition collection.h:334
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:518
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:519
#define DeclException0(Exception0)
Definition exceptions.h:468
#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)
void prev(std::tuple< I1, I2 > &t)