Reference documentation for deal.II version Git f40be01994 2020-04-09 07:13:12 +0200
\(\newcommand{\vcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\vcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
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/config.h>
22 
23 #include <deal.II/base/exceptions.h>
24 #include <deal.II/base/partitioner.h>
25 #include <deal.II/base/vectorization.h>
26 
27 #include <deal.II/dofs/dof_handler.h>
28 
29 #include <deal.II/lac/affine_constraints.h>
30 #include <deal.II/lac/dynamic_sparsity_pattern.h>
31 
32 #include <deal.II/matrix_free/face_info.h>
33 #include <deal.II/matrix_free/task_info.h>
34 
35 #include <array>
36 #include <memory>
37 
38 
39 DEAL_II_NAMESPACE_OPEN
40 
41 namespace internal
42 {
43  namespace MatrixFreeFunctions
44  {
45  // Forward declaration
46 #ifndef DOXYGEN
47  template <typename Number>
48  struct ConstraintValues;
49 #endif
50 
71  struct DoFInfo
72  {
85  static const unsigned int chunk_size_zero_vector = 64;
86 
90  DoFInfo();
91 
95  DoFInfo(const DoFInfo &) = default;
96 
100  void
101  clear();
102 
108  unsigned int
109  fe_index_from_degree(const unsigned int first_selected_component,
110  const unsigned int fe_degree) const;
111 
131  void
132  get_dof_indices_on_cell_batch(std::vector<unsigned int> &locall_indices,
133  const unsigned int cell,
134  const bool with_constraints = true) const;
135 
144  template <typename number>
145  void
147  const std::vector<types::global_dof_index> &local_indices,
148  const std::vector<unsigned int> & lexicographic_inv,
149  const AffineConstraints<number> & constraints,
150  const unsigned int cell_number,
151  ConstraintValues<double> & constraint_values,
152  bool & cell_at_boundary);
153 
161  void
162  assign_ghosts(const std::vector<unsigned int> &boundary_cells);
163 
170  void
171  reorder_cells(const TaskInfo & task_info,
172  const std::vector<unsigned int> & renumbering,
173  const std::vector<unsigned int> & constraint_pool_row_index,
174  const std::vector<unsigned char> &irregular_cells);
175 
180  void
182  const std::vector<unsigned char> &irregular_cells);
183 
188  template <int length>
189  void
191  const std::vector<FaceToCellTopology<length>> &faces);
192 
198  void
199  make_connectivity_graph(const TaskInfo & task_info,
200  const std::vector<unsigned int> &renumbering,
201  DynamicSparsityPattern &connectivity) const;
202 
213  void
215  std::vector<types::global_dof_index> &renumbering);
216 
226  template <int length>
227  void
229  const TaskInfo & task_info,
230  const std::vector<FaceToCellTopology<length>> &faces);
231 
235  std::size_t
236  memory_consumption() const;
237 
242  template <typename StreamType>
243  void
244  print_memory_consumption(StreamType & out,
245  const TaskInfo &size_info) const;
246 
251  template <typename Number>
252  void
253  print(const std::vector<Number> & constraint_pool_data,
254  const std::vector<unsigned int> &constraint_pool_row_index,
255  std::ostream & out) const;
256 
268  enum class IndexStorageVariants : unsigned char
269  {
278  full,
290  interleaved,
299  contiguous,
349  };
350 
355  enum DoFAccessIndex : unsigned char
356  {
369  };
370 
376  unsigned int dimension;
377 
386  unsigned int vectorization_length;
387 
395  std::vector<IndexStorageVariants> index_storage_variants[3];
396 
403  std::vector<std::pair<unsigned int, unsigned int>> row_starts;
404 
420  std::vector<unsigned int> dof_indices;
421 
431  std::vector<std::pair<unsigned short, unsigned short>>
433 
437  std::vector<unsigned int> dof_indices_interleaved;
438 
447  std::vector<unsigned int> dof_indices_contiguous[3];
448 
457  std::vector<unsigned int> dof_indices_interleave_strides[3];
458 
468  std::vector<unsigned char> n_vectorization_lanes_filled[3];
469 
476  std::shared_ptr<const Utilities::MPI::Partitioner> vector_partitioner;
477 
496  std::array<std::shared_ptr<const Utilities::MPI::Partitioner>, 5>
498 
503  std::vector<unsigned int> constrained_dofs;
504 
509  std::vector<unsigned int> row_starts_plain_indices;
510 
519  std::vector<unsigned int> plain_dof_indices;
520 
526 
531  unsigned int n_base_elements;
532 
537  std::vector<unsigned int> n_components;
538 
543  std::vector<unsigned int> start_components;
544 
549  std::vector<unsigned int> component_to_base_index;
550 
562  std::vector<std::vector<unsigned int>> component_dof_indices_offset;
563 
567  std::vector<unsigned int> dofs_per_cell;
568 
572  std::vector<unsigned int> dofs_per_face;
573 
578 
582  std::vector<unsigned int> cell_active_fe_index;
583 
588  unsigned int max_fe_index;
589 
595  std::vector<std::vector<unsigned int>> fe_index_conversion;
596 
602  std::vector<types::global_dof_index> ghost_dofs;
603 
609  std::vector<unsigned int> vector_zero_range_list_index;
610 
614  std::vector<std::pair<unsigned int, unsigned int>> vector_zero_range_list;
615 
621  std::vector<unsigned int> cell_loop_pre_list_index;
622 
627  std::vector<std::pair<unsigned int, unsigned int>> cell_loop_pre_list;
628 
634  std::vector<unsigned int> cell_loop_post_list_index;
635 
640  std::vector<std::pair<unsigned int, unsigned int>> cell_loop_post_list;
641  };
642 
643 
644  /*-------------------------- Inline functions ---------------------------*/
645 
646 #ifndef DOXYGEN
647 
648 
649  inline unsigned int
650  DoFInfo::fe_index_from_degree(const unsigned int first_selected_component,
651  const unsigned int fe_degree) const
652  {
653  const unsigned int n_indices = fe_index_conversion.size();
654  if (n_indices <= 1)
655  return 0;
656  for (unsigned int i = 0; i < n_indices; ++i)
657  if (fe_index_conversion[i][first_selected_component] == fe_degree)
658  return i;
660  }
661 
662 #endif // ifndef DOXYGEN
663 
664  } // end of namespace MatrixFreeFunctions
665 } // end of namespace internal
666 
667 DEAL_II_NAMESPACE_CLOSE
668 
669 #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:519
static const unsigned int invalid_unsigned_int
Definition: types.h:190
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:614
std::vector< unsigned int > component_to_base_index
Definition: dof_info.h:549
std::vector< unsigned int > cell_loop_pre_list_index
Definition: dof_info.h:621
std::vector< IndexStorageVariants > index_storage_variants[3]
Definition: dof_info.h:395
std::vector< unsigned int > dof_indices_interleave_strides[3]
Definition: dof_info.h:457
std::shared_ptr< const Utilities::MPI::Partitioner > vector_partitioner
Definition: dof_info.h:476
std::vector< unsigned int > vector_zero_range_list_index
Definition: dof_info.h:609
std::vector< unsigned int > dof_indices
Definition: dof_info.h:420
std::vector< unsigned char > n_vectorization_lanes_filled[3]
Definition: dof_info.h:468
std::vector< unsigned int > cell_loop_post_list_index
Definition: dof_info.h:634
std::vector< unsigned int > dofs_per_face
Definition: dof_info.h:572
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< std::pair< unsigned int, unsigned int > > cell_loop_pre_list
Definition: dof_info.h:627
std::vector< unsigned int > dof_indices_interleaved
Definition: dof_info.h:437
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:509
std::vector< std::vector< unsigned int > > fe_index_conversion
Definition: dof_info.h:595
std::vector< std::pair< unsigned int, unsigned int > > row_starts
Definition: dof_info.h:403
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:432
void compute_face_index_compression(const std::vector< FaceToCellTopology< length >> &faces)
std::vector< types::global_dof_index > ghost_dofs
Definition: dof_info.h:602
std::vector< unsigned int > cell_active_fe_index
Definition: dof_info.h:582
std::vector< unsigned int > dof_indices_contiguous[3]
Definition: dof_info.h:447
std::vector< std::vector< unsigned int > > component_dof_indices_offset
Definition: dof_info.h:562
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:567
std::vector< unsigned int > constrained_dofs
Definition: dof_info.h:503
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:543
std::vector< std::pair< unsigned int, unsigned int > > cell_loop_post_list
Definition: dof_info.h:640
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:537
static const unsigned int chunk_size_zero_vector
Definition: dof_info.h:85
void assign_ghosts(const std::vector< unsigned int > &boundary_cells)
std::array< std::shared_ptr< const Utilities::MPI::Partitioner >, 5 > vector_partitioner_face_variants
Definition: dof_info.h:497