Reference documentation for deal.II version 8.5.1
mapping_info.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2011 - 2016 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 
29 #include <memory>
30 
31 
32 DEAL_II_NAMESPACE_OPEN
33 
34 
35 namespace internal
36 {
37  namespace MatrixFreeFunctions
38  {
45  template <int dim, typename Number>
46  struct MappingInfo
47  {
52  static const std::size_t n_cell_type_bits = 2;
53 
58  static const unsigned int n_cell_types = 1U<<n_cell_type_bits;
59 
65 
69  MappingInfo();
70 
79  void initialize (const ::Triangulation<dim> &tria,
80  const std::vector<std::pair<unsigned int,unsigned int> > &cells,
81  const std::vector<unsigned int> &active_fe_index,
82  const Mapping<dim> &mapping,
83  const std::vector<::hp::QCollection<1> > &quad,
84  const UpdateFlags update_flags);
85 
90  static UpdateFlags
91  compute_update_flags (const UpdateFlags update_flags,
92  const std::vector<::hp::QCollection<1> > &quad =
93  std::vector<::hp::QCollection<1> >());
94 
98  CellType get_cell_type (const unsigned int cell_chunk_no) const;
99 
103  unsigned int get_cell_data_index (const unsigned int cell_chunk_no) const;
104 
108  void clear ();
109 
113  std::size_t memory_consumption() const;
114 
119  template <typename StreamType>
120  void print_memory_consumption(StreamType &out,
121  const SizeInfo &size_info) const;
122 
131  std::vector<unsigned int> cell_type;
132 
147 
162 
169  {
174  std::vector<unsigned int> rowstart_jacobians;
175 
182 
188 
199 
208  AlignedVector<Tensor<1,(dim>1?dim*(dim-1)/2:1),
210 
217  std::vector<unsigned int> rowstart_q_points;
218 
224 
230 
237 
241  std::vector<unsigned int> n_q_points;
242 
249  std::vector<unsigned int> n_q_points_face;
250 
254  std::vector<AlignedVector<VectorizedArray<Number> > > quadrature_weights;
255 
261  std::vector<unsigned int> quad_index_conversion;
262 
269  unsigned int
270  quad_index_from_n_q_points (const unsigned int n_q_points) const;
271 
272 
277  template <typename StreamType>
278  void print_memory_consumption(StreamType &out,
279  const SizeInfo &size_info) const;
280 
284  std::size_t memory_consumption () const;
285  };
286 
290  std::vector<MappingInfoDependent> mapping_data_gen;
291 
296 
301 
306 
310  struct CellData
311  {
312  CellData (const double jac_size);
313  void resize (const unsigned int size);
314 
319  const double jac_size;
320  };
321 
325  void evaluate_on_cell (const ::Triangulation<dim> &tria,
326  const std::pair<unsigned int,unsigned int> *cells,
327  const unsigned int cell,
328  const unsigned int my_q,
329  CellType (&cell_t_prev)[n_vector_elements],
330  CellType (&cell_t)[n_vector_elements],
331  ::FEValues<dim,dim> &fe_values,
332  CellData &cell_data) const;
333  };
334 
335 
336 
337  /* ------------------- inline functions ----------------------------- */
338 
339  template <int dim, typename Number>
340  inline
341  unsigned int
343  quad_index_from_n_q_points (const unsigned int n_q_points) const
344  {
345  for (unsigned int i=0; i<quad_index_conversion.size(); ++i)
347  return i;
348  return 0;
349  }
350 
351 
352 
353  template <int dim, typename Number>
354  inline
355  CellType
356  MappingInfo<dim,Number>::get_cell_type (const unsigned int cell_no) const
357  {
358  AssertIndexRange (cell_no, cell_type.size());
359  CellType enum_cell_type = (CellType)(cell_type[cell_no] % n_cell_types);
360  Assert(enum_cell_type != undefined, ExcInternalError());
361  return enum_cell_type;
362  }
363 
364 
365 
366  template <int dim, typename Number>
367  inline
368  unsigned int
369  MappingInfo<dim,Number>::get_cell_data_index (const unsigned int cell_no) const
370  {
371  AssertIndexRange (cell_no, cell_type.size());
372  return cell_type[cell_no] >> n_cell_type_bits;
373  }
374 
375  } // end of namespace MatrixFreeFunctions
376 } // end of namespace internal
377 
378 DEAL_II_NAMESPACE_CLOSE
379 
380 #endif
AlignedVector< std::pair< Tensor< 1, dim, VectorizedArray< Number > >, VectorizedArray< Number > > > cartesian_data
Definition: mapping_info.h:146
AlignedVector< VectorizedArray< Number > > JxW_values
Definition: mapping_info.h:187
AlignedVector< std::pair< Tensor< 2, dim, VectorizedArray< Number > >, VectorizedArray< Number > > > affine_data
Definition: mapping_info.h:161
#define AssertIndexRange(index, range)
Definition: exceptions.h:1170
unsigned int get_cell_data_index(const unsigned int cell_chunk_no) const
Definition: mapping_info.h:369
std::vector< MappingInfoDependent > mapping_data_gen
Definition: mapping_info.h:290
static const unsigned int n_vector_elements
Definition: mapping_info.h:64
static UpdateFlags compute_update_flags(const UpdateFlags update_flags, const std::vector<::hp::QCollection< 1 > > &quad=std::vector<::hp::QCollection< 1 > >())
unsigned int quad_index_from_n_q_points(const unsigned int n_q_points) const
Definition: mapping_info.h:343
std::vector< unsigned int > cell_type
Definition: mapping_info.h:131
#define Assert(cond, exc)
Definition: exceptions.h:313
UpdateFlags
AlignedVector< Tensor< 1,(dim >1?dim *(dim-1)/2:1), Tensor< 1, dim, VectorizedArray< Number > > > > jacobians_grad_upper
Definition: mapping_info.h:209
void evaluate_on_cell(const ::Triangulation< dim > &tria, const std::pair< unsigned int, unsigned int > *cells, const unsigned int cell, const unsigned int my_q, CellType(&cell_t_prev)[n_vector_elements], CellType(&cell_t)[n_vector_elements], ::FEValues< dim, dim > &fe_values, CellData &cell_data) const
static const unsigned int n_cell_types
Definition: mapping_info.h:58
void print_memory_consumption(StreamType &out, const SizeInfo &size_info) const
Definition: mpi.h:41
AlignedVector< Point< dim, VectorizedArray< Number > > > quadrature_points
Definition: mapping_info.h:223
void initialize(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)
static const std::size_t n_cell_type_bits
Definition: mapping_info.h:52
Definition: fe.h:30
CellType get_cell_type(const unsigned int cell_chunk_no) const
Definition: mapping_info.h:356
std::vector< AlignedVector< VectorizedArray< Number > > > quadrature_weights
Definition: mapping_info.h:254
AlignedVector< Tensor< 2, dim, VectorizedArray< Number > > > jacobians
Definition: mapping_info.h:181
AlignedVector< Tensor< 2, dim, VectorizedArray< Number > > > jacobians_grad_diag
Definition: mapping_info.h:198
void print_memory_consumption(StreamType &out, const SizeInfo &size_info) const
static ::ExceptionBase & ExcInternalError()