Reference documentation for deal.II version 9.1.0-pre
mapping_info.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2011 - 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.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,
59  affine = 1,
69  general = 3
70  };
71 
72 
73 
108  template <int structdim, int spacedim, typename Number>
110  {
111  struct QuadratureDescriptor
112  {
116  QuadratureDescriptor();
117 
121  void
122  initialize(const Quadrature<1> &quadrature_1d,
123  const UpdateFlags update_flags_inner_faces = update_default);
124 
128  std::size_t
129  memory_consumption() const;
130 
134  unsigned int n_q_points;
135 
139  Quadrature<structdim> quadrature;
140 
145  std::array<AlignedVector<Number>, structdim> tensor_quadrature_weights;
146 
152  AlignedVector<Number> quadrature_weights;
153 
160  ::Table<2, unsigned int> face_orientations;
161  };
162 
170  std::vector<QuadratureDescriptor> descriptor;
171 
179 
188 
196 
209 
226  spacedim *(spacedim + 1) / 2,
227  Tensor<1, spacedim, VectorizedArray<Number>>>>
229 
239 
247 
256 
263  unsigned int
264  quad_index_from_n_q_points(const unsigned int n_q_points) const;
265 
270  template <typename StreamType>
271  void
272  print_memory_consumption(StreamType & out,
273  const SizeInfo &task_info) const;
274 
278  std::size_t
279  memory_consumption() const;
280  };
281 
282 
283 
292  template <int dim, typename Number>
293  struct MappingInfo
294  {
298  MappingInfo();
299 
308  void
309  initialize(
310  const ::Triangulation<dim> & tria,
311  const std::vector<std::pair<unsigned int, unsigned int>> & cells,
313  const std::vector<unsigned int> & active_fe_index,
314  const Mapping<dim> & mapping,
315  const std::vector<::hp::QCollection<1>> &quad,
316  const UpdateFlags update_flags_cells,
317  const UpdateFlags update_flags_boundary_faces,
318  const UpdateFlags update_flags_inner_faces,
319  const UpdateFlags update_flags_faces_by_cells);
320 
325  get_cell_type(const unsigned int cell_chunk_no) const;
326 
330  void
331  clear();
332 
336  std::size_t
337  memory_consumption() const;
338 
343  template <typename StreamType>
344  void
345  print_memory_consumption(StreamType & out,
346  const TaskInfo &task_info) const;
347 
354  std::vector<GeometryType> cell_type;
355 
363  std::vector<GeometryType> face_type;
364 
368  std::vector<MappingInfoStorage<dim, dim, Number>> cell_data;
369 
373  std::vector<MappingInfoStorage<dim - 1, dim, Number>> face_data;
374 
379  std::vector<MappingInfoStorage<dim - 1, dim, Number>> face_data_by_cells;
380 
385  void
386  initialize_cells(
387  const ::Triangulation<dim> & tria,
388  const std::vector<std::pair<unsigned int, unsigned int>> &cells,
389  const std::vector<unsigned int> & active_fe_index,
390  const Mapping<dim> & mapping,
391  const std::vector<::hp::QCollection<1>> &quad,
392  const UpdateFlags update_flags_cells);
393 
398  void
399  initialize_faces(
400  const ::Triangulation<dim> & tria,
401  const std::vector<std::pair<unsigned int, unsigned int>> &cells,
402  const std::vector<
404  const Mapping<dim> & mapping,
405  const std::vector<::hp::QCollection<1>> &quad,
406  const UpdateFlags update_flags_boundary_faces,
407  const UpdateFlags update_flags_inner_faces);
408 
413  void
414  initialize_faces_by_cells(
415  const ::Triangulation<dim> & tria,
416  const std::vector<std::pair<unsigned int, unsigned int>> &cells,
417  const Mapping<dim> & mapping,
418  const std::vector<::hp::QCollection<1>> & quad,
419  const UpdateFlags update_flags_faces_by_cells);
420 
425  static UpdateFlags
426  compute_update_flags(const UpdateFlags update_flags,
427  const std::vector<::hp::QCollection<1>> &quad =
428  std::vector<::hp::QCollection<1>>());
429  };
430 
431 
432 
439  template <int, typename, bool>
441 
442  template <int dim, typename Number>
443  struct MappingInfoCellsOrFaces<dim, Number, false>
444  {
446  get(const MappingInfo<dim, Number> &mapping_info,
447  const unsigned int quad_no)
448  {
449  AssertIndexRange(quad_no, mapping_info.cell_data.size());
450  return &mapping_info.cell_data[quad_no];
451  }
452  };
453 
454  template <int dim, typename Number>
455  struct MappingInfoCellsOrFaces<dim, Number, true>
456  {
457  static const MappingInfoStorage<dim - 1, dim, Number> *
458  get(const MappingInfo<dim, Number> &mapping_info,
459  const unsigned int quad_no)
460  {
461  AssertIndexRange(quad_no, mapping_info.face_data.size());
462  return &mapping_info.face_data[quad_no];
463  }
464  };
465 
466 
467 
479  template <typename Number>
481  {
482  FPArrayComparator(const Number scaling);
483 
484  bool
485  operator()(const std::vector<Number> &v1,
486  const std::vector<Number> &v2) const;
487 
488  bool
489  operator()(
492  const;
493 
494  template <int dim>
495  bool
496  operator()(
497  const Tensor<
498  1,
499  dim,
501  const Tensor<
502  1,
503  dim,
505  const;
506 
507  template <int dim>
508  bool
509  operator()(
510  const Tensor<
511  2,
512  dim,
514  const Tensor<
515  2,
516  dim,
518  const;
519 
520  Number tolerance;
521  };
522 
523 
524 
525  /* ------------------- inline functions ----------------------------- */
526 
527  template <int structdim, int spacedim, typename Number>
528  inline unsigned int
530  const unsigned int n_q_points) const
531  {
532  for (unsigned int i = 0; i < descriptor.size(); ++i)
533  if (n_q_points == descriptor[i].n_q_points)
534  return i;
535  return 0;
536  }
537 
538 
539 
540  template <int dim, typename Number>
541  inline GeometryType
542  MappingInfo<dim, Number>::get_cell_type(const unsigned int cell_no) const
543  {
544  AssertIndexRange(cell_no, cell_type.size());
545  return cell_type[cell_no];
546  }
547 
548  } // end of namespace MatrixFreeFunctions
549 } // end of namespace internal
550 
551 DEAL_II_NAMESPACE_CLOSE
552 
553 #endif
AlignedVector< Tensor< 1, spacedim, VectorizedArray< Number > > > normals_times_jacobians[2]
Definition: mapping_info.h:238
AlignedVector< unsigned int > data_index_offsets
Definition: mapping_info.h:178
AlignedVector< Tensor< 1, spacedim *(spacedim+1)/2, Tensor< 1, spacedim, VectorizedArray< Number > > > > jacobian_gradients[2]
Definition: mapping_info.h:228
void print_memory_consumption(StreamType &out, const SizeInfo &task_info) const
AlignedVector< unsigned int > quadrature_point_offsets
Definition: mapping_info.h:246
#define AssertIndexRange(index, range)
Definition: exceptions.h:1407
std::vector< MappingInfoStorage< dim, dim, Number > > cell_data
Definition: mapping_info.h:368
std::vector< MappingInfoStorage< dim-1, dim, Number > > face_data_by_cells
Definition: mapping_info.h:379
GeometryType get_cell_type(const unsigned int cell_chunk_no) const
Definition: mapping_info.h:542
std::vector< GeometryType > face_type
Definition: mapping_info.h:363
std::vector< QuadratureDescriptor > descriptor
Definition: mapping_info.h:170
No update.
UpdateFlags
unsigned int quad_index_from_n_q_points(const unsigned int n_q_points) const
Definition: mapping_info.h:529
std::vector< MappingInfoStorage< dim-1, dim, Number > > face_data
Definition: mapping_info.h:373
AlignedVector< Point< spacedim, VectorizedArray< Number > > > quadrature_points
Definition: mapping_info.h:255
Definition: mpi.h:55
AlignedVector< Tensor< 1, spacedim, VectorizedArray< Number > > > normal_vectors
Definition: mapping_info.h:195
std::vector< GeometryType > cell_type
Definition: mapping_info.h:354
AlignedVector< Tensor< 2, spacedim, VectorizedArray< Number > > > jacobians[2]
Definition: mapping_info.h:208
AlignedVector< VectorizedArray< Number > > JxW_values
Definition: mapping_info.h:187