24#include <deal.II/matrix_free/dof_info.templates.h>
32 namespace MatrixFreeFunctions
36 static_assert(std::is_same<compressed_constraint_kind, std::uint8_t>::value,
37 "Unexpected type for compressed hanging node indicators!");
66 for (
unsigned int i = 0; i < 3; ++i)
83 const unsigned int cell,
84 const bool apply_constraints)
const
87 const unsigned int fe_index =
95 const unsigned int n_vectorization_actual =
101 my_rows.reserve(n_vectorization * dofs_this_cell);
103 unsigned int total_size = 0;
104 for (
unsigned int v = 0; v < n_vectorization_actual; ++v)
106 const unsigned int ib =
107 (cell * n_vectorization + v) * n_fe_components;
108 const unsigned int ie =
109 (cell * n_vectorization + v + 1) * n_fe_components;
114 const bool has_constraints =
122 auto do_copy = [&](
const unsigned int *begin,
123 const unsigned int *end) {
124 const unsigned int shift = total_size;
125 total_size += (end - begin);
126 my_rows.resize(total_size);
127 std::copy(begin, end, my_rows.begin() + shift);
130 if (!has_constraints || apply_constraints)
132 const unsigned int *begin =
134 const unsigned int *end =
143 const unsigned int *begin =
146 const unsigned int *end = begin + dofs_this_cell;
157 const bool use_vector_data_exchanger_full)
164 const std::size_t n_ghosts =
ghost_dofs.size();
171 std::vector<unsigned int> ghost_numbering(n_ghosts);
175 unsigned int n_unique_ghosts = 0;
179 std::vector<std::pair<types::global_dof_index, unsigned int>>
180 ghost_origin(n_ghosts);
181 for (std::size_t i = 0; i < n_ghosts; ++i)
184 ghost_origin[i].second = i;
186 std::sort(ghost_origin.begin(), ghost_origin.end());
189 ghost_numbering[ghost_origin[0].second] = 0;
190 for (std::size_t i = 1; i < n_ghosts; ++i)
192 if (ghost_origin[i].
first > ghost_origin[i - 1].
first + 1)
194 ghost_indices.
add_range(last_contiguous_start,
195 ghost_origin[i - 1].
first + 1);
196 last_contiguous_start = ghost_origin[i].first;
198 if (ghost_origin[i].
first > ghost_origin[i - 1].
first)
200 ghost_numbering[ghost_origin[i].second] = n_unique_ghosts;
203 ghost_indices.
add_range(last_contiguous_start,
204 ghost_origin.back().first + 1);
211 for (std::size_t i = 0; i < n_ghosts; ++i)
212 Assert(ghost_numbering[i] ==
221 const unsigned int n_boundary_cells = boundary_cells.size();
222 for (
unsigned int i = 0; i < n_boundary_cells; ++i)
224 unsigned int *data_ptr =
227 const unsigned int *row_end =
230 for (; data_ptr != row_end; ++data_ptr)
231 *data_ptr = ((*data_ptr < n_owned) ?
233 n_owned + ghost_numbering[*data_ptr - n_owned]);
238 bool has_hanging_nodes =
false;
240 const unsigned int fe_index =
251 for (
unsigned int comp = 0; comp <
n_components; ++comp)
255 if (has_hanging_nodes ||
260 unsigned int *data_ptr =
263 const unsigned int *row_end =
265 for (; data_ptr != row_end; ++data_ptr)
267 ((*data_ptr < n_owned) ?
269 n_owned + ghost_numbering[*data_ptr - n_owned]);
275 std::vector<types::global_dof_index> empty;
285 if (use_vector_data_exchanger_full ==
false)
291 std::make_shared<MatrixFreeFunctions::VectorDataExchange::Full>(
300 const std::vector<unsigned int> & renumbering,
301 const std::vector<unsigned int> & constraint_pool_row_index,
302 const std::vector<unsigned char> &irregular_cells)
304 (void)constraint_pool_row_index;
310 std::vector<unsigned int> new_active_fe_index;
312 unsigned int position_cell = 0;
313 for (
unsigned int cell = 0;
317 const unsigned int n_comp =
318 (irregular_cells[cell] > 0 ? irregular_cells[cell] :
323 unsigned int fe_index =
325 for (
unsigned int j = 1; j < n_comp; ++j)
330 new_active_fe_index.push_back(fe_index);
331 position_cell += n_comp;
341 std::vector<std::pair<unsigned int, unsigned int>> new_row_starts(
345 std::vector<unsigned int> new_dof_indices;
346 std::vector<std::pair<unsigned short, unsigned short>>
347 new_constraint_indicator;
348 std::vector<unsigned int> new_plain_indices, new_rowstart_plain;
349 unsigned int position_cell = 0;
353 std::vector<compressed_constraint_kind> new_hanging_node_constraint_masks;
354 new_hanging_node_constraint_masks.reserve(
374 const unsigned int n_vect =
375 (irregular_cells[i] > 0 ? irregular_cells[i] :
379 this->dofs_per_cell[0];
381 for (
unsigned int j = 0; j < n_vect; ++j)
383 const unsigned int cell_no =
386 bool has_hanging_nodes =
false;
394 new_hanging_node_constraint_masks.push_back(
mask);
397 for (
unsigned int comp = 0; comp <
n_components; ++comp)
402 for (
unsigned int comp = 0; comp <
n_components; ++comp)
406 .
first = new_dof_indices.size();
409 .
second = new_constraint_indicator.size();
411 new_dof_indices.insert(
412 new_dof_indices.end(),
418 new_constraint_indicator.push_back(
427 new_plain_indices.size();
428 new_plain_indices.insert(
429 new_plain_indices.end(),
438 for (
unsigned int comp = 0; comp <
n_components; ++comp)
442 .
first = new_dof_indices.size();
445 .
second = new_constraint_indicator.size();
450 new_hanging_node_constraint_masks.push_back(
453 position_cell += n_vect;
460 .first = new_dof_indices.size();
463 .second = new_constraint_indicator.size();
466 new_constraint_indicator.size());
478 const unsigned int index_range =
492 const unsigned int row_length_ind =
498 const std::pair<unsigned short, unsigned short> *
505 for (; con_it != end_con; ++con_it)
509 constraint_pool_row_index.size() - 1);
514 unsigned int n_active_cells = 0;
517 if (irregular_cells[c] > 0)
518 n_active_cells += irregular_cells[c];
531 const std::vector<unsigned char> &irregular_cells)
541 irregular_cells.size());
545 irregular_cells.size());
546 for (
unsigned int i = 0; i < irregular_cells.size(); ++i)
547 if (irregular_cells[i] > 0)
562 std::vector<unsigned int> index_kinds(
563 static_cast<unsigned int>(
567 for (
unsigned int i = 0; i < irregular_cells.size(); ++i)
569 const unsigned int ndofs =
571 const unsigned int n_comp =
575 bool has_constraints =
false;
576 for (
unsigned int j = 0; j < n_comp; ++j)
582 has_constraints =
true;
591 bool indices_are_contiguous = (ndofs > 0);
592 for (
unsigned int j = 0; j < n_comp; ++j)
596 this->dof_indices.data() +
602 for (
unsigned int i = 1; i < ndofs; ++i)
605 indices_are_contiguous =
false;
610 bool indices_are_interleaved_and_contiguous =
615 this->dof_indices.data() +
617 for (
unsigned int k = 0;
618 k < ndofs && indices_are_interleaved_and_contiguous;
620 for (
unsigned int j = 0; j < n_comp; ++j)
624 indices_are_interleaved_and_contiguous =
false;
629 if (indices_are_contiguous ||
630 indices_are_interleaved_and_contiguous)
632 for (
unsigned int j = 0; j < n_comp; ++j)
634 const unsigned int start_index =
647 if (indices_are_interleaved_and_contiguous)
652 for (
unsigned int j = 0; j < n_comp; ++j)
656 else if (indices_are_contiguous)
660 for (
unsigned int j = 0; j < n_comp; ++j)
666 int indices_are_interleaved_and_mixed = 2;
671 for (
unsigned int j = 0; j < n_comp; ++j)
674 for (
unsigned int k = 0;
675 k < ndofs && indices_are_interleaved_and_mixed != 0;
677 for (
unsigned int j = 0; j < n_comp; ++j)
684 indices_are_interleaved_and_mixed = 0;
687 if (indices_are_interleaved_and_mixed == 2)
689 for (
unsigned int j = 0; j < n_comp; ++j)
693 for (
unsigned int j = 0; j < n_comp; ++j)
697 for (
unsigned int j = 0; j < n_comp; ++j)
700 indices_are_interleaved_and_mixed = 1;
703 if (indices_are_interleaved_and_mixed == 1 ||
715 this->dof_indices.data() +
732 bool is_sorted =
true;
733 unsigned int previous = indices[0];
734 for (
unsigned int l = 1; l < n_comp; ++l)
736 const unsigned int current = indices[l * ndofs];
737 if (current <= previous)
744 for (
unsigned int j = 0; j < l; ++j)
745 if (indices[j * ndofs] == current)
761 index_kinds[
static_cast<unsigned int>(
771 auto fix_single_interleaved_indices =
773 if (index_kinds[
static_cast<unsigned int>(
776 index_kinds[
static_cast<unsigned int>(variant)] > 0)
777 for (
unsigned int i = 0; i < irregular_cells.size(); ++i)
789 index_kinds[
static_cast<unsigned int>(
792 index_kinds[
static_cast<unsigned int>(variant)]++;
801 unsigned int n_interleaved =
802 index_kinds[
static_cast<unsigned int>(
804 index_kinds[
static_cast<unsigned int>(
806 index_kinds[
static_cast<unsigned int>(
811 if (n_interleaved > 0 && index_kinds[
static_cast<unsigned int>(
813 for (
unsigned int i = 0; i < irregular_cells.size(); ++i)
819 index_kinds[
static_cast<unsigned int>(
821 index_kinds[
static_cast<unsigned int>(
827 if (n_interleaved > 0 &&
829 index_kinds[
static_cast<unsigned int>(
832 for (
unsigned int i = 0; i < irregular_cells.size(); ++i)
836 index_kinds[
static_cast<unsigned int>(
845 index_kinds[
static_cast<unsigned int>(
850 for (
unsigned int i = 0; i < irregular_cells.size(); ++i)
861 const unsigned int ndofs =
866 unsigned int *interleaved_dof_indices =
870 this->dof_indices_interleaved.size());
880 for (
unsigned int k = 0; k < ndofs; ++k)
882 const unsigned int *my_dof_indices =
dof_indices + k;
883 const unsigned int *end =
885 for (; interleaved_dof_indices != end;
886 ++interleaved_dof_indices, my_dof_indices += ndofs)
887 *interleaved_dof_indices = *my_dof_indices;
897 const unsigned int n_owned_cells,
898 const unsigned int n_lanes,
901 const bool fill_cell_centric,
903 const bool use_vector_data_exchanger_full)
909 std::vector<types::global_dof_index> ghost_indices;
912 for (
unsigned int cell = 0; cell < n_owned_cells; ++cell)
920 const unsigned int fe_index =
929 ghost_indices.push_back(
932 std::sort(ghost_indices.begin(), ghost_indices.end());
933 ghost_indices.erase(std::unique(ghost_indices.begin(),
934 ghost_indices.end()),
935 ghost_indices.end());
937 compressed_set.
add_indices(ghost_indices.begin(), ghost_indices.end());
939 const bool all_ghosts_equal =
940 Utilities::MPI::min<int>(
static_cast<int>(
945 std::shared_ptr<const Utilities::MPI::Partitioner> temp_0;
947 if (all_ghosts_equal)
951 temp_0 = std::make_shared<Utilities::MPI::Partitioner>(
957 if (use_vector_data_exchanger_full ==
false)
963 std::make_shared<MatrixFreeFunctions::VectorDataExchange::Full>(
964 temp_0, communicator_sm);
968 std::vector<FaceToCellTopology<1>> all_faces(inner_faces);
969 all_faces.insert(all_faces.end(),
970 ghosted_faces.begin(),
971 ghosted_faces.end());
974 2 * shape_info(0, 0).n_dimensions);
976 for (
unsigned int f = 0; f < all_faces.size(); ++f)
978 cell_and_face_to_faces(all_faces[f].cells_interior[0],
979 all_faces[f].interior_face_no) = f;
980 Assert(all_faces[f].cells_exterior[0] !=
983 cell_and_face_to_faces(all_faces[f].cells_exterior[0],
984 all_faces[f].exterior_face_no) = f;
988 const auto loop_over_faces =
989 [&](
const std::function<
990 void(
const unsigned int,
const unsigned int,
const bool)> &fu) {
991 for (
const auto &face : inner_faces)
994 fu(face.cells_exterior[0], face.exterior_face_no,
false );
998 const auto loop_over_all_faces =
999 [&](
const std::function<
1000 void(
const unsigned int,
const unsigned int,
const bool)> &fu) {
1001 for (
unsigned int c = 0; c < cell_and_face_to_faces.size(0); ++c)
1002 for (
unsigned int d = 0; d < cell_and_face_to_faces.size(1); ++d)
1004 const unsigned int f = cell_and_face_to_faces(c, d);
1008 const unsigned int cell_m = all_faces[f].cells_interior[0];
1009 const unsigned int cell_p = all_faces[f].cells_exterior[0];
1011 const bool ext = c == cell_m;
1016 const unsigned int p = ext ? cell_p : cell_m;
1017 const unsigned int face_no = ext ?
1018 all_faces[f].exterior_face_no :
1019 all_faces[f].interior_face_no;
1021 fu(p, face_no,
true);
1025 const auto process_values =
1027 std::shared_ptr<const Utilities::MPI::Partitioner>
1028 &vector_partitioner_values,
1029 const std::function<void(
1030 const std::function<
void(
1031 const unsigned int,
const unsigned int,
const bool)> &)> &loop) {
1032 bool all_nodal_and_tensorial = shape_info.size(1) == 1;
1034 if (all_nodal_and_tensorial)
1039 if (!si.nodal_at_cell_boundaries ||
1042 all_nodal_and_tensorial =
false;
1045 if (all_nodal_and_tensorial ==
false)
1049 bool has_noncontiguous_cell =
false;
1051 loop([&](
const unsigned int cell_no,
1052 const unsigned int face_no,
1054 const unsigned int index =
1059 const unsigned int stride =
1060 dof_indices_interleave_strides[dof_access_cell][cell_no];
1062 for (unsigned int e = 0; e < n_base_elements; ++e)
1063 for (unsigned int c = 0; c < n_components[e]; ++c)
1065 const ShapeInfo<double> &shape =
1066 shape_info(global_base_element_offset + e, 0);
1067 for (unsigned int j = 0;
1068 j < shape.dofs_per_component_on_face;
1070 ghost_indices.push_back(part.local_to_global(
1072 shape.face_to_cell_index_nodal(face_no, j) *
1074 i += shape.dofs_per_component_on_cell * stride;
1079 has_noncontiguous_cell =
true;
1081 has_noncontiguous_cell =
1082 Utilities::MPI::min<int>(
static_cast<int>(
1083 has_noncontiguous_cell),
1086 std::sort(ghost_indices.begin(), ghost_indices.end());
1087 ghost_indices.erase(std::unique(ghost_indices.begin(),
1088 ghost_indices.end()),
1089 ghost_indices.end());
1092 ghost_indices.end());
1094 const bool all_ghosts_equal =
1095 Utilities::MPI::min<int>(
static_cast<int>(
1099 if (all_ghosts_equal || has_noncontiguous_cell)
1103 vector_partitioner_values =
1104 std::make_shared<Utilities::MPI::Partitioner>(
1107 vector_partitioner_values.get())
1114 const auto process_gradients =
1116 const std::shared_ptr<const Utilities::MPI::Partitioner>
1117 &vector_partitoner_values,
1118 std::shared_ptr<const Utilities::MPI::Partitioner>
1119 &vector_partitioner_gradients,
1120 const std::function<void(
1121 const std::function<
void(
1122 const unsigned int,
const unsigned int,
const bool)> &)> &loop) {
1123 bool all_hermite = shape_info.
size(1) == 1;
1126 for (
unsigned int c = 0; c < n_base_elements; ++c)
1127 if (shape_info(global_base_element_offset + c, 0).element_type !=
1129 all_hermite =
false;
1130 if (all_hermite ==
false ||
1131 vector_partitoner_values.get() == vector_partitioner.get())
1132 vector_partitioner_gradients = vector_partitioner;
1135 loop([&](
const unsigned int cell_no,
1136 const unsigned int face_no,
1138 const unsigned int index =
1139 dof_indices_contiguous[dof_access_cell][cell_no];
1141 index >= part.locally_owned_size()))
1143 const unsigned int stride =
1144 dof_indices_interleave_strides[dof_access_cell][cell_no];
1146 for (unsigned int e = 0; e < n_base_elements; ++e)
1147 for (unsigned int c = 0; c < n_components[e]; ++c)
1149 const ShapeInfo<double> &shape =
1150 shape_info(global_base_element_offset + e, 0);
1151 for (unsigned int j = 0;
1152 j < 2 * shape.dofs_per_component_on_face;
1154 ghost_indices.push_back(part.local_to_global(
1156 shape.face_to_cell_index_hermite(face_no, j) *
1158 i += shape.dofs_per_component_on_cell * stride;
1163 std::sort(ghost_indices.begin(), ghost_indices.end());
1164 ghost_indices.erase(std::unique(ghost_indices.begin(),
1165 ghost_indices.end()),
1166 ghost_indices.end());
1167 IndexSet compressed_set(part.size());
1168 compressed_set.add_indices(ghost_indices.begin(),
1169 ghost_indices.end());
1170 compressed_set.subtract_set(part.locally_owned_range());
1171 const bool all_ghosts_equal =
1172 Utilities::MPI::min<int>(
static_cast<int>(
1173 compressed_set.n_elements() ==
1174 part.ghost_indices().n_elements()),
1175 part.get_mpi_communicator()) != 0;
1176 if (all_ghosts_equal)
1177 vector_partitioner_gradients = vector_partitioner;
1180 vector_partitioner_gradients =
1181 std::make_shared<Utilities::MPI::Partitioner>(
1182 part.locally_owned_range(), part.get_mpi_communicator());
1184 vector_partitioner_gradients.get())
1185 ->set_ghost_indices(compressed_set, part.ghost_indices());
1190 std::shared_ptr<const Utilities::MPI::Partitioner> temp_1, temp_2, temp_3,
1194 process_values(temp_1, loop_over_faces);
1197 process_gradients(temp_1, temp_2, loop_over_faces);
1199 if (fill_cell_centric)
1201 ghost_indices.clear();
1203 process_values(temp_3, loop_over_all_faces);
1205 process_gradients(temp_3, temp_4, loop_over_all_faces);
1209 temp_3 = std::make_shared<Utilities::MPI::Partitioner>(
1210 part.locally_owned_range(), part.get_mpi_communicator());
1211 temp_4 = std::make_shared<Utilities::MPI::Partitioner>(
1212 part.locally_owned_range(), part.get_mpi_communicator());
1215 if (use_vector_data_exchanger_full ==
false)
1217 vector_exchanger_face_variants[1] = std::make_shared<
1218 MatrixFreeFunctions::VectorDataExchange::PartitionerWrapper>(
1220 vector_exchanger_face_variants[2] = std::make_shared<
1221 MatrixFreeFunctions::VectorDataExchange::PartitionerWrapper>(
1223 vector_exchanger_face_variants[3] = std::make_shared<
1224 MatrixFreeFunctions::VectorDataExchange::PartitionerWrapper>(
1226 vector_exchanger_face_variants[4] = std::make_shared<
1227 MatrixFreeFunctions::VectorDataExchange::PartitionerWrapper>(
1232 vector_exchanger_face_variants[1] =
1233 std::make_shared<MatrixFreeFunctions::VectorDataExchange::Full>(
1234 temp_1, communicator_sm);
1235 vector_exchanger_face_variants[2] =
1236 std::make_shared<MatrixFreeFunctions::VectorDataExchange::Full>(
1237 temp_2, communicator_sm);
1238 vector_exchanger_face_variants[3] =
1239 std::make_shared<MatrixFreeFunctions::VectorDataExchange::Full>(
1240 temp_3, communicator_sm);
1241 vector_exchanger_face_variants[4] =
1242 std::make_shared<MatrixFreeFunctions::VectorDataExchange::Full>(
1243 temp_4, communicator_sm);
1250 DoFInfo::compute_shared_memory_contiguous_indices(
1251 std::array<std::vector<std::pair<unsigned int, unsigned int>>, 3>
1252 &cell_indices_contiguous_sm)
1256 for (
unsigned int i = 0; i < 3; ++i)
1258 dof_indices_contiguous_sm[i].resize(
1259 cell_indices_contiguous_sm[i].size());
1261 for (
unsigned int j = 0; j < cell_indices_contiguous_sm[i].size();
1263 if (cell_indices_contiguous_sm[i][j].
first !=
1265 dof_indices_contiguous_sm[i][j] = {
1266 cell_indices_contiguous_sm[i][j].first,
1267 cell_indices_contiguous_sm[i][j].second * dofs_per_cell[0]};
1287 const unsigned int end,
1289 std::vector<std::mutex> & mutexes,
1290 std::vector<unsigned int> &row_lengths)
1292 std::vector<unsigned int> scratch;
1294 for (
unsigned int block = begin; block < end; ++block)
1300 dof_info.
row_starts[block * n_components].first,
1302 dof_info.
row_starts[(block + 1) * n_components].first);
1303 std::sort(scratch.begin(), scratch.end());
1304 std::vector<unsigned int>::const_iterator end_unique =
1305 std::unique(scratch.begin(), scratch.end());
1306 std::vector<unsigned int>::const_iterator it = scratch.begin();
1307 while (it != end_unique)
1311 const unsigned int next_bucket =
1313 std::lock_guard<std::mutex> lock(
1315 for (; it != end_unique && *it < next_bucket; ++it)
1326 const unsigned int end,
1328 const std::vector<unsigned int> &row_lengths,
1329 std::vector<std::mutex> & mutexes,
1332 std::vector<unsigned int> scratch;
1334 for (
unsigned int block = begin; block < end; ++block)
1340 dof_info.
row_starts[block * n_components].first,
1342 dof_info.
row_starts[(block + 1) * n_components].first);
1343 std::sort(scratch.begin(), scratch.end());
1344 std::vector<unsigned int>::const_iterator end_unique =
1345 std::unique(scratch.begin(), scratch.end());
1346 std::vector<unsigned int>::const_iterator it = scratch.begin();
1347 while (it != end_unique)
1349 const unsigned int next_bucket =
1351 std::lock_guard<std::mutex> lock(
1353 for (; it != end_unique && *it < next_bucket; ++it)
1354 if (row_lengths[*it] > 0)
1355 connectivity_dof.
add(*it, block);
1364 const unsigned int end,
1366 const std::vector<unsigned int> &renumbering,
1367 const ::SparsityPattern & connectivity_dof,
1370 ordered_vector row_entries;
1372 for (
unsigned int block = begin; block < end; ++block)
1374 row_entries.clear();
1378 dof_info.
row_starts[block * n_components].first,
1381 for (; it != end_cell; ++it)
1384 std::vector<types::global_dof_index>::iterator insert_pos =
1385 row_entries.begin();
1386 for (; sp != connectivity_dof.end(*it); ++sp)
1387 if (sp->column() != block)
1388 row_entries.insert(renumbering[sp->column()], insert_pos);
1391 row_entries.begin(),
1399 DoFInfo::make_connectivity_graph(
1401 const std::vector<unsigned int> &renumbering,
1404 unsigned int n_rows = (vector_partitioner->local_range().second -
1405 vector_partitioner->local_range().first) +
1406 vector_partitioner->ghost_indices().n_elements();
1413 std::vector<unsigned int> row_lengths(n_rows);
1414 std::vector<std::mutex> mutexes(n_rows / internal::bucket_size_threading +
1419 [
this, &mutexes, &row_lengths](
const unsigned int begin,
1420 const unsigned int end) {
1421 internal::compute_row_lengths(
1422 begin, end, *this, mutexes, row_lengths);
1428 for (
unsigned int row = 0; row < n_rows; ++row)
1429 if (row_lengths[row] <= 1)
1430 row_lengths[row] = 0;
1441 [
this, &row_lengths, &mutexes, &connectivity_dof](
1442 const unsigned int begin,
const unsigned int end) {
1443 internal::fill_connectivity_dofs(
1444 begin, end, *this, row_lengths, mutexes, connectivity_dof);
1451 std::vector<unsigned int> reverse_numbering(task_info.
n_active_cells);
1461 [
this, &reverse_numbering, &connectivity_dof, &connectivity](
1462 const unsigned int begin,
const unsigned int end) {
1463 internal::fill_connectivity(begin,
1476 DoFInfo::compute_dof_renumbering(
1477 std::vector<types::global_dof_index> &renumbering)
1479 const unsigned int locally_owned_size =
1480 vector_partitioner->locally_owned_size();
1481 renumbering.resize(0);
1485 const unsigned int n_components = start_components.back();
1486 const unsigned int n_cell_batches =
1487 n_vectorization_lanes_filled[dof_access_cell].size();
1489 (row_starts.size() - 1) / vectorization_length / n_components,
1491 for (
unsigned int cell_no = 0; cell_no < n_cell_batches; ++cell_no)
1494 if (row_starts[cell_no * n_components * vectorization_length]
1496 row_starts[(cell_no + 1) * n_components * vectorization_length]
1499 const unsigned int ndofs =
1500 dofs_per_cell.size() == 1 ?
1502 (dofs_per_cell[cell_active_fe_index.size() > 0 ?
1503 cell_active_fe_index[cell_no] :
1505 const unsigned int *dof_ind =
1506 dof_indices.data() +
1507 row_starts[cell_no * n_components * vectorization_length].first;
1508 for (
unsigned int i = 0; i < ndofs; ++i)
1509 for (
unsigned int j = 0;
1510 j < n_vectorization_lanes_filled[dof_access_cell][cell_no];
1512 if (dof_ind[j * ndofs + i] < locally_owned_size)
1513 if (renumbering[dof_ind[j * ndofs + i]] ==
1515 renumbering[dof_ind[j * ndofs + i]] = counter++;
1522 dof_index = counter++;
1526 dof_index = vector_partitioner->local_to_global(dof_index);
1534 DoFInfo::memory_consumption()
const
1536 std::size_t memory =
sizeof(*this);
1538 (row_starts.capacity() *
sizeof(std::pair<unsigned int, unsigned int>));
1553 namespace MatrixFreeFunctions
1556 DoFInfo::read_dof_indices<double>(
1557 const std::vector<types::global_dof_index> &,
1558 const std::vector<types::global_dof_index> &,
1560 const ::AffineConstraints<double> &,
1562 ConstraintValues<double> &,
1566 DoFInfo::read_dof_indices<float>(
1567 const std::vector<types::global_dof_index> &,
1568 const std::vector<types::global_dof_index> &,
1570 const ::AffineConstraints<float> &,
1572 ConstraintValues<double> &,
1576 DoFInfo::process_hanging_node_constraints<1>(
1577 const HangingNodes<1> &,
1578 const std::vector<std::vector<unsigned int>> &,
1581 std::vector<types::global_dof_index> &);
1583 DoFInfo::process_hanging_node_constraints<2>(
1584 const HangingNodes<2> &,
1585 const std::vector<std::vector<unsigned int>> &,
1588 std::vector<types::global_dof_index> &);
1590 DoFInfo::process_hanging_node_constraints<3>(
1591 const HangingNodes<3> &,
1592 const std::vector<std::vector<unsigned int>> &,
1595 std::vector<types::global_dof_index> &);
1598 DoFInfo::compute_face_index_compression<1>(
1599 const std::vector<FaceToCellTopology<1>> &);
1601 DoFInfo::compute_face_index_compression<2>(
1602 const std::vector<FaceToCellTopology<2>> &);
1604 DoFInfo::compute_face_index_compression<4>(
1605 const std::vector<FaceToCellTopology<4>> &);
1607 DoFInfo::compute_face_index_compression<8>(
1608 const std::vector<FaceToCellTopology<8>> &);
1610 DoFInfo::compute_face_index_compression<16>(
1611 const std::vector<FaceToCellTopology<16>> &);
1614 DoFInfo::compute_vector_zero_access_pattern<1>(
1616 const std::vector<FaceToCellTopology<1>> &);
1618 DoFInfo::compute_vector_zero_access_pattern<2>(
1620 const std::vector<FaceToCellTopology<2>> &);
1622 DoFInfo::compute_vector_zero_access_pattern<4>(
1624 const std::vector<FaceToCellTopology<4>> &);
1626 DoFInfo::compute_vector_zero_access_pattern<8>(
1628 const std::vector<FaceToCellTopology<8>> &);
1630 DoFInfo::compute_vector_zero_access_pattern<16>(
1632 const std::vector<FaceToCellTopology<16>> &);
1635 DoFInfo::print_memory_consumption<std::ostream>(std::ostream &,
1638 DoFInfo::print_memory_consumption<ConditionalOStream>(
1643 DoFInfo::print<double>(
const std::vector<double> &,
1644 const std::vector<unsigned int> &,
1645 std::ostream &)
const;
1648 DoFInfo::print<float>(
const std::vector<float> &,
1649 const std::vector<unsigned int> &,
1650 std::ostream &)
const;
void add_entries(const size_type row, ForwardIterator begin, ForwardIterator end, const bool indices_are_unique_and_sorted=false)
size_type index_within_set(const size_type global_index) const
size_type n_elements() const
void subtract_set(const IndexSet &other)
void add_range(const size_type begin, const size_type end)
void add_indices(const ForwardIterator &begin, const ForwardIterator &end)
void add(const size_type i, const size_type j)
const IndexSet & locally_owned_range() const
const IndexSet & ghost_indices() const
unsigned int locally_owned_size() const
types::global_dof_index local_to_global(const unsigned int local_index) const
virtual MPI_Comm get_mpi_communicator() const override
void set_ghost_indices(const IndexSet &ghost_indices, const IndexSet &larger_ghost_index_set=IndexSet())
types::global_dof_index size() const
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcNotInitialized()
@ tensor_symmetric_hermite
std::enable_if_t< std::is_fundamental< T >::value, std::size_t > memory_consumption(const T &t)
std::vector< Integer > invert_permutation(const std::vector< Integer > &permutation)
void fill_connectivity_dofs(const unsigned int begin, const unsigned int end, const DoFInfo &dof_info, const std::vector< unsigned int > &row_lengths, std::vector< std::mutex > &mutexes, ::SparsityPattern &connectivity_dof)
void fill_connectivity(const unsigned int begin, const unsigned int end, const DoFInfo &dof_info, const std::vector< unsigned int > &renumbering, const ::SparsityPattern &connectivity_dof, DynamicSparsityPattern &connectivity)
void compute_row_lengths(const unsigned int begin, const unsigned int end, const DoFInfo &dof_info, std::vector< std::mutex > &mutexes, std::vector< unsigned int > &row_lengths)
static constexpr unsigned int bucket_size_threading
constexpr compressed_constraint_kind unconstrained_compressed_constraint_kind
static const unsigned int invalid_unsigned_int
const types::global_dof_index invalid_dof_index
void apply_to_subranges(const Iterator &begin, const std_cxx20::type_identity_t< Iterator > &end, const Function &f, const unsigned int grainsize)
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
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< std::pair< unsigned short, unsigned short > > constraint_indicator
std::vector< std::pair< unsigned int, unsigned int > > row_starts
unsigned int n_base_elements
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)
std::vector< std::vector< bool > > hanging_node_constraint_masks_comp
unsigned int global_base_element_offset
unsigned int max_fe_index
void get_dof_indices_on_cell_batch(std::vector< unsigned int > &local_indices, const unsigned int cell_batch, const bool with_constraints=true) const
void compute_cell_index_compression(const std::vector< unsigned char > &irregular_cells)
std::vector< unsigned int > dofs_per_cell
void assign_ghosts(const std::vector< unsigned int > &boundary_cells, const MPI_Comm communicator_sm, const bool use_vector_data_exchanger_full)
unsigned int vectorization_length
std::shared_ptr< const internal::MatrixFreeFunctions::VectorDataExchange::Base > vector_exchanger
@ interleaved_contiguous_strided
@ interleaved_contiguous_mixed_strides
std::vector< std::vector< unsigned int > > fe_index_conversion
std::vector< unsigned int > dof_indices
std::shared_ptr< const Utilities::MPI::Partitioner > vector_partitioner
std::vector< compressed_constraint_kind > hanging_node_constraint_masks
std::array< std::vector< unsigned int >, 3 > dof_indices_interleave_strides
std::vector< unsigned int > row_starts_plain_indices
std::vector< unsigned int > dofs_per_face
std::vector< unsigned int > n_components
std::vector< types::global_dof_index > ghost_dofs
std::array< std::vector< unsigned int >, 3 > dof_indices_contiguous
std::vector< unsigned int > cell_active_fe_index
std::array< std::shared_ptr< const internal::MatrixFreeFunctions::VectorDataExchange::Base >, 5 > vector_exchanger_face_variants
std::vector< unsigned int > plain_dof_indices
std::array< std::vector< unsigned char >, 3 > n_vectorization_lanes_filled
std::vector< unsigned int > start_components
std::vector< unsigned int > dof_indices_interleaved
std::array< std::vector< IndexStorageVariants >, 3 > index_storage_variants
unsigned int n_active_cells
std::vector< unsigned int > cell_partition_data