Reference documentation for deal.II version Git 53084d8c6a 2020-10-21 00:34:33 -0400
\(\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\}}\)
mapping_q_generic.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2000 - 2020 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_q_generic_h
17 #define dealii_mapping_q_generic_h
18 
19 
20 #include <deal.II/base/config.h>
21 
25 #include <deal.II/base/table.h>
27 
28 #include <deal.II/fe/mapping.h>
29 
31 
33 
34 #include <array>
35 #include <cmath>
36 
38 
39 template <int, int>
40 class MappingQ;
41 
42 template <int, int>
43 class MappingQCache;
44 
45 
48 
49 
133 template <int dim, int spacedim = dim>
134 class MappingQGeneric : public Mapping<dim, spacedim>
135 {
136 public:
142  MappingQGeneric(const unsigned int polynomial_degree);
143 
148 
149  // for documentation, see the Mapping base class
150  virtual std::unique_ptr<Mapping<dim, spacedim>>
151  clone() const override;
152 
157  unsigned int
158  get_degree() const;
159 
164  virtual bool
165  preserves_vertex_locations() const override;
166 
172  // for documentation, see the Mapping base class
173  virtual Point<spacedim>
175  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
176  const Point<dim> &p) const override;
177 
178  // for documentation, see the Mapping base class
179  virtual Point<dim>
181  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
182  const Point<spacedim> &p) const override;
183 
184  // for documentation, see the Mapping base class
185  virtual void
187  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
188  const ArrayView<const Point<spacedim>> & real_points,
189  const ArrayView<Point<dim>> &unit_points) const override;
190 
200  // for documentation, see the Mapping base class
201  virtual void
202  transform(const ArrayView<const Tensor<1, dim>> & input,
203  const MappingKind kind,
204  const typename Mapping<dim, spacedim>::InternalDataBase &internal,
205  const ArrayView<Tensor<1, spacedim>> &output) const override;
206 
207  // for documentation, see the Mapping base class
208  virtual void
210  const MappingKind kind,
211  const typename Mapping<dim, spacedim>::InternalDataBase &internal,
212  const ArrayView<Tensor<2, spacedim>> &output) const override;
213 
214  // for documentation, see the Mapping base class
215  virtual void
216  transform(const ArrayView<const Tensor<2, dim>> & input,
217  const MappingKind kind,
218  const typename Mapping<dim, spacedim>::InternalDataBase &internal,
219  const ArrayView<Tensor<2, spacedim>> &output) const override;
220 
221  // for documentation, see the Mapping base class
222  virtual void
224  const MappingKind kind,
225  const typename Mapping<dim, spacedim>::InternalDataBase &internal,
226  const ArrayView<Tensor<3, spacedim>> &output) const override;
227 
228  // for documentation, see the Mapping base class
229  virtual void
230  transform(const ArrayView<const Tensor<3, dim>> & input,
231  const MappingKind kind,
232  const typename Mapping<dim, spacedim>::InternalDataBase &internal,
233  const ArrayView<Tensor<3, spacedim>> &output) const override;
234 
244 public:
256  class InternalData : public Mapping<dim, spacedim>::InternalDataBase
257  {
258  public:
263  InternalData(const unsigned int polynomial_degree);
264 
273  void
274  initialize(const UpdateFlags update_flags,
275  const Quadrature<dim> &quadrature,
276  const unsigned int n_original_q_points);
277 
283  void
284  initialize_face(const UpdateFlags update_flags,
285  const Quadrature<dim> &quadrature,
286  const unsigned int n_original_q_points);
287 
303  void
304  compute_shape_function_values(const std::vector<Point<dim>> &unit_points);
305 
310  const double &
311  shape(const unsigned int qpoint, const unsigned int shape_nr) const;
312 
316  double &
317  shape(const unsigned int qpoint, const unsigned int shape_nr);
318 
322  const Tensor<1, dim> &
323  derivative(const unsigned int qpoint, const unsigned int shape_nr) const;
324 
329  derivative(const unsigned int qpoint, const unsigned int shape_nr);
330 
334  const Tensor<2, dim> &
335  second_derivative(const unsigned int qpoint,
336  const unsigned int shape_nr) const;
337 
342  second_derivative(const unsigned int qpoint, const unsigned int shape_nr);
343 
347  const Tensor<3, dim> &
348  third_derivative(const unsigned int qpoint,
349  const unsigned int shape_nr) const;
350 
355  third_derivative(const unsigned int qpoint, const unsigned int shape_nr);
356 
360  const Tensor<4, dim> &
361  fourth_derivative(const unsigned int qpoint,
362  const unsigned int shape_nr) const;
363 
368  fourth_derivative(const unsigned int qpoint, const unsigned int shape_nr);
369 
373  virtual std::size_t
374  memory_consumption() const override;
375 
381  std::vector<double> shape_values;
382 
388  std::vector<Tensor<1, dim>> shape_derivatives;
389 
396  std::vector<Tensor<2, dim>> shape_second_derivatives;
397 
404  std::vector<Tensor<3, dim>> shape_third_derivatives;
405 
412  std::vector<Tensor<4, dim>> shape_fourth_derivatives;
413 
427  std::array<std::vector<Tensor<1, dim>>,
430 
435  const unsigned int polynomial_degree;
436 
446  const unsigned int n_shape_functions;
447 
448  /*
449  * The default line support points. Is used in when the shape function
450  * values are computed.
451  *
452  * The number of quadrature points depends on the degree of this
453  * class, and it matches the number of degrees of freedom of an
454  * FE_Q<1>(this->degree).
455  */
457 
465 
471 
477 
483 
489 
495 
500 
510  mutable std::vector<DerivativeForm<1, dim, spacedim>> covariant;
511 
519  mutable std::vector<DerivativeForm<1, dim, spacedim>> contravariant;
520 
524  mutable std::vector<std::vector<Tensor<1, spacedim>>> aux;
525 
530  mutable std::vector<Point<spacedim>> mapping_support_points;
531 
537 
542  mutable std::vector<double> volume_elements;
543  };
544 
545 
546  // documentation can be found in Mapping::requires_update_flags()
547  virtual UpdateFlags
548  requires_update_flags(const UpdateFlags update_flags) const override;
549 
550  // documentation can be found in Mapping::get_data()
551  virtual std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>
552  get_data(const UpdateFlags, const Quadrature<dim> &quadrature) const override;
553 
554  // documentation can be found in Mapping::get_face_data()
555  virtual std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>
556  get_face_data(const UpdateFlags flags,
557  const Quadrature<dim - 1> &quadrature) const override;
558 
559  // documentation can be found in Mapping::get_subface_data()
560  virtual std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>
561  get_subface_data(const UpdateFlags flags,
562  const Quadrature<dim - 1> &quadrature) const override;
563 
564  // documentation can be found in Mapping::fill_fe_values()
567  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
568  const CellSimilarity::Similarity cell_similarity,
569  const Quadrature<dim> & quadrature,
570  const typename Mapping<dim, spacedim>::InternalDataBase & internal_data,
572  &output_data) const override;
573 
574  // documentation can be found in Mapping::fill_fe_face_values()
575  virtual void
577  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
578  const unsigned int face_no,
579  const Quadrature<dim - 1> & quadrature,
580  const typename Mapping<dim, spacedim>::InternalDataBase & internal_data,
582  &output_data) const override;
583 
584  // documentation can be found in Mapping::fill_fe_subface_values()
585  virtual void
587  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
588  const unsigned int face_no,
589  const unsigned int subface_no,
590  const Quadrature<dim - 1> & quadrature,
591  const typename Mapping<dim, spacedim>::InternalDataBase & internal_data,
593  &output_data) const override;
594 
599 protected:
604  const unsigned int polynomial_degree;
605 
606  /*
607  * The default line support points. These are used when computing the
608  * location in real space of the support points on lines and quads, which
609  * are asked to the Manifold<dim,spacedim> class.
610  *
611  * The number of points depends on the degree of this class, and it matches
612  * the number of degrees of freedom of an FE_Q<1>(this->degree).
613  */
614  std::vector<Point<1>> line_support_points;
615 
616  /*
617  * The one-dimensional polynomials defined as Lagrange polynomials from the
618  * line support points. These are used for point evaluations and match the
619  * polynomial space of an FE_Q<1>(this->degree).
620  */
621  std::vector<Polynomials::Polynomial<double>> polynomials_1d;
622 
623  /*
624  * The numbering from the lexicographic to the hierarchical ordering used
625  * when expanding the tensor product with the mapping support points (which
626  * come in hierarchical numbers).
627  */
628  std::vector<unsigned int> renumber_lexicographic_to_hierarchic;
629 
649  std::vector<Table<2, double>> support_point_weights_perimeter_to_interior;
650 
664 
694  virtual std::vector<Point<spacedim>>
696  const typename Triangulation<dim, spacedim>::cell_iterator &cell) const;
697 
702  Point<dim>
704  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
705  const Point<spacedim> & p,
706  const Point<dim> &initial_p_unit) const;
707 
721  virtual void
723  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
724  std::vector<Point<spacedim>> & a) const;
725 
740  virtual void
742  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
743  std::vector<Point<spacedim>> & a) const;
744 
745  // Make MappingQ a friend since it needs to call the fill_fe_values()
746  // functions on its MappingQGeneric(1) sub-object.
747  template <int, int>
748  friend class MappingQ;
749 
750  // Make MappingQCache a friend since it needs to call the
751  // compute_mapping_support_points() function.
752  template <int, int>
753  friend class MappingQCache;
754 };
755 
756 
757 
760 /*----------------------------------------------------------------------*/
761 
762 #ifndef DOXYGEN
763 
764 template <int dim, int spacedim>
765 inline const double &
767  const unsigned int qpoint,
768  const unsigned int shape_nr) const
769 {
770  AssertIndexRange(qpoint * n_shape_functions + shape_nr, shape_values.size());
771  return shape_values[qpoint * n_shape_functions + shape_nr];
772 }
773 
774 
775 
776 template <int dim, int spacedim>
777 inline double &
779  const unsigned int shape_nr)
780 {
781  AssertIndexRange(qpoint * n_shape_functions + shape_nr, shape_values.size());
782  return shape_values[qpoint * n_shape_functions + shape_nr];
783 }
784 
785 
786 template <int dim, int spacedim>
787 inline const Tensor<1, dim> &
789  const unsigned int qpoint,
790  const unsigned int shape_nr) const
791 {
792  AssertIndexRange(qpoint * n_shape_functions + shape_nr,
793  shape_derivatives.size());
794  return shape_derivatives[qpoint * n_shape_functions + shape_nr];
795 }
796 
797 
798 
799 template <int dim, int spacedim>
800 inline Tensor<1, dim> &
802  const unsigned int qpoint,
803  const unsigned int shape_nr)
804 {
805  AssertIndexRange(qpoint * n_shape_functions + shape_nr,
806  shape_derivatives.size());
807  return shape_derivatives[qpoint * n_shape_functions + shape_nr];
808 }
809 
810 
811 template <int dim, int spacedim>
812 inline const Tensor<2, dim> &
814  const unsigned int qpoint,
815  const unsigned int shape_nr) const
816 {
817  AssertIndexRange(qpoint * n_shape_functions + shape_nr,
818  shape_second_derivatives.size());
819  return shape_second_derivatives[qpoint * n_shape_functions + shape_nr];
820 }
821 
822 
823 template <int dim, int spacedim>
824 inline Tensor<2, dim> &
826  const unsigned int qpoint,
827  const unsigned int shape_nr)
828 {
829  AssertIndexRange(qpoint * n_shape_functions + shape_nr,
830  shape_second_derivatives.size());
831  return shape_second_derivatives[qpoint * n_shape_functions + shape_nr];
832 }
833 
834 template <int dim, int spacedim>
835 inline const Tensor<3, dim> &
837  const unsigned int qpoint,
838  const unsigned int shape_nr) const
839 {
840  AssertIndexRange(qpoint * n_shape_functions + shape_nr,
841  shape_third_derivatives.size());
842  return shape_third_derivatives[qpoint * n_shape_functions + shape_nr];
843 }
844 
845 
846 template <int dim, int spacedim>
847 inline Tensor<3, dim> &
849  const unsigned int qpoint,
850  const unsigned int shape_nr)
851 {
852  AssertIndexRange(qpoint * n_shape_functions + shape_nr,
853  shape_third_derivatives.size());
854  return shape_third_derivatives[qpoint * n_shape_functions + shape_nr];
855 }
856 
857 
858 template <int dim, int spacedim>
859 inline const Tensor<4, dim> &
861  const unsigned int qpoint,
862  const unsigned int shape_nr) const
863 {
864  AssertIndexRange(qpoint * n_shape_functions + shape_nr,
865  shape_fourth_derivatives.size());
866  return shape_fourth_derivatives[qpoint * n_shape_functions + shape_nr];
867 }
868 
869 
870 template <int dim, int spacedim>
871 inline Tensor<4, dim> &
873  const unsigned int qpoint,
874  const unsigned int shape_nr)
875 {
876  AssertIndexRange(qpoint * n_shape_functions + shape_nr,
877  shape_fourth_derivatives.size());
878  return shape_fourth_derivatives[qpoint * n_shape_functions + shape_nr];
879 }
880 
881 
882 
883 template <int dim, int spacedim>
884 inline bool
886 {
887  return true;
888 }
889 
890 #endif // DOXYGEN
891 
892 /* -------------- declaration of explicit specializations ------------- */
893 
894 
896 
897 #endif
std::vector< Tensor< 2, dim > > shape_second_derivatives
const unsigned int polynomial_degree
Table< 2, double > support_point_weights_cell
virtual void add_quad_support_points(const typename Triangulation< dim, spacedim >::cell_iterator &cell, std::vector< Point< spacedim >> &a) const
AlignedVector< VectorizedArray< double > > values_quad
const Tensor< 1, dim > & derivative(const unsigned int qpoint, const unsigned int shape_nr) const
virtual UpdateFlags requires_update_flags(const UpdateFlags update_flags) const override
virtual void add_line_support_points(const typename Triangulation< dim, spacedim >::cell_iterator &cell, std::vector< Point< spacedim >> &a) const
const Tensor< 3, dim > & third_derivative(const unsigned int qpoint, const unsigned int shape_nr) const
virtual Point< spacedim > transform_unit_to_real_cell(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const Point< dim > &p) const override
#define AssertIndexRange(index, range)
Definition: exceptions.h:1648
std::vector< unsigned int > renumber_lexicographic_to_hierarchic
virtual std::unique_ptr< Mapping< dim, spacedim > > clone() const override
AlignedVector< VectorizedArray< double > > gradients_quad
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
MappingQGeneric(const unsigned int polynomial_degree)
AlignedVector< VectorizedArray< double > > scratch
virtual void fill_fe_face_values(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const unsigned int face_no, const Quadrature< dim - 1 > &quadrature, const typename Mapping< dim, spacedim >::InternalDataBase &internal_data, ::internal::FEValuesImplementation::MappingRelatedData< dim, spacedim > &output_data) const override
MappingKind
Definition: mapping.h:62
InternalData(const unsigned int polynomial_degree)
const unsigned int polynomial_degree
QGaussLobatto< 1 > line_support_points
std::vector< Table< 2, double > > support_point_weights_perimeter_to_interior
std::vector< Polynomials::Polynomial< double > > polynomials_1d
virtual void transform_points_real_to_unit_cell(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const ArrayView< const Point< spacedim >> &real_points, const ArrayView< Point< dim >> &unit_points) const override
void compute_shape_function_values(const std::vector< Point< dim >> &unit_points)
std::vector< std::vector< Tensor< 1, spacedim > > > aux
UpdateFlags
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
Abstract base class for mapping classes.
Definition: mapping.h:301
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:369
std::vector< Point< spacedim > > mapping_support_points
std::vector< Tensor< 3, dim > > shape_third_derivatives
virtual std::unique_ptr< typename Mapping< dim, spacedim >::InternalDataBase > get_data(const UpdateFlags, const Quadrature< dim > &quadrature) const override
void initialize(const UpdateFlags update_flags, const Quadrature< dim > &quadrature, const unsigned int n_original_q_points)
std::vector< double > volume_elements
const unsigned int n_shape_functions
virtual std::unique_ptr< typename Mapping< dim, spacedim >::InternalDataBase > get_subface_data(const UpdateFlags flags, const Quadrature< dim - 1 > &quadrature) const override
std::vector< Tensor< 1, dim > > shape_derivatives
Point< dim > transform_real_to_unit_cell_internal(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const Point< spacedim > &p, const Point< dim > &initial_p_unit) const
AlignedVector< VectorizedArray< double > > hessians_quad
AlignedVector< VectorizedArray< double > > values_dofs
unsigned int get_degree() const
const double & shape(const unsigned int qpoint, const unsigned int shape_nr) const
std::array< std::vector< Tensor< 1, dim > >, GeometryInfo< dim >::faces_per_cell *(dim - 1)> unit_tangentials
std::vector< Point< 1 > > line_support_points
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:368
virtual bool preserves_vertex_locations() const override
const Tensor< 2, dim > & second_derivative(const unsigned int qpoint, const unsigned int shape_nr) const
Triangulation< dim, spacedim >::cell_iterator cell_of_current_support_points
virtual std::size_t memory_consumption() const override
virtual std::vector< Point< spacedim > > compute_mapping_support_points(const typename Triangulation< dim, spacedim >::cell_iterator &cell) const
std::vector< DerivativeForm< 1, dim, spacedim > > contravariant
std::vector< Tensor< 4, dim > > shape_fourth_derivatives
void initialize_face(const UpdateFlags update_flags, const Quadrature< dim > &quadrature, const unsigned int n_original_q_points)
std::vector< double > shape_values
virtual Point< dim > transform_real_to_unit_cell(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const Point< spacedim > &p) const override
const Tensor< 4, dim > & fourth_derivative(const unsigned int qpoint, const unsigned int shape_nr) const
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
std::vector< DerivativeForm< 1, dim, spacedim > > covariant
internal::MatrixFreeFunctions::ShapeInfo< VectorizedArray< double > > shape_info
virtual std::unique_ptr< typename Mapping< dim, spacedim >::InternalDataBase > get_face_data(const UpdateFlags flags, const Quadrature< dim - 1 > &quadrature) const override