Reference documentation for deal.II version 9.1.1
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
dof_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_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/partitioner.h>
23 #include <deal.II/base/vectorization.h>
24 
25 #include <deal.II/dofs/dof_handler.h>
26 
27 #include <deal.II/lac/affine_constraints.h>
28 #include <deal.II/lac/dynamic_sparsity_pattern.h>
29 
30 #include <deal.II/matrix_free/face_info.h>
31 #include <deal.II/matrix_free/task_info.h>
32 
33 #include <array>
34 #include <memory>
35 
36 
37 DEAL_II_NAMESPACE_OPEN
38 
39 namespace internal
40 {
41  namespace MatrixFreeFunctions
42  {
43  template <typename Number>
44  struct ConstraintValues;
45 
66  struct DoFInfo
67  {
78  static const unsigned int chunk_size_zero_vector = 8192;
79 
83  DoFInfo();
84 
88  DoFInfo(const DoFInfo &) = default;
89 
93  void
94  clear();
95 
101  unsigned int
102  fe_index_from_degree(const unsigned int first_selected_component,
103  const unsigned int fe_degree) const;
104 
124  void
125  get_dof_indices_on_cell_batch(std::vector<unsigned int> &locall_indices,
126  const unsigned int cell,
127  const bool with_constraints = true) const;
128 
137  template <typename number>
138  void
140  const std::vector<types::global_dof_index> &local_indices,
141  const std::vector<unsigned int> & lexicographic_inv,
142  const AffineConstraints<number> & constraints,
143  const unsigned int cell_number,
144  ConstraintValues<double> & constraint_values,
145  bool & cell_at_boundary);
146 
154  void
155  assign_ghosts(const std::vector<unsigned int> &boundary_cells);
156 
163  void
164  reorder_cells(const TaskInfo & task_info,
165  const std::vector<unsigned int> & renumbering,
166  const std::vector<unsigned int> & constraint_pool_row_index,
167  const std::vector<unsigned char> &irregular_cells);
168 
173  void
175  const std::vector<unsigned char> &irregular_cells);
176 
181  template <int length>
182  void
184  const std::vector<FaceToCellTopology<length>> &faces);
185 
191  void
192  make_connectivity_graph(const TaskInfo & task_info,
193  const std::vector<unsigned int> &renumbering,
194  DynamicSparsityPattern &connectivity) const;
195 
206  void
208  std::vector<types::global_dof_index> &renumbering);
209 
219  template <int length>
220  void
222  const TaskInfo & task_info,
223  const std::vector<FaceToCellTopology<length>> &faces);
224 
228  std::size_t
229  memory_consumption() const;
230 
235  template <typename StreamType>
236  void
237  print_memory_consumption(StreamType & out,
238  const TaskInfo &size_info) const;
239 
244  template <typename Number>
245  void
246  print(const std::vector<Number> & constraint_pool_data,
247  const std::vector<unsigned int> &constraint_pool_row_index,
248  std::ostream & out) const;
249 
261  enum class IndexStorageVariants : unsigned char
262  {
271  full,
283  interleaved,
292  contiguous,
342  };
343 
348  enum DoFAccessIndex : unsigned char
349  {
362  };
363 
369  unsigned int dimension;
370 
379  unsigned int vectorization_length;
380 
388  std::vector<IndexStorageVariants> index_storage_variants[3];
389 
396  std::vector<std::pair<unsigned int, unsigned int>> row_starts;
397 
413  std::vector<unsigned int> dof_indices;
414 
424  std::vector<std::pair<unsigned short, unsigned short>>
426 
430  std::vector<unsigned int> dof_indices_interleaved;
431 
440  std::vector<unsigned int> dof_indices_contiguous[3];
441 
450  std::vector<unsigned int> dof_indices_interleave_strides[3];
451 
461  std::vector<unsigned char> n_vectorization_lanes_filled[3];
462 
469  std::shared_ptr<const Utilities::MPI::Partitioner> vector_partitioner;
470 
482  std::array<std::shared_ptr<const Utilities::MPI::Partitioner>, 3>
484 
489  std::vector<unsigned int> constrained_dofs;
490 
495  std::vector<unsigned int> row_starts_plain_indices;
496 
505  std::vector<unsigned int> plain_dof_indices;
506 
512 
517  unsigned int n_base_elements;
518 
523  std::vector<unsigned int> n_components;
524 
529  std::vector<unsigned int> start_components;
530 
535  std::vector<unsigned int> component_to_base_index;
536 
548  std::vector<std::vector<unsigned int>> component_dof_indices_offset;
549 
553  std::vector<unsigned int> dofs_per_cell;
554 
558  std::vector<unsigned int> dofs_per_face;
559 
564 
568  std::vector<unsigned int> cell_active_fe_index;
569 
574  unsigned int max_fe_index;
575 
581  std::vector<std::vector<unsigned int>> fe_index_conversion;
582 
588  std::vector<types::global_dof_index> ghost_dofs;
589 
595  std::vector<unsigned int> vector_zero_range_list_index;
596 
600  std::vector<unsigned int> vector_zero_range_list;
601  };
602 
603 
604  /*-------------------------- Inline functions ---------------------------*/
605 
606 #ifndef DOXYGEN
607 
608 
609  inline unsigned int
610  DoFInfo::fe_index_from_degree(const unsigned int first_selected_component,
611  const unsigned int fe_degree) const
612  {
613  const unsigned int n_indices = fe_index_conversion.size();
614  if (n_indices <= 1)
615  return 0;
616  for (unsigned int i = 0; i < n_indices; ++i)
617  if (fe_index_conversion[i][first_selected_component] == fe_degree)
618  return i;
620  }
621 
622 #endif // ifndef DOXYGEN
623 
624  } // end of namespace MatrixFreeFunctions
625 } // end of namespace internal
626 
627 DEAL_II_NAMESPACE_CLOSE
628 
629 #endif
void get_dof_indices_on_cell_batch(std::vector< unsigned int > &locall_indices, const unsigned int cell, const bool with_constraints=true) const
std::vector< unsigned int > plain_dof_indices
Definition: dof_info.h:505
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:535
std::vector< IndexStorageVariants > index_storage_variants[3]
Definition: dof_info.h:388
std::vector< unsigned int > dof_indices_interleave_strides[3]
Definition: dof_info.h:450
std::shared_ptr< const Utilities::MPI::Partitioner > vector_partitioner
Definition: dof_info.h:469
std::vector< unsigned int > vector_zero_range_list_index
Definition: dof_info.h:595
std::vector< unsigned int > dof_indices
Definition: dof_info.h:413
std::vector< unsigned char > n_vectorization_lanes_filled[3]
Definition: dof_info.h:461
std::vector< unsigned int > dofs_per_face
Definition: dof_info.h:558
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:430
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:495
std::vector< std::vector< unsigned int > > fe_index_conversion
Definition: dof_info.h:581
std::vector< std::pair< unsigned int, unsigned int > > row_starts
Definition: dof_info.h:396
void compute_vector_zero_access_pattern(const TaskInfo &task_info, const std::vector< FaceToCellTopology< length >> &faces)
void print_memory_consumption(StreamType &out, const TaskInfo &size_info) const
std::vector< std::pair< unsigned short, unsigned short > > constraint_indicator
Definition: dof_info.h:425
void compute_face_index_compression(const std::vector< FaceToCellTopology< length >> &faces)
std::vector< types::global_dof_index > ghost_dofs
Definition: dof_info.h:588
std::vector< unsigned int > cell_active_fe_index
Definition: dof_info.h:568
std::vector< unsigned int > dof_indices_contiguous[3]
Definition: dof_info.h:440
std::vector< std::vector< unsigned int > > component_dof_indices_offset
Definition: dof_info.h:548
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:553
std::vector< unsigned int > constrained_dofs
Definition: dof_info.h:489
std::vector< unsigned int > vector_zero_range_list
Definition: dof_info.h:600
void read_dof_indices(const std::vector< types::global_dof_index > &local_indices, const std::vector< unsigned int > &lexicographic_inv, const AffineConstraints< number > &constraints, const unsigned int cell_number, ConstraintValues< double > &constraint_values, bool &cell_at_boundary)
std::vector< unsigned int > start_components
Definition: dof_info.h:529
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:523
static const unsigned int chunk_size_zero_vector
Definition: dof_info.h:78
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:483