deal.II version GIT relicensing-6917-gb466a1809f 2026-10-16 06:30:01+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
mapping_data_on_the_fly.h
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) 2014 - 2024 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
13
14#ifndef dealii_matrix_free_mapping_data_on_the_fly_h
15#define dealii_matrix_free_mapping_data_on_the_fly_h
16
17
18#include <deal.II/base/config.h>
19
24
28
31
32
34
35
36namespace internal
37{
38 namespace MatrixFreeFunctions
39 {
56 template <int dim, typename Number>
58 {
59 public:
64
72 const Quadrature<1> &quadrature,
73 const UpdateFlags update_flags);
74
81 const UpdateFlags update_flags);
82
86 void
87 reinit(typename ::Triangulation<dim>::cell_iterator cell);
88
93 bool
95
99 typename ::Triangulation<dim>::cell_iterator
100 get_cell() const;
101
108 const ::FEValues<dim> &
110
119
129
133 const Quadrature<1> &
135
136 private:
141 typename ::Triangulation<dim>::cell_iterator present_cell;
142
147 std::unique_ptr<FE_Nothing<dim>> fe_dummy;
148
152 std::unique_ptr<::FEValues<dim>> fe_values;
153
158
164 };
165
166
167 /*-------------------------- Inline functions ---------------------------*/
168
169 template <int dim, typename Number>
171 const Mapping<dim> &mapping,
172 const Quadrature<1> &quadrature,
173 const UpdateFlags update_flags)
174 : fe_dummy(std::make_unique<FE_Nothing<dim>>())
175 , fe_values(std::make_unique<::FEValues<dim>>(
176 mapping,
177 *fe_dummy,
178 Quadrature<dim>(quadrature),
179 MappingInfoStorage<dim, dim, Number>::compute_update_flags(
180 update_flags)))
181 , quadrature_1d(quadrature)
182 {
184 mapping_info_storage.descriptor[0].initialize(quadrature);
186 mapping_info_storage.JxW_values.resize(fe_values->n_quadrature_points);
187 mapping_info_storage.jacobians[0].resize(fe_values->n_quadrature_points);
188 if (update_flags & update_quadrature_points)
189 {
192 fe_values->n_quadrature_points);
193 }
194 if (fe_values->get_update_flags() & update_normal_vectors)
195 {
197 fe_values->n_quadrature_points);
199 fe_values->n_quadrature_points);
200 }
201 Assert(!(fe_values->get_update_flags() & update_jacobian_grads),
203 }
204
205
206
207 template <int dim, typename Number>
209 const Quadrature<1> &quadrature,
210 const UpdateFlags update_flags)
211 : MappingDataOnTheFly(::StaticMappingQ1<dim, dim>::mapping,
212 quadrature,
213 update_flags)
214 {}
215
216
217
218 template <int dim, typename Number>
219 inline void
221 typename ::Triangulation<dim>::cell_iterator cell)
222 {
223 if (present_cell == cell)
224 return;
225 present_cell = cell;
226 fe_values->reinit(present_cell);
227 for (unsigned int q = 0; q < fe_values->get_quadrature().size(); ++q)
228 {
229 if (fe_values->get_update_flags() & update_JxW_values)
230 mapping_info_storage.JxW_values[q] = fe_values->JxW(q);
231 if (fe_values->get_update_flags() & update_jacobians)
232 {
233 Tensor<2, dim> jac = fe_values->jacobian(q);
234 jac = invert(transpose(jac));
235 for (unsigned int d = 0; d < dim; ++d)
236 for (unsigned int e = 0; e < dim; ++e)
237 mapping_info_storage.jacobians[0][q][d][e] = jac[d][e];
238 }
239 if (fe_values->get_update_flags() & update_quadrature_points)
240 for (unsigned int d = 0; d < dim; ++d)
241 mapping_info_storage.quadrature_points[q][d] =
242 fe_values->quadrature_point(q)[d];
243 if (fe_values->get_update_flags() & update_normal_vectors)
244 {
245 for (unsigned int d = 0; d < dim; ++d)
246 mapping_info_storage.normal_vectors[q][d] =
247 fe_values->normal_vector(q)[d];
248 mapping_info_storage.normals_times_jacobians[0][q] =
249 mapping_info_storage.normal_vectors[q] *
250 mapping_info_storage.jacobians[0][q];
251 }
252 }
253 }
254
255
256
257 template <int dim, typename Number>
258 inline bool
260 {
261 return present_cell !=
262 typename ::Triangulation<dim>::cell_iterator();
263 }
264
265
266
267 template <int dim, typename Number>
268 inline typename ::Triangulation<dim>::cell_iterator
270 {
271 return fe_values->get_cell();
272 }
273
274
275
276 template <int dim, typename Number>
277 inline const ::FEValues<dim> &
279 {
280 return *fe_values;
281 }
282
283
284
285 template <int dim, typename Number>
288 {
289 return mapping_info_storage;
290 }
291
292
293
294 template <int dim, typename Number>
297 {
298 return mapping_info_storage;
299 }
300
301
302
303 template <int dim, typename Number>
304 inline const Quadrature<1> &
306 {
307 return quadrature_1d;
308 }
309
310
311 } // end of namespace MatrixFreeFunctions
312} // end of namespace internal
313
314
316
317#endif
void resize(const size_type new_size)
Abstract base class for mapping classes.
Definition mapping.h:318
const MappingInfoStorage< dim, dim, Number > & get_data_storage() const
void reinit(typename ::Triangulation< dim >::cell_iterator cell)
MappingDataOnTheFly(const Quadrature< 1 > &quadrature, const UpdateFlags update_flags)
MappingInfoStorage< dim, dim, Number > & get_data_storage()
typename::Triangulation< dim >::cell_iterator present_cell
MappingDataOnTheFly(const Mapping< dim > &mapping, const Quadrature< 1 > &quadrature, const UpdateFlags update_flags)
MappingInfoStorage< dim, dim, Number > mapping_info_storage
typename::Triangulation< dim >::cell_iterator get_cell() const
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
DerivativeForm< 1, spacedim, dim, Number > transpose(const DerivativeForm< 1, dim, spacedim, Number > &DF)
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
UpdateFlags
@ update_jacobian_grads
Gradient of volume element.
@ update_normal_vectors
Normal vectors.
@ update_JxW_values
Transformed quadrature weights.
@ update_jacobians
Volume element.
@ update_quadrature_points
Transformed quadrature points.
std::size_t size
Definition mpi.cc:733
STL namespace.
AlignedVector< Tensor< 1, spacedim, Number > > normal_vectors
std::array< AlignedVector< Tensor< 1, spacedim, Number > >, 2 > normals_times_jacobians
AlignedVector< Point< spacedim, Number > > quadrature_points
std::array< AlignedVector< Tensor< 2, spacedim, Number > >, 2 > jacobians
constexpr SymmetricTensor< 2, dim, Number > invert(const SymmetricTensor< 2, dim, Number > &)