Reference documentation for deal.II version Git 4fbb5374f0 2021-01-22 15:02:13 -0500
\(\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_fe_field.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2001 - 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_fe_field_h
17 #define dealii_mapping_fe_field_h
18 
19 
20 #include <deal.II/base/config.h>
21 
24 
26 
27 #include <deal.II/fe/fe.h>
28 #include <deal.II/fe/fe_values.h>
29 #include <deal.II/fe/mapping.h>
30 
31 #include <deal.II/lac/vector.h>
32 
33 #include <array>
34 
35 
37 
38 
41 
45 template <int dim,
46  int spacedim = dim,
47  typename VectorType = Vector<double>,
48  typename DoFHandlerType = void>
50 
51 #ifndef DOXYGEN
52 // prevent doxygen from complaining about potential recursive class relations
53 template <int dim, int spacedim, typename VectorType, typename DoFHandlerType>
54 class MappingFEField : public MappingFEField<dim, spacedim, VectorType, void>
55 {
56 public:
58  MappingFEField(const DoFHandlerType &euler_dof_handler,
59  const VectorType & euler_vector,
60  const ComponentMask & mask = ComponentMask())
61  : MappingFEField<dim, spacedim, VectorType, void>(euler_dof_handler,
62  euler_vector,
63  mask)
64  {}
65 
67  MappingFEField(const DoFHandlerType & euler_dof_handler,
68  const std::vector<VectorType> &euler_vector,
69  const ComponentMask & mask = ComponentMask())
70  : MappingFEField<dim, spacedim, VectorType, void>(euler_dof_handler,
71  euler_vector,
72  mask)
73  {}
74 
76  MappingFEField(const DoFHandlerType & euler_dof_handler,
77  const MGLevelObject<VectorType> &euler_vector,
78  const ComponentMask & mask = ComponentMask())
79  : MappingFEField<dim, spacedim, VectorType, void>(euler_dof_handler,
80  euler_vector,
81  mask)
82  {}
83 
87  : MappingFEField<dim, spacedim, VectorType, void>(mapping)
88  {}
89 };
90 #endif // DOXYGEN
91 
127 template <int dim, int spacedim, typename VectorType>
128 class MappingFEField<dim, spacedim, VectorType, void>
129  : public Mapping<dim, spacedim>
130 {
131 public:
164  MappingFEField(const DoFHandler<dim, spacedim> &euler_dof_handler,
165  const VectorType & euler_vector,
166  const ComponentMask & mask = ComponentMask());
167 
177  MappingFEField(const DoFHandler<dim, spacedim> &euler_dof_handler,
178  const std::vector<VectorType> & euler_vector,
179  const ComponentMask & mask = ComponentMask());
180 
188  MappingFEField(const DoFHandler<dim, spacedim> &euler_dof_handler,
189  const MGLevelObject<VectorType> &euler_vector,
190  const ComponentMask & mask = ComponentMask());
191 
197 
202  virtual std::unique_ptr<Mapping<dim, spacedim>>
203  clone() const override;
204 
210  virtual bool
211  preserves_vertex_locations() const override;
212 
220  virtual boost::container::small_vector<Point<spacedim>,
222  get_vertices(const typename Triangulation<dim, spacedim>::cell_iterator &cell)
223  const override;
224 
230  // for documentation, see the Mapping base class
231  virtual Point<spacedim>
232  transform_unit_to_real_cell(
233  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
234  const Point<dim> &p) const override;
235 
236  // for documentation, see the Mapping base class
237  virtual Point<dim>
239  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
240  const Point<spacedim> &p) const override;
241 
251  // for documentation, see the Mapping base class
252  virtual void
253  transform(const ArrayView<const Tensor<1, dim>> & input,
254  const MappingKind kind,
255  const typename Mapping<dim, spacedim>::InternalDataBase &internal,
256  const ArrayView<Tensor<1, spacedim>> &output) const override;
257 
258  // for documentation, see the Mapping base class
259  virtual void
261  const MappingKind kind,
262  const typename Mapping<dim, spacedim>::InternalDataBase &internal,
263  const ArrayView<Tensor<2, spacedim>> &output) const override;
264 
265  // for documentation, see the Mapping base class
266  virtual void
267  transform(const ArrayView<const Tensor<2, dim>> & input,
268  const MappingKind kind,
269  const typename Mapping<dim, spacedim>::InternalDataBase &internal,
270  const ArrayView<Tensor<2, spacedim>> &output) const override;
271 
272  // for documentation, see the Mapping base class
273  virtual void
275  const MappingKind kind,
276  const typename Mapping<dim, spacedim>::InternalDataBase &internal,
277  const ArrayView<Tensor<3, spacedim>> &output) const override;
278 
279  // for documentation, see the Mapping base class
280  virtual void
281  transform(const ArrayView<const Tensor<3, dim>> & input,
282  const MappingKind kind,
283  const typename Mapping<dim, spacedim>::InternalDataBase &internal,
284  const ArrayView<Tensor<3, spacedim>> &output) const override;
285 
294  unsigned int
295  get_degree() const;
296 
302  get_component_mask() const;
303 
307  DeclException0(ExcInactiveCell);
308 
309 private:
315  // documentation can be found in Mapping::requires_update_flags()
316  virtual UpdateFlags
317  requires_update_flags(const UpdateFlags update_flags) const override;
318 
319 public:
331  class InternalData : public Mapping<dim, spacedim>::InternalDataBase
332  {
333  public:
337  InternalData(const FiniteElement<dim, spacedim> &fe,
338  const ComponentMask & mask);
339 
344  const double &
345  shape(const unsigned int qpoint, const unsigned int shape_nr) const;
346 
350  double &
351  shape(const unsigned int qpoint, const unsigned int shape_nr);
352 
356  const Tensor<1, dim> &
357  derivative(const unsigned int qpoint, const unsigned int shape_nr) const;
358 
363  derivative(const unsigned int qpoint, const unsigned int shape_nr);
364 
368  const Tensor<2, dim> &
369  second_derivative(const unsigned int qpoint,
370  const unsigned int shape_nr) const;
371 
376  second_derivative(const unsigned int qpoint, const unsigned int shape_nr);
377 
381  const Tensor<3, dim> &
382  third_derivative(const unsigned int qpoint,
383  const unsigned int shape_nr) const;
384 
389  third_derivative(const unsigned int qpoint, const unsigned int shape_nr);
390 
394  const Tensor<4, dim> &
395  fourth_derivative(const unsigned int qpoint,
396  const unsigned int shape_nr) const;
397 
402  fourth_derivative(const unsigned int qpoint, const unsigned int shape_nr);
403 
407  virtual std::size_t
408  memory_consumption() const override;
409 
415  std::vector<double> shape_values;
416 
422  std::vector<Tensor<1, dim>> shape_derivatives;
423 
430  std::vector<Tensor<2, dim>> shape_second_derivatives;
431 
438  std::vector<Tensor<3, dim>> shape_third_derivatives;
439 
446  std::vector<Tensor<4, dim>> shape_fourth_derivatives;
447 
461  std::array<std::vector<Tensor<1, dim>>,
463  unit_tangentials;
464 
471  unsigned int n_shape_functions;
472 
486 
496  mutable std::vector<DerivativeForm<1, dim, spacedim>> covariant;
497 
505  mutable std::vector<DerivativeForm<1, dim, spacedim>> contravariant;
506 
511  mutable std::vector<double> volume_elements;
512 
516  mutable std::vector<std::vector<Tensor<1, spacedim>>> aux;
517 
521  mutable std::vector<types::global_dof_index> local_dof_indices;
522 
526  mutable std::vector<double> local_dof_values;
527  };
528 
529 private:
530  // documentation can be found in Mapping::get_data()
531  virtual std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>
532  get_data(const UpdateFlags, const Quadrature<dim> &quadrature) const override;
533 
535 
536  // documentation can be found in Mapping::get_face_data()
537  virtual std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>
538  get_face_data(const UpdateFlags flags,
539  const hp::QCollection<dim - 1> &quadrature) const override;
540 
541  // documentation can be found in Mapping::get_subface_data()
542  virtual std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>
543  get_subface_data(const UpdateFlags flags,
544  const Quadrature<dim - 1> &quadrature) const override;
545 
546  // documentation can be found in Mapping::fill_fe_values()
548  fill_fe_values(
549  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
550  const CellSimilarity::Similarity cell_similarity,
551  const Quadrature<dim> & quadrature,
552  const typename Mapping<dim, spacedim>::InternalDataBase & internal_data,
554  &output_data) const override;
555 
557 
558  // documentation can be found in Mapping::fill_fe_face_values()
559  virtual void
560  fill_fe_face_values(
561  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
562  const unsigned int face_no,
563  const hp::QCollection<dim - 1> & quadrature,
564  const typename Mapping<dim, spacedim>::InternalDataBase & internal_data,
566  &output_data) const override;
567 
568  // documentation can be found in Mapping::fill_fe_subface_values()
569  virtual void
570  fill_fe_subface_values(
571  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
572  const unsigned int face_no,
573  const unsigned int subface_no,
574  const Quadrature<dim - 1> & quadrature,
575  const typename Mapping<dim, spacedim>::InternalDataBase & internal_data,
577  &output_data) const override;
578 
587  const bool uses_level_dofs;
588 
592  std::vector<SmartPointer<const VectorType,
595 
602 
603 private:
620  do_transform_unit_to_real_cell(const InternalData &mdata) const;
621 
622 
637  Point<dim>
638  do_transform_real_to_unit_cell(
639  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
640  const Point<spacedim> & p,
641  const Point<dim> & initial_p_unit,
642  InternalData & mdata) const;
643 
647  void
648  update_internal_dofs(
649  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
651  &data) const;
652 
656  virtual void
657  compute_shapes_virtual(
658  const std::vector<Point<dim>> &unit_points,
660  &data) const;
661 
662  /*
663  * Which components to use for the mapping.
664  */
666 
676  std::vector<unsigned int> fe_to_real;
677 
683 
687  mutable std::mutex fe_values_mutex;
688 
689  void
690  compute_data(const UpdateFlags update_flags,
691  const Quadrature<dim> &q,
692  const unsigned int n_original_q_points,
693  InternalData & data) const;
694 
695  void
696  compute_face_data(const UpdateFlags update_flags,
697  const Quadrature<dim> &q,
698  const unsigned int n_original_q_points,
699  InternalData & data) const;
700 
701 
702  // Declare other MappingFEField classes friends.
703  template <int, int, class, class>
704  friend class MappingFEField;
705 };
706 
709 /* -------------- declaration of explicit specializations ------------- */
710 
711 #ifndef DOXYGEN
712 
713 #endif // DOXYGEN
714 
716 
717 #endif
void transform(const InputIterator &begin_in, const InputIterator &end_in, OutputIterator out, const Predicate &predicate, const unsigned int grainsize)
Definition: parallel.h:213
Point< 1 > transform_real_to_unit_cell(const std::array< Point< spacedim >, GeometryInfo< 1 >::vertices_per_cell > &vertices, const Point< spacedim > &p)
std::vector< DerivativeForm< 1, dim, spacedim > > covariant
MappingKind
Definition: mapping.h:64
std::vector< DerivativeForm< 1, dim, spacedim > > contravariant
std::vector< SmartPointer< const VectorType, MappingFEField< dim, spacedim, VectorType, void > > > euler_vector
UpdateFlags
Abstract base class for mapping classes.
Definition: mapping.h:303
#define DeclException0(Exception0)
Definition: exceptions.h:470
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:380
unsigned int get_degree(const std::vector< BarycentricPolynomial< dim >> &polys)
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:379
std::vector< std::vector< Tensor< 1, spacedim > > > aux
#define DEAL_II_DEPRECATED
Definition: config.h:152
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)
SmartPointer< const DoFHandler< dim, spacedim >, MappingFEField< dim, spacedim, VectorType, void > > euler_dof_handler