Reference documentation for deal.II version 9.0.0
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 at
12 // the top level of the deal.II distribution.
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/exceptions.h>
22 #include <deal.II/base/vectorization.h>
23 #include <deal.II/base/aligned_vector.h>
24 #include <deal.II/hp/q_collection.h>
25 #include <deal.II/fe/fe.h>
26 #include <deal.II/fe/mapping.h>
27 #include <deal.II/matrix_free/helper_functions.h>
28 #include <deal.II/matrix_free/face_info.h>
29 
30 #include <memory>
31 
32 
33 DEAL_II_NAMESPACE_OPEN
34 
35 
36 namespace internal
37 {
38  namespace MatrixFreeFunctions
39  {
47  enum GeometryType : unsigned char
48  {
52  cartesian = 0,
56  affine = 1,
66  general = 3
67  };
68 
69 
70 
105  template <int structdim, int spacedim, typename Number>
107  {
108  struct QuadratureDescriptor
109  {
113  QuadratureDescriptor();
114 
118  void initialize(const Quadrature<1> &quadrature_1d,
119  const UpdateFlags update_flags_inner_faces = update_default);
120 
124  std::size_t memory_consumption() const;
125 
129  unsigned int n_q_points;
130 
134  Quadrature<structdim> quadrature;
135 
140  std::array<AlignedVector<Number>, structdim> tensor_quadrature_weights;
141 
147  AlignedVector<Number> quadrature_weights;
148 
155  ::Table<2,unsigned int> face_orientations;
156  };
157 
165  std::vector<QuadratureDescriptor> descriptor;
166 
174 
183 
190 
203 
219  AlignedVector<Tensor<1,spacedim *(spacedim+1)/2,
221 
230 
238 
247 
254  unsigned int
255  quad_index_from_n_q_points (const unsigned int n_q_points) const;
256 
261  template <typename StreamType>
262  void print_memory_consumption(StreamType &out,
263  const SizeInfo &task_info) const;
264 
268  std::size_t memory_consumption () const;
269  };
270 
271 
272 
281  template <int dim, typename Number>
282  struct MappingInfo
283  {
287  MappingInfo();
288 
297  void initialize (const ::Triangulation<dim> &tria,
298  const std::vector<std::pair<unsigned int,unsigned int> > &cells,
300  const std::vector<unsigned int> &active_fe_index,
301  const Mapping<dim> &mapping,
302  const std::vector<::hp::QCollection<1> > &quad,
303  const UpdateFlags update_flags_cells,
304  const UpdateFlags update_flags_boundary_faces,
305  const UpdateFlags update_flags_inner_faces,
306  const UpdateFlags update_flags_faces_by_cells);
307 
311  GeometryType get_cell_type (const unsigned int cell_chunk_no) const;
312 
316  void clear ();
317 
321  std::size_t memory_consumption() const;
322 
327  template <typename StreamType>
328  void print_memory_consumption(StreamType &out,
329  const TaskInfo &task_info) const;
330 
337  std::vector<GeometryType> cell_type;
338 
346  std::vector<GeometryType> face_type;
347 
351  std::vector<MappingInfoStorage<dim,dim,Number> > cell_data;
352 
356  std::vector<MappingInfoStorage<dim-1,dim,Number> > face_data;
357 
362  std::vector<MappingInfoStorage<dim-1,dim,Number> > face_data_by_cells;
363 
368  void initialize_cells (const ::Triangulation<dim> &tria,
369  const std::vector<std::pair<unsigned int,unsigned int> > &cells,
370  const std::vector<unsigned int> &active_fe_index,
371  const Mapping<dim> &mapping,
372  const std::vector<::hp::QCollection<1> > &quad,
373  const UpdateFlags update_flags_cells);
374 
379  void initialize_faces (const ::Triangulation<dim> &tria,
380  const std::vector<std::pair<unsigned int,unsigned int> > &cells,
382  const Mapping<dim> &mapping,
383  const std::vector<::hp::QCollection<1> > &quad,
384  const UpdateFlags update_flags_boundary_faces,
385  const UpdateFlags update_flags_inner_faces);
386 
392  (const ::Triangulation<dim> &tria,
393  const std::vector<std::pair<unsigned int,unsigned int> > &cells,
394  const Mapping<dim> &mapping,
395  const std::vector<::hp::QCollection<1> > &quad,
396  const UpdateFlags update_flags_faces_by_cells);
397 
402  static UpdateFlags
403  compute_update_flags (const UpdateFlags update_flags,
404  const std::vector<::hp::QCollection<1> > &quad =
405  std::vector<::hp::QCollection<1> >());
406  };
407 
408 
409 
416  template <int, typename, bool> struct MappingInfoCellsOrFaces;
417 
418  template <int dim, typename Number>
419  struct MappingInfoCellsOrFaces<dim,Number,false>
420  {
422  get(const MappingInfo<dim,Number> &mapping_info,
423  const unsigned int quad_no)
424  {
425  AssertIndexRange(quad_no, mapping_info.cell_data.size());
426  return &mapping_info.cell_data[quad_no];
427  }
428  };
429 
430  template <int dim, typename Number>
431  struct MappingInfoCellsOrFaces<dim,Number,true>
432  {
433  static const MappingInfoStorage<dim-1,dim,Number> *
434  get(const MappingInfo<dim,Number> &mapping_info,
435  const unsigned int quad_no)
436  {
437  AssertIndexRange(quad_no, mapping_info.face_data.size());
438  return &mapping_info.face_data[quad_no];
439  }
440  };
441 
442 
443 
455  template <typename Number>
457  {
458  FPArrayComparator (const Number scaling);
459 
460  bool operator() (const std::vector<Number> &v1,
461  const std::vector<Number> &v2) const;
462 
463  bool operator ()(const Tensor<1,VectorizedArray<Number>::n_array_elements,Number> &t1,
464  const Tensor<1,VectorizedArray<Number>::n_array_elements,Number> &t2) const;
465 
466  template <int dim>
467  bool operator ()(const Tensor<1,dim,Tensor<1,VectorizedArray<Number>::n_array_elements,Number> > &t1,
468  const Tensor<1,dim,Tensor<1,VectorizedArray<Number>::n_array_elements,Number> > &t2) const;
469 
470  template <int dim>
471  bool operator ()(const Tensor<2,dim,Tensor<1,VectorizedArray<Number>::n_array_elements,Number> > &t1,
472  const Tensor<2,dim,Tensor<1,VectorizedArray<Number>::n_array_elements,Number> > &t2) const;
473 
474  Number tolerance;
475  };
476 
477 
478 
479  /* ------------------- inline functions ----------------------------- */
480 
481  template <int structdim, int spacedim, typename Number>
482  inline
483  unsigned int
485  ::quad_index_from_n_q_points (const unsigned int n_q_points) const
486  {
487  for (unsigned int i=0; i<descriptor.size(); ++i)
488  if (n_q_points == descriptor[i].n_q_points)
489  return i;
490  return 0;
491  }
492 
493 
494 
495  template <int dim, typename Number>
496  inline
498  MappingInfo<dim,Number>::get_cell_type (const unsigned int cell_no) const
499  {
500  AssertIndexRange (cell_no, cell_type.size());
501  return cell_type[cell_no];
502  }
503 
504  } // end of namespace MatrixFreeFunctions
505 } // end of namespace internal
506 
507 DEAL_II_NAMESPACE_CLOSE
508 
509 #endif
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, const std::vector<::hp::QCollection< 1 > > &quad, const UpdateFlags update_flags_cells)
AlignedVector< unsigned int > data_index_offsets
Definition: mapping_info.h:173
AlignedVector< unsigned int > quadrature_point_offsets
Definition: mapping_info.h:237
#define AssertIndexRange(index, range)
Definition: exceptions.h:1284
void print_memory_consumption(StreamType &out, const TaskInfo &task_info) const
AlignedVector< Tensor< 1, spacedim, VectorizedArray< Number > > > normals_times_jacobians[2]
Definition: mapping_info.h:229
std::vector< GeometryType > face_type
Definition: mapping_info.h:346
std::vector< QuadratureDescriptor > descriptor
Definition: mapping_info.h:165
static UpdateFlags compute_update_flags(const UpdateFlags update_flags, const std::vector<::hp::QCollection< 1 > > &quad=std::vector<::hp::QCollection< 1 > >())
AlignedVector< Tensor< 2, spacedim, VectorizedArray< Number > > > jacobians[2]
Definition: mapping_info.h:202
void initialize_faces(const ::Triangulation< dim > &tria, const std::vector< std::pair< unsigned int, unsigned int > > &cells, const std::vector< FaceToCellTopology< VectorizedArray< Number >::n_array_elements > > &faces, const Mapping< dim > &mapping, const std::vector<::hp::QCollection< 1 > > &quad, const UpdateFlags update_flags_boundary_faces, const UpdateFlags update_flags_inner_faces)
void initialize_faces_by_cells(const ::Triangulation< dim > &tria, const std::vector< std::pair< unsigned int, unsigned int > > &cells, const Mapping< dim > &mapping, const std::vector<::hp::QCollection< 1 > > &quad, const UpdateFlags update_flags_faces_by_cells)
No update.
AlignedVector< Tensor< 1, spacedim, VectorizedArray< Number > > > normal_vectors
Definition: mapping_info.h:189
UpdateFlags
GeometryType get_cell_type(const unsigned int cell_chunk_no) const
Definition: mapping_info.h:498
void print_memory_consumption(StreamType &out, const SizeInfo &task_info) const
std::vector< MappingInfoStorage< dim-1, dim, Number > > face_data_by_cells
Definition: mapping_info.h:362
unsigned int quad_index_from_n_q_points(const unsigned int n_q_points) const
Definition: mapping_info.h:485
std::vector< MappingInfoStorage< dim, dim, Number > > cell_data
Definition: mapping_info.h:351
void initialize(const ::Triangulation< dim > &tria, const std::vector< std::pair< unsigned int, unsigned int > > &cells, const FaceInfo< VectorizedArray< Number >::n_array_elements > &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)
AlignedVector< Point< spacedim, VectorizedArray< Number > > > quadrature_points
Definition: mapping_info.h:246
Definition: mpi.h:53
AlignedVector< Tensor< 1, spacedim *(spacedim+1)/2, Tensor< 1, spacedim, VectorizedArray< Number > > > > jacobian_gradients[2]
Definition: mapping_info.h:220
std::vector< GeometryType > cell_type
Definition: mapping_info.h:337
AlignedVector< VectorizedArray< Number > > JxW_values
Definition: mapping_info.h:182
std::vector< MappingInfoStorage< dim-1, dim, Number > > face_data
Definition: mapping_info.h:356