Reference documentation for deal.II version Git cf38156a17 2020-04-01 20:09:03 -0400
\(\newcommand{\vcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\vcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
mapping_info.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2011 - 2019 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 
23 #include <deal.II/base/aligned_vector.h>
24 #include <deal.II/base/exceptions.h>
25 #include <deal.II/base/vectorization.h>
26 
27 #include <deal.II/fe/fe.h>
28 #include <deal.II/fe/mapping.h>
29 
30 #include <deal.II/hp/q_collection.h>
31 
32 #include <deal.II/matrix_free/face_info.h>
33 #include <deal.II/matrix_free/helper_functions.h>
34 
35 #include <memory>
36 
37 
38 DEAL_II_NAMESPACE_OPEN
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(
120  std::is_same<Number, typename VectorizedArrayType::value_type>::value,
121  "Type of Number and of VectorizedArrayType do not match.");
122 
123  struct QuadratureDescriptor
124  {
128  QuadratureDescriptor();
129 
133  void
134  initialize(const Quadrature<1> &quadrature_1d,
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 
152  Quadrature<1> quadrature_1d;
153 
157  Quadrature<structdim> quadrature;
158 
163  std::array<AlignedVector<Number>, structdim> tensor_quadrature_weights;
164 
170  AlignedVector<Number> quadrature_weights;
171 
178  ::Table<2, unsigned int> face_orientations;
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,
334  const UpdateFlags update_flags_cells,
335  const UpdateFlags update_flags_boundary_faces,
336  const UpdateFlags update_flags_inner_faces,
337  const UpdateFlags update_flags_faces_by_cells);
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
466  compute_mapping_q(
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
477  initialize_cells(
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
488  initialize_faces(
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
500  initialize_faces_by_cells(
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  {
530  get(const MappingInfo<dim, Number, VectorizedArrayType> &mapping_info,
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  *
543  get(const MappingInfo<dim, Number, VectorizedArrayType> &mapping_info,
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 
653 DEAL_II_NAMESPACE_CLOSE
654 
655 #endif
void print_memory_consumption(StreamType &out, const TaskInfo &task_info) const
std::vector< MappingInfoStorage< dim - 1, dim, Number, VectorizedArrayType > > face_data
Definition: mapping_info.h:430
AlignedVector< unsigned int > data_index_offsets
Definition: mapping_info.h:196
unsigned int quad_index_from_n_q_points(const unsigned int n_q_points) const
Definition: mapping_info.h:631
AlignedVector< Tensor< 2, spacedim, VectorizedArrayType > > jacobians[2]
Definition: mapping_info.h:225
#define AssertIndexRange(index, range)
Definition: exceptions.h:1649
AlignedVector< Tensor< 1, spacedim *(spacedim+1)/2, Tensor< 1, spacedim, VectorizedArrayType > > > jacobian_gradients[2]
Definition: mapping_info.h:245
AlignedVector< Point< spacedim, VectorizedArrayType > > quadrature_points
Definition: mapping_info.h:272
No update.
AlignedVector< unsigned int > quadrature_point_offsets
Definition: mapping_info.h:263
std::vector< QuadratureDescriptor > descriptor
Definition: mapping_info.h:188
UpdateFlags
GeometryType get_cell_type(const unsigned int cell_chunk_no) const
Definition: mapping_info.h:643
std::vector< GeometryType > face_type
Definition: mapping_info.h:418
Definition: tensor.h:417
AlignedVector< Tensor< 1, spacedim, VectorizedArrayType > > normals_times_jacobians[2]
Definition: mapping_info.h:255
AlignedVector< VectorizedArrayType > JxW_values
Definition: mapping_info.h:205
std::vector< MappingInfoStorage< dim - 1, dim, Number, VectorizedArrayType > > face_data_by_cells
Definition: mapping_info.h:437
std::vector< GeometryType > cell_type
Definition: mapping_info.h:409
AlignedVector< Tensor< 1, spacedim, VectorizedArrayType > > normal_vectors
Definition: mapping_info.h:212
SmartPointer< const Mapping< dim > > mapping
Definition: mapping_info.h:442
std::vector< MappingInfoStorage< dim, dim, Number, VectorizedArrayType > > cell_data
Definition: mapping_info.h:424