16#ifndef dealii_matrix_free_h
17#define dealii_matrix_free_h
110 typename Number = double,
115 std::is_same_v<Number, typename VectorizedArrayType::value_type>,
116 "Type of Number and of VectorizedArrayType do not match.");
587 template <
typename QuadratureType,
typename number2,
typename MappingType>
592 const QuadratureType &quad,
616 template <
typename QuadratureType,
typename number2,
typename MappingType>
621 const std::vector<QuadratureType> &quad,
631 template <
typename QuadratureType,
typename number2,
typename MappingType>
636 const QuadratureType &quad,
793 template <
typename OutVector,
typename InVector>
799 const std::pair<unsigned int, unsigned int> &)> &cell_operation,
802 const bool zero_dst_vector =
false)
const;
850 template <
typename CLASS,
typename OutVector,
typename InVector>
856 const
std::pair<unsigned
int, unsigned
int> &) const,
857 const CLASS *owning_class,
860 const
bool zero_dst_vector = false) const;
865 template <
typename CLASS,
typename OutVector,
typename InVector>
871 const
std::pair<unsigned
int, unsigned
int> &),
875 const
bool zero_dst_vector = false) const;
961 template <
typename CLASS,
typename OutVector,
typename InVector>
967 const
std::pair<unsigned
int, unsigned
int> &) const,
968 const CLASS *owning_class,
971 const
std::function<void(const unsigned
int, const unsigned
int)>
972 &operation_before_loop,
973 const
std::function<void(const unsigned
int, const unsigned
int)>
974 &operation_after_loop,
975 const unsigned
int dof_handler_index_pre_post = 0) const;
980 template <
typename CLASS,
typename OutVector,
typename InVector>
986 const
std::pair<unsigned
int, unsigned
int> &),
990 const
std::function<void(const unsigned
int, const unsigned
int)>
991 &operation_before_loop,
992 const
std::function<void(const unsigned
int, const unsigned
int)>
993 &operation_after_loop,
994 const unsigned
int dof_handler_index_pre_post = 0) const;
1000 template <
typename OutVector,
typename InVector>
1006 const std::pair<unsigned int, unsigned int> &)> &cell_operation,
1008 const InVector &src,
1009 const std::function<
void(
const unsigned int,
const unsigned int)>
1010 &operation_before_loop,
1011 const std::function<
void(
const unsigned int,
const unsigned int)>
1012 &operation_after_loop,
1013 const unsigned int dof_handler_index_pre_post = 0)
const;
1090 template <
typename OutVector,
typename InVector>
1093 const std::function<
1097 const std::pair<unsigned int, unsigned int> &)> &cell_operation,
1098 const std::function<
void(
1102 const std::pair<unsigned int, unsigned int> &)> &inner_face_operation,
1103 const std::function<
void(
1107 const std::pair<unsigned int, unsigned int> &)> &boundary_face_operation,
1109 const InVector &src,
1110 const bool zero_dst_vector =
false,
1204 template <
typename CLASS,
typename OutVector,
typename InVector>
1206 loop(
void (CLASS::*cell_operation)(
1210 const
std::pair<unsigned
int, unsigned
int> &) const,
1211 void (CLASS::*inner_face_operation)(
1215 const
std::pair<unsigned
int, unsigned
int> &) const,
1216 void (CLASS::*boundary_face_operation)(
1220 const
std::pair<unsigned
int, unsigned
int> &) const,
1221 const CLASS *owning_class,
1223 const InVector &src,
1224 const
bool zero_dst_vector = false,
1233 template <
typename CLASS,
typename OutVector,
typename InVector>
1235 loop(
void (CLASS::*cell_operation)(
1239 const
std::pair<unsigned
int, unsigned
int> &),
1240 void (CLASS::*inner_face_operation)(
1244 const
std::pair<unsigned
int, unsigned
int> &),
1245 void (CLASS::*boundary_face_operation)(
1249 const
std::pair<unsigned
int, unsigned
int> &),
1250 CLASS *owning_class,
1252 const InVector &src,
1253 const
bool zero_dst_vector = false,
1380 template <
typename CLASS,
typename OutVector,
typename InVector>
1382 loop(
void (CLASS::*cell_operation)(
1386 const
std::pair<unsigned
int, unsigned
int> &) const,
1387 void (CLASS::*inner_face_operation)(
1391 const
std::pair<unsigned
int, unsigned
int> &) const,
1392 void (CLASS::*boundary_face_operation)(
1396 const
std::pair<unsigned
int, unsigned
int> &) const,
1397 const CLASS *owning_class,
1399 const InVector &src,
1400 const
std::function<void(const unsigned
int, const unsigned
int)>
1401 &operation_before_loop,
1402 const
std::function<void(const unsigned
int, const unsigned
int)>
1403 &operation_after_loop,
1404 const unsigned
int dof_handler_index_pre_post = 0,
1413 template <
typename CLASS,
typename OutVector,
typename InVector>
1415 loop(
void (CLASS::*cell_operation)(
1419 const
std::pair<unsigned
int, unsigned
int> &),
1420 void (CLASS::*inner_face_operation)(
1424 const
std::pair<unsigned
int, unsigned
int> &),
1425 void (CLASS::*boundary_face_operation)(
1429 const
std::pair<unsigned
int, unsigned
int> &),
1430 const CLASS *owning_class,
1432 const InVector &src,
1433 const
std::function<void(const unsigned
int, const unsigned
int)>
1434 &operation_before_loop,
1435 const
std::function<void(const unsigned
int, const unsigned
int)>
1436 &operation_after_loop,
1437 const unsigned
int dof_handler_index_pre_post = 0,
1448 template <
typename OutVector,
typename InVector>
1451 const std::function<
1455 const std::pair<unsigned int, unsigned int> &)> &cell_operation,
1456 const std::function<
void(
1460 const std::pair<unsigned int, unsigned int> &)> &inner_face_operation,
1461 const std::function<
void(
1465 const std::pair<unsigned int, unsigned int> &)> &boundary_face_operation,
1467 const InVector &src,
1468 const std::function<
void(
const unsigned int,
const unsigned int)>
1469 &operation_before_loop,
1470 const std::function<
void(
const unsigned int,
const unsigned int)>
1471 &operation_after_loop,
1472 const unsigned int dof_handler_index_pre_post = 0,
1542 template <
typename CLASS,
typename OutVector,
typename InVector>
1548 const
std::pair<unsigned
int, unsigned
int> &) const,
1549 const CLASS *owning_class,
1551 const InVector &src,
1552 const
bool zero_dst_vector = false,
1559 template <
typename CLASS,
typename OutVector,
typename InVector>
1565 const
std::pair<unsigned
int, unsigned
int> &),
1566 CLASS *owning_class,
1568 const InVector &src,
1569 const
bool zero_dst_vector = false,
1576 template <
typename OutVector,
typename InVector>
1582 const std::pair<unsigned int, unsigned int> &)>
1585 const InVector &src,
1586 const bool zero_dst_vector =
false,
1597 std::pair<unsigned int, unsigned int>
1599 const unsigned int fe_degree,
1600 const unsigned int dof_handler_index = 0)
const;
1608 std::pair<unsigned int, unsigned int>
1610 const std::pair<unsigned int, unsigned int> &range,
1611 const unsigned int fe_index,
1612 const unsigned int dof_handler_index = 0)
const;
1625 const std::pair<unsigned int, unsigned int> range)
const;
1632 const bool is_interior_face =
true)
const;
1645 template <
typename T>
1654 template <
typename T>
1671 template <
typename VectorType>
1674 const unsigned int dof_handler_index = 0)
const;
1693 template <
typename Number2>
1696 const unsigned int dof_handler_index = 0)
const;
1708 const std::shared_ptr<const Utilities::MPI::Partitioner> &
1732 const std::vector<unsigned int> &
1747 const unsigned int dof_handler_index = 0);
1758 template <
int spacedim>
1857 const unsigned int face_number)
const;
1889 const unsigned int lane_index,
1890 const unsigned int dof_handler_index = 0)
const;
1899 const unsigned int lane_index)
const;
1923 std::pair<typename DoFHandler<dim>::cell_iterator,
unsigned int>
1925 const unsigned int lane_index,
1926 const bool interior =
true,
1927 const unsigned int fe_component = 0)
const;
1973 const unsigned int hp_active_fe_index = 0)
const;
1980 const unsigned int hp_active_fe_index = 0)
const;
1988 const unsigned int hp_active_fe_index = 0)
const;
1996 const unsigned int hp_active_fe_index = 0)
const;
2003 const unsigned int hp_active_fe_index = 0)
const;
2010 const unsigned int hp_active_fe_index = 0)
const;
2026 const std::pair<unsigned int, unsigned int> cell_batch_range)
const;
2032 std::pair<unsigned int, unsigned int>
2034 const std::pair<unsigned int, unsigned int> face_batch_range)
const;
2054 std::pair<unsigned int, unsigned int>
2088 template <
typename StreamType>
2116 const internal::MatrixFreeFunctions::
2117 MappingInfo<dim, Number, VectorizedArrayType> &
2152 const unsigned int quad_index = 0,
2153 const unsigned int fe_base_element = 0,
2154 const unsigned int hp_active_fe_index = 0,
2155 const unsigned int hp_active_quad_index = 0)
const;
2161 VectorizedArrayType::size()> &
2221 template <
typename number2,
int q_dim>
2227 const std::vector<IndexSet> &locally_owned_set,
2237 template <
typename number2>
2241 const std::vector<IndexSet> &locally_owned_set,
2263 std::vector<ObserverPointer<const AffineConstraints<Number>>>
2270 std::vector<internal::MatrixFreeFunctions::DoFInfo>
dof_info;
2352 std::list<std::pair<bool, AlignedVector<VectorizedArrayType>>>>
2359 mutable std::list<std::pair<bool, AlignedVector<Number>>>
2382template <
int dim,
typename Number,
typename VectorizedArrayType>
2383template <
typename T>
2388 vec.
resize(this->n_cell_batches() + this->n_ghost_cell_batches());
2393template <
int dim,
typename Number,
typename VectorizedArrayType>
2394template <
typename T>
2399 vec.
resize(this->n_inner_face_batches() + this->n_boundary_face_batches() +
2400 this->n_ghost_inner_face_batches());
2405template <
int dim,
typename Number,
typename VectorizedArrayType>
2406template <
typename VectorType>
2410 const unsigned int comp)
const
2413 "This function is not supported for block vectors.");
2415 Assert(task_info.n_procs == 1,
2416 ExcMessage(
"This function can only be used in serial."));
2419 vec.reinit(dof_info[comp].vector_partitioner->size());
2424template <
int dim,
typename Number,
typename VectorizedArrayType>
2425template <
typename Number2>
2429 const unsigned int comp)
const
2432 vec.
reinit(dof_info[comp].vector_partitioner, task_info.communicator_sm);
2437template <
int dim,
typename Number,
typename VectorizedArrayType>
2438inline const std::shared_ptr<const Utilities::MPI::Partitioner> &
2440 const unsigned int comp)
const
2443 return dof_info[comp].vector_partitioner;
2448template <
int dim,
typename Number,
typename VectorizedArrayType>
2449inline const std::vector<unsigned int> &
2451 const unsigned int comp)
const
2454 return dof_info[comp].constrained_dofs;
2459template <
int dim,
typename Number,
typename VectorizedArrayType>
2464 return dof_handlers.size();
2469template <
int dim,
typename Number,
typename VectorizedArrayType>
2472 const unsigned int dof_no)
const
2476 return dof_handlers[dof_no]->get_fe().n_base_elements();
2481template <
int dim,
typename Number,
typename VectorizedArrayType>
2490template <
int dim,
typename Number,
typename VectorizedArrayType>
2494 return task_info.n_active_cells;
2499template <
int dim,
typename Number,
typename VectorizedArrayType>
2503 return *(task_info.cell_partition_data.end() - 2);
2508template <
int dim,
typename Number,
typename VectorizedArrayType>
2512 return *(task_info.cell_partition_data.end() - 1) -
2513 *(task_info.cell_partition_data.end() - 2);
2518template <
int dim,
typename Number,
typename VectorizedArrayType>
2522 if (task_info.face_partition_data.empty())
2524 return task_info.face_partition_data.back();
2529template <
int dim,
typename Number,
typename VectorizedArrayType>
2533 if (task_info.face_partition_data.empty())
2535 return task_info.boundary_partition_data.back() -
2536 task_info.face_partition_data.back();
2541template <
int dim,
typename Number,
typename VectorizedArrayType>
2545 if (task_info.face_partition_data.empty())
2547 return face_info.faces.size() - task_info.boundary_partition_data.back();
2552template <
int dim,
typename Number,
typename VectorizedArrayType>
2555 const unsigned int face_batch_index)
const
2557 Assert(face_batch_index >= task_info.boundary_partition_data[0] &&
2558 face_batch_index < task_info.boundary_partition_data.back(),
2560 task_info.boundary_partition_data[0],
2561 task_info.boundary_partition_data.back()));
2567template <
int dim,
typename Number,
typename VectorizedArrayType>
2570 const unsigned int cell_batch_index,
2571 const unsigned int face_number)
const
2575 Assert(face_info.cell_and_face_boundary_id.size(0) >= n_cell_batches(),
2579 for (
unsigned int v = 0;
2580 v < n_active_entries_per_cell_batch(cell_batch_index);
2583 face_info.cell_and_face_boundary_id(cell_batch_index, face_number, v);
2589template <
int dim,
typename Number,
typename VectorizedArrayType>
2590inline const internal::MatrixFreeFunctions::
2591 MappingInfo<dim, Number, VectorizedArrayType> &
2594 return mapping_info;
2599template <
int dim,
typename Number,
typename VectorizedArrayType>
2602 const unsigned int dof_index)
const
2605 return dof_info[dof_index];
2610template <
int dim,
typename Number,
typename VectorizedArrayType>
2614 return constraint_pool_row_index.size() - 1;
2619template <
int dim,
typename Number,
typename VectorizedArrayType>
2620inline const Number *
2622 const unsigned int row)
const
2625 return constraint_pool_data.empty() ?
2627 constraint_pool_data.data() + constraint_pool_row_index[row];
2632template <
int dim,
typename Number,
typename VectorizedArrayType>
2633inline const Number *
2635 const unsigned int row)
const
2638 return constraint_pool_data.empty() ?
2640 constraint_pool_data.data() + constraint_pool_row_index[row + 1];
2645template <
int dim,
typename Number,
typename VectorizedArrayType>
2646inline std::pair<unsigned int, unsigned int>
2648 const std::pair<unsigned int, unsigned int> &range,
2649 const unsigned int degree,
2650 const unsigned int dof_handler_component)
const
2652 if (dof_info[dof_handler_component].cell_active_fe_index.empty())
2655 dof_info[dof_handler_component].fe_index_conversion.size(), 1);
2657 dof_info[dof_handler_component].fe_index_conversion[0].
size(), 1);
2658 if (dof_info[dof_handler_component].fe_index_conversion[0][0] == degree)
2661 return {range.second, range.second};
2665 dof_info[dof_handler_component].fe_index_from_degree(0, degree);
2666 if (fe_index >= dof_info[dof_handler_component].max_fe_index)
2667 return {range.second, range.second};
2669 return create_cell_subrange_hp_by_index(range,
2671 dof_handler_component);
2676template <
int dim,
typename Number,
typename VectorizedArrayType>
2679 const unsigned int cell_batch_index)
const
2682 return VectorizedArrayType::size() > 1 &&
2683 cell_level_index[(cell_batch_index + 1) * VectorizedArrayType::size() -
2684 1] == cell_level_index[(cell_batch_index + 1) *
2685 VectorizedArrayType::size() -
2691template <
int dim,
typename Number,
typename VectorizedArrayType>
2695 return shape_info.size(2);
2699template <
int dim,
typename Number,
typename VectorizedArrayType>
2702 const std::pair<unsigned int, unsigned int> range)
const
2704 const auto &fe_indices =
2705 dof_info[first_hp_dof_handler_index].cell_active_fe_index;
2707 if (fe_indices.empty() ==
true ||
2708 dof_handlers[0]->get_fe_collection().size() == 1)
2711 const auto index = fe_indices[range.first];
2713 for (
unsigned int i = range.first; i < range.second; ++i)
2721template <
int dim,
typename Number,
typename VectorizedArrayType>
2724 const std::pair<unsigned int, unsigned int> range,
2725 const bool is_interior_face)
const
2727 const auto &fe_indices =
2728 dof_info[first_hp_dof_handler_index].cell_active_fe_index;
2730 if (fe_indices.empty() ==
true)
2733 if (is_interior_face)
2735 const unsigned int index =
2736 fe_indices[face_info.faces[range.first].cells_interior[0] /
2737 VectorizedArrayType::size()];
2739 for (
unsigned int i = range.first; i < range.second; ++i)
2741 fe_indices[face_info.faces[i].cells_interior[0] /
2742 VectorizedArrayType::size()]);
2748 const unsigned int index =
2749 fe_indices[face_info.faces[range.first].cells_exterior[0] /
2750 VectorizedArrayType::size()];
2752 for (
unsigned int i = range.first; i < range.second; ++i)
2754 fe_indices[face_info.faces[i].cells_exterior[0] /
2755 VectorizedArrayType::size()]);
2763template <
int dim,
typename Number,
typename VectorizedArrayType>
2766 const unsigned int cell_batch_index)
const
2770 const std::vector<unsigned char> &n_lanes_filled =
2771 dof_info[0].n_vectorization_lanes_filled
2775 return n_lanes_filled[cell_batch_index];
2780template <
int dim,
typename Number,
typename VectorizedArrayType>
2783 const unsigned int face_batch_index)
const
2787 const std::vector<unsigned char> &n_lanes_filled =
2788 dof_info[0].n_vectorization_lanes_filled
2791 return n_lanes_filled[face_batch_index];
2796template <
int dim,
typename Number,
typename VectorizedArrayType>
2799 const unsigned int dof_handler_index,
2800 const unsigned int active_fe_index)
const
2802 return dof_info[dof_handler_index].dofs_per_cell[active_fe_index];
2807template <
int dim,
typename Number,
typename VectorizedArrayType>
2810 const unsigned int quad_index,
2811 const unsigned int active_fe_index)
const
2814 return mapping_info.cell_data[quad_index]
2815 .descriptor[active_fe_index]
2821template <
int dim,
typename Number,
typename VectorizedArrayType>
2824 const unsigned int dof_handler_index,
2825 const unsigned int active_fe_index)
const
2827 return dof_info[dof_handler_index].dofs_per_face[active_fe_index];
2832template <
int dim,
typename Number,
typename VectorizedArrayType>
2835 const unsigned int quad_index,
2836 const unsigned int active_fe_index)
const
2839 return mapping_info.face_data[quad_index]
2840 .descriptor[active_fe_index]
2846template <
int dim,
typename Number,
typename VectorizedArrayType>
2849 const unsigned int dof_handler_index)
const
2851 return dof_info[dof_handler_index].vector_partitioner->locally_owned_range();
2856template <
int dim,
typename Number,
typename VectorizedArrayType>
2859 const unsigned int dof_handler_index)
const
2861 return dof_info[dof_handler_index].vector_partitioner->ghost_indices();
2866template <
int dim,
typename Number,
typename VectorizedArrayType>
2869 const unsigned int dof_handler_index,
2870 const unsigned int index_quad,
2871 const unsigned int index_fe,
2872 const unsigned int active_fe_index,
2873 const unsigned int active_quad_index)
const
2876 const unsigned int ind =
2877 dof_info[dof_handler_index].global_base_element_offset + index_fe;
2882 return shape_info(ind, index_quad, active_fe_index, active_quad_index);
2887template <
int dim,
typename Number,
typename VectorizedArrayType>
2889 VectorizedArrayType::size()> &
2891 const unsigned int face_batch_index)
const
2894 return face_info.faces[face_batch_index];
2899template <
int dim,
typename Number,
typename VectorizedArrayType>
2904 return face_info.cell_and_face_to_plain_faces;
2909template <
int dim,
typename Number,
typename VectorizedArrayType>
2912 const unsigned int quad_index,
2913 const unsigned int active_fe_index)
const
2916 return mapping_info.cell_data[quad_index]
2917 .descriptor[active_fe_index]
2923template <
int dim,
typename Number,
typename VectorizedArrayType>
2926 const unsigned int quad_index,
2927 const unsigned int active_fe_index)
const
2930 return mapping_info.face_data[quad_index]
2931 .descriptor[active_fe_index]
2937template <
int dim,
typename Number,
typename VectorizedArrayType>
2940 const std::pair<unsigned int, unsigned int> range)
const
2942 auto result = get_cell_category(range.first);
2944 for (
unsigned int i = range.first; i < range.second; ++i)
2945 result =
std::max(result, get_cell_category(i));
2952template <
int dim,
typename Number,
typename VectorizedArrayType>
2953inline std::pair<unsigned int, unsigned int>
2955 const std::pair<unsigned int, unsigned int> range)
const
2957 auto result = get_face_category(range.first);
2959 for (
unsigned int i = range.first; i < range.second; ++i)
2961 result.first =
std::max(result.first, get_face_category(i).
first);
2962 result.second =
std::max(result.second, get_face_category(i).
second);
2970template <
int dim,
typename Number,
typename VectorizedArrayType>
2973 const unsigned int cell_batch_index)
const
2978 dof_info[first_hp_dof_handler_index].cell_active_fe_index.size());
2979 if (dof_info[first_hp_dof_handler_index].cell_active_fe_index.empty())
2982 return dof_info[first_hp_dof_handler_index]
2983 .cell_active_fe_index[cell_batch_index];
2988template <
int dim,
typename Number,
typename VectorizedArrayType>
2989inline std::pair<unsigned int, unsigned int>
2991 const unsigned int face_batch_index)
const
2994 if (dof_info[first_hp_dof_handler_index].cell_active_fe_index.empty())
2995 return std::make_pair(0U, 0U);
2997 std::pair<unsigned int, unsigned int> result = std::make_pair(0U, 0U);
2998 for (
unsigned int v = 0;
2999 v < VectorizedArrayType::size() &&
3000 face_info.faces[face_batch_index].cells_interior[v] !=
3005 dof_info[first_hp_dof_handler_index].cell_active_fe_index
3006 [face_info.faces[face_batch_index].cells_interior[v] /
3007 VectorizedArrayType::size()]);
3008 if (face_info.faces[face_batch_index].cells_exterior[0] !=
3010 for (
unsigned int v = 0;
3011 v < VectorizedArrayType::size() &&
3012 face_info.faces[face_batch_index].cells_exterior[v] !=
3017 dof_info[first_hp_dof_handler_index].cell_active_fe_index
3018 [face_info.faces[face_batch_index].cells_exterior[v] /
3019 VectorizedArrayType::size()]);
3027template <
int dim,
typename Number,
typename VectorizedArrayType>
3031 return indices_are_initialized;
3036template <
int dim,
typename Number,
typename VectorizedArrayType>
3040 return mapping_is_initialized;
3044template <
int dim,
typename Number,
typename VectorizedArrayType>
3053template <
int dim,
typename Number,
typename VectorizedArrayType>
3058 std::list<std::pair<bool, AlignedVector<VectorizedArrayType>>>;
3059 list_type &
data = scratch_pad.get();
3060 for (
typename list_type::iterator it =
data.begin(); it !=
data.end(); ++it)
3061 if (it->first ==
false)
3067 return &
data.front().second;
3072template <
int dim,
typename Number,
typename VectorizedArrayType>
3078 std::list<std::pair<bool, AlignedVector<VectorizedArrayType>>>;
3079 list_type &
data = scratch_pad.get();
3080 for (
typename list_type::iterator it =
data.begin(); it !=
data.end(); ++it)
3081 if (&it->second == scratch)
3092template <
int dim,
typename Number,
typename VectorizedArrayType>
3098 scratch_pad_non_threadsafe.
begin();
3099 it != scratch_pad_non_threadsafe.end();
3101 if (it->first ==
false)
3106 scratch_pad_non_threadsafe.push_front(
3108 return &scratch_pad_non_threadsafe.front().second;
3113template <
int dim,
typename Number,
typename VectorizedArrayType>
3120 scratch_pad_non_threadsafe.
begin();
3121 it != scratch_pad_non_threadsafe.end();
3123 if (&it->second == scratch)
3138 namespace MatrixFreeImplementation
3140 template <
int dim,
int spacedim>
3141 inline std::vector<IndexSet>
3142 extract_locally_owned_index_sets(
3144 const unsigned int level)
3146 std::vector<IndexSet> locally_owned_set;
3147 locally_owned_set.reserve(dofh.size());
3148 for (
unsigned int j = 0; j < dofh.size(); ++j)
3150 locally_owned_set.push_back(dofh[j]->locally_owned_dofs());
3152 locally_owned_set.push_back(dofh[j]->locally_owned_mg_dofs(
level));
3153 return locally_owned_set;
3160template <
int dim,
typename Number,
typename VectorizedArrayType>
3161template <
typename QuadratureType,
typename number2,
typename MappingType>
3164 const MappingType &mapping,
3167 const QuadratureType &quad,
3171 std::vector<const DoFHandler<dim, dim> *> dof_handlers;
3172 std::vector<const AffineConstraints<number2> *> constraints;
3174 dof_handlers.push_back(&dof_handler);
3175 constraints.push_back(&constraints_in);
3177 std::vector<IndexSet> locally_owned_sets =
3178 internal::MatrixFreeImplementation::extract_locally_owned_index_sets(
3179 dof_handlers, additional_data.
mg_level);
3181 std::vector<hp::QCollection<dim>> quad_hp;
3182 quad_hp.emplace_back(quad);
3194template <
int dim,
typename Number,
typename VectorizedArrayType>
3195template <
typename QuadratureType,
typename number2,
typename MappingType>
3198 const MappingType &mapping,
3201 const QuadratureType &quad,
3205 std::vector<IndexSet> locally_owned_set =
3206 internal::MatrixFreeImplementation::extract_locally_owned_index_sets(
3207 dof_handler, additional_data.
mg_level);
3208 std::vector<hp::QCollection<dim>> quad_hp;
3209 quad_hp.emplace_back(quad);
3221template <
int dim,
typename Number,
typename VectorizedArrayType>
3222template <
typename QuadratureType,
typename number2,
typename MappingType>
3225 const MappingType &mapping,
3228 const std::vector<QuadratureType> &quad,
3232 std::vector<IndexSet> locally_owned_set =
3233 internal::MatrixFreeImplementation::extract_locally_owned_index_sets(
3234 dof_handler, additional_data.
mg_level);
3235 std::vector<hp::QCollection<dim>> quad_hp;
3236 for (
unsigned int q = 0; q < quad.size(); ++q)
3237 quad_hp.emplace_back(quad[q]);
3264 template <
int dim,
typename Number,
typename VectorizedArrayType>
3265 struct VectorDataExchange
3272 static constexpr unsigned int channel_shift = 20;
3281 const ::MatrixFree<dim, Number, VectorizedArrayType> &matrix_free,
3282 const typename ::MatrixFree<dim, Number, VectorizedArrayType>::
3283 DataAccessOnFaces vector_face_access,
3284 const unsigned
int n_components)
3285 : matrix_free(matrix_free)
3286 , vector_face_access(
3287 matrix_free.get_task_info().face_partition_data.empty() ?
3288 ::
MatrixFree<dim, Number, VectorizedArrayType>::
3289 DataAccessOnFaces::unspecified :
3291 , ghosts_were_set(false)
3292# ifdef DEAL_II_WITH_MPI
3293 , tmp_data(n_components)
3294 , requests(n_components)
3298 if (this->vector_face_access !=
3300 DataAccessOnFaces::unspecified)
3301 for (unsigned
int c = 0; c < matrix_free.n_components(); ++c)
3303 matrix_free.get_dof_info(c).vector_exchanger_face_variants.size(),
3312 ~VectorDataExchange()
3314# ifdef DEAL_II_WITH_MPI
3315 for (
unsigned int i = 0; i < tmp_data.size(); ++i)
3316 if (tmp_data[i] !=
nullptr)
3317 matrix_free.release_scratch_data_non_threadsafe(tmp_data[i]);
3327 template <
typename VectorType>
3329 find_vector_in_mf(
const VectorType &vec,
3330 const bool check_global_compatibility =
true)
const
3333 for (
unsigned int c = 0; c < matrix_free.n_components(); ++c)
3334 if (vec.get_partitioner().get() ==
3335 matrix_free.get_dof_info(c).vector_partitioner.get())
3339 for (
unsigned int c = 0; c < matrix_free.n_components(); ++c)
3340 if (check_global_compatibility ?
3341 vec.get_partitioner()->is_globally_compatible(
3342 *matrix_free.get_dof_info(c).vector_partitioner) :
3343 vec.get_partitioner()->is_compatible(
3344 *matrix_free.get_dof_info(c).vector_partitioner))
3360 get_partitioner(
const unsigned int mf_component)
const
3363 .vector_exchanger_face_variants.size(),
3365 if (vector_face_access ==
3367 DataAccessOnFaces::
none)
3368 return *matrix_free.get_dof_info(mf_component)
3369 .vector_exchanger_face_variants[0];
3370 else if (vector_face_access ==
3372 DataAccessOnFaces::
values)
3373 return *matrix_free.get_dof_info(mf_component)
3374 .vector_exchanger_face_variants[1];
3375 else if (vector_face_access ==
3378 return *matrix_free.get_dof_info(mf_component)
3379 .vector_exchanger_face_variants[2];
3380 else if (vector_face_access ==
3382 DataAccessOnFaces::values_all_faces)
3383 return *matrix_free.get_dof_info(mf_component)
3384 .vector_exchanger_face_variants[3];
3385 else if (vector_face_access ==
3387 DataAccessOnFaces::gradients_all_faces)
3388 return *matrix_free.get_dof_info(mf_component)
3389 .vector_exchanger_face_variants[4];
3391 return *matrix_free.get_dof_info(mf_component).vector_exchanger.get();
3400 std::enable_if_t<is_not_parallel_vector<VectorType>,
VectorType>
3403 update_ghost_values_start(
const unsigned int ,
3404 const VectorType & )
3413 std::enable_if_t<!has_update_ghost_values_start<VectorType> &&
3414 !is_not_parallel_vector<VectorType>,
3417 update_ghost_values_start(
const unsigned int component_in_block_vector,
3418 const VectorType &vec)
3420 (void)component_in_block_vector;
3421 const bool ghosts_set = vec.has_ghost_elements();
3423 Assert(matrix_free.get_task_info().allow_ghosted_vectors_in_loops ||
3424 ghosts_set ==
false,
3429 ghosts_were_set =
true;
3433 vec.update_ghost_values();
3444 std::enable_if_t<has_update_ghost_values_start<VectorType> &&
3445 !has_exchange_on_subset<VectorType>,
3448 update_ghost_values_start(
const unsigned int component_in_block_vector,
3449 const VectorType &vec)
3451 (void)component_in_block_vector;
3452 const bool ghosts_set = vec.has_ghost_elements();
3454 Assert(matrix_free.get_task_info().allow_ghosted_vectors_in_loops ||
3455 ghosts_set ==
false,
3460 ghosts_were_set =
true;
3464 vec.update_ghost_values_start(component_in_block_vector + channel_shift);
3476 std::enable_if_t<has_update_ghost_values_start<VectorType> &&
3477 has_exchange_on_subset<VectorType>,
3480 update_ghost_values_start(
const unsigned int component_in_block_vector,
3481 const VectorType &vec)
3483 static_assert(std::is_same_v<Number, typename VectorType::value_type>,
3484 "Type mismatch between VectorType and VectorDataExchange");
3485 (void)component_in_block_vector;
3486 const bool ghosts_set = vec.has_ghost_elements();
3488 Assert(matrix_free.get_task_info().allow_ghosted_vectors_in_loops ||
3489 ghosts_set ==
false,
3494 ghosts_were_set =
true;
3498 if (vec.size() != 0)
3500# ifdef DEAL_II_WITH_MPI
3501 const unsigned int mf_component = find_vector_in_mf(vec);
3503 const auto &part = get_partitioner(mf_component);
3505 if (part.n_ghost_indices() == 0 && part.n_import_indices() == 0 &&
3506 part.n_import_sm_procs() == 0)
3509 tmp_data[component_in_block_vector] =
3510 matrix_free.acquire_scratch_data_non_threadsafe();
3511 tmp_data[component_in_block_vector]->resize_fast(
3512 part.n_import_indices());
3515 part.export_to_ghosted_array_start(
3516 component_in_block_vector * 2 + channel_shift,
3518 vec.shared_vector_data(),
3520 part.locally_owned_size(),
3521 matrix_free.get_dof_info(mf_component)
3522 .vector_partitioner->n_ghost_indices()),
3524 part.n_import_indices()),
3525 this->requests[component_in_block_vector]);
3537 std::enable_if_t<!has_update_ghost_values_start<VectorType>,
3540 update_ghost_values_finish(
const unsigned int ,
3541 const VectorType & )
3552 std::enable_if_t<has_update_ghost_values_start<VectorType> &&
3553 !has_exchange_on_subset<VectorType>,
3556 update_ghost_values_finish(
const unsigned int component_in_block_vector,
3557 const VectorType &vec)
3559 (void)component_in_block_vector;
3561 if (ghosts_were_set)
3564 vec.update_ghost_values_finish();
3576 std::enable_if_t<has_update_ghost_values_start<VectorType> &&
3577 has_exchange_on_subset<VectorType>,
3580 update_ghost_values_finish(
const unsigned int component_in_block_vector,
3581 const VectorType &vec)
3583 static_assert(std::is_same_v<Number, typename VectorType::value_type>,
3584 "Type mismatch between VectorType and VectorDataExchange");
3585 (void)component_in_block_vector;
3587 if (ghosts_were_set)
3590 if (vec.size() != 0)
3592# ifdef DEAL_II_WITH_MPI
3596 const unsigned int mf_component = find_vector_in_mf(vec);
3598 const auto &part = get_partitioner(mf_component);
3600 if (part.n_ghost_indices() != 0 || part.n_import_indices() != 0 ||
3601 part.n_import_sm_procs() != 0)
3603 part.export_to_ghosted_array_finish(
3605 vec.shared_vector_data(),
3607 part.locally_owned_size(),
3608 matrix_free.get_dof_info(mf_component)
3609 .vector_partitioner->n_ghost_indices()),
3610 this->requests[component_in_block_vector]);
3612 matrix_free.release_scratch_data_non_threadsafe(
3613 tmp_data[component_in_block_vector]);
3614 tmp_data[component_in_block_vector] =
nullptr;
3620 vec.set_ghost_state(
true);
3629 std::enable_if_t<is_not_parallel_vector<VectorType>,
VectorType>
3632 compress_start(
const unsigned int ,
3643 std::enable_if_t<!has_compress_start<VectorType> &&
3644 !is_not_parallel_vector<VectorType>,
3647 compress_start(
const unsigned int component_in_block_vector,
3650 (void)component_in_block_vector;
3663 std::enable_if_t<has_compress_start<VectorType> &&
3664 !has_exchange_on_subset<VectorType>,
3667 compress_start(
const unsigned int component_in_block_vector,
3670 (void)component_in_block_vector;
3672 vec.compress_start(component_in_block_vector + channel_shift);
3684 std::enable_if_t<has_compress_start<VectorType> &&
3685 has_exchange_on_subset<VectorType>,
3688 compress_start(
const unsigned int component_in_block_vector,
3691 static_assert(std::is_same_v<Number, typename VectorType::value_type>,
3692 "Type mismatch between VectorType and VectorDataExchange");
3693 (void)component_in_block_vector;
3696 if (vec.size() != 0)
3698# ifdef DEAL_II_WITH_MPI
3699 const unsigned int mf_component = find_vector_in_mf(vec);
3701 const auto &part = get_partitioner(mf_component);
3703 if (part.n_ghost_indices() == 0 && part.n_import_indices() == 0 &&
3704 part.n_import_sm_procs() == 0)
3707 tmp_data[component_in_block_vector] =
3708 matrix_free.acquire_scratch_data_non_threadsafe();
3709 tmp_data[component_in_block_vector]->resize_fast(
3710 part.n_import_indices());
3713 part.import_from_ghosted_array_start(
3715 component_in_block_vector * 2 + channel_shift,
3717 vec.shared_vector_data(),
3719 matrix_free.get_dof_info(mf_component)
3720 .vector_partitioner->n_ghost_indices()),
3722 part.n_import_indices()),
3723 this->requests[component_in_block_vector]);
3736 std::enable_if_t<!has_compress_start<VectorType>,
VectorType> * =
nullptr>
3738 compress_finish(
const unsigned int ,
3750 std::enable_if_t<has_compress_start<VectorType> &&
3751 !has_exchange_on_subset<VectorType>,
3754 compress_finish(
const unsigned int component_in_block_vector,
3757 (void)component_in_block_vector;
3770 std::enable_if_t<has_compress_start<VectorType> &&
3771 has_exchange_on_subset<VectorType>,
3774 compress_finish(
const unsigned int component_in_block_vector,
3777 static_assert(std::is_same_v<Number, typename VectorType::value_type>,
3778 "Type mismatch between VectorType and VectorDataExchange");
3779 (void)component_in_block_vector;
3780 if (vec.size() != 0)
3782# ifdef DEAL_II_WITH_MPI
3786 const unsigned int mf_component = find_vector_in_mf(vec);
3788 const auto &part = get_partitioner(mf_component);
3790 if (part.n_ghost_indices() != 0 || part.n_import_indices() != 0 ||
3791 part.n_import_sm_procs() != 0)
3793 part.import_from_ghosted_array_finish(
3796 vec.shared_vector_data(),
3798 matrix_free.get_dof_info(mf_component)
3799 .vector_partitioner->n_ghost_indices()),
3801 tmp_data[component_in_block_vector]->begin(),
3802 part.n_import_indices()),
3803 this->requests[component_in_block_vector]);
3805 matrix_free.release_scratch_data_non_threadsafe(
3806 tmp_data[component_in_block_vector]);
3807 tmp_data[component_in_block_vector] =
nullptr;
3813 MPI_Barrier(matrix_free.get_task_info().communicator_sm);
3826 std::enable_if_t<is_not_parallel_vector<VectorType>,
VectorType>
3829 reset_ghost_values(
const VectorType & )
const
3839 std::enable_if_t<!has_exchange_on_subset<VectorType> &&
3840 !is_not_parallel_vector<VectorType>,
3843 reset_ghost_values(
const VectorType &vec)
const
3845 if (ghosts_were_set ==
true)
3848 vec.zero_out_ghost_values();
3859 std::enable_if_t<has_exchange_on_subset<VectorType>,
VectorType>
3862 reset_ghost_values(
const VectorType &vec)
const
3864 static_assert(std::is_same_v<Number, typename VectorType::value_type>,
3865 "Type mismatch between VectorType and VectorDataExchange");
3866 if (ghosts_were_set ==
true)
3869 if (vec.size() != 0)
3871# ifdef DEAL_II_WITH_MPI
3874 const unsigned int mf_component = find_vector_in_mf(vec);
3876 const auto &part = get_partitioner(mf_component);
3878 if (part.n_ghost_indices() > 0)
3883 part.locally_owned_size(),
3884 matrix_free.get_dof_info(mf_component)
3885 .vector_partitioner->n_ghost_indices()));
3891 vec.set_ghost_state(
false);
3902 std::enable_if_t<has_exchange_on_subset<VectorType>,
VectorType>
3905 zero_vector_region(
const unsigned int range_index, VectorType &vec)
const
3907 static_assert(std::is_same_v<Number, typename VectorType::value_type>,
3908 "Type mismatch between VectorType and VectorDataExchange");
3913 const unsigned int mf_component = find_vector_in_mf(vec,
false);
3915 matrix_free.get_dof_info(mf_component);
3923 for (
unsigned int id =
3943 std::enable_if_t<!has_exchange_on_subset<VectorType>,
VectorType>
3945 typename VectorType::value_type * =
nullptr>
3947 zero_vector_region(
const unsigned int range_index, VectorType &vec)
const
3951 if constexpr (std::is_same_v<
3955 for (
unsigned int i = 0; i < vec.size(); ++i)
3956 vec[i] =
typename VectorType::value_type();
3959 vec =
typename VectorType::value_type();
3970 zero_vector_region(
const unsigned int, ...)
const
3974 "which provide VectorType::value_type"));
3979 const ::MatrixFree<dim, Number, VectorizedArrayType> &matrix_free;
3980 const typename ::MatrixFree<dim, Number, VectorizedArrayType>::
3981 DataAccessOnFaces vector_face_access;
3982 bool ghosts_were_set;
3983# ifdef DEAL_II_WITH_MPI
3984 std::vector<AlignedVector<Number> *> tmp_data;
3985 std::vector<std::vector<MPI_Request>> requests;
3989 template <
typename VectorStruct>
3991 n_components(
const VectorStruct &vec);
3993 template <
typename VectorStruct>
3995 n_components_block(
const VectorStruct &vec,
const std::bool_constant<true>)
3997 unsigned int components = 0;
3998 for (
unsigned int bl = 0; bl < vec.n_blocks(); ++bl)
3999 components += n_components(vec.block(bl));
4003 template <
typename VectorStruct>
4005 n_components_block(
const VectorStruct &,
const std::bool_constant<false>)
4010 template <
typename VectorStruct>
4012 n_components(
const VectorStruct &vec)
4014 return n_components_block(
4018 template <
typename VectorStruct>
4020 n_components(
const std::vector<VectorStruct> &vec)
4022 unsigned int components = 0;
4023 for (
unsigned int comp = 0; comp < vec.size(); ++comp)
4024 components += n_components_block(
4029 template <
typename VectorStruct>
4031 n_components(
const std::vector<VectorStruct *> &vec)
4033 unsigned int components = 0;
4034 for (
unsigned int comp = 0; comp < vec.size(); ++comp)
4035 components += n_components_block(
4047 template <
typename VectorStruct,
4048 std::enable_if_t<!has_communication_block_size<VectorStruct>,
4049 VectorStruct> * =
nullptr>
4050 constexpr unsigned int
4051 get_communication_block_size(
const VectorStruct &)
4058 template <
typename VectorStruct,
4059 std::enable_if_t<has_communication_block_size<VectorStruct>,
4060 VectorStruct> * =
nullptr>
4061 constexpr unsigned int
4062 get_communication_block_size(
const VectorStruct &)
4064 return VectorStruct::communication_block_size;
4070 std::enable_if_t<is_not_parallel_vector<VectorType>,
VectorType> * =
4073 has_ghost_elements(
const VectorType &vec)
4082 std::enable_if_t<!is_not_parallel_vector<VectorType>,
VectorType>
4085 has_ghost_elements(
const VectorType &vec)
4087 return vec.has_ghost_elements();
4102 typename VectorStruct,
4104 typename VectorizedArrayType,
4105 std::enable_if_t<IsBlockVector<VectorStruct>::value, VectorStruct>
4108 update_ghost_values_start(
4109 const VectorStruct &vec,
4110 VectorDataExchange<dim, Number, VectorizedArrayType> &exchanger,
4111 const unsigned int channel = 0)
4113 if (get_communication_block_size(vec) < vec.n_blocks())
4115 const bool ghosts_set = vec.has_ghost_elements();
4117 Assert(exchanger.matrix_free.get_task_info()
4118 .allow_ghosted_vectors_in_loops ||
4119 ghosts_set ==
false,
4124 exchanger.ghosts_were_set =
true;
4128 vec.update_ghost_values();
4132 for (
unsigned int i = 0; i < vec.n_blocks(); ++i)
4133 update_ghost_values_start(vec.block(i), exchanger, channel + i);
4141 typename VectorStruct,
4143 typename VectorizedArrayType,
4144 std::enable_if_t<!IsBlockVector<VectorStruct>::value, VectorStruct>
4147 update_ghost_values_start(
4148 const VectorStruct &vec,
4149 VectorDataExchange<dim, Number, VectorizedArrayType> &exchanger,
4150 const unsigned int channel = 0)
4152 exchanger.update_ghost_values_start(channel, vec);
4159 typename VectorStruct,
4161 typename VectorizedArrayType>
4163 update_ghost_values_start(
4164 const std::vector<VectorStruct> &vec,
4165 VectorDataExchange<dim, Number, VectorizedArrayType> &exchanger)
4167 unsigned int component_index = 0;
4168 for (
unsigned int comp = 0; comp < vec.size(); ++comp)
4170 update_ghost_values_start(vec[comp], exchanger, component_index);
4171 component_index += n_components(vec[comp]);
4179 typename VectorStruct,
4181 typename VectorizedArrayType>
4183 update_ghost_values_start(
4184 const std::vector<VectorStruct *> &vec,
4185 VectorDataExchange<dim, Number, VectorizedArrayType> &exchanger)
4187 unsigned int component_index = 0;
4188 for (
unsigned int comp = 0; comp < vec.size(); ++comp)
4190 update_ghost_values_start(*vec[comp], exchanger, component_index);
4191 component_index += n_components(*vec[comp]);
4203 typename VectorStruct,
4205 typename VectorizedArrayType,
4206 std::enable_if_t<IsBlockVector<VectorStruct>::value, VectorStruct>
4209 update_ghost_values_finish(
4210 const VectorStruct &vec,
4211 VectorDataExchange<dim, Number, VectorizedArrayType> &exchanger,
4212 const unsigned int channel = 0)
4214 if (get_communication_block_size(vec) < vec.n_blocks())
4220 for (
unsigned int i = 0; i < vec.n_blocks(); ++i)
4221 update_ghost_values_finish(vec.block(i), exchanger, channel + i);
4228 typename VectorStruct,
4230 typename VectorizedArrayType,
4231 std::enable_if_t<!IsBlockVector<VectorStruct>::value, VectorStruct>
4234 update_ghost_values_finish(
4235 const VectorStruct &vec,
4236 VectorDataExchange<dim, Number, VectorizedArrayType> &exchanger,
4237 const unsigned int channel = 0)
4239 exchanger.update_ghost_values_finish(channel, vec);
4246 typename VectorStruct,
4248 typename VectorizedArrayType>
4250 update_ghost_values_finish(
4251 const std::vector<VectorStruct> &vec,
4252 VectorDataExchange<dim, Number, VectorizedArrayType> &exchanger)
4254 unsigned int component_index = 0;
4255 for (
unsigned int comp = 0; comp < vec.size(); ++comp)
4257 update_ghost_values_finish(vec[comp], exchanger, component_index);
4258 component_index += n_components(vec[comp]);
4266 typename VectorStruct,
4268 typename VectorizedArrayType>
4270 update_ghost_values_finish(
4271 const std::vector<VectorStruct *> &vec,
4272 VectorDataExchange<dim, Number, VectorizedArrayType> &exchanger)
4274 unsigned int component_index = 0;
4275 for (
unsigned int comp = 0; comp < vec.size(); ++comp)
4277 update_ghost_values_finish(*vec[comp], exchanger, component_index);
4278 component_index += n_components(*vec[comp]);
4290 typename VectorStruct,
4292 typename VectorizedArrayType,
4293 std::enable_if_t<IsBlockVector<VectorStruct>::value, VectorStruct>
4298 VectorDataExchange<dim, Number, VectorizedArrayType> &exchanger,
4299 const unsigned int channel = 0)
4301 if (get_communication_block_size(vec) < vec.n_blocks())
4304 for (
unsigned int i = 0; i < vec.n_blocks(); ++i)
4305 compress_start(vec.block(i), exchanger, channel + i);
4312 typename VectorStruct,
4314 typename VectorizedArrayType,
4315 std::enable_if_t<!IsBlockVector<VectorStruct>::value, VectorStruct>
4320 VectorDataExchange<dim, Number, VectorizedArrayType> &exchanger,
4321 const unsigned int channel = 0)
4323 exchanger.compress_start(channel, vec);
4330 typename VectorStruct,
4332 typename VectorizedArrayType>
4335 std::vector<VectorStruct> &vec,
4336 VectorDataExchange<dim, Number, VectorizedArrayType> &exchanger)
4338 unsigned int component_index = 0;
4339 for (
unsigned int comp = 0; comp < vec.size(); ++comp)
4341 compress_start(vec[comp], exchanger, component_index);
4342 component_index += n_components(vec[comp]);
4350 typename VectorStruct,
4352 typename VectorizedArrayType>
4355 std::vector<VectorStruct *> &vec,
4356 VectorDataExchange<dim, Number, VectorizedArrayType> &exchanger)
4358 unsigned int component_index = 0;
4359 for (
unsigned int comp = 0; comp < vec.size(); ++comp)
4361 compress_start(*vec[comp], exchanger, component_index);
4362 component_index += n_components(*vec[comp]);
4374 typename VectorStruct,
4376 typename VectorizedArrayType,
4377 std::enable_if_t<IsBlockVector<VectorStruct>::value, VectorStruct>
4382 VectorDataExchange<dim, Number, VectorizedArrayType> &exchanger,
4383 const unsigned int channel = 0)
4385 if (get_communication_block_size(vec) < vec.n_blocks())
4391 for (
unsigned int i = 0; i < vec.n_blocks(); ++i)
4392 compress_finish(vec.block(i), exchanger, channel + i);
4399 typename VectorStruct,
4401 typename VectorizedArrayType,
4402 std::enable_if_t<!IsBlockVector<VectorStruct>::value, VectorStruct>
4407 VectorDataExchange<dim, Number, VectorizedArrayType> &exchanger,
4408 const unsigned int channel = 0)
4410 exchanger.compress_finish(channel, vec);
4417 typename VectorStruct,
4419 typename VectorizedArrayType>
4422 std::vector<VectorStruct> &vec,
4423 VectorDataExchange<dim, Number, VectorizedArrayType> &exchanger)
4425 unsigned int component_index = 0;
4426 for (
unsigned int comp = 0; comp < vec.size(); ++comp)
4428 compress_finish(vec[comp], exchanger, component_index);
4429 component_index += n_components(vec[comp]);
4437 typename VectorStruct,
4439 typename VectorizedArrayType>
4442 std::vector<VectorStruct *> &vec,
4443 VectorDataExchange<dim, Number, VectorizedArrayType> &exchanger)
4445 unsigned int component_index = 0;
4446 for (
unsigned int comp = 0; comp < vec.size(); ++comp)
4448 compress_finish(*vec[comp], exchanger, component_index);
4449 component_index += n_components(*vec[comp]);
4465 typename VectorStruct,
4467 typename VectorizedArrayType,
4468 std::enable_if_t<IsBlockVector<VectorStruct>::value, VectorStruct>
4472 const VectorStruct &vec,
4473 VectorDataExchange<dim, Number, VectorizedArrayType> &exchanger)
4476 if (exchanger.ghosts_were_set ==
true)
4479 for (
unsigned int i = 0; i < vec.n_blocks(); ++i)
4480 reset_ghost_values(vec.block(i), exchanger);
4487 typename VectorStruct,
4489 typename VectorizedArrayType,
4490 std::enable_if_t<!IsBlockVector<VectorStruct>::value, VectorStruct>
4494 const VectorStruct &vec,
4495 VectorDataExchange<dim, Number, VectorizedArrayType> &exchanger)
4498 if (exchanger.ghosts_were_set ==
true)
4501 exchanger.reset_ghost_values(vec);
4508 typename VectorStruct,
4510 typename VectorizedArrayType>
4513 const std::vector<VectorStruct> &vec,
4514 VectorDataExchange<dim, Number, VectorizedArrayType> &exchanger)
4517 if (exchanger.ghosts_were_set ==
true)
4520 for (
unsigned int comp = 0; comp < vec.size(); ++comp)
4521 reset_ghost_values(vec[comp], exchanger);
4528 typename VectorStruct,
4530 typename VectorizedArrayType>
4533 const std::vector<VectorStruct *> &vec,
4534 VectorDataExchange<dim, Number, VectorizedArrayType> &exchanger)
4537 if (exchanger.ghosts_were_set ==
true)
4540 for (
unsigned int comp = 0; comp < vec.size(); ++comp)
4541 reset_ghost_values(*vec[comp], exchanger);
4552 typename VectorStruct,
4554 typename VectorizedArrayType,
4555 std::enable_if_t<IsBlockVector<VectorStruct>::value, VectorStruct>
4559 const unsigned int range_index,
4561 VectorDataExchange<dim, Number, VectorizedArrayType> &exchanger)
4563 for (
unsigned int i = 0; i < vec.n_blocks(); ++i)
4564 exchanger.zero_vector_region(range_index, vec.block(i));
4571 typename VectorStruct,
4573 typename VectorizedArrayType,
4574 std::enable_if_t<!IsBlockVector<VectorStruct>::value, VectorStruct>
4578 const unsigned int range_index,
4580 VectorDataExchange<dim, Number, VectorizedArrayType> &exchanger)
4582 exchanger.zero_vector_region(range_index, vec);
4589 typename VectorStruct,
4591 typename VectorizedArrayType>
4594 const unsigned int range_index,
4595 std::vector<VectorStruct> &vec,
4596 VectorDataExchange<dim, Number, VectorizedArrayType> &exchanger)
4598 for (
unsigned int comp = 0; comp < vec.size(); ++comp)
4599 zero_vector_region(range_index, vec[comp], exchanger);
4606 typename VectorStruct,
4608 typename VectorizedArrayType>
4611 const unsigned int range_index,
4612 std::vector<VectorStruct *> &vec,
4613 VectorDataExchange<dim, Number, VectorizedArrayType> &exchanger)
4615 for (
unsigned int comp = 0; comp < vec.size(); ++comp)
4616 zero_vector_region(range_index, *vec[comp], exchanger);
4624 template <
typename VectorStruct1,
typename VectorStruct2>
4626 apply_operation_to_constrained_dofs(
const std::vector<unsigned int> &,
4627 const VectorStruct1 &,
4631 template <
typename Number>
4633 apply_operation_to_constrained_dofs(
4634 const std::vector<unsigned int> &constrained_dofs,
4638 for (
const unsigned int i : constrained_dofs)
4639 dst.local_element(i) = src.local_element(i);
4643 namespace MatrixFreeFunctions
4647 template <
typename,
typename,
typename,
typename,
bool>
4648 struct InterfaceSelector
4652 template <
typename MF,
4656 struct InterfaceSelector<MF, InVector, OutVector, Container, true>
4658 using function_type = void (Container::*)(
4662 const
std::pair<unsigned
int, unsigned
int> &) const;
4666 template <
typename MF,
4670 struct InterfaceSelector<MF, InVector, OutVector, Container, false>
4672 using function_type =
4673 void (Container::*)(const MF &,
4676 const
std::pair<unsigned
int, unsigned
int> &);
4684 template <
typename MF,
4689 class MFWorker :
public MFWorkerInterface
4693 using function_type =
typename MatrixFreeFunctions::
4694 InterfaceSelector<MF, InVector, OutVector, Container, is_constant>::
4698 MFWorker(
const MF &matrix_free,
4699 const InVector &src,
4701 const bool zero_dst_vector_setting,
4702 const Container &container,
4703 function_type cell_function,
4704 function_type face_function,
4705 function_type boundary_function,
4706 const typename MF::DataAccessOnFaces src_vector_face_access =
4707 MF::DataAccessOnFaces::none,
4708 const typename MF::DataAccessOnFaces dst_vector_face_access =
4709 MF::DataAccessOnFaces::none,
4710 const std::function<
void(
const unsigned int,
const unsigned int)>
4711 &operation_before_loop = {},
4712 const std::function<void(
const unsigned int,
const unsigned int)>
4713 &operation_after_loop = {},
4714 const unsigned int dof_handler_index_pre_post = 0)
4715 : matrix_free(matrix_free)
4716 , container(const_cast<Container &>(container))
4717 , cell_function(cell_function)
4718 , face_function(face_function)
4719 , boundary_function(boundary_function)
4722 , src_data_exchanger(matrix_free,
4723 src_vector_face_access,
4725 , dst_data_exchanger(matrix_free,
4726 dst_vector_face_access,
4729 , zero_dst_vector_setting(zero_dst_vector_setting &&
4730 !src_and_dst_are_same)
4731 , operation_before_loop(operation_before_loop)
4732 , operation_after_loop(operation_after_loop)
4733 , dof_handler_index_pre_post(dof_handler_index_pre_post)
4735 Assert(!has_ghost_elements(dst),
4736 ExcMessage(
"The destination vector passed to the matrix-free "
4737 "loop is ghosted. This is not allowed."));
4742 cell(
const std::pair<unsigned int, unsigned int> &cell_range)
override
4744 if (cell_function !=
nullptr && cell_range.second > cell_range.first)
4745 for (
unsigned int i = 0; i < matrix_free.n_active_fe_indices(); ++i)
4747 const auto cell_subrange =
4748 matrix_free.create_cell_subrange_hp_by_index(cell_range, i);
4750 if (cell_subrange.second <= cell_subrange.first)
4754 cell_function)(matrix_free, this->dst, this->src, cell_subrange);
4759 cell(
const unsigned int range_index)
override
4761 process_range(cell_function,
4762 matrix_free.get_task_info().cell_partition_data_hp_ptr,
4763 matrix_free.get_task_info().cell_partition_data_hp,
4768 face(
const unsigned int range_index)
override
4770 process_range(face_function,
4771 matrix_free.get_task_info().face_partition_data_hp_ptr,
4772 matrix_free.get_task_info().face_partition_data_hp,
4777 boundary(
const unsigned int range_index)
override
4779 process_range(boundary_function,
4780 matrix_free.get_task_info().boundary_partition_data_hp_ptr,
4781 matrix_free.get_task_info().boundary_partition_data_hp,
4787 process_range(
const function_type &fu,
4788 const std::vector<unsigned int> &ptr,
4789 const std::vector<unsigned int> &
data,
4790 const unsigned int range_index)
4796 for (
unsigned int i = ptr[range_index]; i < ptr[range_index + 1]; ++i)
4799 (container.*fu)(matrix_free,
4802 std::make_pair(
data[2 * i],
data[2 * i + 1]));
4814 vector_update_ghosts_start()
override
4816 if (!src_and_dst_are_same)
4817 internal::update_ghost_values_start(src, src_data_exchanger);
4822 vector_update_ghosts_finish()
override
4824 if (!src_and_dst_are_same)
4825 internal::update_ghost_values_finish(src, src_data_exchanger);
4830 vector_compress_start()
override
4832 internal::compress_start(dst, dst_data_exchanger);
4837 vector_compress_finish()
override
4839 internal::compress_finish(dst, dst_data_exchanger);
4840 if (!src_and_dst_are_same)
4841 internal::reset_ghost_values(src, src_data_exchanger);
4846 zero_dst_vector_range(
const unsigned int range_index)
override
4848 if (zero_dst_vector_setting)
4849 internal::zero_vector_region(range_index, dst, dst_data_exchanger);
4853 cell_loop_pre_range(
const unsigned int range_index)
override
4855 if (operation_before_loop)
4858 matrix_free.get_dof_info(dof_handler_index_pre_post);
4865 operation_before_loop,
4872 for (
unsigned int id =
4883 cell_loop_post_range(
const unsigned int range_index)
override
4885 if (operation_after_loop)
4889 const std::vector<unsigned int> &partition_row_index =
4890 matrix_free.get_task_info().partition_row_index;
4892 partition_row_index[partition_row_index.size() - 2] - 1)
4893 apply_operation_to_constrained_dofs(
4894 matrix_free.get_constrained_dofs(dof_handler_index_pre_post),
4899 matrix_free.get_dof_info(dof_handler_index_pre_post);
4906 operation_after_loop,
4913 for (
unsigned int id =
4924 const MF &matrix_free;
4925 Container &container;
4926 function_type cell_function;
4927 function_type face_function;
4928 function_type boundary_function;
4930 const InVector &src;
4932 VectorDataExchange<MF::dimension,
4933 typename MF::value_type,
4934 typename MF::vectorized_value_type>
4936 VectorDataExchange<MF::dimension,
4937 typename MF::value_type,
4938 typename MF::vectorized_value_type>
4940 const bool src_and_dst_are_same;
4941 const bool zero_dst_vector_setting;
4942 const std::function<void(
const unsigned int,
const unsigned int)>
4943 operation_before_loop;
4944 const std::function<void(
const unsigned int,
const unsigned int)>
4945 operation_after_loop;
4946 const unsigned int dof_handler_index_pre_post;
4955 template <
class MF,
typename InVector,
typename OutVector>
4956 struct MFClassWrapper
4958 using function_type =
4959 std::function<void(
const MF &,
4962 const std::pair<unsigned int, unsigned int> &)>;
4964 MFClassWrapper(
const function_type cell,
4965 const function_type face,
4966 const function_type boundary)
4969 , boundary(boundary)
4973 cell_integrator(
const MF &mf,
4975 const InVector &src,
4976 const std::pair<unsigned int, unsigned int> &range)
const
4979 cell(mf, dst, src, range);
4983 face_integrator(
const MF &mf,
4985 const InVector &src,
4986 const std::pair<unsigned int, unsigned int> &range)
const
4989 face(mf, dst, src, range);
4993 boundary_integrator(
4996 const InVector &src,
4997 const std::pair<unsigned int, unsigned int> &range)
const
5000 boundary(mf, dst, src, range);
5003 const function_type cell;
5004 const function_type face;
5005 const function_type boundary;
5012template <
int dim,
typename Number,
typename VectorizedArrayType>
5013template <
typename OutVector,
typename InVector>
5019 const std::pair<unsigned int, unsigned int> &)>
5022 const InVector &src,
5023 const bool zero_dst_vector)
const
5026 internal::MFClassWrapper<MatrixFree<dim, Number, VectorizedArrayType>,
5029 Wrapper wrap(cell_operation,
nullptr,
nullptr);
5030 internal::MFWorker<MatrixFree<dim, Number, VectorizedArrayType>,
5040 &Wrapper::cell_integrator,
5041 &Wrapper::face_integrator,
5042 &Wrapper::boundary_integrator);
5044 task_info.loop(worker);
5049template <
int dim,
typename Number,
typename VectorizedArrayType>
5050template <
typename OutVector,
typename InVector>
5056 const std::pair<unsigned int, unsigned int> &)>
5059 const InVector &src,
5060 const std::function<
void(
const unsigned int,
const unsigned int)>
5061 &operation_before_loop,
5062 const std::function<
void(
const unsigned int,
const unsigned int)>
5063 &operation_after_loop,
5064 const unsigned int dof_handler_index_pre_post)
const
5067 internal::MFClassWrapper<MatrixFree<dim, Number, VectorizedArrayType>,
5070 Wrapper wrap(cell_operation,
nullptr,
nullptr);
5071 internal::MFWorker<MatrixFree<dim, Number, VectorizedArrayType>,
5081 &Wrapper::cell_integrator,
5082 &Wrapper::face_integrator,
5083 &Wrapper::boundary_integrator,
5084 DataAccessOnFaces::none,
5085 DataAccessOnFaces::none,
5086 operation_before_loop,
5087 operation_after_loop,
5088 dof_handler_index_pre_post);
5090 task_info.loop(worker);
5095template <
int dim,
typename Number,
typename VectorizedArrayType>
5096template <
typename OutVector,
typename InVector>
5102 const std::pair<unsigned int, unsigned int> &)>
5107 const std::pair<unsigned int, unsigned int> &)>
5108 &inner_face_operation,
5112 const std::pair<unsigned int, unsigned int> &)>
5113 &boundary_face_operation,
5115 const InVector &src,
5116 const bool zero_dst_vector,
5117 const DataAccessOnFaces dst_vector_face_access,
5118 const DataAccessOnFaces src_vector_face_access)
const
5121 internal::MFClassWrapper<MatrixFree<dim, Number, VectorizedArrayType>,
5124 Wrapper wrap(cell_operation, inner_face_operation, boundary_face_operation);
5125 internal::MFWorker<MatrixFree<dim, Number, VectorizedArrayType>,
5135 &Wrapper::cell_integrator,
5136 &Wrapper::face_integrator,
5137 &Wrapper::boundary_integrator,
5138 src_vector_face_access,
5139 dst_vector_face_access);
5141 task_info.loop(worker);
5146template <
int dim,
typename Number,
typename VectorizedArrayType>
5147template <
typename CLASS,
typename OutVector,
typename InVector>
5150 void (CLASS::*function_pointer)(
5151 const
MatrixFree<dim, Number, VectorizedArrayType> &,
5154 const
std::pair<unsigned
int, unsigned
int> &) const,
5155 const CLASS *owning_class,
5157 const InVector &src,
5158 const
bool zero_dst_vector) const
5160 internal::MFWorker<MatrixFree<dim, Number, VectorizedArrayType>,
5178template <
int dim,
typename Number,
typename VectorizedArrayType>
5179template <
typename CLASS,
typename OutVector,
typename InVector>
5182 void (CLASS::*function_pointer)(
5183 const
MatrixFree<dim, Number, VectorizedArrayType> &,
5186 const
std::pair<unsigned
int, unsigned
int> &) const,
5187 const CLASS *owning_class,
5189 const InVector &src,
5190 const
std::function<void(const unsigned
int, const unsigned
int)>
5191 &operation_before_loop,
5192 const
std::function<void(const unsigned
int, const unsigned
int)>
5193 &operation_after_loop,
5194 const unsigned
int dof_handler_index_pre_post) const
5196 internal::MFWorker<MatrixFree<dim, Number, VectorizedArrayType>,
5211 operation_before_loop,
5212 operation_after_loop,
5213 dof_handler_index_pre_post);
5219template <
int dim,
typename Number,
typename VectorizedArrayType>
5220template <
typename CLASS,
typename OutVector,
typename InVector>
5223 void (CLASS::*cell_operation)(
5224 const
MatrixFree<dim, Number, VectorizedArrayType> &,
5227 const
std::pair<unsigned
int, unsigned
int> &) const,
5228 void (CLASS::*inner_face_operation)(
5229 const
MatrixFree<dim, Number, VectorizedArrayType> &,
5232 const
std::pair<unsigned
int, unsigned
int> &) const,
5233 void (CLASS::*boundary_face_operation)(
5234 const
MatrixFree<dim, Number, VectorizedArrayType> &,
5237 const
std::pair<unsigned
int, unsigned
int> &) const,
5238 const CLASS *owning_class,
5240 const InVector &src,
5241 const
bool zero_dst_vector,
5242 const DataAccessOnFaces dst_vector_face_access,
5243 const DataAccessOnFaces src_vector_face_access) const
5245 internal::MFWorker<MatrixFree<dim, Number, VectorizedArrayType>,
5256 inner_face_operation,
5257 boundary_face_operation,
5258 src_vector_face_access,
5259 dst_vector_face_access);
5265template <
int dim,
typename Number,
typename VectorizedArrayType>
5266template <
typename CLASS,
typename OutVector,
typename InVector>
5269 void (CLASS::*function_pointer)(
5270 const
MatrixFree<dim, Number, VectorizedArrayType> &,
5273 const
std::pair<unsigned
int, unsigned
int> &),
5274 CLASS *owning_class,
5276 const InVector &src,
5277 const
bool zero_dst_vector) const
5279 internal::MFWorker<MatrixFree<dim, Number, VectorizedArrayType>,
5297template <
int dim,
typename Number,
typename VectorizedArrayType>
5298template <
typename CLASS,
typename OutVector,
typename InVector>
5301 void (CLASS::*function_pointer)(
5302 const
MatrixFree<dim, Number, VectorizedArrayType> &,
5305 const
std::pair<unsigned
int, unsigned
int> &),
5306 CLASS *owning_class,
5308 const InVector &src,
5309 const
std::function<void(const unsigned
int, const unsigned
int)>
5310 &operation_before_loop,
5311 const
std::function<void(const unsigned
int, const unsigned
int)>
5312 &operation_after_loop,
5313 const unsigned
int dof_handler_index_pre_post) const
5315 internal::MFWorker<MatrixFree<dim, Number, VectorizedArrayType>,
5330 operation_before_loop,
5331 operation_after_loop,
5332 dof_handler_index_pre_post);
5338template <
int dim,
typename Number,
typename VectorizedArrayType>
5339template <
typename CLASS,
typename OutVector,
typename InVector>
5342 void (CLASS::*cell_operation)(
5343 const
MatrixFree<dim, Number, VectorizedArrayType> &,
5346 const
std::pair<unsigned
int, unsigned
int> &),
5347 void (CLASS::*inner_face_operation)(
5348 const
MatrixFree<dim, Number, VectorizedArrayType> &,
5351 const
std::pair<unsigned
int, unsigned
int> &),
5352 void (CLASS::*boundary_face_operation)(
5353 const
MatrixFree<dim, Number, VectorizedArrayType> &,
5356 const
std::pair<unsigned
int, unsigned
int> &),
5357 CLASS *owning_class,
5359 const InVector &src,
5360 const
bool zero_dst_vector,
5361 const DataAccessOnFaces dst_vector_face_access,
5362 const DataAccessOnFaces src_vector_face_access) const
5364 internal::MFWorker<MatrixFree<dim, Number, VectorizedArrayType>,
5375 inner_face_operation,
5376 boundary_face_operation,
5377 src_vector_face_access,
5378 dst_vector_face_access);
5384template <
int dim,
typename Number,
typename VectorizedArrayType>
5385template <
typename OutVector,
typename InVector>
5391 const std::pair<unsigned int, unsigned int> &)>
5396 const std::pair<unsigned int, unsigned int> &)>
5397 &inner_face_operation,
5401 const std::pair<unsigned int, unsigned int> &)>
5402 &boundary_face_operation,
5404 const InVector &src,
5405 const std::function<
void(
const unsigned int,
const unsigned int)>
5406 &operation_before_loop,
5407 const std::function<
void(
const unsigned int,
const unsigned int)>
5408 &operation_after_loop,
5409 const unsigned int dof_handler_index_pre_post,
5410 const DataAccessOnFaces dst_vector_face_access,
5411 const DataAccessOnFaces src_vector_face_access)
const
5414 internal::MFClassWrapper<MatrixFree<dim, Number, VectorizedArrayType>,
5417 Wrapper wrap(cell_operation, inner_face_operation, boundary_face_operation);
5418 internal::MFWorker<MatrixFree<dim, Number, VectorizedArrayType>,
5428 &Wrapper::cell_integrator,
5429 &Wrapper::face_integrator,
5430 &Wrapper::boundary_integrator,
5431 src_vector_face_access,
5432 dst_vector_face_access,
5433 operation_before_loop,
5434 operation_after_loop,
5435 dof_handler_index_pre_post);
5437 task_info.loop(worker);
5442template <
int dim,
typename Number,
typename VectorizedArrayType>
5443template <
typename CLASS,
typename OutVector,
typename InVector>
5446 void (CLASS::*cell_operation)(const
MatrixFree &,
5449 const
std::pair<unsigned
int, unsigned
int> &)
5451 void (CLASS::*inner_face_operation)(
5455 const
std::pair<unsigned
int, unsigned
int> &) const,
5456 void (CLASS::*boundary_face_operation)(
5460 const
std::pair<unsigned
int, unsigned
int> &) const,
5461 const CLASS *owning_class,
5463 const InVector &src,
5464 const
std::function<void(const unsigned
int, const unsigned
int)>
5465 &operation_before_loop,
5466 const
std::function<void(const unsigned
int, const unsigned
int)>
5467 &operation_after_loop,
5468 const unsigned
int dof_handler_index_pre_post,
5469 const DataAccessOnFaces dst_vector_face_access,
5470 const DataAccessOnFaces src_vector_face_access) const
5472 internal::MFWorker<MatrixFree<dim, Number, VectorizedArrayType>,
5483 inner_face_operation,
5484 boundary_face_operation,
5485 src_vector_face_access,
5486 dst_vector_face_access,
5487 operation_before_loop,
5488 operation_after_loop,
5489 dof_handler_index_pre_post);
5495template <
int dim,
typename Number,
typename VectorizedArrayType>
5496template <
typename CLASS,
typename OutVector,
typename InVector>
5499 void (CLASS::*cell_operation)(const
MatrixFree &,
5502 const
std::pair<unsigned
int, unsigned
int> &),
5503 void (CLASS::*inner_face_operation)(
5507 const
std::pair<unsigned
int, unsigned
int> &),
5508 void (CLASS::*boundary_face_operation)(
5512 const
std::pair<unsigned
int, unsigned
int> &),
5513 const CLASS *owning_class,
5515 const InVector &src,
5516 const
std::function<void(const unsigned
int, const unsigned
int)>
5517 &operation_before_loop,
5518 const
std::function<void(const unsigned
int, const unsigned
int)>
5519 &operation_after_loop,
5520 const unsigned
int dof_handler_index_pre_post,
5521 const DataAccessOnFaces dst_vector_face_access,
5522 const DataAccessOnFaces src_vector_face_access) const
5524 internal::MFWorker<MatrixFree<dim, Number, VectorizedArrayType>,
5535 inner_face_operation,
5536 boundary_face_operation,
5537 src_vector_face_access,
5538 dst_vector_face_access,
5539 operation_before_loop,
5540 operation_after_loop,
5541 dof_handler_index_pre_post);
5547template <
int dim,
typename Number,
typename VectorizedArrayType>
5548template <
typename CLASS,
typename OutVector,
typename InVector>
5551 void (CLASS::*function_pointer)(
5552 const
MatrixFree<dim, Number, VectorizedArrayType> &,
5555 const
std::pair<unsigned
int, unsigned
int> &) const,
5556 const CLASS *owning_class,
5558 const InVector &src,
5559 const
bool zero_dst_vector,
5560 const DataAccessOnFaces src_vector_face_access) const
5562 auto src_vector_face_access_temp = src_vector_face_access;
5568 internal::MFWorker<MatrixFree<dim, Number, VectorizedArrayType>,
5581 src_vector_face_access_temp,
5588template <
int dim,
typename Number,
typename VectorizedArrayType>
5589template <
typename CLASS,
typename OutVector,
typename InVector>
5592 void (CLASS::*function_pointer)(
5593 const
MatrixFree<dim, Number, VectorizedArrayType> &,
5596 const
std::pair<unsigned
int, unsigned
int> &),
5597 CLASS *owning_class,
5599 const InVector &src,
5600 const
bool zero_dst_vector,
5601 const DataAccessOnFaces src_vector_face_access) const
5603 auto src_vector_face_access_temp = src_vector_face_access;
5609 internal::MFWorker<MatrixFree<dim, Number, VectorizedArrayType>,
5622 src_vector_face_access_temp,
5629template <
int dim,
typename Number,
typename VectorizedArrayType>
5630template <
typename OutVector,
typename InVector>
5636 const std::pair<unsigned int, unsigned int> &)>
5639 const InVector &src,
5640 const bool zero_dst_vector,
5641 const DataAccessOnFaces src_vector_face_access)
const
5643 auto src_vector_face_access_temp = src_vector_face_access;
5644 if (DataAccessOnFaces::gradients == src_vector_face_access_temp)
5645 src_vector_face_access_temp = DataAccessOnFaces::gradients_all_faces;
5646 else if (DataAccessOnFaces::values == src_vector_face_access_temp)
5647 src_vector_face_access_temp = DataAccessOnFaces::values_all_faces;
5650 internal::MFClassWrapper<MatrixFree<dim, Number, VectorizedArrayType>,
5653 Wrapper wrap(cell_operation,
nullptr,
nullptr);
5655 internal::MFWorker<MatrixFree<dim, Number, VectorizedArrayType>,
5665 &Wrapper::cell_integrator,
5666 &Wrapper::face_integrator,
5667 &Wrapper::boundary_integrator,
5668 src_vector_face_access_temp,
5669 DataAccessOnFaces::none);
5670 task_info.loop(worker);
void resize(const size_type new_size)
void reinit(const size_type size, const bool omit_zeroing_entries=false)
Abstract base class for mapping classes.
unsigned int n_active_fe_indices() const
std::pair< typename DoFHandler< dim >::cell_iterator, unsigned int > get_face_iterator(const unsigned int face_batch_index, const unsigned int lane_index, const bool interior=true, const unsigned int fe_component=0) const
void loop_cell_centric(void(CLASS::*cell_operation)(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &), CLASS *owning_class, OutVector &dst, const InVector &src, const bool zero_dst_vector=false, const DataAccessOnFaces src_vector_face_access=DataAccessOnFaces::unspecified) const
internal::MatrixFreeFunctions::MappingInfo< dim, Number, VectorizedArrayType > mapping_info
unsigned int get_cell_active_fe_index(const std::pair< unsigned int, unsigned int > range) const
const internal::MatrixFreeFunctions::TaskInfo & get_task_info() const
unsigned int n_ghost_cell_batches() const
void initialize_dof_handlers(const std::vector< const DoFHandler< dim, dim > * > &dof_handlers, const AdditionalData &additional_data)
types::boundary_id get_boundary_id(const unsigned int face_batch_index) const
void print(std::ostream &out) const
void update_mapping(const std::shared_ptr< hp::MappingCollection< dim > > &mapping)
const Table< 3, unsigned int > & get_cell_and_face_to_plain_faces() const
unsigned int n_inner_face_batches() const
unsigned int n_active_entries_per_cell_batch(const unsigned int cell_batch_index) const
void update_mapping(const Mapping< dim > &mapping)
const Quadrature< dim > & get_quadrature(const unsigned int quad_index=0, const unsigned int hp_active_fe_index=0) const
const internal::MatrixFreeFunctions::FaceToCellTopology< VectorizedArrayType::size()> & get_face_info(const unsigned int face_batch_index) const
unsigned int get_mg_level() const
void loop(void(CLASS::*cell_operation)(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &) const, void(CLASS::*inner_face_operation)(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &) const, void(CLASS::*boundary_face_operation)(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &) const, const CLASS *owning_class, OutVector &dst, const InVector &src, const std::function< void(const unsigned int, const unsigned int)> &operation_before_loop, const std::function< void(const unsigned int, const unsigned int)> &operation_after_loop, const unsigned int dof_handler_index_pre_post=0, const DataAccessOnFaces dst_vector_face_access=DataAccessOnFaces::unspecified, const DataAccessOnFaces src_vector_face_access=DataAccessOnFaces::unspecified) const
void print_memory_consumption(StreamType &out) const
bool mapping_initialized() const
void cell_loop(const std::function< void(const MatrixFree< dim, Number, VectorizedArrayType > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &)> &cell_operation, OutVector &dst, const InVector &src, const std::function< void(const unsigned int, const unsigned int)> &operation_before_loop, const std::function< void(const unsigned int, const unsigned int)> &operation_after_loop, const unsigned int dof_handler_index_pre_post=0) const
void internal_reinit(const std::shared_ptr< hp::MappingCollection< dim > > &mapping, const std::vector< const DoFHandler< dim, dim > * > &dof_handlers, const std::vector< const AffineConstraints< number2 > * > &constraint, const std::vector< IndexSet > &locally_owned_set, const std::vector< hp::QCollection< q_dim > > &quad, const AdditionalData &additional_data)
unsigned int get_n_q_points_face(const unsigned int quad_index=0, const unsigned int hp_active_fe_index=0) const
void loop(const std::function< void(const MatrixFree< dim, Number, VectorizedArrayType > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &)> &cell_operation, const std::function< void(const MatrixFree< dim, Number, VectorizedArrayType > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &)> &inner_face_operation, const std::function< void(const MatrixFree< dim, Number, VectorizedArrayType > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &)> &boundary_face_operation, OutVector &dst, const InVector &src, const std::function< void(const unsigned int, const unsigned int)> &operation_before_loop, const std::function< void(const unsigned int, const unsigned int)> &operation_after_loop, const unsigned int dof_handler_index_pre_post=0, const DataAccessOnFaces dst_vector_face_access=DataAccessOnFaces::unspecified, const DataAccessOnFaces src_vector_face_access=DataAccessOnFaces::unspecified) const
const internal::MatrixFreeFunctions::DoFInfo & get_dof_info(const unsigned int dof_handler_index_component=0) const
AlignedVector< VectorizedArrayType > * acquire_scratch_data() const
bool at_irregular_cell(const unsigned int cell_batch_index) const
~MatrixFree() override=default
const AffineConstraints< Number > & get_affine_constraints(const unsigned int dof_handler_index=0) const
void copy_from(const MatrixFree< dim, Number, VectorizedArrayType > &matrix_free_base)
void initialize_face_data_vector(AlignedVector< T > &vec) const
unsigned int get_dofs_per_cell(const unsigned int dof_handler_index=0, const unsigned int hp_active_fe_index=0) const
unsigned int n_constraint_pool_entries() const
void cell_loop(void(CLASS::*cell_operation)(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &), CLASS *owning_class, OutVector &dst, const InVector &src, const std::function< void(const unsigned int, const unsigned int)> &operation_before_loop, const std::function< void(const unsigned int, const unsigned int)> &operation_after_loop, const unsigned int dof_handler_index_pre_post=0) const
const Number * constraint_pool_begin(const unsigned int pool_index) const
AlignedVector< Number > * acquire_scratch_data_non_threadsafe() const
const IndexSet & get_locally_owned_set(const unsigned int dof_handler_index=0) const
unsigned int get_dofs_per_face(const unsigned int dof_handler_index=0, const unsigned int hp_active_fe_index=0) const
internal::MatrixFreeFunctions::TaskInfo task_info
const DoFHandler< dim > & get_dof_handler(const unsigned int dof_handler_index=0) const
void release_scratch_data(const AlignedVector< VectorizedArrayType > *memory) const
std::vector< ObserverPointer< const DoFHandler< dim > > > dof_handlers
void loop(void(CLASS::*cell_operation)(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &) const, void(CLASS::*inner_face_operation)(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &) const, void(CLASS::*boundary_face_operation)(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &) const, const CLASS *owning_class, OutVector &dst, const InVector &src, const bool zero_dst_vector=false, const DataAccessOnFaces dst_vector_face_access=DataAccessOnFaces::unspecified, const DataAccessOnFaces src_vector_face_access=DataAccessOnFaces::unspecified) const
unsigned int first_hp_dof_handler_index
bool mapping_is_initialized
void loop_cell_centric(void(CLASS::*cell_operation)(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &) const, const CLASS *owning_class, OutVector &dst, const InVector &src, const bool zero_dst_vector=false, const DataAccessOnFaces src_vector_face_access=DataAccessOnFaces::unspecified) const
void initialize_dof_vector(LinearAlgebra::distributed::Vector< Number2 > &vec, const unsigned int dof_handler_index=0) const
DoFHandler< dim >::cell_iterator get_cell_iterator(const unsigned int cell_batch_index, const unsigned int lane_index, const unsigned int dof_handler_index=0) const
MatrixFree(const MatrixFree< dim, Number, VectorizedArrayType > &other)
std::pair< unsigned int, unsigned int > create_cell_subrange_hp(const std::pair< unsigned int, unsigned int > &range, const unsigned int fe_degree, const unsigned int dof_handler_index=0) const
std::pair< unsigned int, unsigned int > create_cell_subrange_hp_by_index(const std::pair< unsigned int, unsigned int > &range, const unsigned int fe_index, const unsigned int dof_handler_index=0) const
std::pair< unsigned int, unsigned int > get_face_range_category(const std::pair< unsigned int, unsigned int > face_batch_range) const
void cell_loop(void(CLASS::*cell_operation)(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &) const, const CLASS *owning_class, OutVector &dst, const InVector &src, const std::function< void(const unsigned int, const unsigned int)> &operation_before_loop, const std::function< void(const unsigned int, const unsigned int)> &operation_after_loop, const unsigned int dof_handler_index_pre_post=0) const
std::vector< std::pair< unsigned int, unsigned int > > cell_level_index
const std::shared_ptr< const Utilities::MPI::Partitioner > & get_vector_partitioner(const unsigned int dof_handler_index=0) const
std::vector< ObserverPointer< const AffineConstraints< Number > > > affine_constraints
const internal::MatrixFreeFunctions::MappingInfo< dim, Number, VectorizedArrayType > & get_mapping_info() const
std::vector< Number > constraint_pool_data
VectorizedArrayType vectorized_value_type
unsigned int n_cell_batches() const
const IndexSet & get_ghost_set(const unsigned int dof_handler_index=0) const
std::pair< int, int > get_cell_level_and_index(const unsigned int cell_batch_index, const unsigned int lane_index) const
bool indices_initialized() const
const Quadrature< dim - 1 > & get_face_quadrature(const unsigned int quad_index=0, const unsigned int hp_active_fe_index=0) const
unsigned int get_cell_category(const unsigned int cell_batch_index) const
Threads::ThreadLocalStorage< std::list< std::pair< bool, AlignedVector< VectorizedArrayType > > > > scratch_pad
unsigned int get_matrix_free_cell_index(const typename Triangulation< dim >::cell_iterator &cell) const
std::size_t memory_consumption() const
std::pair< unsigned int, unsigned int > get_face_category(const unsigned int face_batch_index) const
unsigned int n_boundary_face_batches() const
void cell_loop(void(CLASS::*cell_operation)(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &) const, const CLASS *owning_class, OutVector &dst, const InVector &src, const bool zero_dst_vector=false) const
void loop(void(CLASS::*cell_operation)(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &), void(CLASS::*inner_face_operation)(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &), void(CLASS::*boundary_face_operation)(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &), const CLASS *owning_class, OutVector &dst, const InVector &src, const std::function< void(const unsigned int, const unsigned int)> &operation_before_loop, const std::function< void(const unsigned int, const unsigned int)> &operation_after_loop, const unsigned int dof_handler_index_pre_post=0, const DataAccessOnFaces dst_vector_face_access=DataAccessOnFaces::unspecified, const DataAccessOnFaces src_vector_face_access=DataAccessOnFaces::unspecified) const
std::list< std::pair< bool, AlignedVector< Number > > > scratch_pad_non_threadsafe
const Number * constraint_pool_end(const unsigned int pool_index) const
void loop_cell_centric(const std::function< void(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &)> &cell_operation, OutVector &dst, const InVector &src, const bool zero_dst_vector=false, const DataAccessOnFaces src_vector_face_access=DataAccessOnFaces::unspecified) const
void loop(const std::function< void(const MatrixFree< dim, Number, VectorizedArrayType > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &)> &cell_operation, const std::function< void(const MatrixFree< dim, Number, VectorizedArrayType > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &)> &inner_face_operation, const std::function< void(const MatrixFree< dim, Number, VectorizedArrayType > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &)> &boundary_face_operation, OutVector &dst, const InVector &src, const bool zero_dst_vector=false, const DataAccessOnFaces dst_vector_face_access=DataAccessOnFaces::unspecified, const DataAccessOnFaces src_vector_face_access=DataAccessOnFaces::unspecified) const
void initialize_indices(const std::vector< const AffineConstraints< number2 > * > &constraint, const std::vector< IndexSet > &locally_owned_set, const AdditionalData &additional_data)
unsigned int n_components() const
unsigned int n_physical_cells() const
void initialize_dof_vector(VectorType &vec, const unsigned int dof_handler_index=0) const
unsigned int get_n_q_points(const unsigned int quad_index=0, const unsigned int hp_active_fe_index=0) const
void reinit(const MappingType &mapping, const std::vector< const DoFHandler< dim > * > &dof_handler, const std::vector< const AffineConstraints< number2 > * > &constraint, const QuadratureType &quad, const AdditionalData &additional_data=AdditionalData())
std::vector< unsigned int > mf_cell_indices
void cell_loop(const std::function< void(const MatrixFree< dim, Number, VectorizedArrayType > &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &)> &cell_operation, OutVector &dst, const InVector &src, const bool zero_dst_vector=false) const
void loop(void(CLASS::*cell_operation)(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &), void(CLASS::*inner_face_operation)(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &), void(CLASS::*boundary_face_operation)(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &), CLASS *owning_class, OutVector &dst, const InVector &src, const bool zero_dst_vector=false, const DataAccessOnFaces dst_vector_face_access=DataAccessOnFaces::unspecified, const DataAccessOnFaces src_vector_face_access=DataAccessOnFaces::unspecified) const
void cell_loop(void(CLASS::*cell_operation)(const MatrixFree &, OutVector &, const InVector &, const std::pair< unsigned int, unsigned int > &), CLASS *owning_class, OutVector &dst, const InVector &src, const bool zero_dst_vector=false) const
std::vector< internal::MatrixFreeFunctions::DoFInfo > dof_info
void initialize_cell_data_vector(AlignedVector< T > &vec) const
unsigned int n_ghost_inner_face_batches() const
void release_scratch_data_non_threadsafe(const AlignedVector< Number > *memory) const
void renumber_dofs(std::vector< types::global_dof_index > &renumbering, const unsigned int dof_handler_index=0)
unsigned int get_face_active_fe_index(const std::pair< unsigned int, unsigned int > range, const bool is_interior_face=true) const
unsigned int n_active_entries_per_face_batch(const unsigned int face_batch_index) const
bool indices_are_initialized
internal::MatrixFreeFunctions::FaceInfo< VectorizedArrayType::size()> face_info
void reinit(const MappingType &mapping, const DoFHandler< dim > &dof_handler, const AffineConstraints< number2 > &constraint, const QuadratureType &quad, const AdditionalData &additional_data=AdditionalData())
unsigned int get_cell_range_category(const std::pair< unsigned int, unsigned int > cell_batch_range) const
void reinit(const MappingType &mapping, const std::vector< const DoFHandler< dim > * > &dof_handler, const std::vector< const AffineConstraints< number2 > * > &constraint, const std::vector< QuadratureType > &quad, const AdditionalData &additional_data=AdditionalData())
std::array< types::boundary_id, VectorizedArrayType::size()> get_faces_by_cells_boundary_id(const unsigned int cell_batch_index, const unsigned int face_number) const
std::vector< unsigned int > constraint_pool_row_index
const internal::MatrixFreeFunctions::ShapeInfo< Number > & get_shape_info(const unsigned int dof_handler_index_component=0, const unsigned int quad_index=0, const unsigned int fe_base_element=0, const unsigned int hp_active_fe_index=0, const unsigned int hp_active_quad_index=0) const
const std::vector< unsigned int > & get_constrained_dofs(const unsigned int dof_handler_index=0) const
unsigned int cell_level_index_end_local
unsigned int n_base_elements(const unsigned int dof_handler_index) const
Table< 4, internal::MatrixFreeFunctions::ShapeInfo< Number > > shape_info
static bool is_supported(const FiniteElement< dim, spacedim > &fe)
static constexpr unsigned int dimension
A class that provides a separate storage location on each thread that accesses the object.
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
#define AssertThrowMPI(error_code)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcIndexRange(std::size_t arg1, std::size_t arg2, std::size_t arg3)
static ::ExceptionBase & ExcNotInitialized()
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
typename ActiveSelector::cell_iterator cell_iterator
@ update_JxW_values
Transformed quadrature weights.
@ update_gradients
Shape function gradients.
@ update_default
No update.
std::vector< index_type > data
Tpetra::Vector< Number, LO, GO, NodeType< MemorySpace > > VectorType
VectorType::value_type * begin(VectorType &V)
unsigned int minimum_parallel_grain_size
const types::boundary_id invalid_boundary_id
static const unsigned int invalid_unsigned_int
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 > &)
unsigned short int fe_index
TasksParallelScheme tasks_parallel_scheme
bool hold_all_faces_to_owned_cells
UpdateFlags mapping_update_flags_inner_faces
AdditionalData(const TasksParallelScheme tasks_parallel_scheme=partition_partition, const unsigned int tasks_block_size=0, const UpdateFlags mapping_update_flags=update_gradients|update_JxW_values, const UpdateFlags mapping_update_flags_boundary_faces=update_default, const UpdateFlags mapping_update_flags_inner_faces=update_default, const UpdateFlags mapping_update_flags_faces_by_cells=update_default, const unsigned int mg_level=numbers::invalid_unsigned_int, const bool store_plain_indices=true, const bool initialize_indices=true, const bool initialize_mapping=true, const bool overlap_communication_computation=true, const bool hold_all_faces_to_owned_cells=false, const bool cell_vectorization_categories_strict=false, const bool allow_ghosted_vectors_in_loops=true)
std::vector< unsigned int > cell_vectorization_category
AdditionalData & operator=(const AdditionalData &other)
bool cell_vectorization_categories_strict
UpdateFlags mapping_update_flags_boundary_faces
UpdateFlags mapping_update_flags
UpdateFlags mapping_update_flags_faces_by_cells
AdditionalData(const AdditionalData &other)
bool allow_ghosted_vectors_in_loops
unsigned int tasks_block_size
bool overlap_communication_computation
@ dof_access_face_interior
std::vector< unsigned int > cell_loop_pre_list_index
std::vector< unsigned int > cell_loop_post_list_index
std::vector< std::pair< unsigned int, unsigned int > > vector_zero_range_list
std::shared_ptr< const Utilities::MPI::Partitioner > vector_partitioner
std::vector< std::pair< unsigned int, unsigned int > > cell_loop_pre_list
std::vector< unsigned int > vector_zero_range_list_index
std::vector< std::pair< unsigned int, unsigned int > > cell_loop_post_list
void loop(MFWorkerInterface &worker) const