Reference documentation for deal.II version Git aba33d3846 2022-01-19 21:43:57 -0500
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
dof_info.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2011 - 2020 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/config.h>
22 
26 
28 
31 
37 
38 #include <array>
39 #include <memory>
40 
41 
43 
44 #ifndef DOXYGEN
45 namespace internal
46 {
47  namespace MatrixFreeFunctions
48  {
49  template <int dim>
50  class HangingNodes;
51 
52  template <typename, typename>
53  struct FPArrayComparator;
54  } // namespace MatrixFreeFunctions
55 } // namespace internal
56 #endif
57 
58 namespace internal
59 {
60  namespace MatrixFreeFunctions
61  {
66  template <typename Number>
68  {
70 
78  template <typename number2>
79  unsigned short
80  insert_entries(
81  const std::vector<std::pair<types::global_dof_index, number2>>
82  &entries);
83 
84  std::vector<std::pair<types::global_dof_index, double>>
86  std::vector<types::global_dof_index> constraint_indices;
87 
88  std::pair<std::vector<Number>, types::global_dof_index> next_constraint;
89  std::map<std::vector<Number>,
93  };
94 
113  struct DoFInfo
114  {
127  static const unsigned int chunk_size_zero_vector = 64;
128 
132  DoFInfo();
133 
137  DoFInfo(const DoFInfo &) = default;
138 
142  DoFInfo(DoFInfo &&) noexcept = default;
143 
147  ~DoFInfo() = default;
148 
152  DoFInfo &
153  operator=(const DoFInfo &) = default;
154 
158  DoFInfo &
159  operator=(DoFInfo &&) noexcept = default;
160 
164  void
165  clear();
166 
172  unsigned int
173  fe_index_from_degree(const unsigned int first_selected_component,
174  const unsigned int fe_degree) const;
175 
195  void
196  get_dof_indices_on_cell_batch(std::vector<unsigned int> &locall_indices,
197  const unsigned int cell,
198  const bool with_constraints = true) const;
199 
209  template <typename number>
210  void
211  read_dof_indices(
212  const std::vector<types::global_dof_index> &local_indices_resolved,
213  const std::vector<types::global_dof_index> &local_indices,
214  const bool cell_has_hanging_nodes,
215  const ::AffineConstraints<number> & constraints,
216  const unsigned int cell_number,
217  ConstraintValues<double> & constraint_values,
218  bool & cell_at_boundary);
219 
224  template <int dim>
225  bool
226  process_hanging_node_constraints(
227  const HangingNodes<dim> & hanging_nodes,
228  const std::vector<std::vector<unsigned int>> &lexicographic_mapping,
229  const unsigned int cell_number,
230  const TriaIterator<DoFCellAccessor<dim, dim, false>> &cell,
231  std::vector<types::global_dof_index> & dof_indices);
232 
240  void
241  assign_ghosts(const std::vector<unsigned int> &boundary_cells,
242  const MPI_Comm & communicator_sm,
243  const bool use_vector_data_exchanger_full);
244 
251  void
252  reorder_cells(const TaskInfo & task_info,
253  const std::vector<unsigned int> & renumbering,
254  const std::vector<unsigned int> & constraint_pool_row_index,
255  const std::vector<unsigned char> &irregular_cells);
256 
261  void
262  compute_cell_index_compression(
263  const std::vector<unsigned char> &irregular_cells);
264 
269  template <int length>
270  void
271  compute_face_index_compression(
272  const std::vector<FaceToCellTopology<length>> &faces);
273 
279  void
280  make_connectivity_graph(const TaskInfo & task_info,
281  const std::vector<unsigned int> &renumbering,
282  DynamicSparsityPattern &connectivity) const;
283 
289  void
290  compute_tight_partitioners(
291  const Table<2, ShapeInfo<double>> & shape_info,
292  const unsigned int n_owned_cells,
293  const unsigned int n_lanes,
294  const std::vector<FaceToCellTopology<1>> &inner_faces,
295  const std::vector<FaceToCellTopology<1>> &ghosted_faces,
296  const bool fill_cell_centric,
297  const MPI_Comm & communicator_sm,
298  const bool use_vector_data_exchanger_full);
299 
305  void
306  compute_shared_memory_contiguous_indices(
307  std::array<std::vector<std::pair<unsigned int, unsigned int>>, 3>
308  &cell_indices_contiguous_sm);
309 
320  void
321  compute_dof_renumbering(
322  std::vector<types::global_dof_index> &renumbering);
323 
333  template <int length>
334  void
335  compute_vector_zero_access_pattern(
336  const TaskInfo & task_info,
337  const std::vector<FaceToCellTopology<length>> &faces);
338 
342  std::size_t
343  memory_consumption() const;
344 
349  template <typename StreamType>
350  void
351  print_memory_consumption(StreamType & out,
352  const TaskInfo &size_info) const;
353 
358  template <typename Number>
359  void
360  print(const std::vector<Number> & constraint_pool_data,
361  const std::vector<unsigned int> &constraint_pool_row_index,
362  std::ostream & out) const;
363 
375  enum class IndexStorageVariants : unsigned char
376  {
385  full,
397  interleaved,
406  contiguous,
430  interleaved_contiguous,
442  interleaved_contiguous_strided,
455  interleaved_contiguous_mixed_strides
456  };
457 
462  enum DoFAccessIndex : unsigned char
463  {
467  dof_access_face_interior = 0,
471  dof_access_face_exterior = 1,
475  dof_access_cell = 2
476  };
477 
483  unsigned int dimension;
484 
493  unsigned int vectorization_length;
494 
502  std::array<std::vector<IndexStorageVariants>, 3> index_storage_variants;
503 
510  std::vector<std::pair<unsigned int, unsigned int>> row_starts;
511 
527  std::vector<unsigned int> dof_indices;
528 
533  std::vector<ConstraintKinds> hanging_node_constraint_masks;
534 
544  std::vector<std::pair<unsigned short, unsigned short>>
546 
550  std::vector<unsigned int> dof_indices_interleaved;
551 
560  std::array<std::vector<unsigned int>, 3> dof_indices_contiguous;
561 
570  std::array<std::vector<std::pair<unsigned int, unsigned int>>, 3>
572 
581  std::array<std::vector<unsigned int>, 3> dof_indices_interleave_strides;
582 
592  std::array<std::vector<unsigned char>, 3> n_vectorization_lanes_filled;
593 
600  std::shared_ptr<const Utilities::MPI::Partitioner> vector_partitioner;
601 
605  std::shared_ptr<
608 
628  std::array<
629  std::shared_ptr<
631  5>
633 
638  std::vector<unsigned int> constrained_dofs;
639 
644  std::vector<unsigned int> row_starts_plain_indices;
645 
654  std::vector<unsigned int> plain_dof_indices;
655 
661 
666  unsigned int n_base_elements;
667 
672  std::vector<unsigned int> n_components;
673 
678  std::vector<unsigned int> start_components;
679 
684  std::vector<unsigned int> component_to_base_index;
685 
697  std::vector<std::vector<unsigned int>> component_dof_indices_offset;
698 
702  std::vector<unsigned int> dofs_per_cell;
703 
707  std::vector<unsigned int> dofs_per_face;
708 
713 
717  std::vector<unsigned int> cell_active_fe_index;
718 
723  unsigned int max_fe_index;
724 
730  std::vector<std::vector<unsigned int>> fe_index_conversion;
731 
737  std::vector<types::global_dof_index> ghost_dofs;
738 
744  std::vector<unsigned int> vector_zero_range_list_index;
745 
749  std::vector<std::pair<unsigned int, unsigned int>> vector_zero_range_list;
750 
756  std::vector<unsigned int> cell_loop_pre_list_index;
757 
762  std::vector<std::pair<unsigned int, unsigned int>> cell_loop_pre_list;
763 
769  std::vector<unsigned int> cell_loop_post_list_index;
770 
775  std::vector<std::pair<unsigned int, unsigned int>> cell_loop_post_list;
776  };
777 
778 
779  /*-------------------------- Inline functions ---------------------------*/
780 
781 #ifndef DOXYGEN
782 
783 
784  inline unsigned int
785  DoFInfo::fe_index_from_degree(const unsigned int first_selected_component,
786  const unsigned int fe_degree) const
787  {
788  const unsigned int n_indices = fe_index_conversion.size();
789  if (n_indices <= 1)
790  return 0;
791  for (unsigned int i = 0; i < n_indices; ++i)
792  if (fe_index_conversion[i][first_selected_component] == fe_degree)
793  return i;
795  }
796 
797 #endif // ifndef DOXYGEN
798 
799  } // end of namespace MatrixFreeFunctions
800 } // end of namespace internal
801 
803 
804 #endif
std::vector< unsigned int > plain_dof_indices
Definition: dof_info.h:654
static const unsigned int invalid_unsigned_int
Definition: types.h:196
unsigned int fe_index_from_degree(const unsigned int first_selected_component, const unsigned int fe_degree) const
std::vector< std::pair< unsigned int, unsigned int > > vector_zero_range_list
Definition: dof_info.h:749
std::vector< unsigned int > component_to_base_index
Definition: dof_info.h:684
std::map< std::vector< Number >, types::global_dof_index, FPArrayComparator< Number, VectorizedArray< Number > > > constraints
Definition: dof_info.h:92
std::vector< unsigned int > cell_loop_pre_list_index
Definition: dof_info.h:756
std::array< std::vector< IndexStorageVariants >, 3 > index_storage_variants
Definition: dof_info.h:502
std::shared_ptr< const Utilities::MPI::Partitioner > vector_partitioner
Definition: dof_info.h:600
std::vector< unsigned int > vector_zero_range_list_index
Definition: dof_info.h:744
STL namespace.
std::vector< unsigned int > dof_indices
Definition: dof_info.h:527
std::array< std::vector< std::pair< unsigned int, unsigned int > >, 3 > dof_indices_contiguous_sm
Definition: dof_info.h:571
std::vector< unsigned int > cell_loop_post_list_index
Definition: dof_info.h:769
std::vector< unsigned int > dofs_per_face
Definition: dof_info.h:707
std::vector< std::pair< types::global_dof_index, double > > constraint_entries
Definition: dof_info.h:85
Definition: types.h:31
std::vector< std::pair< unsigned int, unsigned int > > cell_loop_pre_list
Definition: dof_info.h:762
std::vector< unsigned int > dof_indices_interleaved
Definition: dof_info.h:550
std::vector< unsigned int > row_starts_plain_indices
Definition: dof_info.h:644
std::vector< types::global_dof_index > constraint_indices
Definition: dof_info.h:86
std::vector< std::vector< unsigned int > > fe_index_conversion
Definition: dof_info.h:730
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:407
std::vector< std::pair< unsigned int, unsigned int > > row_starts
Definition: dof_info.h:510
std::vector< std::pair< unsigned short, unsigned short > > constraint_indicator
Definition: dof_info.h:545
std::array< std::vector< unsigned int >, 3 > dof_indices_contiguous
Definition: dof_info.h:560
std::array< std::shared_ptr< const internal::MatrixFreeFunctions::VectorDataExchange::Base >, 5 > vector_exchanger_face_variants
Definition: dof_info.h:632
std::size_t memory_consumption(const ConstraintKinds &)
std::pair< std::vector< Number >, types::global_dof_index > next_constraint
Definition: dof_info.h:88
unsigned int global_dof_index
Definition: types.h:76
std::vector< types::global_dof_index > ghost_dofs
Definition: dof_info.h:737
std::array< std::vector< unsigned char >, 3 > n_vectorization_lanes_filled
Definition: dof_info.h:592
std::shared_ptr< const internal::MatrixFreeFunctions::VectorDataExchange::Base > vector_exchanger
Definition: dof_info.h:607
std::vector< unsigned int > cell_active_fe_index
Definition: dof_info.h:717
std::vector< std::vector< unsigned int > > component_dof_indices_offset
Definition: dof_info.h:697
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:406
std::vector< unsigned int > dofs_per_cell
Definition: dof_info.h:702
std::vector< unsigned int > constrained_dofs
Definition: dof_info.h:638
std::vector< ConstraintKinds > hanging_node_constraint_masks
Definition: dof_info.h:533
std::vector< unsigned int > start_components
Definition: dof_info.h:678
std::vector< std::pair< unsigned int, unsigned int > > cell_loop_post_list
Definition: dof_info.h:775
std::vector< unsigned int > n_components
Definition: dof_info.h:672
std::array< std::vector< unsigned int >, 3 > dof_indices_interleave_strides
Definition: dof_info.h:581