Reference documentation for deal.II version Git e67cfc96e3 2021-10-16 16:07:33 +0200
\(\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 
38 
39 #include <array>
40 #include <memory>
41 
42 
44 
45 #ifndef DOXYGEN
46 namespace internal
47 {
48  namespace MatrixFreeFunctions
49  {
50  template <int dim>
51  class HangingNodes;
52  }
53 } // namespace internal
54 #endif
55 
56 namespace internal
57 {
58  namespace MatrixFreeFunctions
59  {
64  template <typename Number>
66  {
68 
76  template <typename number2>
77  unsigned short
78  insert_entries(
79  const std::vector<std::pair<types::global_dof_index, number2>>
80  &entries);
81 
82  std::vector<std::pair<types::global_dof_index, double>>
84  std::vector<types::global_dof_index> constraint_indices;
85 
86  std::pair<std::vector<Number>, types::global_dof_index> next_constraint;
87  std::map<std::vector<Number>,
91  };
92 
111  struct DoFInfo
112  {
125  static const unsigned int chunk_size_zero_vector = 64;
126 
130  DoFInfo();
131 
135  DoFInfo(const DoFInfo &) = default;
136 
140  DoFInfo(DoFInfo &&) noexcept = default;
141 
145  ~DoFInfo() = default;
146 
150  DoFInfo &
151  operator=(const DoFInfo &) = default;
152 
156  DoFInfo &
157  operator=(DoFInfo &&) noexcept = default;
158 
162  void
163  clear();
164 
170  unsigned int
171  fe_index_from_degree(const unsigned int first_selected_component,
172  const unsigned int fe_degree) const;
173 
193  void
194  get_dof_indices_on_cell_batch(std::vector<unsigned int> &locall_indices,
195  const unsigned int cell,
196  const bool with_constraints = true) const;
197 
207  template <typename number>
208  void
209  read_dof_indices(
210  const std::vector<types::global_dof_index> &local_indices_resolved,
211  const std::vector<types::global_dof_index> &local_indices,
212  const bool cell_has_hanging_nodes,
213  const ::AffineConstraints<number> & constraints,
214  const unsigned int cell_number,
215  ConstraintValues<double> & constraint_values,
216  bool & cell_at_boundary);
217 
222  template <int dim>
223  bool
224  process_hanging_node_constraints(
225  const HangingNodes<dim> & hanging_nodes,
226  const std::vector<unsigned int> &lexicographic_mapping,
227  const unsigned int cell_number,
228  const TriaIterator<DoFCellAccessor<dim, dim, false>> &cell,
229  std::vector<types::global_dof_index> & dof_indices);
230 
238  void
239  assign_ghosts(const std::vector<unsigned int> &boundary_cells,
240  const MPI_Comm & communicator_sm,
241  const bool use_vector_data_exchanger_full);
242 
249  void
250  reorder_cells(const TaskInfo & task_info,
251  const std::vector<unsigned int> & renumbering,
252  const std::vector<unsigned int> & constraint_pool_row_index,
253  const std::vector<unsigned char> &irregular_cells);
254 
259  void
260  compute_cell_index_compression(
261  const std::vector<unsigned char> &irregular_cells);
262 
267  template <int length>
268  void
269  compute_face_index_compression(
270  const std::vector<FaceToCellTopology<length>> &faces);
271 
277  void
278  make_connectivity_graph(const TaskInfo & task_info,
279  const std::vector<unsigned int> &renumbering,
280  DynamicSparsityPattern &connectivity) const;
281 
287  void
288  compute_tight_partitioners(
289  const Table<2, ShapeInfo<double>> & shape_info,
290  const unsigned int n_owned_cells,
291  const unsigned int n_lanes,
292  const std::vector<FaceToCellTopology<1>> &inner_faces,
293  const std::vector<FaceToCellTopology<1>> &ghosted_faces,
294  const bool fill_cell_centric,
295  const MPI_Comm & communicator_sm,
296  const bool use_vector_data_exchanger_full);
297 
303  void
304  compute_shared_memory_contiguous_indices(
305  std::array<std::vector<std::pair<unsigned int, unsigned int>>, 3>
306  &cell_indices_contiguous_sm);
307 
318  void
319  compute_dof_renumbering(
320  std::vector<types::global_dof_index> &renumbering);
321 
331  template <int length>
332  void
333  compute_vector_zero_access_pattern(
334  const TaskInfo & task_info,
335  const std::vector<FaceToCellTopology<length>> &faces);
336 
340  std::size_t
341  memory_consumption() const;
342 
347  template <typename StreamType>
348  void
349  print_memory_consumption(StreamType & out,
350  const TaskInfo &size_info) const;
351 
356  template <typename Number>
357  void
358  print(const std::vector<Number> & constraint_pool_data,
359  const std::vector<unsigned int> &constraint_pool_row_index,
360  std::ostream & out) const;
361 
373  enum class IndexStorageVariants : unsigned char
374  {
383  full,
395  interleaved,
404  contiguous,
428  interleaved_contiguous,
440  interleaved_contiguous_strided,
453  interleaved_contiguous_mixed_strides
454  };
455 
460  enum DoFAccessIndex : unsigned char
461  {
465  dof_access_face_interior = 0,
469  dof_access_face_exterior = 1,
473  dof_access_cell = 2
474  };
475 
481  unsigned int dimension;
482 
491  unsigned int vectorization_length;
492 
500  std::array<std::vector<IndexStorageVariants>, 3> index_storage_variants;
501 
508  std::vector<std::pair<unsigned int, unsigned int>> row_starts;
509 
525  std::vector<unsigned int> dof_indices;
526 
531  std::vector<ConstraintKinds> hanging_node_constraint_masks;
532 
542  std::vector<std::pair<unsigned short, unsigned short>>
544 
548  std::vector<unsigned int> dof_indices_interleaved;
549 
558  std::array<std::vector<unsigned int>, 3> dof_indices_contiguous;
559 
568  std::array<std::vector<std::pair<unsigned int, unsigned int>>, 3>
570 
579  std::array<std::vector<unsigned int>, 3> dof_indices_interleave_strides;
580 
590  std::array<std::vector<unsigned char>, 3> n_vectorization_lanes_filled;
591 
598  std::shared_ptr<const Utilities::MPI::Partitioner> vector_partitioner;
599 
603  std::shared_ptr<
606 
626  std::array<
627  std::shared_ptr<
629  5>
631 
636  std::vector<unsigned int> constrained_dofs;
637 
642  std::vector<unsigned int> row_starts_plain_indices;
643 
652  std::vector<unsigned int> plain_dof_indices;
653 
659 
664  unsigned int n_base_elements;
665 
670  std::vector<unsigned int> n_components;
671 
676  std::vector<unsigned int> start_components;
677 
682  std::vector<unsigned int> component_to_base_index;
683 
695  std::vector<std::vector<unsigned int>> component_dof_indices_offset;
696 
700  std::vector<unsigned int> dofs_per_cell;
701 
705  std::vector<unsigned int> dofs_per_face;
706 
711 
715  std::vector<unsigned int> cell_active_fe_index;
716 
721  unsigned int max_fe_index;
722 
728  std::vector<std::vector<unsigned int>> fe_index_conversion;
729 
735  std::vector<types::global_dof_index> ghost_dofs;
736 
742  std::vector<unsigned int> vector_zero_range_list_index;
743 
747  std::vector<std::pair<unsigned int, unsigned int>> vector_zero_range_list;
748 
754  std::vector<unsigned int> cell_loop_pre_list_index;
755 
760  std::vector<std::pair<unsigned int, unsigned int>> cell_loop_pre_list;
761 
767  std::vector<unsigned int> cell_loop_post_list_index;
768 
773  std::vector<std::pair<unsigned int, unsigned int>> cell_loop_post_list;
774  };
775 
776 
777  /*-------------------------- Inline functions ---------------------------*/
778 
779 #ifndef DOXYGEN
780 
781 
782  inline unsigned int
783  DoFInfo::fe_index_from_degree(const unsigned int first_selected_component,
784  const unsigned int fe_degree) const
785  {
786  const unsigned int n_indices = fe_index_conversion.size();
787  if (n_indices <= 1)
788  return 0;
789  for (unsigned int i = 0; i < n_indices; ++i)
790  if (fe_index_conversion[i][first_selected_component] == fe_degree)
791  return i;
793  }
794 
795 #endif // ifndef DOXYGEN
796 
797  } // end of namespace MatrixFreeFunctions
798 } // end of namespace internal
799 
801 
802 #endif
std::vector< unsigned int > plain_dof_indices
Definition: dof_info.h:652
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:747
std::vector< unsigned int > component_to_base_index
Definition: dof_info.h:682
std::vector< unsigned int > cell_loop_pre_list_index
Definition: dof_info.h:754
std::array< std::vector< IndexStorageVariants >, 3 > index_storage_variants
Definition: dof_info.h:500
std::shared_ptr< const Utilities::MPI::Partitioner > vector_partitioner
Definition: dof_info.h:598
std::vector< unsigned int > vector_zero_range_list_index
Definition: dof_info.h:742
STL namespace.
std::vector< unsigned int > dof_indices
Definition: dof_info.h:525
std::array< std::vector< std::pair< unsigned int, unsigned int > >, 3 > dof_indices_contiguous_sm
Definition: dof_info.h:569
std::vector< unsigned int > cell_loop_post_list_index
Definition: dof_info.h:767
std::vector< unsigned int > dofs_per_face
Definition: dof_info.h:705
std::vector< std::pair< types::global_dof_index, double > > constraint_entries
Definition: dof_info.h:83
Definition: types.h:31
std::vector< std::pair< unsigned int, unsigned int > > cell_loop_pre_list
Definition: dof_info.h:760
std::vector< unsigned int > dof_indices_interleaved
Definition: dof_info.h:548
std::vector< unsigned int > row_starts_plain_indices
Definition: dof_info.h:642
std::vector< types::global_dof_index > constraint_indices
Definition: dof_info.h:84
std::vector< std::vector< unsigned int > > fe_index_conversion
Definition: dof_info.h:728
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:401
std::vector< std::pair< unsigned int, unsigned int > > row_starts
Definition: dof_info.h:508
std::vector< std::pair< unsigned short, unsigned short > > constraint_indicator
Definition: dof_info.h:543
std::array< std::vector< unsigned int >, 3 > dof_indices_contiguous
Definition: dof_info.h:558
std::array< std::shared_ptr< const internal::MatrixFreeFunctions::VectorDataExchange::Base >, 5 > vector_exchanger_face_variants
Definition: dof_info.h:630
std::pair< std::vector< Number >, types::global_dof_index > next_constraint
Definition: dof_info.h:86
unsigned int global_dof_index
Definition: types.h:76
std::vector< types::global_dof_index > ghost_dofs
Definition: dof_info.h:735
std::array< std::vector< unsigned char >, 3 > n_vectorization_lanes_filled
Definition: dof_info.h:590
std::shared_ptr< const internal::MatrixFreeFunctions::VectorDataExchange::Base > vector_exchanger
Definition: dof_info.h:605
std::vector< unsigned int > cell_active_fe_index
Definition: dof_info.h:715
std::vector< std::vector< unsigned int > > component_dof_indices_offset
Definition: dof_info.h:695
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:400
std::map< std::vector< Number >, types::global_dof_index, FPArrayComparator< Number > > constraints
Definition: dof_info.h:90
std::vector< unsigned int > dofs_per_cell
Definition: dof_info.h:700
std::vector< unsigned int > constrained_dofs
Definition: dof_info.h:636
std::vector< ConstraintKinds > hanging_node_constraint_masks
Definition: dof_info.h:531
std::vector< unsigned int > start_components
Definition: dof_info.h:676
std::vector< std::pair< unsigned int, unsigned int > > cell_loop_post_list
Definition: dof_info.h:773
std::vector< unsigned int > n_components
Definition: dof_info.h:670
std::array< std::vector< unsigned int >, 3 > dof_indices_interleave_strides
Definition: dof_info.h:579
std::enable_if< std::is_fundamental< T >::value, std::size_t >::type memory_consumption(const T &t)