Reference documentation for deal.II version 9.0.0
dof_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_dof_info_h
18 #define dealii_matrix_free_dof_info_h
19 
20 
21 #include <deal.II/base/exceptions.h>
22 #include <deal.II/base/vectorization.h>
23 #include <deal.II/base/partitioner.h>
24 #include <deal.II/lac/constraint_matrix.h>
25 #include <deal.II/lac/dynamic_sparsity_pattern.h>
26 #include <deal.II/dofs/dof_handler.h>
27 #include <deal.II/matrix_free/task_info.h>
28 #include <deal.II/matrix_free/face_info.h>
29 
30 #include <array>
31 #include <memory>
32 
33 
34 DEAL_II_NAMESPACE_OPEN
35 
36 namespace internal
37 {
38  namespace MatrixFreeFunctions
39  {
40  template <typename Number> struct ConstraintValues;
41 
62  struct DoFInfo
63  {
74  static const unsigned int chunk_size_zero_vector = 8192;
75 
79  DoFInfo ();
80 
84  DoFInfo (const DoFInfo &) = default;
85 
89  void clear ();
90 
96  unsigned int fe_index_from_degree (const unsigned int first_selected_component,
97  const unsigned int fe_degree) const;
98 
107  void read_dof_indices (const std::vector<types::global_dof_index> &local_indices,
108  const std::vector<unsigned int> &lexicographic_inv,
109  const ConstraintMatrix &constraints,
110  const unsigned int cell_number,
111  ConstraintValues<double> &constraint_values,
112  bool &cell_at_boundary);
113 
121  void assign_ghosts(const std::vector<unsigned int> &boundary_cells);
122 
129  void reorder_cells (const TaskInfo &task_info,
130  const std::vector<unsigned int> &renumbering,
131  const std::vector<unsigned int> &constraint_pool_row_index,
132  const std::vector<unsigned char> &irregular_cells);
133 
138  void
139  compute_cell_index_compression(const std::vector<unsigned char> &irregular_cells);
140 
145  template <int length>
146  void
148 
154  void
155  make_connectivity_graph (const TaskInfo &task_info,
156  const std::vector<unsigned int> &renumbering,
157  DynamicSparsityPattern &connectivity) const;
158 
169  void compute_dof_renumbering (std::vector<types::global_dof_index> &renumbering);
170 
180  template <int length>
181  void
183  const std::vector<FaceToCellTopology<length> > &faces);
184 
188  std::size_t memory_consumption() const;
189 
194  template <typename StreamType>
195  void print_memory_consumption(StreamType &out,
196  const TaskInfo &size_info) const;
197 
202  template <typename Number>
203  void print (const std::vector<Number> &constraint_pool_data,
204  const std::vector<unsigned int> &constraint_pool_row_index,
205  std::ostream &out) const;
206 
218  enum class IndexStorageVariants : unsigned char
219  {
228  full,
240  interleaved,
249  contiguous
250  };
251 
256  enum DoFAccessIndex : unsigned char
257  {
270  };
271 
277  unsigned int dimension;
278 
287  unsigned int vectorization_length;
288 
296  std::vector<IndexStorageVariants> index_storage_variants[3];
297 
304  std::vector<std::pair<unsigned int, unsigned int> > row_starts;
305 
321  std::vector<unsigned int> dof_indices;
322 
332  std::vector<std::pair<unsigned short,unsigned short> > constraint_indicator;
333 
337  std::vector<unsigned int> dof_indices_interleaved;
338 
347  std::vector<unsigned int> dof_indices_contiguous[3];
348 
358  std::vector<unsigned char> n_vectorization_lanes_filled[3];
359 
366  std::shared_ptr<const Utilities::MPI::Partitioner> vector_partitioner;
367 
379  std::array<std::shared_ptr<const Utilities::MPI::Partitioner>, 3> vector_partitioner_face_variants;
380 
385  std::vector<unsigned int> constrained_dofs;
386 
391  std::vector<unsigned int> row_starts_plain_indices;
392 
401  std::vector<unsigned int> plain_dof_indices;
402 
408 
413  unsigned int n_base_elements;
414 
419  std::vector<unsigned int> n_components;
420 
425  std::vector<unsigned int> start_components;
426 
431  std::vector<unsigned int> component_to_base_index;
432 
444  std::vector<std::vector<unsigned int> > component_dof_indices_offset;
445 
449  std::vector<unsigned int> dofs_per_cell;
450 
454  std::vector<unsigned int> dofs_per_face;
455 
460 
464  std::vector<unsigned int> cell_active_fe_index;
465 
470  unsigned int max_fe_index;
471 
477  std::vector<std::vector<unsigned int> > fe_index_conversion;
478 
484  std::vector<types::global_dof_index> ghost_dofs;
485 
491  std::vector<unsigned int> vector_zero_range_list_index;
492 
496  std::vector<unsigned int> vector_zero_range_list;
497  };
498 
499 
500  /*----------------------- Inline functions ----------------------------------*/
501 
502 #ifndef DOXYGEN
503 
504 
505  inline
506  unsigned int
507  DoFInfo::fe_index_from_degree (const unsigned int first_selected_component,
508  const unsigned int fe_degree) const
509  {
510  const unsigned int n_indices = fe_index_conversion.size();
511  if (n_indices <= 1)
512  return 0;
513  for (unsigned int i=0; i<n_indices; ++i)
514  if (fe_index_conversion[i][first_selected_component] == fe_degree)
515  return i;
517  }
518 
519 #endif // ifndef DOXYGEN
520 
521  } // end of namespace MatrixFreeFunctions
522 } // end of namespace internal
523 
524 DEAL_II_NAMESPACE_CLOSE
525 
526 #endif
std::vector< unsigned int > plain_dof_indices
Definition: dof_info.h:401
static const unsigned int invalid_unsigned_int
Definition: types.h:173
unsigned int fe_index_from_degree(const unsigned int first_selected_component, const unsigned int fe_degree) const
std::vector< unsigned int > component_to_base_index
Definition: dof_info.h:431
std::vector< IndexStorageVariants > index_storage_variants[3]
Definition: dof_info.h:296
void compute_vector_zero_access_pattern(const TaskInfo &task_info, const std::vector< FaceToCellTopology< length > > &faces)
std::shared_ptr< const Utilities::MPI::Partitioner > vector_partitioner
Definition: dof_info.h:366
std::vector< unsigned int > vector_zero_range_list_index
Definition: dof_info.h:491
std::vector< std::pair< unsigned short, unsigned short > > constraint_indicator
Definition: dof_info.h:332
std::vector< unsigned int > dof_indices
Definition: dof_info.h:321
std::vector< unsigned char > n_vectorization_lanes_filled[3]
Definition: dof_info.h:358
std::vector< unsigned int > dofs_per_face
Definition: dof_info.h:454
void compute_dof_renumbering(std::vector< types::global_dof_index > &renumbering)
void compute_cell_index_compression(const std::vector< unsigned char > &irregular_cells)
std::vector< unsigned int > dof_indices_interleaved
Definition: dof_info.h:337
void print(const std::vector< Number > &constraint_pool_data, const std::vector< unsigned int > &constraint_pool_row_index, std::ostream &out) const
std::vector< unsigned int > row_starts_plain_indices
Definition: dof_info.h:391
std::vector< std::vector< unsigned int > > fe_index_conversion
Definition: dof_info.h:477
std::vector< std::pair< unsigned int, unsigned int > > row_starts
Definition: dof_info.h:304
void compute_face_index_compression(const std::vector< FaceToCellTopology< length > > &faces)
void print_memory_consumption(StreamType &out, const TaskInfo &size_info) const
void read_dof_indices(const std::vector< types::global_dof_index > &local_indices, const std::vector< unsigned int > &lexicographic_inv, const ConstraintMatrix &constraints, const unsigned int cell_number, ConstraintValues< double > &constraint_values, bool &cell_at_boundary)
std::vector< types::global_dof_index > ghost_dofs
Definition: dof_info.h:484
std::vector< unsigned int > cell_active_fe_index
Definition: dof_info.h:464
std::vector< unsigned int > dof_indices_contiguous[3]
Definition: dof_info.h:347
std::vector< std::vector< unsigned int > > component_dof_indices_offset
Definition: dof_info.h:444
void make_connectivity_graph(const TaskInfo &task_info, const std::vector< unsigned int > &renumbering, DynamicSparsityPattern &connectivity) const
std::vector< unsigned int > dofs_per_cell
Definition: dof_info.h:449
std::vector< unsigned int > constrained_dofs
Definition: dof_info.h:385
std::vector< unsigned int > vector_zero_range_list
Definition: dof_info.h:496
std::vector< unsigned int > start_components
Definition: dof_info.h:425
void reorder_cells(const TaskInfo &task_info, const std::vector< unsigned int > &renumbering, const std::vector< unsigned int > &constraint_pool_row_index, const std::vector< unsigned char > &irregular_cells)
std::vector< unsigned int > n_components
Definition: dof_info.h:419
static const unsigned int chunk_size_zero_vector
Definition: dof_info.h:74
void assign_ghosts(const std::vector< unsigned int > &boundary_cells)
std::array< std::shared_ptr< const Utilities::MPI::Partitioner >, 3 > vector_partitioner_face_variants
Definition: dof_info.h:379