deal.II version 9.8.0
\(\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_data.cc
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2001 - 2026 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
14
15#include <deal.II/fe/fe.h>
16
18
19namespace internal
20{
21 template <int dim>
22 internal::GenericDoFsPerObject
23 expand(const std::vector<unsigned int> &dofs_per_object,
24 const ReferenceCell<dim> cell_type)
25 {
27
28 const unsigned int face_no = 0;
29
30 result.dofs_per_object_exclusive.resize(4, std::vector<unsigned int>(1));
31 result.dofs_per_object_inclusive.resize(4, std::vector<unsigned int>(1));
32 result.object_index.resize(4, std::vector<unsigned int>(1));
33 result.first_object_index_on_face.resize(3, std::vector<unsigned int>(1));
34
35 // dofs_per_vertex
36 const unsigned int dofs_per_vertex = dofs_per_object[0];
37 result.dofs_per_object_exclusive[0][0] = dofs_per_vertex;
38
39 // dofs_per_line
40 const unsigned int dofs_per_line = dofs_per_object[1];
41 result.dofs_per_object_exclusive[1][0] = dofs_per_line;
42
43 // dofs_per_quad
44 const unsigned int dofs_per_quad = dim > 1 ? dofs_per_object[2] : 0;
45 result.dofs_per_object_exclusive[2][0] = dofs_per_quad;
46
47 // dofs_per_hex
48 const unsigned int dofs_per_hex = dim > 2 ? dofs_per_object[3] : 0;
49 result.dofs_per_object_exclusive[3][0] = dofs_per_hex;
50
51
52 // first_line_index
53 const unsigned int first_line_index =
54 (cell_type.n_vertices() * dofs_per_vertex);
55 result.object_index[1][0] = first_line_index;
56
57 // first_quad_index
58 const unsigned int first_quad_index =
59 (first_line_index + cell_type.n_lines() * dofs_per_line);
60 result.object_index[2][0] = first_quad_index;
61
62 // first_hex_index
63 result.object_index[3][0] =
64 (first_quad_index +
65 (dim == 2 ? 1 : (dim == 3 ? cell_type.n_faces() : 0)) * dofs_per_quad);
66
67 // first_face_line_index
68 result.first_object_index_on_face[1][0] =
69 (cell_type.face_reference_cell(face_no).n_vertices() * dofs_per_vertex);
70
71 // first_face_quad_index
72 result.first_object_index_on_face[2][0] =
73 ((dim == 3 ? cell_type.face_reference_cell(face_no).n_vertices() *
74 dofs_per_vertex :
75 cell_type.n_vertices() * dofs_per_vertex) +
76 cell_type.face_reference_cell(face_no).n_lines() * dofs_per_line);
77
78 // dofs_per_face
79 result.dofs_per_object_inclusive[dim - 1][0] =
80 (cell_type.face_reference_cell(face_no).n_vertices() * dofs_per_vertex +
81 cell_type.face_reference_cell(face_no).n_lines() * dofs_per_line +
82 (dim == 3 ? 1 : 0) * dofs_per_quad);
83
84
85 // dofs_per_cell
86 result.dofs_per_object_inclusive[dim][0] =
87 (cell_type.n_vertices() * dofs_per_vertex +
88 cell_type.n_lines() * dofs_per_line +
89 (dim == 2 ? 1 : (dim == 3 ? cell_type.n_faces() : 0)) * dofs_per_quad +
90 (dim == 3 ? 1 : 0) * dofs_per_hex);
91
92 return result;
93 }
94
95 unsigned int
96 number_unique_entries(const std::vector<unsigned int> &vector)
97 {
98 if (std::all_of(vector.begin(), vector.end(), [&](const auto &e) {
99 return e == vector.front();
100 }))
101 {
102 return 1;
103 }
104 else
105 return vector.size();
106 }
107} // namespace internal
108
109
110
111template <int dim>
113 const std::vector<unsigned int> &dofs_per_object,
114 const unsigned int n_components,
115 const unsigned int degree,
116 const Conformity conformity,
118 : FiniteElementData(dofs_per_object,
119 ReferenceCells::get_hypercube<dim>(),
121 degree,
122 conformity,
124{}
125
126template <int dim>
128 const std::vector<unsigned int> &dofs_per_object,
129 const ReferenceCell<dim> cell_type,
130 const unsigned int n_components,
131 const unsigned int degree,
132 const Conformity conformity,
134 : FiniteElementData(internal::expand<dim>(dofs_per_object, cell_type),
135 cell_type,
137 degree,
138 conformity,
140{}
141
142
143
144template <int dim>
148 const unsigned int n_components,
149 const unsigned int degree,
150 const Conformity conformity,
154 internal::number_unique_entries(data.dofs_per_object_inclusive[2]))
156 internal::number_unique_entries(data.dofs_per_object_inclusive[dim - 1]))
157 , dofs_per_vertex(data.dofs_per_object_exclusive[0][0])
158 , dofs_per_line(data.dofs_per_object_exclusive[1][0])
159 , n_dofs_on_quad(data.dofs_per_object_exclusive[2])
162 *max_element(n_dofs_on_quad.begin(), n_dofs_on_quad.end()))
163 , dofs_per_hex(data.dofs_per_object_exclusive[3][0])
164 , first_line_index(data.object_index[1][0])
165 , first_index_of_quads(data.object_index[2])
167 , first_hex_index(data.object_index[3][0])
168 , first_line_index_of_faces(data.first_object_index_on_face[1])
170 , first_quad_index_of_faces(data.first_object_index_on_face[2])
172 , n_dofs_on_face(data.dofs_per_object_inclusive[dim - 1])
175 *max_element(n_dofs_on_face.begin(), n_dofs_on_face.end()))
176 , dofs_per_cell(data.dofs_per_object_inclusive[dim][0])
178 , degree(degree)
179 , conforming_space(conformity)
180 , block_indices_data(block_indices.size() == 0 ?
183{}
184
185
186
187template <int dim>
188bool
197
198
199
200namespace internal
201{
203 expand<1>(const std::vector<unsigned int> &dofs_per_object,
204 const ReferenceCell<1> cell_type);
206 expand<2>(const std::vector<unsigned int> &dofs_per_object,
207 const ReferenceCell<2> cell_type);
209 expand<3>(const std::vector<unsigned int> &dofs_per_object,
210 const ReferenceCell<3> cell_type);
211} // namespace internal
212
213template class FiniteElementData<1>;
214template class FiniteElementData<2>;
215template class FiniteElementData<3>;
216
*  iterator end()
*  *  iterator begin()
const unsigned int dofs_per_quad
Definition fe_data.h:344
const unsigned int first_face_quad_index
Definition fe_data.h:405
const std::vector< unsigned int > first_index_of_quads
Definition fe_data.h:370
const std::vector< unsigned int > first_line_index_of_faces
Definition fe_data.h:387
const unsigned int components
Definition fe_data.h:444
const unsigned int degree
Definition fe_data.h:450
const std::vector< unsigned int > n_dofs_on_face
Definition fe_data.h:412
const unsigned int dofs_per_face
Definition fe_data.h:420
bool operator==(const FiniteElementData &) const
Definition fe_data.cc:189
const unsigned int dofs_per_line
Definition fe_data.h:330
unsigned int n_components() const
const unsigned int first_hex_index
Definition fe_data.h:381
const unsigned int first_face_line_index
Definition fe_data.h:393
const unsigned int dofs_per_quad_max
Definition fe_data.h:350
const unsigned int first_line_index
Definition fe_data.h:362
const unsigned int dofs_per_hex
Definition fe_data.h:357
const BlockIndices block_indices_data
Definition fe_data.h:462
const unsigned int number_unique_faces
Definition fe_data.h:318
const BlockIndices & block_indices() const
const std::vector< unsigned int > first_quad_index_of_faces
Definition fe_data.h:399
const unsigned int number_of_unique_2d_subobjects
Definition fe_data.h:312
const std::vector< unsigned int > n_dofs_on_quad
Definition fe_data.h:337
const Conformity conforming_space
Definition fe_data.h:455
const unsigned int first_quad_index
Definition fe_data.h:376
const unsigned int dofs_per_vertex
Definition fe_data.h:324
const ReferenceCell< dim > reference_cell_kind
Definition fe_data.h:305
const unsigned int dofs_per_cell
Definition fe_data.h:434
FiniteElementData(const std::vector< unsigned int > &dofs_per_object, const unsigned int n_components, const unsigned int degree, const Conformity conformity=unknown, const BlockIndices &block_indices=BlockIndices())
Definition fe_data.cc:112
ReferenceCell< dim > reference_cell() const
const unsigned int dofs_per_face_max
Definition fe_data.h:426
constexpr unsigned int n_vertices() const
constexpr ReferenceCell< dim - 1 > face_reference_cell(const unsigned int face_index) const
constexpr unsigned int n_faces() const
constexpr unsigned int n_lines() const
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
unsigned int number_unique_entries(const std::vector< unsigned int > &vector)
Definition fe_data.cc:96
template internal::GenericDoFsPerObject expand< 3 >(const std::vector< unsigned int > &dofs_per_object, const ReferenceCell< 3 > cell_type)
internal::GenericDoFsPerObject expand(const std::vector< unsigned int > &dofs_per_object, const ReferenceCell< dim > reference_cell)
Definition fe_data.cc:23
template internal::GenericDoFsPerObject expand< 2 >(const std::vector< unsigned int > &dofs_per_object, const ReferenceCell< 2 > cell_type)
template internal::GenericDoFsPerObject expand< 1 >(const std::vector< unsigned int > &dofs_per_object, const ReferenceCell< 1 > cell_type)
std::vector< std::vector< unsigned int > > object_index
Definition fe_data.h:195
std::vector< std::vector< unsigned int > > first_object_index_on_face
Definition fe_data.h:200
std::vector< std::vector< unsigned int > > dofs_per_object_inclusive
Definition fe_data.h:190
std::vector< std::vector< unsigned int > > dofs_per_object_exclusive
Definition fe_data.h:185