Reference documentation for deal.II version 9.2.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\}}\)
mapping_info.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2011 - 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 
17 #ifndef dealii_matrix_free_mapping_info_h
18 #define dealii_matrix_free_mapping_info_h
19 
20 
21 #include <deal.II/base/config.h>
22 
26 
27 #include <deal.II/fe/fe.h>
28 #include <deal.II/fe/mapping.h>
29 
31 
34 
35 #include <memory>
36 
37 
39 
40 
41 namespace internal
42 {
43  namespace MatrixFreeFunctions
44  {
52  enum GeometryType : unsigned char
53  {
57  cartesian = 0,
58 
62  affine = 1,
63 
69 
74  general = 3
75  };
76 
77 
78 
113  template <int structdim,
114  int spacedim,
115  typename Number,
116  typename VectorizedArrayType>
118  {
119  static_assert(
121  "Type of Number and of VectorizedArrayType do not match.");
122 
124  {
129 
133  void
135  const UpdateFlags update_flags_inner_faces = update_default);
136 
140  std::size_t
141  memory_consumption() const;
142 
146  unsigned int n_q_points;
147 
153 
158 
163  std::array<AlignedVector<Number>, structdim> tensor_quadrature_weights;
164 
171 
179  };
180 
188  std::vector<QuadratureDescriptor> descriptor;
189 
197 
206 
213 
226 
243  spacedim *(spacedim + 1) / 2,
246 
256 
264 
273 
277  void
279 
286  unsigned int
287  quad_index_from_n_q_points(const unsigned int n_q_points) const;
288 
293  template <typename StreamType>
294  void
295  print_memory_consumption(StreamType & out,
296  const TaskInfo &task_info) const;
297 
301  std::size_t
302  memory_consumption() const;
303  };
304 
305 
306 
315  template <int dim, typename Number, typename VectorizedArrayType>
316  struct MappingInfo
317  {
326  void
327  initialize(
328  const ::Triangulation<dim> & tria,
329  const std::vector<std::pair<unsigned int, unsigned int>> &cells,
330  const FaceInfo<VectorizedArrayType::size()> & faces,
331  const std::vector<unsigned int> & active_fe_index,
332  const Mapping<dim> & mapping,
333  const std::vector<::hp::QCollection<1>> &quad,
338 
345  void
347  const ::Triangulation<dim> & tria,
348  const std::vector<std::pair<unsigned int, unsigned int>> &cells,
349  const FaceInfo<VectorizedArrayType::size()> & faces,
350  const std::vector<unsigned int> &active_fe_index,
351  const Mapping<dim> & mapping);
352 
357  get_cell_type(const unsigned int cell_chunk_no) const;
358 
362  void
363  clear();
364 
368  std::size_t
369  memory_consumption() const;
370 
375  template <typename StreamType>
376  void
377  print_memory_consumption(StreamType & out,
378  const TaskInfo &task_info) const;
379 
384 
390 
396 
402 
409  std::vector<GeometryType> cell_type;
410 
418  std::vector<GeometryType> face_type;
419 
423  std::vector<MappingInfoStorage<dim, dim, Number, VectorizedArrayType>>
425 
429  std::vector<MappingInfoStorage<dim - 1, dim, Number, VectorizedArrayType>>
431 
436  std::vector<MappingInfoStorage<dim - 1, dim, Number, VectorizedArrayType>>
438 
443 
465  void
467  const ::Triangulation<dim> & tria,
468  const std::vector<std::pair<unsigned int, unsigned int>> &cells,
469  const std::vector<FaceToCellTopology<VectorizedArrayType::size()>>
470  &faces);
471 
476  void
478  const ::Triangulation<dim> & tria,
479  const std::vector<std::pair<unsigned int, unsigned int>> &cells,
480  const std::vector<unsigned int> &active_fe_index,
481  const Mapping<dim> & mapping);
482 
487  void
489  const ::Triangulation<dim> & tria,
490  const std::vector<std::pair<unsigned int, unsigned int>> &cells,
491  const std::vector<FaceToCellTopology<VectorizedArrayType::size()>>
492  & faces,
493  const Mapping<dim> &mapping);
494 
499  void
501  const ::Triangulation<dim> & tria,
502  const std::vector<std::pair<unsigned int, unsigned int>> &cells,
503  const Mapping<dim> & mapping);
504 
509  static UpdateFlags
510  compute_update_flags(const UpdateFlags update_flags,
511  const std::vector<::hp::QCollection<1>> &quad =
512  std::vector<::hp::QCollection<1>>());
513  };
514 
515 
516 
523  template <int, typename, bool, typename>
525 
526  template <int dim, typename Number, typename VectorizedArrayType>
527  struct MappingInfoCellsOrFaces<dim, Number, false, VectorizedArrayType>
528  {
531  const unsigned int quad_no)
532  {
533  AssertIndexRange(quad_no, mapping_info.cell_data.size());
534  return &mapping_info.cell_data[quad_no];
535  }
536  };
537 
538  template <int dim, typename Number, typename VectorizedArrayType>
539  struct MappingInfoCellsOrFaces<dim, Number, true, VectorizedArrayType>
540  {
541  static const MappingInfoStorage<dim - 1, dim, Number, VectorizedArrayType>
542  *
544  const unsigned int quad_no)
545  {
546  AssertIndexRange(quad_no, mapping_info.face_data.size());
547  return &mapping_info.face_data[quad_no];
548  }
549  };
550 
551 
552 
564  template <typename Number,
565  typename VectorizedArrayType = VectorizedArray<Number>>
567  {
568  FPArrayComparator(const Number scaling);
569 
573  bool
574  operator()(const std::vector<Number> &v1,
575  const std::vector<Number> &v2) const;
576 
581  bool
582  operator()(
583  const Tensor<1, VectorizedArrayType::size(), Number> &t1,
584  const Tensor<1, VectorizedArrayType::size(), Number> &t2) const;
585 
590  template <int dim>
591  bool
592  operator()(
593  const Tensor<1, dim, Tensor<1, VectorizedArrayType::size(), Number>>
594  &t1,
595  const Tensor<1, dim, Tensor<1, VectorizedArrayType::size(), Number>>
596  &t2) const;
597 
602  template <int dim>
603  bool
604  operator()(
605  const Tensor<2, dim, Tensor<1, VectorizedArrayType::size(), Number>>
606  &t1,
607  const Tensor<2, dim, Tensor<1, VectorizedArrayType::size(), Number>>
608  &t2) const;
609 
613  template <int dim>
614  bool
615  operator()(const std::array<Tensor<2, dim, Number>, dim + 1> &t1,
616  const std::array<Tensor<2, dim, Number>, dim + 1> &t2) const;
617 
618  Number tolerance;
619  };
620 
621 
622 
623  /* ------------------- inline functions ----------------------------- */
624 
625  template <int structdim,
626  int spacedim,
627  typename Number,
628  typename VectorizedArrayType>
629  inline unsigned int
631  quad_index_from_n_q_points(const unsigned int n_q_points) const
632  {
633  for (unsigned int i = 0; i < descriptor.size(); ++i)
634  if (n_q_points == descriptor[i].n_q_points)
635  return i;
636  return 0;
637  }
638 
639 
640 
641  template <int dim, typename Number, typename VectorizedArrayType>
642  inline GeometryType
644  const unsigned int cell_no) const
645  {
646  AssertIndexRange(cell_no, cell_type.size());
647  return cell_type[cell_no];
648  }
649 
650  } // end of namespace MatrixFreeFunctions
651 } // end of namespace internal
652 
654 
655 #endif
internal::MatrixFreeFunctions::MappingInfo::initialize
void initialize(const ::Triangulation< dim > &tria, const std::vector< std::pair< unsigned int, unsigned int >> &cells, const FaceInfo< VectorizedArrayType::size()> &faces, const std::vector< unsigned int > &active_fe_index, const Mapping< dim > &mapping, const std::vector<::hp::QCollection< 1 >> &quad, const UpdateFlags update_flags_cells, const UpdateFlags update_flags_boundary_faces, const UpdateFlags update_flags_inner_faces, const UpdateFlags update_flags_faces_by_cells)
internal::MatrixFreeFunctions::MappingInfo::memory_consumption
std::size_t memory_consumption() const
internal::MatrixFreeFunctions::affine
@ affine
Definition: mapping_info.h:62
internal::MatrixFreeFunctions::MappingInfo::mapping
SmartPointer< const Mapping< dim > > mapping
Definition: mapping_info.h:442
internal::MatrixFreeFunctions::MappingInfo::cell_data
std::vector< MappingInfoStorage< dim, dim, Number, VectorizedArrayType > > cell_data
Definition: mapping_info.h:424
internal::MatrixFreeFunctions::MappingInfo::update_flags_inner_faces
UpdateFlags update_flags_inner_faces
Definition: mapping_info.h:395
internal::MatrixFreeFunctions::MappingInfo::compute_mapping_q
void compute_mapping_q(const ::Triangulation< dim > &tria, const std::vector< std::pair< unsigned int, unsigned int >> &cells, const std::vector< FaceToCellTopology< VectorizedArrayType::size()>> &faces)
vectorization.h
internal::MatrixFreeFunctions::MappingInfo::compute_update_flags
static UpdateFlags compute_update_flags(const UpdateFlags update_flags, const std::vector<::hp::QCollection< 1 >> &quad=std::vector<::hp::QCollection< 1 >>())
internal::MatrixFreeFunctions::MappingInfoStorage::QuadratureDescriptor::tensor_quadrature_weights
std::array< AlignedVector< Number >, structdim > tensor_quadrature_weights
Definition: mapping_info.h:163
internal::MatrixFreeFunctions::MappingInfoStorage::normal_vectors
AlignedVector< Tensor< 1, spacedim, VectorizedArrayType > > normal_vectors
Definition: mapping_info.h:212
internal::MatrixFreeFunctions::MappingInfo::face_data
std::vector< MappingInfoStorage< dim - 1, dim, Number, VectorizedArrayType > > face_data
Definition: mapping_info.h:430
update_default
@ update_default
No update.
Definition: fe_update_flags.h:69
internal::MatrixFreeFunctions::FaceToCellTopology
Definition: face_info.h:56
internal::MatrixFreeFunctions::MappingInfoStorage::quadrature_points
AlignedVector< Point< spacedim, VectorizedArrayType > > quadrature_points
Definition: mapping_info.h:272
internal::MatrixFreeFunctions::MappingInfoStorage::QuadratureDescriptor::quadrature_1d
Quadrature< 1 > quadrature_1d
Definition: mapping_info.h:152
internal::MatrixFreeFunctions::MappingInfo::update_flags_cells
UpdateFlags update_flags_cells
Definition: mapping_info.h:383
internal::MatrixFreeFunctions::MappingInfoStorage::QuadratureDescriptor::QuadratureDescriptor
QuadratureDescriptor()
internal::MatrixFreeFunctions::general
@ general
Definition: mapping_info.h:74
AssertIndexRange
#define AssertIndexRange(index, range)
Definition: exceptions.h:1649
internal::MatrixFreeFunctions::MappingInfoStorage::quadrature_point_offsets
AlignedVector< unsigned int > quadrature_point_offsets
Definition: mapping_info.h:263
VectorizedArray< Number >
hp::QCollection
Definition: q_collection.h:48
internal::MatrixFreeFunctions::MappingInfoCellsOrFaces< dim, Number, true, VectorizedArrayType >::get
static const MappingInfoStorage< dim - 1, dim, Number, VectorizedArrayType > * get(const MappingInfo< dim, Number, VectorizedArrayType > &mapping_info, const unsigned int quad_no)
Definition: mapping_info.h:543
internal::MatrixFreeFunctions::MappingInfo::update_flags_boundary_faces
UpdateFlags update_flags_boundary_faces
Definition: mapping_info.h:389
face_info.h
internal::MatrixFreeFunctions::TaskInfo
Definition: task_info.h:105
Table< 2, unsigned int >
internal::MatrixFreeFunctions::FPArrayComparator::FPArrayComparator
FPArrayComparator(const Number scaling)
internal::MatrixFreeFunctions::MappingInfoStorage::QuadratureDescriptor::initialize
void initialize(const Quadrature< 1 > &quadrature_1d, const UpdateFlags update_flags_inner_faces=update_default)
internal::MatrixFreeFunctions::MappingInfo::update_flags_faces_by_cells
UpdateFlags update_flags_faces_by_cells
Definition: mapping_info.h:401
internal::MatrixFreeFunctions::FaceInfo
Definition: face_info.h:127
internal::MatrixFreeFunctions::MappingInfoStorage::print_memory_consumption
void print_memory_consumption(StreamType &out, const TaskInfo &task_info) const
internal::MatrixFreeFunctions::MappingInfoStorage::normals_times_jacobians
AlignedVector< Tensor< 1, spacedim, VectorizedArrayType > > normals_times_jacobians[2]
Definition: mapping_info.h:255
Mapping< dim >
internal::MatrixFreeFunctions::MappingInfoStorage::descriptor
std::vector< QuadratureDescriptor > descriptor
Definition: mapping_info.h:188
internal::MatrixFreeFunctions::MappingInfoStorage::QuadratureDescriptor
Definition: mapping_info.h:123
internal::MatrixFreeFunctions::MappingInfo::get_cell_type
GeometryType get_cell_type(const unsigned int cell_chunk_no) const
Definition: mapping_info.h:643
Tensor
Definition: tensor.h:450
internal::MatrixFreeFunctions::MappingInfoStorage::JxW_values
AlignedVector< VectorizedArrayType > JxW_values
Definition: mapping_info.h:205
DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:358
internal::MatrixFreeFunctions::MappingInfo::initialize_faces_by_cells
void initialize_faces_by_cells(const ::Triangulation< dim > &tria, const std::vector< std::pair< unsigned int, unsigned int >> &cells, const Mapping< dim > &mapping)
internal::MatrixFreeFunctions::MappingInfo::initialize_faces
void initialize_faces(const ::Triangulation< dim > &tria, const std::vector< std::pair< unsigned int, unsigned int >> &cells, const std::vector< FaceToCellTopology< VectorizedArrayType::size()>> &faces, const Mapping< dim > &mapping)
internal::MatrixFreeFunctions::cartesian
@ cartesian
Definition: mapping_info.h:57
fe.h
internal::MatrixFreeFunctions::MappingInfoStorage::QuadratureDescriptor::quadrature
Quadrature< structdim > quadrature
Definition: mapping_info.h:157
internal::MatrixFreeFunctions::GeometryType
GeometryType
Definition: mapping_info.h:52
AlignedVector< Number >
internal::MatrixFreeFunctions::MappingInfoCellsOrFaces< dim, Number, false, VectorizedArrayType >::get
static const MappingInfoStorage< dim, dim, Number, VectorizedArrayType > * get(const MappingInfo< dim, Number, VectorizedArrayType > &mapping_info, const unsigned int quad_no)
Definition: mapping_info.h:530
internal::MatrixFreeFunctions::flat_faces
@ flat_faces
Definition: mapping_info.h:68
internal::MatrixFreeFunctions::MappingInfoStorage::quad_index_from_n_q_points
unsigned int quad_index_from_n_q_points(const unsigned int n_q_points) const
Definition: mapping_info.h:631
internal::MatrixFreeFunctions::MappingInfoCellsOrFaces
Definition: mapping_info.h:524
internal::MatrixFreeFunctions::MappingInfoStorage::jacobian_gradients
AlignedVector< Tensor< 1, spacedim *(spacedim+1)/2, Tensor< 1, spacedim, VectorizedArrayType > > > jacobian_gradients[2]
Definition: mapping_info.h:245
exceptions.h
UpdateFlags
UpdateFlags
Definition: fe_update_flags.h:66
internal::MatrixFreeFunctions::MappingInfoStorage::clear_data_fields
void clear_data_fields()
internal::MatrixFreeFunctions::MappingInfo
Definition: mapping_info.h:316
SmartPointer
Definition: smartpointer.h:68
value
static const bool value
Definition: dof_tools_constraints.cc:433
internal::MatrixFreeFunctions::FPArrayComparator::operator()
bool operator()(const std::vector< Number > &v1, const std::vector< Number > &v2) const
mapping.h
internal::MatrixFreeFunctions::MappingInfoStorage::QuadratureDescriptor::quadrature_weights
AlignedVector< Number > quadrature_weights
Definition: mapping_info.h:170
aligned_vector.h
internal::MatrixFreeFunctions::MappingInfo::clear
void clear()
internal::MatrixFreeFunctions::MappingInfo::face_type
std::vector< GeometryType > face_type
Definition: mapping_info.h:418
internal::MatrixFreeFunctions::MappingInfoStorage
Definition: mapping_info.h:117
internal::MatrixFreeFunctions::MappingInfoStorage::data_index_offsets
AlignedVector< unsigned int > data_index_offsets
Definition: mapping_info.h:196
helper_functions.h
config.h
internal::MatrixFreeFunctions::MappingInfoStorage::jacobians
AlignedVector< Tensor< 2, spacedim, VectorizedArrayType > > jacobians[2]
Definition: mapping_info.h:225
internal
Definition: aligned_vector.h:369
q_collection.h
DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:359
internal::MatrixFreeFunctions::MappingInfoStorage::QuadratureDescriptor::memory_consumption
std::size_t memory_consumption() const
Quadrature< 1 >
internal::MatrixFreeFunctions::FPArrayComparator
Definition: mapping_info.h:566
internal::MatrixFreeFunctions::MappingInfo::initialize_cells
void initialize_cells(const ::Triangulation< dim > &tria, const std::vector< std::pair< unsigned int, unsigned int >> &cells, const std::vector< unsigned int > &active_fe_index, const Mapping< dim > &mapping)
internal::MatrixFreeFunctions::MappingInfoStorage::QuadratureDescriptor::face_orientations
::Table< 2, unsigned int > face_orientations
Definition: mapping_info.h:178
internal::MatrixFreeFunctions::MappingInfoStorage::QuadratureDescriptor::n_q_points
unsigned int n_q_points
Definition: mapping_info.h:146
internal::MatrixFreeFunctions::MappingInfo::cell_type
std::vector< GeometryType > cell_type
Definition: mapping_info.h:409
internal::MatrixFreeFunctions::MappingInfo::face_data_by_cells
std::vector< MappingInfoStorage< dim - 1, dim, Number, VectorizedArrayType > > face_data_by_cells
Definition: mapping_info.h:437
internal::MatrixFreeFunctions::MappingInfoStorage::memory_consumption
std::size_t memory_consumption() const
internal::MatrixFreeFunctions::MappingInfo::update_mapping
void update_mapping(const ::Triangulation< dim > &tria, const std::vector< std::pair< unsigned int, unsigned int >> &cells, const FaceInfo< VectorizedArrayType::size()> &faces, const std::vector< unsigned int > &active_fe_index, const Mapping< dim > &mapping)
internal::MatrixFreeFunctions::FPArrayComparator::tolerance
Number tolerance
Definition: mapping_info.h:618
internal::MatrixFreeFunctions::MappingInfo::print_memory_consumption
void print_memory_consumption(StreamType &out, const TaskInfo &task_info) const