Reference documentation for deal.II version GIT 6bdf9a4b6c 2022-08-12 19:20:02+00:00
\(\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 - 2022 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 
25 
29 
30 #include <array>
31 #include <memory>
32 
33 
35 
36 #ifndef DOXYGEN
37 
38 // forward declarations
39 
40 namespace internal
41 {
42  namespace MatrixFreeFunctions
43  {
44  template <int dim>
45  class HangingNodes;
46 
47  template <typename, typename>
48  struct FPArrayComparator;
49 
50  struct TaskInfo;
51  } // namespace MatrixFreeFunctions
52 } // namespace internal
53 
54 template <typename>
55 class AffineConstraints;
56 
58 
59 template <typename>
60 class TriaIterator;
61 
62 template <int, int, bool>
63 class DoFCellAccessor;
64 
65 namespace Utilities
66 {
67  namespace MPI
68  {
69  class Partitioner;
70  }
71 } // namespace Utilities
72 
73 #endif
74 
75 namespace internal
76 {
77  namespace MatrixFreeFunctions
78  {
83  using compressed_constraint_kind = std::uint8_t;
84 
89  template <typename Number>
91  {
93 
101  template <typename number2>
102  unsigned short
104  const std::vector<std::pair<types::global_dof_index, number2>>
105  &entries);
106 
107  std::vector<std::pair<types::global_dof_index, double>>
109  std::vector<types::global_dof_index> constraint_indices;
110 
111  std::pair<std::vector<Number>, types::global_dof_index> next_constraint;
112  std::map<std::vector<Number>,
116  };
117 
136  struct DoFInfo
137  {
150  static const unsigned int chunk_size_zero_vector = 64;
151 
155  DoFInfo();
156 
160  DoFInfo(const DoFInfo &) = default;
161 
165  DoFInfo(DoFInfo &&) noexcept = default;
166 
170  ~DoFInfo() = default;
171 
175  DoFInfo &
176  operator=(const DoFInfo &) = default;
177 
181  DoFInfo &
182  operator=(DoFInfo &&) noexcept = default;
183 
187  void
188  clear();
189 
195  unsigned int
196  fe_index_from_degree(const unsigned int first_selected_component,
197  const unsigned int fe_degree) const;
198 
218  void
219  get_dof_indices_on_cell_batch(std::vector<unsigned int> &local_indices,
220  const unsigned int cell_batch,
221  const bool with_constraints = true) const;
222 
232  template <typename number>
233  void
235  const std::vector<types::global_dof_index> &local_indices_resolved,
236  const std::vector<types::global_dof_index> &local_indices,
237  const bool cell_has_hanging_nodes,
238  const ::AffineConstraints<number> & constraints,
239  const unsigned int cell_number,
240  ConstraintValues<double> & constraint_values,
241  bool & cell_at_boundary);
242 
247  template <int dim>
248  bool
250  const HangingNodes<dim> & hanging_nodes,
251  const std::vector<std::vector<unsigned int>> &lexicographic_mapping,
252  const unsigned int cell_number,
253  const TriaIterator<DoFCellAccessor<dim, dim, false>> &cell,
254  std::vector<types::global_dof_index> & dof_indices);
255 
263  void
264  assign_ghosts(const std::vector<unsigned int> &boundary_cells,
265  const MPI_Comm & communicator_sm,
266  const bool use_vector_data_exchanger_full);
267 
274  void
275  reorder_cells(const TaskInfo & task_info,
276  const std::vector<unsigned int> & renumbering,
277  const std::vector<unsigned int> & constraint_pool_row_index,
278  const std::vector<unsigned char> &irregular_cells);
279 
284  void
286  const std::vector<unsigned char> &irregular_cells);
287 
292  template <int length>
293  void
295  const std::vector<FaceToCellTopology<length>> &faces);
296 
302  void
303  make_connectivity_graph(const TaskInfo & task_info,
304  const std::vector<unsigned int> &renumbering,
305  DynamicSparsityPattern &connectivity) const;
306 
312  void
314  const Table<2, ShapeInfo<double>> & shape_info,
315  const unsigned int n_owned_cells,
316  const unsigned int n_lanes,
317  const std::vector<FaceToCellTopology<1>> &inner_faces,
318  const std::vector<FaceToCellTopology<1>> &ghosted_faces,
319  const bool fill_cell_centric,
320  const MPI_Comm & communicator_sm,
321  const bool use_vector_data_exchanger_full);
322 
328  void
330  std::array<std::vector<std::pair<unsigned int, unsigned int>>, 3>
331  &cell_indices_contiguous_sm);
332 
343  void
345  std::vector<types::global_dof_index> &renumbering);
346 
356  template <int length>
357  void
359  const TaskInfo & task_info,
360  const std::vector<FaceToCellTopology<length>> &faces);
361 
365  std::size_t
366  memory_consumption() const;
367 
372  template <typename StreamType>
373  void
374  print_memory_consumption(StreamType & out,
375  const TaskInfo &size_info) const;
376 
381  template <typename Number>
382  void
383  print(const std::vector<Number> & constraint_pool_data,
384  const std::vector<unsigned int> &constraint_pool_row_index,
385  std::ostream & out) const;
386 
398  enum class IndexStorageVariants : unsigned char
399  {
408  full,
420  interleaved,
429  contiguous,
453  interleaved_contiguous,
465  interleaved_contiguous_strided,
478  interleaved_contiguous_mixed_strides
479  };
480 
485  enum DoFAccessIndex : unsigned char
486  {
498  dof_access_cell = 2
499  };
500 
506  unsigned int dimension;
507 
516  unsigned int vectorization_length;
517 
525  std::array<std::vector<IndexStorageVariants>, 3> index_storage_variants;
526 
533  std::vector<std::pair<unsigned int, unsigned int>> row_starts;
534 
550  std::vector<unsigned int> dof_indices;
551 
556  std::vector<std::vector<bool>> hanging_node_constraint_masks_comp;
557 
562  std::vector<compressed_constraint_kind> hanging_node_constraint_masks;
563 
573  std::vector<std::pair<unsigned short, unsigned short>>
575 
579  std::vector<unsigned int> dof_indices_interleaved;
580 
589  std::array<std::vector<unsigned int>, 3> dof_indices_contiguous;
590 
599  std::array<std::vector<std::pair<unsigned int, unsigned int>>, 3>
601 
610  std::array<std::vector<unsigned int>, 3> dof_indices_interleave_strides;
611 
621  std::array<std::vector<unsigned char>, 3> n_vectorization_lanes_filled;
622 
629  std::shared_ptr<const Utilities::MPI::Partitioner> vector_partitioner;
630 
634  std::shared_ptr<
637 
657  std::array<
658  std::shared_ptr<
660  5>
662 
667  std::vector<unsigned int> constrained_dofs;
668 
673  std::vector<unsigned int> row_starts_plain_indices;
674 
683  std::vector<unsigned int> plain_dof_indices;
684 
690 
695  unsigned int n_base_elements;
696 
701  std::vector<unsigned int> n_components;
702 
707  std::vector<unsigned int> start_components;
708 
713  std::vector<unsigned int> component_to_base_index;
714 
726  std::vector<std::vector<unsigned int>> component_dof_indices_offset;
727 
731  std::vector<unsigned int> dofs_per_cell;
732 
736  std::vector<unsigned int> dofs_per_face;
737 
742 
746  std::vector<unsigned int> cell_active_fe_index;
747 
752  unsigned int max_fe_index;
753 
759  std::vector<std::vector<unsigned int>> fe_index_conversion;
760 
766  std::vector<types::global_dof_index> ghost_dofs;
767 
773  std::vector<unsigned int> vector_zero_range_list_index;
774 
778  std::vector<std::pair<unsigned int, unsigned int>> vector_zero_range_list;
779 
785  std::vector<unsigned int> cell_loop_pre_list_index;
786 
791  std::vector<std::pair<unsigned int, unsigned int>> cell_loop_pre_list;
792 
798  std::vector<unsigned int> cell_loop_post_list_index;
799 
804  std::vector<std::pair<unsigned int, unsigned int>> cell_loop_post_list;
805  };
806 
807 
808  /*-------------------------- Inline functions ---------------------------*/
809 
810 #ifndef DOXYGEN
811 
812 
813  inline unsigned int
814  DoFInfo::fe_index_from_degree(const unsigned int first_selected_component,
815  const unsigned int fe_degree) const
816  {
817  const unsigned int n_indices = fe_index_conversion.size();
818  if (n_indices <= 1)
819  return 0;
820  for (unsigned int i = 0; i < n_indices; ++i)
821  if (fe_index_conversion[i][first_selected_component] == fe_degree)
822  return i;
824  }
825 
826 #endif // ifndef DOXYGEN
827 
828  } // end of namespace MatrixFreeFunctions
829 } // end of namespace internal
830 
832 
833 #endif
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:442
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:443
std::uint8_t compressed_constraint_kind
Definition: dof_info.h:83
static const unsigned int invalid_unsigned_int
Definition: types.h:201
Definition: types.h:32
unsigned int global_dof_index
Definition: types.h:76
std::vector< types::global_dof_index > constraint_indices
Definition: dof_info.h:109
std::map< std::vector< Number >, types::global_dof_index, FPArrayComparator< Number, VectorizedArray< Number > > > constraints
Definition: dof_info.h:115
unsigned short insert_entries(const std::vector< std::pair< types::global_dof_index, number2 >> &entries)
std::vector< std::pair< types::global_dof_index, double > > constraint_entries
Definition: dof_info.h:108
std::pair< std::vector< Number >, types::global_dof_index > next_constraint
Definition: dof_info.h:111
void print(const std::vector< Number > &constraint_pool_data, const std::vector< unsigned int > &constraint_pool_row_index, std::ostream &out) const
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)
Definition: dof_info.cc:296
std::vector< std::pair< unsigned short, unsigned short > > constraint_indicator
Definition: dof_info.h:574
std::vector< unsigned int > cell_loop_pre_list_index
Definition: dof_info.h:785
std::vector< std::pair< unsigned int, unsigned int > > row_starts
Definition: dof_info.h:533
std::vector< std::vector< unsigned int > > component_dof_indices_offset
Definition: dof_info.h:726
std::vector< std::vector< bool > > hanging_node_constraint_masks_comp
Definition: dof_info.h:556
void get_dof_indices_on_cell_batch(std::vector< unsigned int > &local_indices, const unsigned int cell_batch, const bool with_constraints=true) const
Definition: dof_info.cc:80
unsigned int fe_index_from_degree(const unsigned int first_selected_component, const unsigned int fe_degree) const
void compute_cell_index_compression(const std::vector< unsigned char > &irregular_cells)
Definition: dof_info.cc:528
std::vector< unsigned int > cell_loop_post_list_index
Definition: dof_info.h:798
std::vector< unsigned int > dofs_per_cell
Definition: dof_info.h:731
void compute_shared_memory_contiguous_indices(std::array< std::vector< std::pair< unsigned int, unsigned int >>, 3 > &cell_indices_contiguous_sm)
Definition: dof_info.cc:1241
void compute_dof_renumbering(std::vector< types::global_dof_index > &renumbering)
Definition: dof_info.cc:1467
static const unsigned int chunk_size_zero_vector
Definition: dof_info.h:150
std::shared_ptr< const internal::MatrixFreeFunctions::VectorDataExchange::Base > vector_exchanger
Definition: dof_info.h:636
std::vector< std::vector< unsigned int > > fe_index_conversion
Definition: dof_info.h:759
std::vector< unsigned int > dof_indices
Definition: dof_info.h:550
std::vector< std::pair< unsigned int, unsigned int > > vector_zero_range_list
Definition: dof_info.h:778
std::shared_ptr< const Utilities::MPI::Partitioner > vector_partitioner
Definition: dof_info.h:629
std::vector< compressed_constraint_kind > hanging_node_constraint_masks
Definition: dof_info.h:562
std::array< std::vector< unsigned int >, 3 > dof_indices_interleave_strides
Definition: dof_info.h:610
std::array< std::vector< std::pair< unsigned int, unsigned int > >, 3 > dof_indices_contiguous_sm
Definition: dof_info.h:600
std::vector< unsigned int > row_starts_plain_indices
Definition: dof_info.h:673
std::vector< unsigned int > dofs_per_face
Definition: dof_info.h:736
std::size_t memory_consumption() const
Definition: dof_info.cc:1525
std::vector< unsigned int > component_to_base_index
Definition: dof_info.h:713
std::vector< unsigned int > n_components
Definition: dof_info.h:701
void print_memory_consumption(StreamType &out, const TaskInfo &size_info) const
void assign_ghosts(const std::vector< unsigned int > &boundary_cells, const MPI_Comm &communicator_sm, const bool use_vector_data_exchanger_full)
Definition: dof_info.cc:153
std::vector< std::pair< unsigned int, unsigned int > > cell_loop_pre_list
Definition: dof_info.h:791
std::vector< types::global_dof_index > ghost_dofs
Definition: dof_info.h:766
void read_dof_indices(const std::vector< types::global_dof_index > &local_indices_resolved, const std::vector< types::global_dof_index > &local_indices, const bool cell_has_hanging_nodes, const ::AffineConstraints< number > &constraints, const unsigned int cell_number, ConstraintValues< double > &constraint_values, bool &cell_at_boundary)
std::array< std::vector< unsigned int >, 3 > dof_indices_contiguous
Definition: dof_info.h:589
void compute_tight_partitioners(const Table< 2, ShapeInfo< double >> &shape_info, const unsigned int n_owned_cells, const unsigned int n_lanes, const std::vector< FaceToCellTopology< 1 >> &inner_faces, const std::vector< FaceToCellTopology< 1 >> &ghosted_faces, const bool fill_cell_centric, const MPI_Comm &communicator_sm, const bool use_vector_data_exchanger_full)
Definition: dof_info.cc:886
DoFInfo(const DoFInfo &)=default
std::vector< unsigned int > cell_active_fe_index
Definition: dof_info.h:746
std::array< std::shared_ptr< const internal::MatrixFreeFunctions::VectorDataExchange::Base >, 5 > vector_exchanger_face_variants
Definition: dof_info.h:661
std::vector< unsigned int > plain_dof_indices
Definition: dof_info.h:683
std::array< std::vector< unsigned char >, 3 > n_vectorization_lanes_filled
Definition: dof_info.h:621
std::vector< unsigned int > start_components
Definition: dof_info.h:707
std::vector< unsigned int > dof_indices_interleaved
Definition: dof_info.h:579
std::vector< unsigned int > constrained_dofs
Definition: dof_info.h:667
std::array< std::vector< IndexStorageVariants >, 3 > index_storage_variants
Definition: dof_info.h:525
bool process_hanging_node_constraints(const HangingNodes< dim > &hanging_nodes, const std::vector< std::vector< unsigned int >> &lexicographic_mapping, const unsigned int cell_number, const TriaIterator< DoFCellAccessor< dim, dim, false >> &cell, std::vector< types::global_dof_index > &dof_indices)
void make_connectivity_graph(const TaskInfo &task_info, const std::vector< unsigned int > &renumbering, DynamicSparsityPattern &connectivity) const
Definition: dof_info.cc:1390
std::vector< unsigned int > vector_zero_range_list_index
Definition: dof_info.h:773
void compute_face_index_compression(const std::vector< FaceToCellTopology< length >> &faces)
void compute_vector_zero_access_pattern(const TaskInfo &task_info, const std::vector< FaceToCellTopology< length >> &faces)
std::vector< std::pair< unsigned int, unsigned int > > cell_loop_post_list
Definition: dof_info.h:804
DoFInfo(DoFInfo &&) noexcept=default