Reference documentation for deal.II version Git 7026f387cc 2019-10-15 14:19:01 -0400
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
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/aligned_vector.h>
22 #include <deal.II/base/exceptions.h>
23 #include <deal.II/base/vectorization.h>
24 
25 #include <deal.II/fe/fe.h>
26 #include <deal.II/fe/mapping.h>
27 
28 #include <deal.II/hp/q_collection.h>
29 
30 #include <deal.II/matrix_free/face_info.h>
31 #include <deal.II/matrix_free/helper_functions.h>
32 
33 #include <memory>
34 
35 
36 DEAL_II_NAMESPACE_OPEN
37 
38 
39 namespace internal
40 {
41  namespace MatrixFreeFunctions
42  {
50  enum GeometryType : unsigned char
51  {
55  cartesian = 0,
56 
60  affine = 1,
61 
67 
72  general = 3
73  };
74 
75 
76 
111  template <int structdim,
112  int spacedim,
113  typename Number,
114  typename VectorizedArrayType>
116  {
117  static_assert(
118  std::is_same<Number, typename VectorizedArrayType::value_type>::value,
119  "Type of Number and of VectorizedArrayType do not match.");
120 
121  struct QuadratureDescriptor
122  {
126  QuadratureDescriptor();
127 
131  void
132  initialize(const Quadrature<1> &quadrature_1d,
133  const UpdateFlags update_flags_inner_faces = update_default);
134 
138  std::size_t
139  memory_consumption() const;
140 
144  unsigned int n_q_points;
145 
149  Quadrature<structdim> quadrature;
150 
155  std::array<AlignedVector<Number>, structdim> tensor_quadrature_weights;
156 
162  AlignedVector<Number> quadrature_weights;
163 
170  ::Table<2, unsigned int> face_orientations;
171  };
172 
180  std::vector<QuadratureDescriptor> descriptor;
181 
189 
198 
205 
218 
235  spacedim *(spacedim + 1) / 2,
238 
248 
256 
265 
272  unsigned int
273  quad_index_from_n_q_points(const unsigned int n_q_points) const;
274 
279  template <typename StreamType>
280  void
281  print_memory_consumption(StreamType & out,
282  const SizeInfo &task_info) const;
283 
287  std::size_t
288  memory_consumption() const;
289  };
290 
291 
292 
301  template <int dim, typename Number, typename VectorizedArrayType>
302  struct MappingInfo
303  {
312  void
313  initialize(
314  const ::Triangulation<dim> & tria,
315  const std::vector<std::pair<unsigned int, unsigned int>> &cells,
317  const std::vector<unsigned int> & active_fe_index,
318  const Mapping<dim> & mapping,
319  const std::vector<::hp::QCollection<1>> &quad,
320  const UpdateFlags update_flags_cells,
321  const UpdateFlags update_flags_boundary_faces,
322  const UpdateFlags update_flags_inner_faces,
323  const UpdateFlags update_flags_faces_by_cells);
324 
329  get_cell_type(const unsigned int cell_chunk_no) const;
330 
334  void
335  clear();
336 
340  std::size_t
341  memory_consumption() const;
342 
347  template <typename StreamType>
348  void
349  print_memory_consumption(StreamType & out,
350  const TaskInfo &task_info) const;
351 
358  std::vector<GeometryType> cell_type;
359 
367  std::vector<GeometryType> face_type;
368 
372  std::vector<MappingInfoStorage<dim, dim, Number, VectorizedArrayType>>
374 
378  std::vector<MappingInfoStorage<dim - 1, dim, Number, VectorizedArrayType>>
380 
385  std::vector<MappingInfoStorage<dim - 1, dim, Number, VectorizedArrayType>>
387 
392 
397  void
398  initialize_cells(
399  const ::Triangulation<dim> & tria,
400  const std::vector<std::pair<unsigned int, unsigned int>> &cells,
401  const std::vector<unsigned int> & active_fe_index,
402  const Mapping<dim> & mapping,
403  const std::vector<::hp::QCollection<1>> &quad,
404  const UpdateFlags update_flags_cells);
405 
410  void
411  initialize_faces(
412  const ::Triangulation<dim> & tria,
413  const std::vector<std::pair<unsigned int, unsigned int>> &cells,
414  const std::vector<
416  const Mapping<dim> & mapping,
417  const std::vector<::hp::QCollection<1>> & quad,
418  const UpdateFlags update_flags_boundary_faces,
419  const UpdateFlags update_flags_inner_faces);
420 
425  void
426  initialize_faces_by_cells(
427  const ::Triangulation<dim> & tria,
428  const std::vector<std::pair<unsigned int, unsigned int>> &cells,
429  const Mapping<dim> & mapping,
430  const std::vector<::hp::QCollection<1>> & quad,
431  const UpdateFlags update_flags_faces_by_cells);
432 
437  static UpdateFlags
438  compute_update_flags(const UpdateFlags update_flags,
439  const std::vector<::hp::QCollection<1>> &quad =
440  std::vector<::hp::QCollection<1>>());
441  };
442 
443 
444 
451  template <int, typename, bool, typename>
453 
454  template <int dim, typename Number, typename VectorizedArrayType>
455  struct MappingInfoCellsOrFaces<dim, Number, false, VectorizedArrayType>
456  {
458  get(const MappingInfo<dim, Number, VectorizedArrayType> &mapping_info,
459  const unsigned int quad_no)
460  {
461  AssertIndexRange(quad_no, mapping_info.cell_data.size());
462  return &mapping_info.cell_data[quad_no];
463  }
464  };
465 
466  template <int dim, typename Number, typename VectorizedArrayType>
467  struct MappingInfoCellsOrFaces<dim, Number, true, VectorizedArrayType>
468  {
469  static const MappingInfoStorage<dim - 1, dim, Number, VectorizedArrayType>
470  *
471  get(const MappingInfo<dim, Number, VectorizedArrayType> &mapping_info,
472  const unsigned int quad_no)
473  {
474  AssertIndexRange(quad_no, mapping_info.face_data.size());
475  return &mapping_info.face_data[quad_no];
476  }
477  };
478 
479 
480 
492  template <typename Number,
493  typename VectorizedArrayType = VectorizedArray<Number>>
495  {
496  FPArrayComparator(const Number scaling);
497 
498  bool
499  operator()(const std::vector<Number> &v1,
500  const std::vector<Number> &v2) const;
501 
502  bool
503  operator()(
506  const;
507 
508  template <int dim>
509  bool
510  operator()(
511  const Tensor<1,
512  dim,
514  &t1,
515  const Tensor<1,
516  dim,
518  &t2) const;
519 
520  template <int dim>
521  bool
522  operator()(
523  const Tensor<2,
524  dim,
526  &t1,
527  const Tensor<2,
528  dim,
530  &t2) const;
531 
532  Number tolerance;
533  };
534 
535 
536 
537  /* ------------------- inline functions ----------------------------- */
538 
539  template <int structdim,
540  int spacedim,
541  typename Number,
542  typename VectorizedArrayType>
543  inline unsigned int
545  quad_index_from_n_q_points(const unsigned int n_q_points) const
546  {
547  for (unsigned int i = 0; i < descriptor.size(); ++i)
548  if (n_q_points == descriptor[i].n_q_points)
549  return i;
550  return 0;
551  }
552 
553 
554 
555  template <int dim, typename Number, typename VectorizedArrayType>
556  inline GeometryType
558  const unsigned int cell_no) const
559  {
560  AssertIndexRange(cell_no, cell_type.size());
561  return cell_type[cell_no];
562  }
563 
564  } // end of namespace MatrixFreeFunctions
565 } // end of namespace internal
566 
567 DEAL_II_NAMESPACE_CLOSE
568 
569 #endif
std::vector< MappingInfoStorage< dim - 1, dim, Number, VectorizedArrayType > > face_data
Definition: mapping_info.h:379
AlignedVector< unsigned int > data_index_offsets
Definition: mapping_info.h:188
unsigned int quad_index_from_n_q_points(const unsigned int n_q_points) const
Definition: mapping_info.h:545
AlignedVector< Tensor< 2, spacedim, VectorizedArrayType > > jacobians[2]
Definition: mapping_info.h:217
#define AssertIndexRange(index, range)
Definition: exceptions.h:1637
AlignedVector< Tensor< 1, spacedim *(spacedim+1)/2, Tensor< 1, spacedim, VectorizedArrayType > > > jacobian_gradients[2]
Definition: mapping_info.h:237
void print_memory_consumption(StreamType &out, const SizeInfo &task_info) const
AlignedVector< Point< spacedim, VectorizedArrayType > > quadrature_points
Definition: mapping_info.h:264
No update.
AlignedVector< unsigned int > quadrature_point_offsets
Definition: mapping_info.h:255
std::vector< QuadratureDescriptor > descriptor
Definition: mapping_info.h:180
UpdateFlags
GeometryType get_cell_type(const unsigned int cell_chunk_no) const
Definition: mapping_info.h:557
std::vector< GeometryType > face_type
Definition: mapping_info.h:367
Definition: tensor.h:422
AlignedVector< Tensor< 1, spacedim, VectorizedArrayType > > normals_times_jacobians[2]
Definition: mapping_info.h:247
AlignedVector< VectorizedArrayType > JxW_values
Definition: mapping_info.h:197
std::vector< MappingInfoStorage< dim - 1, dim, Number, VectorizedArrayType > > face_data_by_cells
Definition: mapping_info.h:386
std::vector< GeometryType > cell_type
Definition: mapping_info.h:358
AlignedVector< Tensor< 1, spacedim, VectorizedArrayType > > normal_vectors
Definition: mapping_info.h:204
SmartPointer< const Mapping< dim > > mapping
Definition: mapping_info.h:391
std::vector< MappingInfoStorage< dim, dim, Number, VectorizedArrayType > > cell_data
Definition: mapping_info.h:373