Debian Codegraph @

include/deal.II/fe/fe_poly_face.templates.h

raw
1 // ------------------------------------------------------------------------
2 //
3 // SPDX-License-Identifier: LGPL-2.1-or-later
4 // Copyright (C) 2009 - 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_poly_face_templates_h
16 #define dealii_fe_poly_face_templates_h
17
18
19 #include <deal.II/base/config.h>
20
21 #include <deal.II/base/polynomial_space.h>
22 #include <deal.II/base/qprojector.h>
23
24 #include <deal.II/fe/fe_poly_face.h>
25 #include <deal.II/fe/fe_values.h>
26
27
28 DEAL_II_NAMESPACE_OPEN
29
30 template <typename PolynomialType, int dim, int spacedim>
31 FE_PolyFace<PolynomialType, dim, spacedim>::FE_PolyFace(
32 const PolynomialType &poly_space,
33 const FiniteElementData<dim> &fe_data,
34 const std::vector<bool> &restriction_is_additive_flags)
35 : FiniteElement<dim, spacedim>(
36 fe_data,
37 restriction_is_additive_flags,
38 std::vector<ComponentMask>(1, ComponentMask(1, true)))
39 , poly_space(poly_space)
40 {
41 AssertDimension(dim, PolynomialType::dimension + 1);
42 }
43
44
45 template <typename PolynomialType, int dim, int spacedim>
46 unsigned int
47 FE_PolyFace<PolynomialType, dim, spacedim>::get_degree() const
48 {
49 return this->degree;
50 }
51
52
53 //---------------------------------------------------------------------------
54 // Auxiliary functions
55 //---------------------------------------------------------------------------
56
57
58 template <typename PolynomialType, int dim, int spacedim>
59 UpdateFlags
60 FE_PolyFace<PolynomialType, dim, spacedim>::requires_update_flags(
61 const UpdateFlags flags) const
62 {
63 UpdateFlags out = flags & update_values;
64 if (flags & update_gradients)
65 out |= update_gradients | update_covariant_transformation;
66 if (flags & update_hessians)
67 out |= update_hessians | update_covariant_transformation;
68 if (flags & update_normal_vectors)
69 out |= update_normal_vectors | update_JxW_values;
70
71 return out;
72 }
73
74
75 //---------------------------------------------------------------------------
76 // Fill data of FEValues
77 //---------------------------------------------------------------------------
78 template <typename PolynomialType, int dim, int spacedim>
79 void
80 FE_PolyFace<PolynomialType, dim, spacedim>::fill_fe_values(
81 const typename Triangulation<dim, spacedim>::cell_iterator &,
82 const CellSimilarity::Similarity,
83 const Quadrature<dim> &,
84 const Mapping<dim, spacedim> &,
85 const typename Mapping<dim, spacedim>::InternalDataBase &,
86 const internal::FEValuesImplementation::MappingRelatedData<dim, spacedim> &,
87 const typename FiniteElement<dim, spacedim>::InternalDataBase &,
88 dealii::internal::FEValuesImplementation::FiniteElementRelatedData<dim,
89 spacedim>
90 &) const
91 {
92 // Do nothing, since we do not have values in the interior. Since
93 // FEValues initializes the output variables for this function
94 // with invalid values, this means that we simply leave them at
95 // the invalid values -- typically, signaling NaNs. This means
96 // that when you later look at those components of shape
97 // functions or solution vectors that correspond to the
98 // face element, you will see signaling_NaNs. This simply means
99 // that you should not use them -- the shape functions and the
100 // solution do not actually live inside the cell, and so any
101 // attempt at evaluating it there *should* yield an invalid
102 // result.
103 }
104
105
106
107 template <typename PolynomialType, int dim, int spacedim>
108 void
109 FE_PolyFace<PolynomialType, dim, spacedim>::fill_fe_face_values(
110 const typename Triangulation<dim, spacedim>::cell_iterator &,
111 const unsigned int face_no,
112 const hp::QCollection<dim - 1> &quadrature,
113 const Mapping<dim, spacedim> &,
114 const typename Mapping<dim, spacedim>::InternalDataBase &,
115 const internal::FEValuesImplementation::MappingRelatedData<dim, spacedim> &,
116 const typename FiniteElement<dim, spacedim>::InternalDataBase &fe_internal,
117 dealii::internal::FEValuesImplementation::FiniteElementRelatedData<dim,
118 spacedim>
119 &output_data) const
120 {
121 // convert data object to internal
122 // data for this class. fails with
123 // an exception if that is not
124 // possible
125 Assert(dynamic_cast<const InternalData *>(&fe_internal) != nullptr,
126 ExcInternalError());
127 const InternalData &fe_data = static_cast<const InternalData &>(fe_internal);
128
129 AssertDimension(quadrature.size(), 1);
130
131 if (fe_data.update_each & update_values)
132 for (unsigned int i = 0; i < quadrature[0].size(); ++i)
133 {
134 for (unsigned int k = 0; k < this->n_dofs_per_cell(); ++k)
135 output_data.shape_values(k, i) = 0.;
136 switch (dim)
137 {
138 case 3:
139 {
140 // Fill data for quad shape functions
141 if (this->n_dofs_per_quad(face_no) != 0)
142 {
143 const unsigned int foffset =
144 this->get_first_quad_index(face_no);
145 for (unsigned int k = 0; k < this->n_dofs_per_quad(face_no);
146 ++k)
147 output_data.shape_values(foffset + k, i) =
148 fe_data
149 .shape_values[k + this->get_first_face_quad_index(
150 face_no)][i];
151 }
152 }
153 DEAL_II_FALLTHROUGH;
154
155 case 2:
156 {
157 // Fill data for line shape functions
158 if (this->n_dofs_per_line() != 0)
159 {
160 const unsigned int foffset = this->get_first_line_index();
161 for (unsigned int line = 0;
162 line < GeometryInfo<dim>::lines_per_face;
163 ++line)
164 {
165 for (unsigned int k = 0; k < this->n_dofs_per_line();
166 ++k)
167 output_data.shape_values(
168 foffset +
169 GeometryInfo<dim>::face_to_cell_lines(face_no,
170 line) *
171 this->n_dofs_per_line() +
172 k,
173 i) =
174 fe_data.shape_values
175 [k + (line * this->n_dofs_per_line()) +
176 this->get_first_face_line_index(face_no)][i];
177 }
178 }
179 }
180 DEAL_II_FALLTHROUGH;
181
182 case 1:
183 {
184 // Fill data for vertex shape functions
185 if (this->n_dofs_per_vertex() != 0)
186 for (unsigned int lvertex = 0;
187 lvertex < GeometryInfo<dim>::vertices_per_face;
188 ++lvertex)
189 output_data.shape_values(
190 GeometryInfo<dim>::face_to_cell_vertices(face_no,
191 lvertex),
192 i) = fe_data.shape_values[lvertex][i];
193 break;
194 }
195 }
196 }
197 }
198
199
200 template <typename PolynomialType, int dim, int spacedim>
201 void
202 FE_PolyFace<PolynomialType, dim, spacedim>::fill_fe_subface_values(
203 const typename Triangulation<dim, spacedim>::cell_iterator &,
204 const unsigned int face_no,
205 const unsigned int sub_no,
206 const Quadrature<dim - 1> &quadrature,
207 const Mapping<dim, spacedim> &,
208 const typename Mapping<dim, spacedim>::InternalDataBase &,
209 const internal::FEValuesImplementation::MappingRelatedData<dim, spacedim> &,
210 const typename FiniteElement<dim, spacedim>::InternalDataBase &fe_internal,
211 dealii::internal::FEValuesImplementation::FiniteElementRelatedData<dim,
212 spacedim>
213 &output_data) const
214 {
215 // convert data object to internal
216 // data for this class. fails with
217 // an exception if that is not
218 // possible
219 Assert(dynamic_cast<const InternalData *>(&fe_internal) != nullptr,
220 ExcInternalError());
221 const InternalData &fe_data = static_cast<const InternalData &>(fe_internal);
222
223 const unsigned int foffset = fe_data.shape_values.size() * face_no;
224 const unsigned int offset = sub_no * quadrature.size();
225
226 if (fe_data.update_each & update_values)
227 {
228 for (unsigned int k = 0; k < this->n_dofs_per_cell(); ++k)
229 for (unsigned int i = 0; i < quadrature.size(); ++i)
230 output_data.shape_values(k, i) = 0.;
231 for (unsigned int k = 0; k < fe_data.shape_values.size(); ++k)
232 for (unsigned int i = 0; i < quadrature.size(); ++i)
233 output_data.shape_values(foffset + k, i) =
234 fe_data.shape_values[k][i + offset];
235 }
236
237 Assert(!(fe_data.update_each & update_gradients), ExcNotImplemented());
238 Assert(!(fe_data.update_each & update_hessians), ExcNotImplemented());
239 }
240
241 DEAL_II_NAMESPACE_CLOSE
242
243 #endif