Reference documentation for deal.II version 9.0.0
mapping_q_generic.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2000 - 2018 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 at
12 // the top level of the deal.II distribution.
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 #include <deal.II/base/derivative_form.h>
22 #include <deal.II/base/table.h>
23 #include <deal.II/base/quadrature_lib.h>
24 #include <deal.II/base/vectorization.h>
25 #include <deal.II/grid/tria_iterator.h>
26 #include <deal.II/fe/mapping.h>
27 #include <deal.II/fe/fe_q.h>
28 #include <deal.II/matrix_free/shape_info.h>
29 
30 #include <array>
31 #include <cmath>
32 
33 DEAL_II_NAMESPACE_OPEN
34 
35 template <int,int> class MappingQ;
36 
37 
40 
41 
127 template <int dim, int spacedim=dim>
128 class MappingQGeneric : public Mapping<dim,spacedim>
129 {
130 public:
136  MappingQGeneric (const unsigned int polynomial_degree);
137 
142 
143  // for documentation, see the Mapping base class
144  virtual
145  std::unique_ptr<Mapping<dim,spacedim>> clone () const override;
146 
151  unsigned int get_degree () const;
152 
157  virtual
158  bool preserves_vertex_locations () const override;
159 
165  // for documentation, see the Mapping base class
166  virtual
169  const Point<dim> &p) const override;
170 
171  // for documentation, see the Mapping base class
172  virtual
173  Point<dim>
175  const Point<spacedim> &p) const override;
176 
186  // for documentation, see the Mapping base class
187  virtual
188  void
189  transform (const ArrayView<const Tensor<1,dim> > &input,
190  const MappingType type,
191  const typename Mapping<dim,spacedim>::InternalDataBase &internal,
192  const ArrayView<Tensor<1,spacedim> > &output) const override;
193 
194  // for documentation, see the Mapping base class
195  virtual
196  void
198  const MappingType type,
199  const typename Mapping<dim,spacedim>::InternalDataBase &internal,
200  const ArrayView<Tensor<2,spacedim> > &output) const override;
201 
202  // for documentation, see the Mapping base class
203  virtual
204  void
205  transform (const ArrayView<const Tensor<2, dim> > &input,
206  const MappingType type,
207  const typename Mapping<dim,spacedim>::InternalDataBase &internal,
208  const ArrayView<Tensor<2,spacedim> > &output) const override;
209 
210  // for documentation, see the Mapping base class
211  virtual
212  void
214  const MappingType type,
215  const typename Mapping<dim,spacedim>::InternalDataBase &internal,
216  const ArrayView<Tensor<3,spacedim> > &output) const override;
217 
218  // for documentation, see the Mapping base class
219  virtual
220  void
221  transform (const ArrayView<const Tensor<3, dim> > &input,
222  const MappingType type,
223  const typename Mapping<dim,spacedim>::InternalDataBase &internal,
224  const ArrayView<Tensor<3,spacedim> > &output) const override;
225 
235 public:
247  class InternalData : public Mapping<dim,spacedim>::InternalDataBase
248  {
249  public:
254  InternalData(const unsigned int polynomial_degree);
255 
264  void
265  initialize (const UpdateFlags update_flags,
266  const Quadrature<dim> &quadrature,
267  const unsigned int n_original_q_points);
268 
274  void
275  initialize_face (const UpdateFlags update_flags,
276  const Quadrature<dim> &quadrature,
277  const unsigned int n_original_q_points);
278 
294  void compute_shape_function_values (const std::vector<Point<dim> > &unit_points);
295 
296 
301  const double &shape (const unsigned int qpoint,
302  const unsigned int shape_nr) const;
303 
307  double &shape (const unsigned int qpoint,
308  const unsigned int shape_nr);
309 
313  const Tensor<1,dim> &derivative (const unsigned int qpoint,
314  const unsigned int shape_nr) const;
315 
319  Tensor<1,dim> &derivative (const unsigned int qpoint,
320  const unsigned int shape_nr);
321 
325  const Tensor<2,dim> &second_derivative (const unsigned int qpoint,
326  const unsigned int shape_nr) const;
327 
331  Tensor<2,dim> &second_derivative (const unsigned int qpoint,
332  const unsigned int shape_nr);
333 
337  const Tensor<3,dim> &third_derivative (const unsigned int qpoint,
338  const unsigned int shape_nr) const;
339 
343  Tensor<3,dim> &third_derivative (const unsigned int qpoint,
344  const unsigned int shape_nr);
345 
349  const Tensor<4,dim> &fourth_derivative (const unsigned int qpoint,
350  const unsigned int shape_nr) const;
351 
355  Tensor<4,dim> &fourth_derivative (const unsigned int qpoint,
356  const unsigned int shape_nr);
357 
361  virtual
362  std::size_t memory_consumption () const override;
363 
369  std::vector<double> shape_values;
370 
376  std::vector<Tensor<1,dim> > shape_derivatives;
377 
384  std::vector<Tensor<2,dim> > shape_second_derivatives;
385 
392  std::vector<Tensor<3,dim> > shape_third_derivatives;
393 
400  std::vector<Tensor<4,dim> > shape_fourth_derivatives;
401 
415  std::array<std::vector<Tensor<1,dim> >, GeometryInfo<dim>::faces_per_cell *(dim-1)> unit_tangentials;
416 
421  const unsigned int polynomial_degree;
422 
432  const unsigned int n_shape_functions;
433 
434  /*
435  * The default line support points. Is used in when the shape function
436  * values are computed.
437  *
438  * The number of quadrature points depends on the degree of this
439  * class, and it matches the number of degrees of freedom of an
440  * FE_Q<1>(this->degree).
441  */
442  QGaussLobatto<1> line_support_points;
443 
450 
456 
462 
468 
474 
480 
485 
495  mutable std::vector<DerivativeForm<1,dim, spacedim > > covariant;
496 
504  mutable std::vector< DerivativeForm<1,dim,spacedim> > contravariant;
505 
509  mutable std::vector<std::vector<Tensor<1,spacedim> > > aux;
510 
515  mutable std::vector<Point<spacedim> > mapping_support_points;
516 
521 
526  mutable std::vector<double> volume_elements;
527  };
528 
529 
530  // documentation can be found in Mapping::requires_update_flags()
531  virtual
533  requires_update_flags (const UpdateFlags update_flags) const override;
534 
535  // documentation can be found in Mapping::get_data()
536  virtual
537  std::unique_ptr<typename Mapping<dim,spacedim>::InternalDataBase>
538  get_data (const UpdateFlags,
539  const Quadrature<dim> &quadrature) const override;
540 
541  // documentation can be found in Mapping::get_face_data()
542  virtual
543  std::unique_ptr<typename Mapping<dim,spacedim>::InternalDataBase>
544  get_face_data (const UpdateFlags flags,
545  const Quadrature<dim-1>& quadrature) const override;
546 
547  // documentation can be found in Mapping::get_subface_data()
548  virtual
549  std::unique_ptr<typename Mapping<dim,spacedim>::InternalDataBase>
550  get_subface_data (const UpdateFlags flags,
551  const Quadrature<dim-1>& quadrature) const override;
552 
553  // documentation can be found in Mapping::fill_fe_values()
554  virtual
557  const CellSimilarity::Similarity cell_similarity,
558  const Quadrature<dim> &quadrature,
559  const typename Mapping<dim,spacedim>::InternalDataBase &internal_data,
561 
562  // documentation can be found in Mapping::fill_fe_face_values()
563  virtual
564  void
566  const unsigned int face_no,
567  const Quadrature<dim-1> &quadrature,
568  const typename Mapping<dim,spacedim>::InternalDataBase &internal_data,
570 
571  // documentation can be found in Mapping::fill_fe_subface_values()
572  virtual
573  void
575  const unsigned int face_no,
576  const unsigned int subface_no,
577  const Quadrature<dim-1> &quadrature,
578  const typename Mapping<dim,spacedim>::InternalDataBase &internal_data,
580 
585 protected:
586 
591  const unsigned int polynomial_degree;
592 
593  /*
594  * The default line support points. These are used when computing
595  * the location in real space of the support points on lines and
596  * quads, which are asked to the Manifold<dim,spacedim> class.
597  *
598  * The number of quadrature points depends on the degree of this
599  * class, and it matches the number of degrees of freedom of an
600  * FE_Q<1>(this->degree).
601  */
602  QGaussLobatto<1> line_support_points;
603 
609  const std::unique_ptr<FE_Q<dim> > fe_q;
610 
630  std::vector<Table<2,double> > support_point_weights_perimeter_to_interior;
631 
645 
675  virtual
676  std::vector<Point<spacedim> >
678 
683  Point<dim>
685  const Point<spacedim> &p,
686  const Point<dim> &initial_p_unit) const;
687 
701  virtual
702  void
704  std::vector<Point<spacedim> > &a) const;
705 
720  virtual
721  void
723  std::vector<Point<spacedim> > &a) const;
724 
729  template <int, int> friend class MappingQ;
730 };
731 
732 
733 
736 /*----------------------------------------------------------------------*/
737 
738 #ifndef DOXYGEN
739 
740 template <int dim, int spacedim>
741 inline
742 const double &
743 MappingQGeneric<dim,spacedim>::InternalData::shape (const unsigned int qpoint,
744  const unsigned int shape_nr) const
745 {
746  Assert(qpoint*n_shape_functions + shape_nr < shape_values.size(),
747  ExcIndexRange(qpoint*n_shape_functions + shape_nr, 0,
748  shape_values.size()));
749  return shape_values [qpoint*n_shape_functions + shape_nr];
750 }
751 
752 
753 
754 template <int dim, int spacedim>
755 inline
756 double &
757 MappingQGeneric<dim,spacedim>::InternalData::shape (const unsigned int qpoint,
758  const unsigned int shape_nr)
759 {
760  Assert(qpoint*n_shape_functions + shape_nr < shape_values.size(),
761  ExcIndexRange(qpoint*n_shape_functions + shape_nr, 0,
762  shape_values.size()));
763  return shape_values [qpoint*n_shape_functions + shape_nr];
764 }
765 
766 
767 template <int dim, int spacedim>
768 inline
769 const Tensor<1,dim> &
771  const unsigned int shape_nr) const
772 {
773  Assert(qpoint*n_shape_functions + shape_nr < shape_derivatives.size(),
774  ExcIndexRange(qpoint*n_shape_functions + shape_nr, 0,
775  shape_derivatives.size()));
776  return shape_derivatives [qpoint*n_shape_functions + shape_nr];
777 }
778 
779 
780 
781 template <int dim, int spacedim>
782 inline
785  const unsigned int shape_nr)
786 {
787  Assert(qpoint*n_shape_functions + shape_nr < shape_derivatives.size(),
788  ExcIndexRange(qpoint*n_shape_functions + shape_nr, 0,
789  shape_derivatives.size()));
790  return shape_derivatives [qpoint*n_shape_functions + shape_nr];
791 }
792 
793 
794 template <int dim, int spacedim>
795 inline
796 const Tensor<2,dim> &
798  const unsigned int shape_nr) const
799 {
800  Assert(qpoint*n_shape_functions + shape_nr < shape_second_derivatives.size(),
801  ExcIndexRange(qpoint*n_shape_functions + shape_nr, 0,
802  shape_second_derivatives.size()));
803  return shape_second_derivatives [qpoint*n_shape_functions + shape_nr];
804 }
805 
806 
807 template <int dim, int spacedim>
808 inline
811  const unsigned int shape_nr)
812 {
813  Assert(qpoint*n_shape_functions + shape_nr < shape_second_derivatives.size(),
814  ExcIndexRange(qpoint*n_shape_functions + shape_nr, 0,
815  shape_second_derivatives.size()));
816  return shape_second_derivatives [qpoint*n_shape_functions + shape_nr];
817 }
818 
819 template <int dim, int spacedim>
820 inline
821 const Tensor<3,dim> &
823  const unsigned int shape_nr) const
824 {
825  Assert(qpoint*n_shape_functions + shape_nr < shape_third_derivatives.size(),
826  ExcIndexRange(qpoint*n_shape_functions + shape_nr, 0,
827  shape_third_derivatives.size()));
828  return shape_third_derivatives [qpoint*n_shape_functions + shape_nr];
829 }
830 
831 
832 template <int dim, int spacedim>
833 inline
836  const unsigned int shape_nr)
837 {
838  Assert(qpoint*n_shape_functions + shape_nr < shape_third_derivatives.size(),
839  ExcIndexRange(qpoint*n_shape_functions + shape_nr, 0,
840  shape_third_derivatives.size()));
841  return shape_third_derivatives [qpoint*n_shape_functions + shape_nr];
842 }
843 
844 
845 template <int dim, int spacedim>
846 inline
847 const Tensor<4,dim> &
849  const unsigned int shape_nr) const
850 {
851  Assert(qpoint*n_shape_functions + shape_nr < shape_fourth_derivatives.size(),
852  ExcIndexRange(qpoint*n_shape_functions + shape_nr, 0,
853  shape_fourth_derivatives.size()));
854  return shape_fourth_derivatives [qpoint*n_shape_functions + shape_nr];
855 }
856 
857 
858 template <int dim, int spacedim>
859 inline
862  const unsigned int shape_nr)
863 {
864  Assert(qpoint*n_shape_functions + shape_nr < shape_fourth_derivatives.size(),
865  ExcIndexRange(qpoint*n_shape_functions + shape_nr, 0,
866  shape_fourth_derivatives.size()));
867  return shape_fourth_derivatives [qpoint*n_shape_functions + shape_nr];
868 }
869 
870 
871 
872 template <int dim, int spacedim>
873 inline
874 bool
876 {
877  return true;
878 }
879 
880 #endif // DOXYGEN
881 
882 /* -------------- declaration of explicit specializations ------------- */
883 
884 
885 DEAL_II_NAMESPACE_CLOSE
886 
887 #endif
std::vector< DerivativeForm< 1, dim, spacedim > > covariant
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
std::vector< Tensor< 2, dim > > shape_second_derivatives
const unsigned int polynomial_degree
AlignedVector< VectorizedArray< double > > values_quad
MappingType
Definition: mapping.h:51
virtual UpdateFlags requires_update_flags(const UpdateFlags update_flags) const override
std::vector< Table< 2, double > > support_point_weights_perimeter_to_interior
std::vector< Tensor< 4, dim > > shape_fourth_derivatives
virtual Point< spacedim > transform_unit_to_real_cell(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const Point< dim > &p) const override
Table< 2, double > support_point_weights_cell
virtual std::unique_ptr< Mapping< dim, spacedim > > clone() const override
AlignedVector< VectorizedArray< double > > gradients_quad
Triangulation< dim, spacedim >::cell_iterator cell_of_current_support_points
const Tensor< 3, dim > & third_derivative(const unsigned int qpoint, const unsigned int shape_nr) const
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
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
const Tensor< 4, dim > & fourth_derivative(const unsigned int qpoint, const unsigned int shape_nr) const
const std::unique_ptr< FE_Q< dim > > fe_q
InternalData(const unsigned int polynomial_degree)
const unsigned int polynomial_degree
std::vector< Tensor< 1, dim > > shape_derivatives
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 void add_quad_support_points(const typename Triangulation< dim, spacedim >::cell_iterator &cell, std::vector< Point< spacedim > > &a) const
void compute_shape_function_values(const std::vector< Point< dim > > &unit_points)
#define Assert(cond, exc)
Definition: exceptions.h:1142
UpdateFlags
Abstract base class for mapping classes.
Definition: dof_tools.h:46
virtual void transform(const ArrayView< const Tensor< 1, dim > > &input, const MappingType type, const typename Mapping< dim, spacedim >::InternalDataBase &internal, const ArrayView< Tensor< 1, spacedim > > &output) const override
std::vector< Point< spacedim > > mapping_support_points
std::vector< DerivativeForm< 1, dim, spacedim > > contravariant
std::vector< std::vector< Tensor< 1, spacedim > > > aux
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
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
virtual std::unique_ptr< typename Mapping< dim, spacedim >::InternalDataBase > get_face_data(const UpdateFlags flags, const Quadrature< dim-1 > &quadrature) const override
std::array< std::vector< Tensor< 1, dim > >, GeometryInfo< dim >::faces_per_cell *(dim-1)> unit_tangentials
virtual bool preserves_vertex_locations() const override
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
virtual void add_line_support_points(const typename Triangulation< dim, spacedim >::cell_iterator &cell, std::vector< Point< spacedim > > &a) const
std::vector< Tensor< 3, dim > > shape_third_derivatives
const Tensor< 2, dim > & second_derivative(const unsigned int qpoint, const unsigned int shape_nr) const
const Tensor< 1, dim > & derivative(const unsigned int qpoint, const unsigned int shape_nr) const
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
internal::MatrixFreeFunctions::ShapeInfo< VectorizedArray< double > > shape_info
virtual std::unique_ptr< typename Mapping< dim, spacedim >::InternalDataBase > get_subface_data(const UpdateFlags flags, const Quadrature< dim-1 > &quadrature) const override