Reference documentation for deal.II version 9.5.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
mapping_fe.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 2020 - 2023 by the deal.II authors
4//
5// This file is part of the deal.II library.
6//
7// The deal.II library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE.md at
12// the top level directory of deal.II.
13//
14// ---------------------------------------------------------------------
15
16#ifndef dealii_mapping_fe_h
17#define dealii_mapping_fe_h
18
19
20#include <deal.II/base/config.h>
21
24#include <deal.II/base/table.h>
26
27#include <deal.II/fe/mapping.h>
28
30
31#include <array>
32#include <cmath>
33
35
36
59template <int dim, int spacedim = dim>
60class MappingFE : public Mapping<dim, spacedim>
61{
62public:
67
71 MappingFE(const MappingFE<dim, spacedim> &mapping);
72
73 // for documentation, see the Mapping base class
74 virtual std::unique_ptr<Mapping<dim, spacedim>>
75 clone() const override;
76
81 unsigned int
82 get_degree() const;
83
84 // for documentation, see the Mapping base class
87 &cell) const override;
88
89
90 virtual bool
91 is_compatible_with(const ReferenceCell &reference_cell) const override;
92
97 virtual bool
99
105 // for documentation, see the Mapping base class
106 virtual Point<spacedim>
109 const Point<dim> &p) const override;
110
111 // for documentation, see the Mapping base class
112 virtual Point<dim>
115 const Point<spacedim> &p) const override;
116
126 // for documentation, see the Mapping base class
127 virtual void
128 transform(const ArrayView<const Tensor<1, dim>> & input,
129 const MappingKind kind,
131 const ArrayView<Tensor<1, spacedim>> &output) const override;
132
133 // for documentation, see the Mapping base class
134 virtual void
136 const MappingKind kind,
138 const ArrayView<Tensor<2, spacedim>> &output) const override;
139
140 // for documentation, see the Mapping base class
141 virtual void
142 transform(const ArrayView<const Tensor<2, dim>> & input,
143 const MappingKind kind,
145 const ArrayView<Tensor<2, spacedim>> &output) const override;
146
147 // for documentation, see the Mapping base class
148 virtual void
150 const MappingKind kind,
152 const ArrayView<Tensor<3, spacedim>> &output) const override;
153
154 // for documentation, see the Mapping base class
155 virtual void
156 transform(const ArrayView<const Tensor<3, dim>> & input,
157 const MappingKind kind,
159 const ArrayView<Tensor<3, spacedim>> &output) const override;
160
181 class InternalData : public Mapping<dim, spacedim>::InternalDataBase
182 {
183 public:
188
197 void
198 initialize(const UpdateFlags update_flags,
199 const Quadrature<dim> &quadrature,
200 const unsigned int n_original_q_points);
201
207 void
208 initialize_face(const UpdateFlags update_flags,
209 const Quadrature<dim> &quadrature,
210 const unsigned int n_original_q_points);
211
216 void
217 compute_shape_function_values(const std::vector<Point<dim>> &unit_points);
218
219
224 const double &
225 shape(const unsigned int qpoint, const unsigned int shape_nr) const;
226
230 double &
231 shape(const unsigned int qpoint, const unsigned int shape_nr);
232
236 const Tensor<1, dim> &
237 derivative(const unsigned int qpoint, const unsigned int shape_nr) const;
238
243 derivative(const unsigned int qpoint, const unsigned int shape_nr);
244
248 const Tensor<2, dim> &
249 second_derivative(const unsigned int qpoint,
250 const unsigned int shape_nr) const;
251
256 second_derivative(const unsigned int qpoint, const unsigned int shape_nr);
257
261 const Tensor<3, dim> &
262 third_derivative(const unsigned int qpoint,
263 const unsigned int shape_nr) const;
264
269 third_derivative(const unsigned int qpoint, const unsigned int shape_nr);
270
274 const Tensor<4, dim> &
275 fourth_derivative(const unsigned int qpoint,
276 const unsigned int shape_nr) const;
277
282 fourth_derivative(const unsigned int qpoint, const unsigned int shape_nr);
283
287 virtual std::size_t
288 memory_consumption() const override;
289
295 std::vector<double> shape_values;
296
302 std::vector<Tensor<1, dim>> shape_derivatives;
303
310 std::vector<Tensor<2, dim>> shape_second_derivatives;
311
318 std::vector<Tensor<3, dim>> shape_third_derivatives;
319
326 std::vector<Tensor<4, dim>> shape_fourth_derivatives;
327
334 std::array<std::vector<Tensor<1, dim>>,
337
342
346 const unsigned int polynomial_degree;
347
351 const unsigned int n_shape_functions;
352
362 mutable std::vector<DerivativeForm<1, dim, spacedim>> covariant;
363
371 mutable std::vector<DerivativeForm<1, dim, spacedim>> contravariant;
372
376 mutable std::vector<std::vector<Tensor<1, spacedim>>> aux;
377
382 mutable std::vector<Point<spacedim>> mapping_support_points;
383
389
394 mutable std::vector<double> volume_elements;
395
399 mutable std::vector<double> quadrature_weights;
400 };
401
402
403 // documentation can be found in Mapping::requires_update_flags()
404 virtual UpdateFlags
405 requires_update_flags(const UpdateFlags update_flags) const override;
406
407 // documentation can be found in Mapping::get_data()
408 virtual std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>
409 get_data(const UpdateFlags, const Quadrature<dim> &quadrature) const override;
410
411 using Mapping<dim, spacedim>::get_face_data;
412
413 // documentation can be found in Mapping::get_face_data()
414 virtual std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>
415 get_face_data(const UpdateFlags flags,
416 const hp::QCollection<dim - 1> &quadrature) const override;
417
418 // documentation can be found in Mapping::get_subface_data()
419 virtual std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>
420 get_subface_data(const UpdateFlags flags,
421 const Quadrature<dim - 1> &quadrature) const override;
422
423 // documentation can be found in Mapping::fill_fe_values()
427 const CellSimilarity::Similarity cell_similarity,
428 const Quadrature<dim> & quadrature,
429 const typename Mapping<dim, spacedim>::InternalDataBase & internal_data,
431 &output_data) const override;
432
433 using Mapping<dim, spacedim>::fill_fe_face_values;
434
435 // documentation can be found in Mapping::fill_fe_face_values()
436 virtual void
439 const unsigned int face_no,
440 const hp::QCollection<dim - 1> & quadrature,
441 const typename Mapping<dim, spacedim>::InternalDataBase & internal_data,
443 &output_data) const override;
444
445 // documentation can be found in Mapping::fill_fe_subface_values()
446 virtual void
449 const unsigned int face_no,
450 const unsigned int subface_no,
451 const Quadrature<dim - 1> & quadrature,
452 const typename Mapping<dim, spacedim>::InternalDataBase & internal_data,
454 &output_data) const override;
455
460protected:
461 const std::unique_ptr<FiniteElement<dim, spacedim>> fe;
462
467 const unsigned int polynomial_degree;
468
472 virtual std::vector<Point<spacedim>>
474 const typename Triangulation<dim, spacedim>::cell_iterator &cell) const;
475
476private:
478};
479
480
481
484/*----------------------------------------------------------------------*/
485
486#ifndef DOXYGEN
487
488template <int dim, int spacedim>
489inline const double &
490MappingFE<dim, spacedim>::InternalData::shape(const unsigned int qpoint,
491 const unsigned int shape_nr) const
492{
493 AssertIndexRange(qpoint * n_shape_functions + shape_nr, shape_values.size());
494 return shape_values[qpoint * n_shape_functions + shape_nr];
495}
496
497
498
499template <int dim, int spacedim>
500inline double &
501MappingFE<dim, spacedim>::InternalData::shape(const unsigned int qpoint,
502 const unsigned int shape_nr)
503{
504 AssertIndexRange(qpoint * n_shape_functions + shape_nr, shape_values.size());
505 return shape_values[qpoint * n_shape_functions + shape_nr];
506}
507
508
509template <int dim, int spacedim>
510inline const Tensor<1, dim> &
512 const unsigned int qpoint,
513 const unsigned int shape_nr) const
514{
515 AssertIndexRange(qpoint * n_shape_functions + shape_nr,
516 shape_derivatives.size());
517 return shape_derivatives[qpoint * n_shape_functions + shape_nr];
518}
519
520
521
522template <int dim, int spacedim>
523inline Tensor<1, dim> &
525 const unsigned int shape_nr)
526{
527 AssertIndexRange(qpoint * n_shape_functions + shape_nr,
528 shape_derivatives.size());
529 return shape_derivatives[qpoint * n_shape_functions + shape_nr];
530}
531
532
533template <int dim, int spacedim>
534inline const Tensor<2, dim> &
536 const unsigned int qpoint,
537 const unsigned int shape_nr) const
538{
539 AssertIndexRange(qpoint * n_shape_functions + shape_nr,
540 shape_second_derivatives.size());
541 return shape_second_derivatives[qpoint * n_shape_functions + shape_nr];
542}
543
544
545template <int dim, int spacedim>
546inline Tensor<2, dim> &
548 const unsigned int qpoint,
549 const unsigned int shape_nr)
550{
551 AssertIndexRange(qpoint * n_shape_functions + shape_nr,
552 shape_second_derivatives.size());
553 return shape_second_derivatives[qpoint * n_shape_functions + shape_nr];
554}
555
556template <int dim, int spacedim>
557inline const Tensor<3, dim> &
559 const unsigned int qpoint,
560 const unsigned int shape_nr) const
561{
562 AssertIndexRange(qpoint * n_shape_functions + shape_nr,
563 shape_third_derivatives.size());
564 return shape_third_derivatives[qpoint * n_shape_functions + shape_nr];
565}
566
567
568template <int dim, int spacedim>
569inline Tensor<3, dim> &
571 const unsigned int qpoint,
572 const unsigned int shape_nr)
573{
574 AssertIndexRange(qpoint * n_shape_functions + shape_nr,
575 shape_third_derivatives.size());
576 return shape_third_derivatives[qpoint * n_shape_functions + shape_nr];
577}
578
579
580template <int dim, int spacedim>
581inline const Tensor<4, dim> &
583 const unsigned int qpoint,
584 const unsigned int shape_nr) const
585{
586 AssertIndexRange(qpoint * n_shape_functions + shape_nr,
587 shape_fourth_derivatives.size());
588 return shape_fourth_derivatives[qpoint * n_shape_functions + shape_nr];
589}
590
591
592template <int dim, int spacedim>
593inline Tensor<4, dim> &
595 const unsigned int qpoint,
596 const unsigned int shape_nr)
597{
598 AssertIndexRange(qpoint * n_shape_functions + shape_nr,
599 shape_fourth_derivatives.size());
600 return shape_fourth_derivatives[qpoint * n_shape_functions + shape_nr];
601}
602
603
604
605template <int dim, int spacedim>
606inline bool
608{
609 return true;
610}
611
612
613
614#endif // DOXYGEN
615
616/* -------------- declaration of explicit specializations ------------- */
617
618
620
621#endif
const Tensor< 3, dim > & third_derivative(const unsigned int qpoint, const unsigned int shape_nr) const
Tensor< 2, dim > & second_derivative(const unsigned int qpoint, const unsigned int shape_nr)
void initialize_face(const UpdateFlags update_flags, const Quadrature< dim > &quadrature, const unsigned int n_original_q_points)
std::vector< Point< spacedim > > mapping_support_points
Definition mapping_fe.h:382
const Tensor< 4, dim > & fourth_derivative(const unsigned int qpoint, const unsigned int shape_nr) const
std::vector< std::vector< Tensor< 1, spacedim > > > aux
Definition mapping_fe.h:376
std::vector< Tensor< 3, dim > > shape_third_derivatives
Definition mapping_fe.h:318
std::vector< Tensor< 2, dim > > shape_second_derivatives
Definition mapping_fe.h:310
Tensor< 1, dim > & derivative(const unsigned int qpoint, const unsigned int shape_nr)
std::vector< Tensor< 4, dim > > shape_fourth_derivatives
Definition mapping_fe.h:326
Tensor< 3, dim > & third_derivative(const unsigned int qpoint, const unsigned int shape_nr)
void initialize(const UpdateFlags update_flags, const Quadrature< dim > &quadrature, const unsigned int n_original_q_points)
Definition mapping_fe.cc:80
Triangulation< dim, spacedim >::cell_iterator cell_of_current_support_points
Definition mapping_fe.h:388
Tensor< 4, dim > & fourth_derivative(const unsigned int qpoint, const unsigned int shape_nr)
void compute_shape_function_values(const std::vector< Point< dim > > &unit_points)
std::array< std::vector< Tensor< 1, dim > >, GeometryInfo< dim >::faces_per_cell *(dim - 1)> unit_tangentials
Definition mapping_fe.h:336
std::vector< double > quadrature_weights
Definition mapping_fe.h:399
const FiniteElement< dim, spacedim > & fe
Definition mapping_fe.h:341
std::vector< DerivativeForm< 1, dim, spacedim > > contravariant
Definition mapping_fe.h:371
std::vector< DerivativeForm< 1, dim, spacedim > > covariant
Definition mapping_fe.h:362
const Tensor< 1, dim > & derivative(const unsigned int qpoint, const unsigned int shape_nr) const
double & shape(const unsigned int qpoint, const unsigned int shape_nr)
std::vector< double > shape_values
Definition mapping_fe.h:295
std::vector< Tensor< 1, dim > > shape_derivatives
Definition mapping_fe.h:302
virtual std::size_t memory_consumption() const override
Definition mapping_fe.cc:60
const Tensor< 2, dim > & second_derivative(const unsigned int qpoint, const unsigned int shape_nr) const
const unsigned int n_shape_functions
Definition mapping_fe.h:351
std::vector< double > volume_elements
Definition mapping_fe.h:394
const double & shape(const unsigned int qpoint, const unsigned int shape_nr) const
const unsigned int polynomial_degree
Definition mapping_fe.h:346
virtual CellSimilarity::Similarity fill_fe_values(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const CellSimilarity::Similarity cell_similarity, const Quadrature< dim > &quadrature, const typename Mapping< dim, spacedim >::InternalDataBase &internal_data, internal::FEValuesImplementation::MappingRelatedData< dim, spacedim > &output_data) const override
const unsigned int polynomial_degree
Definition mapping_fe.h:467
virtual std::unique_ptr< typename Mapping< dim, spacedim >::InternalDataBase > get_face_data(const UpdateFlags flags, const hp::QCollection< dim - 1 > &quadrature) const override
virtual Point< dim > transform_real_to_unit_cell(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const Point< spacedim > &p) const override
virtual UpdateFlags requires_update_flags(const UpdateFlags update_flags) const override
virtual void fill_fe_face_values(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const unsigned int face_no, const hp::QCollection< dim - 1 > &quadrature, const typename Mapping< dim, spacedim >::InternalDataBase &internal_data, internal::FEValuesImplementation::MappingRelatedData< dim, spacedim > &output_data) const override
Table< 2, double > mapping_support_point_weights
Definition mapping_fe.h:477
virtual std::vector< Point< spacedim > > compute_mapping_support_points(const typename Triangulation< dim, spacedim >::cell_iterator &cell) const
virtual void transform(const ArrayView< const Tensor< 1, dim > > &input, const MappingKind kind, const typename Mapping< dim, spacedim >::InternalDataBase &internal, const ArrayView< Tensor< 1, spacedim > > &output) const override
virtual BoundingBox< spacedim > get_bounding_box(const typename Triangulation< dim, spacedim >::cell_iterator &cell) const override
virtual std::unique_ptr< typename Mapping< dim, spacedim >::InternalDataBase > get_data(const UpdateFlags, const Quadrature< dim > &quadrature) const override
virtual std::unique_ptr< typename Mapping< dim, spacedim >::InternalDataBase > get_subface_data(const UpdateFlags flags, const Quadrature< dim - 1 > &quadrature) const override
unsigned int get_degree() const
virtual bool is_compatible_with(const ReferenceCell &reference_cell) const override
virtual void fill_fe_subface_values(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const unsigned int face_no, const unsigned int subface_no, const Quadrature< dim - 1 > &quadrature, const typename Mapping< dim, spacedim >::InternalDataBase &internal_data, internal::FEValuesImplementation::MappingRelatedData< dim, spacedim > &output_data) const override
virtual bool preserves_vertex_locations() const override
virtual std::unique_ptr< Mapping< dim, spacedim > > clone() const override
virtual Point< spacedim > transform_unit_to_real_cell(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const Point< dim > &p) const override
const std::unique_ptr< FiniteElement< dim, spacedim > > fe
Definition mapping_fe.h:461
Abstract base class for mapping classes.
Definition mapping.h:317
Definition point.h:112
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:472
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:473
#define AssertIndexRange(index, range)
UpdateFlags
MappingKind
Definition mapping.h:78