deal.II version GIT relicensing-6834-g5b78e6bcdf 2026-10-01 11:20:01+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\}}\)
Loading...
Searching...
No Matches
dof_info.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2012 - 2024 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13
14#ifndef dealii_matrix_free_dof_info_h
15#define dealii_matrix_free_dof_info_h
16
17
18#include <deal.II/base/config.h>
19
22
25
26#include <array>
27#include <memory>
28
29
31
32#ifndef DOXYGEN
33
34// forward declarations
35
36namespace internal
37{
38 namespace MatrixFreeFunctions
39 {
40 template <int dim>
41 class HangingNodes;
42
43 struct TaskInfo;
44
45 template <typename Number>
46 struct ConstraintValues;
47
48 namespace VectorDataExchange
49 {
50 class Base;
51 }
52 } // namespace MatrixFreeFunctions
53} // namespace internal
54
55template <typename>
57
59
60template <typename>
61class TriaIterator;
62
63template <int, int, bool>
64class DoFCellAccessor;
65
66namespace Utilities
67{
68 namespace MPI
69 {
70 class Partitioner;
71 }
72} // namespace Utilities
73
74#endif
75
76namespace internal
77{
78 namespace MatrixFreeFunctions
79 {
84 using compressed_constraint_kind = std::uint8_t;
85
104 struct DoFInfo
105 {
118 static const unsigned int chunk_size_zero_vector = 64;
119
123 DoFInfo();
124
128 DoFInfo(const DoFInfo &) = default;
129
133 DoFInfo(DoFInfo &&) noexcept = default;
134
138 ~DoFInfo() = default;
139
143 DoFInfo &
144 operator=(const DoFInfo &) = default;
145
149 DoFInfo &
150 operator=(DoFInfo &&) noexcept = default;
151
155 void
156 clear();
157
163 unsigned int
164 fe_index_from_degree(const unsigned int first_selected_component,
165 const unsigned int fe_degree) const;
166
186 void
187 get_dof_indices_on_cell_batch(std::vector<unsigned int> &local_indices,
188 const unsigned int cell_batch,
189 const bool with_constraints = true) const;
190
200 template <typename number>
201 void
203 const std::vector<types::global_dof_index> &local_indices_resolved,
204 const std::vector<types::global_dof_index> &local_indices,
205 const bool cell_has_hanging_nodes,
206 const ::AffineConstraints<number> &constraints,
207 const unsigned int cell_number,
208 ConstraintValues<double> &constraint_values,
209 bool &cell_at_boundary);
210
215 template <int dim>
216 bool
218 const HangingNodes<dim> &hanging_nodes,
219 const std::vector<std::vector<unsigned int>> &lexicographic_mapping,
220 const unsigned int cell_number,
221 const TriaIterator<DoFCellAccessor<dim, dim, false>> &cell,
222 std::vector<types::global_dof_index> &dof_indices);
223
231 void
232 assign_ghosts(const std::vector<unsigned int> &boundary_cells,
233 const MPI_Comm communicator_sm,
234 const bool use_vector_data_exchanger_full);
235
242 void
243 reorder_cells(const TaskInfo &task_info,
244 const std::vector<unsigned int> &renumbering,
245 const std::vector<unsigned int> &constraint_pool_row_index,
246 const std::vector<unsigned char> &irregular_cells);
247
252 void
254 const std::vector<unsigned char> &irregular_cells);
255
260 template <int length>
261 void
263 const std::vector<FaceToCellTopology<length>> &faces,
264 bool hold_all_faces_to_owned_cells);
265
271 void
272 make_connectivity_graph(const TaskInfo &task_info,
273 const std::vector<unsigned int> &renumbering,
274 DynamicSparsityPattern &connectivity) const;
275
281 void
283 const Table<2, ShapeInfo<double>> &shape_info,
284 const unsigned int n_owned_cells,
285 const unsigned int n_lanes,
286 const std::vector<FaceToCellTopology<1>> &inner_faces,
287 const std::vector<FaceToCellTopology<1>> &ghosted_faces,
288 const bool fill_cell_centric,
289 const MPI_Comm communicator_sm,
290 const bool use_vector_data_exchanger_full);
291
297 void
299 std::array<std::vector<std::pair<unsigned int, unsigned int>>, 3>
300 &cell_indices_contiguous_sm);
301
312 void
314 std::vector<types::global_dof_index> &renumbering);
315
325 template <int length>
326 void
328 const TaskInfo &task_info,
329 const std::vector<FaceToCellTopology<length>> &faces);
330
334 std::size_t
335 memory_consumption() const;
336
341 template <typename StreamType>
342 void
344 const TaskInfo &size_info) const;
345
350 template <typename Number>
351 void
352 print(const std::vector<Number> &constraint_pool_data,
353 const std::vector<unsigned int> &constraint_pool_row_index,
354 std::ostream &out) const;
355
449
469
479
487 std::array<std::vector<IndexStorageVariants>, 3> index_storage_variants;
488
495 std::vector<std::pair<unsigned int, unsigned int>> row_starts;
496
512 std::vector<unsigned int> dof_indices;
513
518 std::vector<std::vector<bool>> hanging_node_constraint_masks_comp;
519
524 std::vector<compressed_constraint_kind> hanging_node_constraint_masks;
525
535 std::vector<std::pair<unsigned short, unsigned short>>
537
541 std::vector<unsigned int> dof_indices_interleaved;
542
551 std::array<std::vector<unsigned int>, 3> dof_indices_contiguous;
552
561 std::array<std::vector<std::pair<unsigned int, unsigned int>>, 3>
563
572 std::array<std::vector<unsigned int>, 3> dof_indices_interleave_strides;
573
583 std::array<std::vector<unsigned char>, 3> n_vectorization_lanes_filled;
584
591 std::shared_ptr<const Utilities::MPI::Partitioner> vector_partitioner;
592
596 std::shared_ptr<
599
619 std::array<
620 std::shared_ptr<
622 5>
624
629 std::vector<unsigned int> constrained_dofs;
630
635 std::vector<unsigned int> row_starts_plain_indices;
636
645 std::vector<unsigned int> plain_dof_indices;
646
652
657 unsigned int n_base_elements;
658
663 std::vector<unsigned int> n_components;
664
669 std::vector<unsigned int> start_components;
670
675 std::vector<unsigned int> component_to_base_index;
676
688 std::vector<std::vector<unsigned int>> component_dof_indices_offset;
689
693 std::vector<unsigned int> dofs_per_cell;
694
698 std::vector<unsigned int> dofs_per_face;
699
704
708 std::vector<unsigned int> cell_active_fe_index;
709
714 unsigned int max_fe_index;
715
721 std::vector<std::vector<unsigned int>> fe_index_conversion;
722
728 std::vector<types::global_dof_index> ghost_dofs;
729
735 std::vector<unsigned int> vector_zero_range_list_index;
736
740 std::vector<std::pair<unsigned int, unsigned int>> vector_zero_range_list;
741
747 std::vector<unsigned int> cell_loop_pre_list_index;
748
753 std::vector<std::pair<unsigned int, unsigned int>> cell_loop_pre_list;
754
760 std::vector<unsigned int> cell_loop_post_list_index;
761
766 std::vector<std::pair<unsigned int, unsigned int>> cell_loop_post_list;
767 };
768
769
770 /*-------------------------- Inline functions ---------------------------*/
771
772#ifndef DOXYGEN
773
774
775 inline unsigned int
776 DoFInfo::fe_index_from_degree(const unsigned int first_selected_component,
777 const unsigned int fe_degree) const
778 {
779 const unsigned int n_indices = fe_index_conversion.size();
780 if (n_indices <= 1)
781 return 0;
782 for (unsigned int i = 0; i < n_indices; ++i)
783 if (fe_index_conversion[i][first_selected_component] == fe_degree)
784 return i;
786 }
787
788#endif // ifndef DOXYGEN
789
790 } // end of namespace MatrixFreeFunctions
791} // end of namespace internal
792
794
795#endif
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
std::uint8_t compressed_constraint_kind
Definition dof_info.h:84
constexpr unsigned int invalid_unsigned_int
Definition types.h:228
STL namespace.
Definition types.h:30
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:277
std::vector< std::pair< unsigned short, unsigned short > > constraint_indicator
Definition dof_info.h:536
std::vector< unsigned int > cell_loop_pre_list_index
Definition dof_info.h:747
std::vector< std::pair< unsigned int, unsigned int > > row_starts
Definition dof_info.h:495
std::vector< std::vector< unsigned int > > component_dof_indices_offset
Definition dof_info.h:688
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:842
std::vector< std::vector< bool > > hanging_node_constraint_masks_comp
Definition dof_info.h:518
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:82
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:500
std::vector< unsigned int > cell_loop_post_list_index
Definition dof_info.h:760
std::vector< unsigned int > dofs_per_cell
Definition dof_info.h:693
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:145
void compute_dof_renumbering(std::vector< types::global_dof_index > &renumbering)
Definition dof_info.cc:1412
static const unsigned int chunk_size_zero_vector
Definition dof_info.h:118
std::shared_ptr< const internal::MatrixFreeFunctions::VectorDataExchange::Base > vector_exchanger
Definition dof_info.h:598
std::vector< std::vector< unsigned int > > fe_index_conversion
Definition dof_info.h:721
std::vector< unsigned int > dof_indices
Definition dof_info.h:512
std::vector< std::pair< unsigned int, unsigned int > > vector_zero_range_list
Definition dof_info.h:740
std::shared_ptr< const Utilities::MPI::Partitioner > vector_partitioner
Definition dof_info.h:591
std::vector< compressed_constraint_kind > hanging_node_constraint_masks
Definition dof_info.h:524
std::array< std::vector< unsigned int >, 3 > dof_indices_interleave_strides
Definition dof_info.h:572
std::array< std::vector< std::pair< unsigned int, unsigned int > >, 3 > dof_indices_contiguous_sm
Definition dof_info.h:562
std::vector< unsigned int > row_starts_plain_indices
Definition dof_info.h:635
std::vector< unsigned int > dofs_per_face
Definition dof_info.h:698
std::vector< unsigned int > component_to_base_index
Definition dof_info.h:675
void compute_vector_zero_access_pattern(const TaskInfo &task_info, const std::vector< FaceToCellTopology< length > > &faces)
std::vector< unsigned int > n_components
Definition dof_info.h:663
void print_memory_consumption(StreamType &out, const TaskInfo &size_info) const
void compute_face_index_compression(const std::vector< FaceToCellTopology< length > > &faces, bool hold_all_faces_to_owned_cells)
std::vector< std::pair< unsigned int, unsigned int > > cell_loop_pre_list
Definition dof_info.h:753
std::vector< types::global_dof_index > ghost_dofs
Definition dof_info.h:728
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:551
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)
DoFInfo(const DoFInfo &)=default
std::vector< unsigned int > cell_active_fe_index
Definition dof_info.h:708
std::array< std::shared_ptr< const internal::MatrixFreeFunctions::VectorDataExchange::Base >, 5 > vector_exchanger_face_variants
Definition dof_info.h:623
std::vector< unsigned int > plain_dof_indices
Definition dof_info.h:645
std::array< std::vector< unsigned char >, 3 > n_vectorization_lanes_filled
Definition dof_info.h:583
std::vector< unsigned int > start_components
Definition dof_info.h:669
std::vector< unsigned int > dof_indices_interleaved
Definition dof_info.h:541
std::vector< unsigned int > constrained_dofs
Definition dof_info.h:629
std::array< std::vector< IndexStorageVariants >, 3 > index_storage_variants
Definition dof_info.h:487
void make_connectivity_graph(const TaskInfo &task_info, const std::vector< unsigned int > &renumbering, DynamicSparsityPattern &connectivity) const
Definition dof_info.cc:1335
std::vector< unsigned int > vector_zero_range_list_index
Definition dof_info.h:735
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:1185
std::vector< std::pair< unsigned int, unsigned int > > cell_loop_post_list
Definition dof_info.h:766
DoFInfo(DoFInfo &&) noexcept=default