39 template <
int dim,
typename Number,
bool is_face_>
52 std::function<std::vector<std::unique_ptr<FEEvalType>>(
53 const std::pair<unsigned int, unsigned int> &)>
55 std::function<void(std::vector<std::unique_ptr<FEEvalType>> &,
58 std::function<void(std::vector<std::unique_ptr<FEEvalType>> &)>
68 template <
int dim,
typename AdditionalData>
71 AdditionalData &additional_data);
91 typename VectorizedArrayType,
96 VectorType &diagonal_global,
102 VectorizedArrayType> &)>
104 const unsigned int dof_handler_index = 0,
105 const unsigned int quadrature_index = 0,
106 const unsigned int first_selected_component = 0,
107 const unsigned int first_vector_component = 0);
118 typename QuadOperation>
123 const QuadOperation &quad_operation,
126 const unsigned int dof_handler_index = 0,
127 const unsigned int quadrature_index = 0,
128 const unsigned int first_selected_component = 0,
129 const unsigned int first_vector_component = 0);
134 template <
typename CLASS,
140 typename VectorizedArrayType,
145 VectorType &diagonal_global,
151 VectorizedArrayType> &) const,
152 const CLASS *owning_class,
153 const unsigned
int dof_handler_index = 0,
154 const unsigned
int quadrature_index = 0,
155 const unsigned
int first_selected_component = 0,
156 const unsigned
int first_vector_component = 0);
175 typename VectorizedArrayType,
180 VectorType &diagonal_global,
186 VectorizedArrayType> &)>
193 VectorizedArrayType> &,
199 VectorizedArrayType> &)>
206 VectorizedArrayType> &)>
208 const unsigned int dof_handler_index = 0,
209 const unsigned int quadrature_index = 0,
210 const unsigned int first_selected_component = 0,
211 const unsigned int first_vector_component = 0);
218 template <
typename CLASS,
224 typename VectorizedArrayType,
229 VectorType &diagonal_global,
235 VectorizedArrayType> &) const,
241 VectorizedArrayType> &,
247 VectorizedArrayType> &)
254 VectorizedArrayType> &)
256 const CLASS *owning_class,
257 const unsigned
int dof_handler_index = 0,
258 const unsigned
int quadrature_index = 0,
259 const unsigned
int first_selected_component = 0,
260 const unsigned
int first_vector_component = 0);
277 typename VectorizedArrayType,
289 VectorizedArrayType> &)>
291 const unsigned int dof_handler_index = 0,
292 const unsigned int quadrature_index = 0,
293 const unsigned int first_selected_component = 0);
300 template <
typename CLASS,
306 typename VectorizedArrayType,
318 VectorizedArrayType> &) const,
319 const CLASS *owning_class,
320 const unsigned
int dof_handler_index = 0,
321 const unsigned
int quadrature_index = 0,
322 const unsigned
int first_selected_component = 0);
348 typename QuadOperation>
352 const QuadOperation &quad_operation,
355 const unsigned int dof_handler_index = 0,
356 const unsigned int quadrature_index = 0,
357 const unsigned int first_selected_component = 0);
368 typename VectorizedArrayType,
370 typename VectorType2>
380 VectorType &diagonal_global,
381 std::vector<VectorType2 *> &diagonal_global_components);
389 typename VectorizedArrayType,
420 typename VectorizedArrayType,
432 VectorizedArrayType> &)>
439 VectorizedArrayType> &,
445 VectorizedArrayType> &)>
452 VectorizedArrayType> &)>
454 const unsigned int dof_handler_index = 0,
455 const unsigned int quadrature_index = 0,
456 const unsigned int first_selected_component = 0);
463 template <
typename CLASS,
469 typename VectorizedArrayType,
481 VectorizedArrayType> &) const,
487 VectorizedArrayType> &,
493 VectorizedArrayType> &)
500 VectorizedArrayType> &)
502 const CLASS *owning_class,
503 const unsigned
int dof_handler_index = 0,
504 const unsigned
int quadrature_index = 0,
505 const unsigned
int first_selected_component = 0);
557 std::vector<unsigned int> valid_fe_indices;
559 const auto &fe_collection =
561 .get_fe_collection();
563 for (
unsigned int i = 0; i < fe_collection.size(); ++i)
564 if (fe_collection[i].n_dofs_per_cell() > 0)
565 valid_fe_indices.push_back(i);
579 template <
typename VectorTypeOut,
typename VectorTypeIn>
584 const VectorTypeIn &,
585 const std::pair<unsigned int, unsigned int> &)> &cell_operation,
587 const VectorTypeIn &src,
588 const bool zero_dst_vector =
false)
const
590 const auto ebd_cell_operation = [&](
const auto &
matrix_free,
594 const auto category =
matrix_free.get_cell_range_category(range);
602 matrix_free->template cell_loop<VectorTypeOut, VectorTypeIn>(
603 ebd_cell_operation, dst, src, zero_dst_vector);
613 template <
typename VectorTypeOut,
typename VectorTypeIn>
618 const VectorTypeIn &,
619 const std::pair<unsigned int, unsigned int> &)> &cell_operation,
623 const VectorTypeIn &,
624 const std::pair<unsigned int, unsigned int> &)> &face_operation,
628 const VectorTypeIn &,
629 const std::pair<unsigned int, unsigned int> &,
630 const bool)> &boundary_operation,
632 const VectorTypeIn &src,
633 const bool zero_dst_vector =
false)
const
635 const auto ebd_cell_operation = [&](
const auto &
matrix_free,
639 const auto category =
matrix_free.get_cell_range_category(range);
647 const auto ebd_internal_or_boundary_face_operation =
652 const auto category =
matrix_free.get_face_range_category(range);
654 const unsigned int type =
668 matrix_free->template loop<VectorTypeOut, VectorTypeIn>(
670 ebd_internal_or_boundary_face_operation,
671 ebd_internal_or_boundary_face_operation,
694 template <
int dim,
typename AdditionalData>
697 AdditionalData &additional_data)
700 const unsigned int level = additional_data.mg_level;
705 additional_data.cell_vectorization_category.assign(
708 additional_data.cell_vectorization_category.assign(tria.
n_active_cells(),
715 std::sort(bids.begin(), bids.end());
718 unsigned int n_bids = bids.size() + 1;
720 for (
unsigned int i = 0; i < GeometryInfo<dim>::faces_per_cell;
721 i++, offset = offset * n_bids)
725 const auto to_category = [&](
const auto &cell) {
726 unsigned int c_num = 0;
727 for (
unsigned int i = 0; i < GeometryInfo<dim>::faces_per_cell; ++i)
729 const auto face = cell->face(i);
730 if (face->at_boundary() && !cell->has_periodic_neighbor(i))
732 factors[i] * (1 + std::distance(bids.begin(),
733 std::find(bids.begin(),
735 face->boundary_id())));
744 if (cell->is_locally_owned())
746 .cell_vectorization_category[cell->active_cell_index()] =
754 if (cell->is_locally_owned_on_level())
755 additional_data.cell_vectorization_category[cell->index()] =
761 additional_data.hold_all_faces_to_owned_cells =
true;
762 additional_data.cell_vectorization_categories_strict =
true;
763 additional_data.mapping_update_flags_faces_by_cells =
764 additional_data.mapping_update_flags_inner_faces |
765 additional_data.mapping_update_flags_boundary_faces;
770 template <
typename Number>
773 std::vector<unsigned int> row_lid_to_gid;
774 std::vector<unsigned int> row;
775 std::vector<unsigned int> col;
776 std::vector<Number> val;
778 std::vector<unsigned int> inverse_lookup_rows;
779 std::vector<std::pair<unsigned int, unsigned int>> inverse_lookup_origins;
782 template <
int dim,
typename VectorizedArrayType,
bool is_face>
783 class ComputeDiagonalHelper
786 using FEEvaluationType =
789 using Number =
typename VectorizedArrayType::value_type;
790 static const unsigned int n_lanes = VectorizedArrayType::size();
792 ComputeDiagonalHelper()
794 , matrix_free(nullptr)
795 , dofs_per_component(0)
799 ComputeDiagonalHelper(
const ComputeDiagonalHelper &)
801 , matrix_free(nullptr)
802 , dofs_per_component(0)
808 FEEvaluationType &phi,
810 const unsigned int n_components)
814 if (dofs_per_component !=
815 phi.get_shape_info().dofs_per_component_on_cell)
817 locally_relevant_constraints_hn_map.
clear();
819 phi.get_shape_info().dofs_per_component_on_cell;
821 this->n_components = n_components;
822 this->dofs_per_cell = n_components * dofs_per_component;
824 this->matrix_free = &matrix_free;
828 reinit(
const unsigned int cell)
831 const auto &matrix_free = *this->matrix_free;
839 const unsigned int first_selected_component =
840 n_fe_components == 1 ? 0 : phi->get_first_selected_component();
842 this->n_lanes_filled =
849 const std::array<unsigned int, n_lanes> &cells =
850 this->phi->get_cell_ids();
852 inverse_lookup_count.resize(dofs_per_cell);
853 for (
unsigned int v = 0; v < n_lanes_filled; ++v)
858 const unsigned int *dof_indices;
859 unsigned int index_indicators, next_index_indicators;
861 const unsigned int start =
862 cells[v] * n_fe_components + first_selected_component;
864 dof_info.dof_indices.data() + dof_info.row_starts[start].first;
865 index_indicators = dof_info.row_starts[start].second;
866 next_index_indicators = dof_info.row_starts[start + 1].second;
870 locally_relevant_constraints.clear();
872 if (n_components == 1 || n_fe_components == 1)
874 unsigned int ind_local = 0;
875 for (; index_indicators != next_index_indicators;
876 ++index_indicators, ++ind_local)
878 const std::pair<unsigned short, unsigned short> indicator =
879 dof_info.constraint_indicator[index_indicators];
881 for (
unsigned int j = 0; j < indicator.first;
883 locally_relevant_constraints.emplace_back(ind_local,
887 dof_indices += indicator.first;
894 for (; data_val != end_pool; ++data_val, ++dof_indices)
895 locally_relevant_constraints.emplace_back(ind_local,
902 for (; ind_local < dofs_per_component;
903 ++dof_indices, ++ind_local)
904 locally_relevant_constraints.emplace_back(ind_local,
915 for (
unsigned int comp = 0; comp < n_components; ++comp)
917 unsigned int ind_local = 0;
921 for (; index_indicators != next_index_indicators;
922 ++index_indicators, ++ind_local)
924 const std::pair<unsigned short, unsigned short>
926 dof_info.constraint_indicator[index_indicators];
929 for (
unsigned int j = 0; j < indicator.first;
931 locally_relevant_constraints.emplace_back(
932 comp * dofs_per_component + ind_local,
935 dof_indices += indicator.first;
942 for (; data_val != end_pool; ++data_val, ++dof_indices)
943 locally_relevant_constraints.emplace_back(
944 comp * dofs_per_component + ind_local,
952 for (; ind_local < dofs_per_component;
953 ++dof_indices, ++ind_local)
954 locally_relevant_constraints.emplace_back(
955 comp * dofs_per_component + ind_local,
959 if (comp + 1 < n_components)
960 next_index_indicators =
961 dof_info.row_starts[start + comp + 2].second;
968 for (
unsigned int i = 1; i < locally_relevant_constraints.size();
970 Assert(std::get<0>(locally_relevant_constraints[i]) >=
971 std::get<0>(locally_relevant_constraints[i - 1]),
975 if (dof_info.hanging_node_constraint_masks.size() > 0 &&
976 dof_info.hanging_node_constraint_masks_comp.size() > 0 &&
977 dof_info.hanging_node_constraint_masks_comp
978 [phi->get_active_fe_index()][first_selected_component])
981 dof_info.hanging_node_constraint_masks[cells[v]];
984 if (mask != ::internal::MatrixFreeFunctions::
989 if (locally_relevant_constraints_hn_map.find(mask) ==
990 locally_relevant_constraints_hn_map.end())
991 fill_constraint_type_into_map(mask);
993 const auto &locally_relevant_constraints_hn =
994 locally_relevant_constraints_hn_map[
mask];
996 locally_relevant_constraints_tmp.clear();
997 if (locally_relevant_constraints_tmp.capacity() <
998 locally_relevant_constraints.size())
999 locally_relevant_constraints_tmp.reserve(
1000 locally_relevant_constraints.size() +
1001 locally_relevant_constraints_hn.size());
1006 constraint_position.assign(dofs_per_cell,
1008 for (
auto &a : locally_relevant_constraints)
1009 if (constraint_position[
std::get<0>(a)] ==
1011 constraint_position[
std::get<0>(a)] =
1012 std::distance(locally_relevant_constraints.
data(),
1014 is_constrained_hn.assign(dofs_per_cell,
false);
1015 for (
auto &hn : locally_relevant_constraints_hn)
1016 is_constrained_hn[
std::get<0>(hn)] = 1;
1019 for (
const auto &a : locally_relevant_constraints)
1020 if (is_constrained_hn[
std::get<0>(a)] == 0)
1021 locally_relevant_constraints_tmp.
push_back(a);
1025 for (
const auto &hn : locally_relevant_constraints_hn)
1026 if (constraint_position[
std::get<1>(hn)] !=
1030 locally_relevant_constraints.size());
1031 auto other = locally_relevant_constraints.begin() +
1032 constraint_position[std::get<1>(hn)];
1035 for (; other != locally_relevant_constraints.end() &&
1036 std::get<0>(*other) == std::get<1>(hn);
1038 locally_relevant_constraints_tmp.emplace_back(
1040 std::get<1>(*other),
1041 std::get<2>(hn) * std::get<2>(*other));
1044 std::swap(locally_relevant_constraints,
1045 locally_relevant_constraints_tmp);
1050 std::sort(locally_relevant_constraints.begin(),
1051 locally_relevant_constraints.end(),
1052 [](
const auto &a,
const auto &b) {
1053 if (std::get<1>(a) < std::get<1>(b))
1055 return (std::get<1>(a) == std::get<1>(b)) &&
1056 (std::get<0>(a) < std::get<0>(b));
1060 auto &c_pool = c_pools[v];
1062 c_pool.row_lid_to_gid.clear();
1064 c_pool.row.push_back(0);
1068 if (locally_relevant_constraints.size() > 0)
1069 c_pool.row_lid_to_gid.emplace_back(
1070 std::get<1>(locally_relevant_constraints.front()));
1071 for (
const auto &j : locally_relevant_constraints)
1073 if (c_pool.row_lid_to_gid.back() != std::get<1>(j))
1075 c_pool.row_lid_to_gid.push_back(std::get<1>(j));
1076 c_pool.row.push_back(c_pool.val.size());
1079 c_pool.col.emplace_back(std::get<0>(j));
1080 c_pool.val.emplace_back(std::get<2>(j));
1083 if (c_pool.val.size() > 0)
1084 c_pool.row.push_back(c_pool.val.size());
1086 c_pool.inverse_lookup_rows.clear();
1087 c_pool.inverse_lookup_rows.resize(1 + dofs_per_cell);
1088 for (
const unsigned int i : c_pool.col)
1089 c_pool.inverse_lookup_rows[1 + i]++;
1091 std::partial_sum(c_pool.inverse_lookup_rows.begin(),
1092 c_pool.inverse_lookup_rows.end(),
1093 c_pool.inverse_lookup_rows.begin());
1097 c_pool.inverse_lookup_origins.resize(c_pool.col.size());
1098 std::fill(inverse_lookup_count.begin(),
1099 inverse_lookup_count.end(),
1101 for (
unsigned int row = 0; row < c_pool.row.size() - 1; ++row)
1102 for (
unsigned int col = c_pool.row[row];
1103 col < c_pool.row[row + 1];
1106 const unsigned int index = c_pool.col[col];
1107 c_pool.inverse_lookup_origins
1108 [c_pool.inverse_lookup_rows[
index] +
1109 inverse_lookup_count[
index]] = std::make_pair(row, col);
1110 ++inverse_lookup_count[
index];
1139 for (
unsigned int v = 0; v < n_lanes_filled; ++v)
1140 diagonals_local_constrained[v].assign(
1141 c_pools[v].row_lid_to_gid.size() *
1142 (n_fe_components == 1 ? n_components : 1),
1146 bool use_fast_path =
true;
1148 for (
unsigned int v = 0; v < n_lanes_filled; ++v)
1150 auto &c_pool = c_pools[v];
1152 for (
unsigned int i = 0; i < c_pool.row.size() - 1; ++i)
1154 if ((c_pool.row[i + 1] - c_pool.row[i]) > 1)
1156 use_fast_path =
false;
1159 else if (((c_pool.row[i + 1] - c_pool.row[i]) == 1) &&
1160 (c_pool.val[c_pool.row[i]] != 1.0))
1162 use_fast_path =
false;
1167 if (use_fast_path ==
false)
1171 this->has_simple_constraints_ = use_fast_path;
1175 fill_constraint_type_into_map(
1176 const ::internal::MatrixFreeFunctions::compressed_constraint_kind
1179 auto &constraints_hn = locally_relevant_constraints_hn_map[
mask];
1184 const unsigned int degree =
1185 phi->get_shape_info().data.front().fe_degree;
1190 values_dofs.resize(dofs_per_component);
1193 VectorizedArrayType::size()>
1195 constraint_mask.fill(::internal::MatrixFreeFunctions::
1197 constraint_mask[0] =
mask;
1199 for (
unsigned int i = 0; i < dofs_per_component; ++i)
1201 for (
unsigned int j = 0; j < dofs_per_component; ++j)
1202 values_dofs[j] = VectorizedArrayType();
1203 values_dofs[i] =
Number(1);
1208 VectorizedArrayType>::apply(1,
1210 phi->get_shape_info(),
1213 values_dofs.data());
1217 std::numeric_limits<Number>::epsilon() * 16);
1218 for (
unsigned int j = 0; j < dofs_per_component; ++j)
1219 if (
std::abs(values_dofs[j][0]) > tolerance &&
1222 constraints_hn.emplace_back(j, i, values_dofs[j][0]);
1226 const unsigned int n_hn_constraints = constraints_hn.size();
1227 constraints_hn.resize(n_hn_constraints * n_components);
1229 for (
unsigned int c = 1; c < n_components; ++c)
1230 for (
unsigned int i = 0; i < n_hn_constraints; ++i)
1231 constraints_hn[c * n_hn_constraints + i] = std::make_tuple(
1232 std::get<0>(constraints_hn[i]) + c * dofs_per_component,
1233 std::get<1>(constraints_hn[i]) + c * dofs_per_component,
1234 std::get<2>(constraints_hn[i]));
1238 prepare_basis_vector(
const unsigned int i)
1245 VectorizedArrayType *dof_values = phi->begin_dof_values();
1246 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
1247 dof_values[j] = VectorizedArrayType();
1248 dof_values[i] =
Number(1);
1254 VectorizedArrayType *dof_values = phi->begin_dof_values();
1255 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
1256 dof_values[j] = VectorizedArrayType();
1265 const unsigned int n_fe_components =
1266 phi->get_dof_info().start_components.back();
1267 const unsigned int comp =
1268 n_fe_components == 1 ? i / dofs_per_component : 0;
1269 const unsigned int i_comp =
1270 n_fe_components == 1 ? (i % dofs_per_component) : i;
1274 for (
unsigned int v = 0; v < n_lanes_filled; ++v)
1276 const auto &c_pool = c_pools[v];
1278 for (
unsigned int jj = c_pool.inverse_lookup_rows[i_comp];
1279 jj < c_pool.inverse_lookup_rows[i_comp + 1];
1282 const unsigned int j = c_pool.inverse_lookup_origins[jj].first;
1285 for (
unsigned int k = c_pool.row[j]; k < c_pool.row[j + 1]; ++k)
1286 temp += c_pool.val[k] *
1287 phi->begin_dof_values()[comp * dofs_per_component +
1291 diagonals_local_constrained
1292 [v][j + comp * c_pools[v].row_lid_to_gid.size()] +=
1293 temp * c_pool.val[c_pool.inverse_lookup_origins[jj].second];
1298 template <
typename VectorType>
1300 distribute_local_to_global(std::vector<VectorType *> &diagonal_global)
1303 const unsigned int n_fe_components =
1304 phi->get_dof_info().start_components.back();
1306 if (n_fe_components == 1)
1309 for (
unsigned int v = 0; v < n_lanes_filled; ++v)
1313 for (
unsigned int j = 0; j < c_pools[v].row.size() - 1; ++j)
1314 for (
unsigned int comp = 0;
1315 comp < (n_fe_components == 1 ?
1316 static_cast<unsigned int>(n_components) :
1321 *diagonal_global[n_fe_components == 1 ? comp : 0],
1322 c_pools[v].row_lid_to_gid[j],
1323 diagonals_local_constrained
1324 [v][j + comp * c_pools[v].row_lid_to_gid.
size()]);
1328 has_simple_constraints()
const
1330 return has_simple_constraints_;
1334 FEEvaluationType *phi;
1337 unsigned int dofs_per_component;
1338 unsigned int dofs_per_cell;
1339 unsigned int n_components;
1343 unsigned int n_lanes_filled;
1345 std::array<internal::LocalCSR<Number>, n_lanes> c_pools;
1350 std::array<std::vector<Number>, n_lanes> diagonals_local_constrained;
1354 std::vector<std::tuple<unsigned int, unsigned int, Number>>>
1355 locally_relevant_constraints_hn_map;
1360 std::vector<std::tuple<unsigned int, unsigned int, Number>>
1361 locally_relevant_constraints;
1362 std::vector<std::tuple<unsigned int, unsigned int, Number>>
1363 locally_relevant_constraints_tmp;
1364 std::vector<unsigned int> constraint_position;
1365 std::vector<unsigned char> is_constrained_hn;
1366 std::vector<unsigned int> inverse_lookup_count;
1368 bool has_simple_constraints_;
1371 template <
bool is_face,
1374 typename VectorizedArrayType>
1378 const std::pair<unsigned int, unsigned int> &range,
1379 const unsigned int dof_handler_index,
1380 const unsigned int quadrature_index,
1381 const unsigned int first_selected_component,
1382 const unsigned int fe_degree,
1383 const unsigned int n_q_points_1d,
1384 const bool is_interior_face =
true)
1386 const unsigned int static_n_q_points =
1390 const unsigned int active_fe_index =
1394 dof_handler_index) :
1397 const auto init_data = ::internal::
1398 extract_initialization_data<is_face, dim, Number, VectorizedArrayType>(
1401 first_selected_component,
1409 return init_data.shape_info->dofs_per_component_on_cell == 0;
1422 typename QuadOperation>
1423 class ComputeDiagonalCellAction
1426 ComputeDiagonalCellAction(
1427 const unsigned int dof_handler_index,
1428 const QuadOperation &quad_operation,
1431 : m_dof_handler_index(dof_handler_index)
1432 , m_quad_operation(quad_operation)
1433 , m_evaluation_flags(evaluation_flags)
1434 , m_integration_flags(integration_flags)
1437 KOKKOS_FUNCTION
void
1443 FEEvaluation<dim, fe_degree, n_q_points_1d, n_components, Number>
1444 fe_eval(
data, m_dof_handler_index);
1446 *gpu_data = &
data->precomputed_data[m_dof_handler_index];
1449 constexpr int dofs_per_cell =
decltype(fe_eval)::tensor_dofs_per_cell;
1450 constexpr int scalar_dofs_per_cell = dofs_per_cell / n_components;
1451 typename decltype(fe_eval)
::value_type diagonal[scalar_dofs_per_cell] =
1453 for (
unsigned int i = 0; i < dofs_per_cell; ++i)
1456 const unsigned int scalar_dof = i / n_components;
1457 const unsigned int c = i % n_components;
1461 const unsigned int local_index =
1462 scalar_dof + scalar_dofs_per_cell * c;
1470 Kokkos::parallel_for(
1471 Kokkos::TeamThreadRange(
data->team_member, scalar_dofs_per_cell),
1472 [&](
unsigned int j) {
1473 typename decltype(fe_eval)::value_type val = {};
1475 if constexpr (n_components == 1)
1477 val = (i == j) ? 1 : 0;
1481 val[c] = (scalar_dof == j) ? 1 : 0;
1484 fe_eval.submit_dof_value(val, j);
1487 data->team_member.team_barrier();
1489 Portable::internal::
1490 resolve_hanging_nodes<dim, fe_degree, false, Number>(
1494 Kokkos::subview(
data->shared_data[m_dof_handler_index].values,
1498 fe_eval.evaluate(m_evaluation_flags);
1499 data->for_each_quad_point(
1500 [&](
const int &q_point) { m_quad_operation(&fe_eval, q_point); });
1501 fe_eval.integrate(m_integration_flags);
1503 Portable::internal::
1504 resolve_hanging_nodes<dim, fe_degree, true, Number>(
1508 Kokkos::subview(
data->shared_data[m_dof_handler_index].values,
1512 Kokkos::single(Kokkos::PerTeam(
data->team_member), [&] {
1513 if constexpr (n_components == 1)
1514 diagonal[i] = fe_eval.get_dof_value(i);
1516 diagonal[scalar_dof][c] = fe_eval.get_dof_value(scalar_dof)[c];
1519 data->team_member.team_barrier();
1522 Kokkos::single(Kokkos::PerTeam(
data->team_member), [&] {
1523 for (unsigned int i = 0; i < scalar_dofs_per_cell; ++i)
1524 fe_eval.submit_dof_value(diagonal[i], i);
1527 data->team_member.team_barrier();
1533 Kokkos::parallel_for(
1534 Kokkos::TeamThreadRange(
data->team_member, dofs_per_cell),
1536 const types::global_dof_index index =
1537 gpu_data->local_to_global(i, cell);
1538 if (index != numbers::invalid_unsigned_int)
1539 dst[index] += data->shared_data[m_dof_handler_index].values(
1540 i % scalar_dofs_per_cell, i / scalar_dofs_per_cell);
1545 Kokkos::parallel_for(
1546 Kokkos::TeamThreadRange(
data->team_member, dofs_per_cell),
1548 const types::global_dof_index index =
1549 gpu_data->local_to_global(i, cell);
1550 if (index != numbers::invalid_unsigned_int)
1551 Kokkos::atomic_add(&dst[index],
1552 data->shared_data[m_dof_handler_index]
1553 .values(i % scalar_dofs_per_cell,
1554 i / scalar_dofs_per_cell));
1559 static constexpr unsigned int n_q_points =
1563 const unsigned int m_dof_handler_index;
1564 const QuadOperation m_quad_operation;
1578 typename QuadOperation,
1579 typename LocalMatrix,
1581 struct ComputeMatrixCellAction
1583 static constexpr unsigned int n_q_points =
1586 unsigned int dof_handler_index;
1587 QuadOperation quad_operation;
1592 LocalMap column_map;
1600 FEEvaluation<dim, fe_degree, n_q_points_1d, n_components, Number>
1601 phi(
data, dof_handler_index);
1602 constexpr unsigned int scalar_dofs =
1603 decltype(phi)::tensor_dofs_per_cell / n_components;
1604 constexpr unsigned int dofs_per_cell =
1605 decltype(phi)::tensor_dofs_per_cell;
1606 const auto &team =
data->team_member;
1607 const auto &cell_data =
data->precomputed_data[dof_handler_index];
1608 const unsigned int cell = team.league_rank();
1612 for (
unsigned int j = 0; j < dofs_per_cell; ++j)
1614 const auto index = cell_data.local_to_global(j, cell);
1617 const unsigned int component = j / scalar_dofs;
1618 Kokkos::parallel_for(
1619 Kokkos::TeamThreadRange(team, scalar_dofs),
1620 [&](
const unsigned int i) {
1622 if constexpr (n_components == 1)
1627 phi.submit_dof_value(value, i);
1629 team.team_barrier();
1631 Portable::internal::
1632 resolve_hanging_nodes<dim, fe_degree, false, Number>(
1634 cell_data.constraint_weights,
1635 cell_data.constraint_mask(cell * n_components + component),
1636 Kokkos::subview(
data->shared_data[dof_handler_index].values,
1640 phi.evaluate(evaluation_flags);
1641 data->for_each_quad_point(
1642 [&](
const int q) { quad_operation(&phi, q); });
1643 phi.integrate(integration_flags);
1647 for (
unsigned int c = 0; c < n_components; ++c)
1651 cell_data.constraint_weights,
1652 cell_data.constraint_mask(cell * n_components + c),
1657 const auto column = column_map.getLocalElement(index);
1658 Kokkos::parallel_for(
1659 Kokkos::TeamThreadRange(team, dofs_per_cell),
1660 [&](
const unsigned int i) {
1661 const auto row_index = cell_data.local_to_global(i, cell);
1664 const auto row = row_map.getLocalElement(row_index);
1666 data->shared_data[dof_handler_index].values(
1667 i % scalar_dofs, i / scalar_dofs);
1668 matrix.sumIntoValues(row, &column, 1, &value,
false,
true);
1672 team.team_barrier();
1687 typename QuadOperation>
1691 const QuadOperation &quad_operation,
1694 const unsigned int dof_handler_index,
1695 const unsigned int quadrature_index,
1696 const unsigned int first_selected_component)
1702 ExcMessage(
"Portable compute_matrix() currently requires a single MPI "
1704 static_assert(fe_degree >= 0);
1705 static_assert(n_q_points_1d >= fe_degree + 1);
1712 const auto &partitioner =
1714 AssertThrow(!partitioner || partitioner->locally_owned_size() == dst.
size(),
1715 ExcMessage(
"Portable compute_matrix() requires all DoFs to be "
1722 const auto local_matrix =
matrix.trilinos_matrix().getLocalMatrixDevice();
1723 const auto row_map =
matrix.trilinos_matrix().getRowMap()->getLocalMap();
1724 const auto column_map =
1725 matrix.trilinos_matrix().getColMap()->getLocalMap();
1726 internal::ComputeMatrixCellAction<dim,
1732 decltype(local_matrix),
1741 matrix_free.
cell_loop(cell_action, dst, dst);
1747 Kokkos::parallel_for(
1748 "MatrixFreeTools::compute_matrix constrained diagonal",
1749 Kokkos::RangePolicy<
1750 typename MemorySpace::Default::kokkos_space::execution_space>(
1752 KOKKOS_LAMBDA(
const unsigned int i) {
1753 if (constrained[i] !=
Number())
1755 const auto row = row_map.getLocalElement(i);
1756 const auto column = column_map.getLocalElement(i);
1758 local_matrix.replaceValues(row, &column, 1, &one);
1774 typename QuadOperation>
1779 const QuadOperation &quad_operation,
1782 const unsigned int dof_handler_index,
1783 const unsigned int quadrature_index,
1784 const unsigned int first_selected_component,
1785 const unsigned int first_vector_component)
1794 internal::ComputeDiagonalCellAction<dim,
1805 matrix_free.
cell_loop(cell_action, dummy, diagonal_global);
1817 typename VectorizedArrayType,
1822 VectorType &diagonal_global,
1828 VectorizedArrayType> &)>
1830 const unsigned int dof_handler_index,
1831 const unsigned int quadrature_index,
1832 const unsigned int first_selected_component,
1833 const unsigned int first_vector_component)
1840 VectorizedArrayType,
1848 first_selected_component,
1849 first_vector_component);
1852 template <
typename CLASS,
1858 typename VectorizedArrayType,
1863 VectorType &diagonal_global,
1869 VectorizedArrayType> &)
const,
1870 const CLASS *owning_class,
1871 const unsigned
int dof_handler_index,
1872 const unsigned
int quadrature_index,
1873 const unsigned
int first_selected_component,
1874 const unsigned
int first_vector_component)
1881 VectorizedArrayType,
1885 [&](
auto &phi) { (owning_class->*cell_operation)(phi); },
1888 first_selected_component,
1889 first_vector_component);
1897 typename VectorizedArrayType,
1902 VectorType &diagonal_global,
1908 VectorizedArrayType> &)>
1915 VectorizedArrayType> &,
1921 VectorizedArrayType> &)>
1928 VectorizedArrayType> &)>
1929 &boundary_operation,
1930 const unsigned int dof_handler_index,
1931 const unsigned int quadrature_index,
1932 const unsigned int first_selected_component,
1933 const unsigned int first_vector_component)
1935 std::vector<typename ::internal::BlockVectorSelector<
1938 diagonal_global_components(n_components);
1940 for (
unsigned int d = 0;
d < n_components; ++
d)
1941 diagonal_global_components[d] = ::internal::
1943 get_vector_component(diagonal_global,
d + first_vector_component);
1945 const auto &dof_info = matrix_free.
get_dof_info(dof_handler_index);
1947 if (dof_info.start_components.back() == 1)
1948 for (
unsigned int comp = 0; comp < n_components; ++comp)
1950 Assert(diagonal_global_components[comp] !=
nullptr,
1951 ExcMessage(
"The finite element underlying this FEEvaluation "
1952 "object is scalar, but you requested " +
1953 std::to_string(n_components) +
1954 " components via the template argument in "
1955 "FEEvaluation. In that case, you must pass an "
1956 "std::vector<VectorType> or a BlockVector to " +
1957 "read_dof_values and distribute_local_to_global."));
1959 *diagonal_global_components[comp], matrix_free, dof_info);
1964 *diagonal_global_components[0], matrix_free, dof_info);
1972 VectorizedArrayType>;
1979 VectorizedArrayType>;
1981 internal::ComputeMatrixScratchData<dim, VectorizedArrayType, false>
1984 data_cell.dof_numbers = {dof_handler_index};
1985 data_cell.quad_numbers = {quadrature_index};
1986 data_cell.n_components = {n_components};
1987 data_cell.first_selected_components = {first_selected_component};
1988 data_cell.batch_type = {0};
1990 data_cell.op_create =
1991 [&](
const std::pair<unsigned int, unsigned int> &range) {
1993 std::unique_ptr<FEEvaluationData<dim, VectorizedArrayType, false>>>
1996 if (!internal::is_fe_nothing<false>(matrix_free,
2000 first_selected_component,
2004 std::make_unique<FEEvalType>(matrix_free,
2008 first_selected_component));
2013 data_cell.op_reinit = [](
auto &phi,
const unsigned batch) {
2014 if (phi.size() == 1)
2015 static_cast<FEEvalType &
>(*phi[0]).reinit(batch);
2019 data_cell.op_compute = [&](
auto &phi) {
2020 cell_operation(
static_cast<FEEvalType &
>(*phi[0]));
2023 internal::ComputeMatrixScratchData<dim, VectorizedArrayType, true>
2026 data_face.dof_numbers = {dof_handler_index, dof_handler_index};
2027 data_face.quad_numbers = {quadrature_index, quadrature_index};
2028 data_face.n_components = {n_components, n_components};
2029 data_face.first_selected_components = {first_selected_component,
2030 first_selected_component};
2031 data_face.batch_type = {1, 2};
2033 data_face.op_create =
2034 [&](
const std::pair<unsigned int, unsigned int> &range) {
2036 std::unique_ptr<FEEvaluationData<dim, VectorizedArrayType, true>>>
2039 if (!internal::is_fe_nothing<true>(matrix_free,
2043 first_selected_component,
2047 !internal::is_fe_nothing<true>(matrix_free,
2051 first_selected_component,
2057 std::make_unique<FEFaceEvalType>(matrix_free,
2062 first_selected_component));
2064 std::make_unique<FEFaceEvalType>(matrix_free,
2069 first_selected_component));
2075 data_face.op_reinit = [](
auto &phi,
const unsigned batch) {
2076 if (phi.size() == 2)
2078 static_cast<FEFaceEvalType &
>(*phi[0]).
reinit(batch);
2079 static_cast<FEFaceEvalType &
>(*phi[1]).
reinit(batch);
2084 data_face.op_compute = [&](
auto &phi) {
2085 face_operation(
static_cast<FEFaceEvalType &
>(*phi[0]),
2086 static_cast<FEFaceEvalType &
>(*phi[1]));
2089 internal::ComputeMatrixScratchData<dim, VectorizedArrayType, true>
2092 data_boundary.dof_numbers = {dof_handler_index};
2093 data_boundary.quad_numbers = {quadrature_index};
2094 data_boundary.n_components = {n_components};
2095 data_boundary.first_selected_components = {first_selected_component};
2096 data_boundary.batch_type = {1};
2098 data_boundary.op_create =
2099 [&](
const std::pair<unsigned int, unsigned int> &range) {
2101 std::unique_ptr<FEEvaluationData<dim, VectorizedArrayType, true>>>
2104 if (!internal::is_fe_nothing<true>(matrix_free,
2108 first_selected_component,
2113 std::make_unique<FEFaceEvalType>(matrix_free,
2118 first_selected_component));
2123 data_boundary.op_reinit = [](
auto &phi,
const unsigned batch) {
2124 if (phi.size() == 1)
2125 static_cast<FEFaceEvalType &
>(*phi[0]).reinit(batch);
2128 if (boundary_operation)
2129 data_boundary.op_compute = [&](
auto &phi) {
2130 boundary_operation(
static_cast<FEFaceEvalType &
>(*phi[0]));
2133 internal::compute_diagonal(matrix_free,
2138 diagonal_global_components);
2145 typename VectorizedArrayType,
2147 typename VectorType2>
2151 const internal::ComputeMatrixScratchData<dim, VectorizedArrayType, false>
2153 const internal::ComputeMatrixScratchData<dim, VectorizedArrayType, true>
2155 const internal::ComputeMatrixScratchData<dim, VectorizedArrayType, true>
2157 VectorType &diagonal_global,
2158 std::vector<VectorType2 *> &diagonal_global_components)
2165 internal::ComputeDiagonalHelper<dim, VectorizedArrayType, false>;
2168 internal::ComputeDiagonalHelper<dim, VectorizedArrayType, true>;
2172 scratch_data_internal;
2175 const auto batch_operation =
2178 const std::pair<unsigned int, unsigned int> &range) {
2179 if (!
data.op_compute)
2182 auto phi =
data.op_create(range);
2184 const unsigned int n_blocks = phi.size();
2186 auto &helpers = scratch_data.
get();
2187 helpers.resize(n_blocks);
2190 helpers[b].initialize(*phi[b], matrix_free,
data.n_components[b]);
2192 for (
unsigned int batch = range.first; batch < range.second; ++batch)
2194 data.op_reinit(phi, batch);
2197 helpers[b].
reinit(batch);
2201 Assert(std::all_of(helpers.begin(),
2203 [](
const auto &helper) {
2204 return helper.has_simple_constraints();
2211 for (
unsigned int i = 0;
2212 i < phi[
b]->get_shape_info().dofs_per_component_on_cell *
2213 data.n_components[b];
2216 for (
unsigned int bb = 0; bb <
n_blocks; ++bb)
2218 helpers[bb].prepare_basis_vector(i);
2220 helpers[bb].zero_basis_vector();
2222 data.op_compute(phi);
2223 helpers[
b].submit();
2226 helpers[
b].distribute_local_to_global(
2227 diagonal_global_components);
2232 const auto cell_operation_wrapped =
2233 [&](
const auto &,
auto &,
const auto &,
const auto range) {
2234 batch_operation(data_cell, scratch_data, range);
2237 const auto face_operation_wrapped =
2238 [&](
const auto &,
auto &,
const auto &,
const auto range) {
2239 batch_operation(data_face, scratch_data_internal, range);
2242 const auto boundary_operation_wrapped =
2243 [&](
const auto &,
auto &,
const auto &,
const auto range) {
2244 batch_operation(data_boundary, scratch_data_bc, range);
2247 if (data_face.op_compute || data_boundary.op_compute)
2248 matrix_free.template loop<VectorType, int>(cell_operation_wrapped,
2249 face_operation_wrapped,
2250 boundary_operation_wrapped,
2255 matrix_free.template cell_loop<VectorType, int>(cell_operation_wrapped,
2262 template <
typename CLASS,
2268 typename VectorizedArrayType,
2273 VectorType &diagonal_global,
2279 VectorizedArrayType> &)
const,
2285 VectorizedArrayType> &,
2291 VectorizedArrayType> &)
2298 VectorizedArrayType> &)
2300 const CLASS *owning_class,
2301 const unsigned
int dof_handler_index,
2302 const unsigned
int quadrature_index,
2303 const unsigned
int first_selected_component,
2304 const unsigned
int first_vector_component)
2311 VectorizedArrayType,
2315 [&](
auto &phi) { (owning_class->*cell_operation)(phi); },
2316 [&](
auto &phi_m,
auto &phi_p) {
2317 (owning_class->*face_operation)(phi_m, phi_p);
2319 [&](
auto &phi) { (owning_class->*boundary_operation)(phi); },
2322 first_selected_component,
2323 first_vector_component);
2335 std::enable_if_t<std::is_same_v<
2336 std::remove_const_t<
2337 std::remove_reference_t<typename MatrixType::value_type>>,
2338 std::remove_const_t<std::remove_reference_t<Number>>>> * =
nullptr>
2340 create_new_affine_constraints_if_needed(
2356 std::enable_if_t<!std::is_same_v<
2357 std::remove_const_t<
2358 std::remove_reference_t<typename MatrixType::value_type>>,
2359 std::remove_const_t<std::remove_reference_t<Number>>>> * =
nullptr>
2361 create_new_affine_constraints_if_needed(
2368 std::make_unique<AffineConstraints<typename MatrixType::value_type>>();
2369 new_constraints->
copy_from(constraints);
2371 return *new_constraints;
2380 typename VectorizedArrayType,
2392 VectorizedArrayType> &)>
2394 const unsigned int dof_handler_index,
2395 const unsigned int quadrature_index,
2396 const unsigned int first_selected_component)
2403 VectorizedArrayType,
2412 first_selected_component);
2415 template <
typename CLASS,
2421 typename VectorizedArrayType,
2433 VectorizedArrayType> &)
const,
2434 const CLASS *owning_class,
2435 const unsigned
int dof_handler_index,
2436 const unsigned
int quadrature_index,
2437 const unsigned
int first_selected_component)
2444 VectorizedArrayType,
2449 [&](
auto &phi) { (owning_class->*cell_operation)(phi); },
2452 first_selected_component);
2460 typename VectorizedArrayType,
2472 VectorizedArrayType> &)>
2479 VectorizedArrayType> &,
2485 VectorizedArrayType> &)>
2492 VectorizedArrayType> &)>
2493 &boundary_operation,
2494 const unsigned int dof_handler_index,
2495 const unsigned int quadrature_index,
2496 const unsigned int first_selected_component)
2503 VectorizedArrayType>;
2510 VectorizedArrayType>;
2512 internal::ComputeMatrixScratchData<dim, VectorizedArrayType, false>
2515 data_cell.dof_numbers = {dof_handler_index};
2516 data_cell.quad_numbers = {quadrature_index};
2517 data_cell.n_components = {n_components};
2518 data_cell.first_selected_components = {first_selected_component};
2519 data_cell.batch_type = {0};
2521 data_cell.op_create =
2522 [&](
const std::pair<unsigned int, unsigned int> &range) {
2524 std::unique_ptr<FEEvaluationData<dim, VectorizedArrayType, false>>>
2527 if (!internal::is_fe_nothing<false>(matrix_free,
2531 first_selected_component,
2535 std::make_unique<FEEvalType>(matrix_free,
2539 first_selected_component));
2544 data_cell.op_reinit = [](
auto &phi,
const unsigned batch) {
2545 if (phi.size() == 1)
2546 static_cast<FEEvalType &
>(*phi[0]).reinit(batch);
2550 data_cell.op_compute = [&](
auto &phi) {
2551 cell_operation(
static_cast<FEEvalType &
>(*phi[0]));
2554 internal::ComputeMatrixScratchData<dim, VectorizedArrayType, true>
2557 data_face.dof_numbers = {dof_handler_index, dof_handler_index};
2558 data_face.quad_numbers = {quadrature_index, quadrature_index};
2559 data_face.n_components = {n_components, n_components};
2560 data_face.first_selected_components = {first_selected_component,
2561 first_selected_component};
2562 data_face.batch_type = {1, 2};
2564 data_face.op_create =
2565 [&](
const std::pair<unsigned int, unsigned int> &range) {
2567 std::unique_ptr<FEEvaluationData<dim, VectorizedArrayType, true>>>
2570 if (!internal::is_fe_nothing<true>(matrix_free,
2574 first_selected_component,
2578 !internal::is_fe_nothing<true>(matrix_free,
2582 first_selected_component,
2588 std::make_unique<FEFaceEvalType>(matrix_free,
2593 first_selected_component));
2595 std::make_unique<FEFaceEvalType>(matrix_free,
2600 first_selected_component));
2606 data_face.op_reinit = [](
auto &phi,
const unsigned batch) {
2607 if (phi.size() == 2)
2609 static_cast<FEFaceEvalType &
>(*phi[0]).
reinit(batch);
2610 static_cast<FEFaceEvalType &
>(*phi[1]).
reinit(batch);
2615 data_face.op_compute = [&](
auto &phi) {
2616 face_operation(
static_cast<FEFaceEvalType &
>(*phi[0]),
2617 static_cast<FEFaceEvalType &
>(*phi[1]));
2620 internal::ComputeMatrixScratchData<dim, VectorizedArrayType, true>
2623 data_boundary.dof_numbers = {dof_handler_index};
2624 data_boundary.quad_numbers = {quadrature_index};
2625 data_boundary.n_components = {n_components};
2626 data_boundary.first_selected_components = {first_selected_component};
2627 data_boundary.batch_type = {1};
2629 data_boundary.op_create =
2630 [&](
const std::pair<unsigned int, unsigned int> &range) {
2632 std::unique_ptr<FEEvaluationData<dim, VectorizedArrayType, true>>>
2635 if (!internal::is_fe_nothing<true>(matrix_free,
2639 first_selected_component,
2644 std::make_unique<FEFaceEvalType>(matrix_free,
2649 first_selected_component));
2654 data_boundary.op_reinit = [](
auto &phi,
const unsigned batch) {
2655 if (phi.size() == 1)
2656 static_cast<FEFaceEvalType &
>(*phi[0]).reinit(batch);
2659 if (boundary_operation)
2660 data_boundary.op_compute = [&](
auto &phi) {
2661 boundary_operation(
static_cast<FEFaceEvalType &
>(*phi[0]));
2664 internal::compute_matrix(
2665 matrix_free, constraints_in, data_cell, data_face, data_boundary, matrix);
2672 typename VectorizedArrayType,
2678 const internal::ComputeMatrixScratchData<dim, VectorizedArrayType, false>
2680 const internal::ComputeMatrixScratchData<dim, VectorizedArrayType, true>
2682 const internal::ComputeMatrixScratchData<dim, VectorizedArrayType, true>
2686 std::unique_ptr<AffineConstraints<typename MatrixType::value_type>>
2687 constraints_for_matrix;
2689 internal::create_new_affine_constraints_if_needed(
2690 matrix, constraints_in, constraints_for_matrix);
2692 const auto batch_operation =
2693 [&matrix_free, &constraints, &
matrix](
2694 auto &
data,
const std::pair<unsigned int, unsigned int> &range) {
2695 if (!
data.op_compute)
2698 auto phi =
data.op_create(range);
2700 const unsigned int n_blocks = phi.size();
2709 n_blocks, VectorizedArrayType::size());
2712 std::array<FullMatrix<typename MatrixType::value_type>,
2713 VectorizedArrayType::size()>>
2714 matrices(n_blocks, n_blocks);
2719 .get_fe(phi[b]->get_active_fe_index());
2721 const auto component_base =
2724 const auto component_in_base =
2725 data.first_selected_components[
b] -
2730 data.dof_numbers[b],
2731 data.quad_numbers[b],
2733 phi[b]->get_active_fe_index(),
2734 phi[b]->get_active_quadrature_index());
2737 shape_info.dofs_per_component_on_cell *
data.n_components[
b];
2739 dof_indices[
b].resize(fe.n_dofs_per_cell());
2741 for (
unsigned int v = 0; v < VectorizedArrayType::size(); ++v)
2742 dof_indices_mf[b][v].resize(dofs_per_cell[b]);
2744 lexicographic_numbering[
b].insert(
2745 lexicographic_numbering[b].
begin(),
2746 shape_info.lexicographic_numbering.begin() +
2747 component_in_base * shape_info.dofs_per_component_on_cell,
2748 shape_info.lexicographic_numbering.begin() +
2749 (component_in_base +
data.n_components[
b]) *
2750 shape_info.dofs_per_component_on_cell);
2753 for (
unsigned int bj = 0; bj <
n_blocks; ++bj)
2754 for (
unsigned int bi = 0; bi <
n_blocks; ++bi)
2755 std::fill_n(matrices[bi][bj].
begin(),
2756 VectorizedArrayType::size(),
2758 dofs_per_cell[bi], dofs_per_cell[bj]));
2760 for (
auto batch = range.first; batch < range.second; ++batch)
2762 data.op_reinit(phi, batch);
2764 const unsigned int n_filled_lanes =
2769 for (
unsigned int v = 0; v < n_filled_lanes; ++v)
2773 (
data.batch_type[
b] == 0) ?
2774 (batch * VectorizedArrayType::size() + v) :
2775 ((
data.batch_type[
b] == 1) ?
2776 matrix_free.get_face_info(batch).cells_interior[v] :
2777 matrix_free.get_face_info(batch).cells_exterior[v]);
2782 data.dof_numbers[b]);
2786 cell_iterator->get_mg_dof_indices(dof_indices[b]);
2788 cell_iterator->get_dof_indices(dof_indices[b]);
2790 for (
unsigned int j = 0; j < dofs_per_cell[
b]; ++j)
2791 dof_indices_mf[b][v][j] =
2792 dof_indices[b][lexicographic_numbering[b][j]];
2795 for (
unsigned int bj = 0; bj <
n_blocks; ++bj)
2797 for (
unsigned int j = 0; j < dofs_per_cell[bj]; ++j)
2799 for (
unsigned int bi = 0; bi <
n_blocks; ++bi)
2800 for (
unsigned int i = 0; i < dofs_per_cell[bi]; ++i)
2801 phi[bi]->begin_dof_values()[i] =
2802 (bj == bi) ?
static_cast<Number>(i == j) : 0.0;
2804 data.op_compute(phi);
2806 for (
unsigned int bi = 0; bi <
n_blocks; ++bi)
2807 for (
unsigned int i = 0; i < dofs_per_cell[bi]; ++i)
2808 for (
unsigned int v = 0; v < n_filled_lanes; ++v)
2809 matrices[bi][bj][v](i, j) =
2810 phi[bi]->begin_dof_values()[i][v];
2813 for (
unsigned int v = 0; v < n_filled_lanes; ++v)
2814 for (
unsigned int bi = 0; bi <
n_blocks; ++bi)
2822 matrices[bi][bi][v], dof_indices_mf[bi][v], matrix);
2825 matrices[bi][bj][v],
2826 dof_indices_mf[bi][v],
2827 dof_indices_mf[bj][v],
2833 const auto cell_operation_wrapped =
2834 [&](
const auto &,
auto &,
const auto &,
const auto range) {
2835 batch_operation(data_cell, range);
2838 const auto face_operation_wrapped =
2839 [&](
const auto &,
auto &,
const auto &,
const auto range) {
2840 batch_operation(data_face, range);
2843 const auto boundary_operation_wrapped =
2844 [&](
const auto &,
auto &,
const auto &,
const auto range) {
2845 batch_operation(data_boundary, range);
2848 if (data_face.op_compute || data_boundary.op_compute)
2850 matrix_free.template loop<MatrixType, MatrixType>(
2851 cell_operation_wrapped,
2852 face_operation_wrapped,
2853 boundary_operation_wrapped,
2858 matrix_free.template cell_loop<MatrixType, MatrixType>(
2859 cell_operation_wrapped, matrix, matrix);
2865 template <
typename CLASS,
2871 typename VectorizedArrayType,
2883 VectorizedArrayType> &)
const,
2889 VectorizedArrayType> &,
2895 VectorizedArrayType> &)
2902 VectorizedArrayType> &)
2904 const CLASS *owning_class,
2905 const unsigned
int dof_handler_index,
2906 const unsigned
int quadrature_index,
2907 const unsigned
int first_selected_component)
2914 VectorizedArrayType,
2919 [&](
auto &phi) { (owning_class->*cell_operation)(phi); },
2920 [&](
auto &phi_m,
auto &phi_p) {
2921 (owning_class->*face_operation)(phi_m, phi_p);
2923 [&](
auto &phi) { (owning_class->*boundary_operation)(phi); },
2926 first_selected_component);