deal.II version GIT relicensing-6960-g70e9c5b7be 2026-10-22 20:10:01+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
portable_matrix_free.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2017 - 2026 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13
14#ifndef dealii_portable_matrix_free_h
15#define dealii_portable_matrix_free_h
16
17#include <deal.II/base/config.h>
18
24#include <deal.II/base/tensor.h>
26
28
30#include <deal.II/fe/mapping.h>
31
33
36
39
40#include <Kokkos_Array.hpp>
41#include <Kokkos_Core.hpp>
42
43
44
46
47// Forward declaration
48namespace internal
49{
50 namespace MatrixFreeFunctions
51 {
52 enum class ConstraintKinds : std::uint16_t;
53 }
54} // namespace internal
55
56namespace Portable
57{
58 // forward declaration
59#ifndef DOXYGEN
60 namespace internal
61 {
62 template <int dim, typename Number>
63 class ReinitHelper;
64 }
65 template <int dim, typename Number>
66 struct SharedData;
67#endif
68
75 inline constexpr unsigned int n_max_dof_handlers = 5;
76
84 template <typename Number>
86 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>;
87
94 template <typename Number>
96 {
97 public:
102 : n_blocks(0)
103 {}
104
108 DeviceBlockVector(const DeviceBlockVector &other) = default;
109
115 : n_blocks(1)
116 , blocks{src}
117 {}
118
123 template <typename MemorySpace>
126 : n_blocks(src.n_blocks())
127 {
129 ExcMessage("Portable::MatrixFree is configured with " +
131 " but you are passing a BlockVector with " +
132 Utilities::to_string(src.n_blocks()) + " blocks."));
133
134 for (int b = 0; b < src.n_blocks(); ++b)
135 blocks[b] = DeviceVector<Number>(src.block(b).get_values(),
136 src.block(b).locally_owned_size());
137 }
138
144 block(unsigned int index)
145 {
147 return blocks[index];
148 }
149
154 block(unsigned int index) const
155 {
157 return blocks[index];
158 }
159
160 private:
164 unsigned int n_blocks;
165
169 Kokkos::Array<DeviceVector<Number>, n_max_dof_handlers> blocks;
170 };
171
196 template <int dim, typename Number = double>
198 {
199 public:
206
268
269
270
277 {
281 Kokkos::View<point_type **, MemorySpace::Default::kokkos_space> q_points;
282
287 Kokkos::View<types::global_dof_index **,
290
298 Kokkos::View<Number *[dim][dim], MemorySpace::Default::kokkos_space>
300
311 Kokkos::View<Number *, MemorySpace::Default::kokkos_space> JxW;
312
319
324 Kokkos::View<unsigned int *, MemorySpace::Default::kokkos_space>
326
331 Kokkos::View<Number *, MemorySpace::Default::kokkos_space> q_weights;
332
339
343 Kokkos::View<Number *, MemorySpace::Default::kokkos_space> shape_values;
344
348 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
350
354 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
356
360 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
362
366 unsigned int n_cells;
367
371 unsigned int n_components;
372
380 unsigned int first_cell;
381
387
394
398 unsigned int scratch_pad_size;
399
404 DEAL_II_HOST_DEVICE unsigned int
405 inv_jacobian_index(const int cell, const int q_point) const
406 {
407 return data_index_offsets(cell) +
408 ((cell_type(cell) ==
410 q_point :
411 0);
412 }
413
419 JxW_value(const int cell, const int q_point) const
420 {
421 const unsigned int offset = data_index_offsets(cell);
422 return (cell_type(cell) ==
424 JxW(offset + q_point) :
425 JxW(offset) * q_weights(q_point);
426 }
427 };
428
429
437 struct Data
438 {
439 using TeamHandle = Kokkos::TeamPolicy<
440 MemorySpace::Default::kokkos_space::execution_space>::member_type;
441
446
447 const unsigned int n_q_points;
448 const unsigned int n_dof_handler;
449 const int cell_index;
450 const Kokkos::Array<PrecomputedData, n_max_dof_handlers>
452 Kokkos::Array<SharedData<dim, Number>, n_max_dof_handlers> &shared_data;
453
458 DEAL_II_HOST_DEVICE unsigned int
459 local_q_point_id(const unsigned int cell,
460 const unsigned int q_point) const
461 {
464 "The cell index is smaller than the first cell of the "
465 "current color."));
466
469
471
473 precomputed_data[0].q_points.extent(1),
474 ExcInternalError("q_points array has wrong size"));
475 Assert(n_q_points == precomputed_data[0].q_points.extent(0),
476 ExcInternalError("q_points array has wrong size"));
477
478 return cell * n_q_points + q_point;
479 }
480
481
482
488 get_quadrature_point(const unsigned int cell,
489 const unsigned int q_point) const
490 {
493 "The cell index is smaller than the first cell of the "
494 "current color."));
495 const unsigned int local_cell = cell - precomputed_data[0].first_cell;
497 precomputed_data[0].q_points.extent(1),
501 Assert(n_q_points == precomputed_data[0].q_points.extent(0),
503 return precomputed_data[0].q_points(q_point, local_cell);
504 }
505
514 template <typename Functor>
516 for_each_quad_point(const Functor &func) const
517 {
518 Kokkos::parallel_for(Kokkos::TeamThreadRange(team_member, n_q_points),
519 [&](const int &q) { func(q); });
520 team_member.team_barrier();
521 }
522 };
523
528
539 template <typename IteratorFiltersType>
540 void
541 reinit(const Mapping<dim> &mapping,
542 const DoFHandler<dim> &dof_handler,
543 const AffineConstraints<Number> &constraints,
544 const Quadrature<1> &quad,
545 const IteratorFiltersType &iterator_filter,
546 const AdditionalData &additional_data = AdditionalData());
547
551 void
552 reinit(const Mapping<dim> &mapping,
553 const DoFHandler<dim> &dof_handler,
554 const AffineConstraints<Number> &constraints,
555 const Quadrature<1> &quad,
556 const AdditionalData &additional_data = AdditionalData());
557
561 void
562 reinit(const DoFHandler<dim> &dof_handler,
563 const AffineConstraints<Number> &constraints,
564 const Quadrature<1> &quad,
565 const AdditionalData &additional_data = AdditionalData());
566
567
571 template <typename IteratorFiltersType>
572 void
573 reinit(const Mapping<dim> &mapping,
574 const std::vector<const DoFHandler<dim> *> &dof_handler,
575 const std::vector<const AffineConstraints<Number> *> &constraints,
576 const Quadrature<1> &quad,
577 const IteratorFiltersType &iterator_filter,
578 const AdditionalData &additional_data = AdditionalData());
579
583 void
584 reinit(const Mapping<dim> &mapping,
585 const std::vector<const DoFHandler<dim> *> &dof_handler,
586 const std::vector<const AffineConstraints<Number> *> &constraints,
587 const Quadrature<1> &quad,
588 const AdditionalData &additional_data = AdditionalData());
589
594 get_data(const unsigned int color,
595 const unsigned int dof_handler_index = 0) const;
596
597 // clang-format off
620 // clang-format on
621 template <typename Functor, typename VectorType>
622 void
623 cell_loop(const Functor &func,
624 const VectorType &src,
625 VectorType &dst) const;
626
644 template <typename Functor>
645 void
646 evaluate_coefficients(Functor func) const;
647
654 template <typename VectorType>
655 void
656 copy_constrained_values(const VectorType &src,
657 VectorType &dst,
658 const unsigned int dof_handler_index = 0) const;
659
668 void
673 &dst) const;
674
682 template <typename VectorType>
683 void
684 set_constrained_values(const Number value,
685 VectorType &dst,
686 const unsigned int dof_handler_index = 0) const;
687
696 template <typename MemorySpaceType>
697 void
700 const unsigned int dof_handler_index = 0) const;
701
708 template <typename MemorySpaceType>
709 void
712 const;
713
720 const std::vector<std::vector<CellFilter>> &
722
729 const std::vector<std::vector<LevelCellFilter>> &
731
742 const std::shared_ptr<const Utilities::MPI::Partitioner> &
743 get_vector_partitioner(const unsigned int dof_handler_index = 0) const;
744
748 const DoFHandler<dim> &
749 get_dof_handler(const unsigned int dof_handler_index = 0) const;
750
756 unsigned int
758
767 get_cell_iterator(const unsigned int color,
768 const unsigned int index,
769 const unsigned int dof_handler_index = 0) const;
770
774 unsigned int
775 n_cells_per_color(const unsigned int color) const;
776
782 bool
784
788 std::size_t
790
791 private:
795 template <typename IteratorFiltersType>
796 void
798 const Mapping<dim> &mapping,
799 const std::vector<const DoFHandler<dim> *> &dof_handler,
800 const std::vector<const AffineConstraints<Number> *> &constraints,
801 const Quadrature<1> &quad,
802 const IteratorFiltersType &iterator_filter,
803 const std::shared_ptr<const MPI_Comm> &comm,
804 const AdditionalData additional_data);
805
810 template <typename Functor, typename VectorType>
811 void
812 serial_cell_loop(const Functor &func,
813 const VectorType &src,
814 VectorType &dst) const;
815
820 template <typename Functor>
821 void
823 const Functor &func,
825 &src,
827 const;
828
832 template <typename Functor>
833 void
835 const Functor &func,
839 &dst) const;
840
841
845 int my_id;
846
853
859
864 unsigned int mg_level;
865
870 unsigned int team_size;
871
872
878 {
883 std::vector<
884 Kokkos::View<point_type **, MemorySpace::Default::kokkos_space>>
886
891 std::vector<
892 Kokkos::View<Number *[dim][dim], MemorySpace::Default::kokkos_space>>
894
899 std::vector<Kokkos::View<Number *, MemorySpace::Default::kokkos_space>>
901
906 std::vector<
910
916 std::vector<
917 Kokkos::View<unsigned int *, MemorySpace::Default::kokkos_space>>
919
923 Kokkos::View<Number *, MemorySpace::Default::kokkos_space> q_weights;
924 };
925
930 std::vector<MappingInfo> mapping_info;
931
935 struct DoFInfo
936 {
941
948
952 unsigned int scratch_pad_size;
953
957 unsigned int fe_degree;
958
962 unsigned int n_components;
963
968
972 unsigned int dofs_per_cell;
973
977 unsigned int n_constrained_dofs;
978
983 std::vector<Kokkos::View<types::global_dof_index **,
986
990 Kokkos::View<types::global_dof_index *,
993
997 std::vector<
1001
1005 Kokkos::View<Number *, MemorySpace::Default::kokkos_space> shape_values;
1006
1010 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
1012
1016 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
1018
1022 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
1024
1029
1034 std::shared_ptr<const Utilities::MPI::Partitioner> partitioner;
1035 };
1036
1040 std::vector<DoFInfo> dof_handler_data;
1041
1045 unsigned int q_points_per_cell;
1046
1050 unsigned int n_colors;
1051
1055 std::vector<unsigned int> n_cells;
1056
1064 std::vector<unsigned int> first_cell;
1065
1070 std::vector<std::vector<CellFilter>> graph;
1071
1076 std::vector<std::vector<LevelCellFilter>> level_graph;
1077
1078 friend class internal::ReinitHelper<dim, Number>;
1079 };
1080
1081
1082
1083 template <int dim, typename Number>
1085 {
1086 using TeamHandle = Kokkos::TeamPolicy<
1087 MemorySpace::Default::kokkos_space::execution_space>::member_type;
1088
1089 using SharedViewValues = Kokkos::View<
1090 Number **,
1091 MemorySpace::Default::kokkos_space::execution_space::scratch_memory_space,
1092 Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
1093 using SharedViewGradients = Kokkos::View<
1094 Number ***,
1095 MemorySpace::Default::kokkos_space::execution_space::scratch_memory_space,
1096 Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
1097 using SharedViewScratchPad = Kokkos::View<
1098 Number *,
1099 MemorySpace::Default::kokkos_space::execution_space::scratch_memory_space,
1100 Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
1101
1106 void
1107 reinit(const TeamHandle &team_handle,
1108 const unsigned int n_q_points,
1109 const typename MatrixFree<dim, Number>::PrecomputedData &gpu_data)
1110 {
1111 values = SharedViewValues(team_handle.team_shmem(),
1112 n_q_points,
1113 gpu_data.n_components);
1114 gradients = SharedViewGradients(team_handle.team_shmem(),
1115 n_q_points,
1116 dim,
1117 gpu_data.n_components);
1118 scratch_pad = SharedViewScratchPad(team_handle.team_shmem(),
1119 gpu_data.scratch_pad_size);
1120 }
1121
1126
1131
1136 };
1137
1138
1139
1144 template <int dim, typename Number>
1146 {
1150 typename Kokkos::View<Point<dim, Number> **,
1151 MemorySpace::Default::kokkos_space>::host_mirror_type
1153
1158 typename Kokkos::View<types::global_dof_index **,
1159 MemorySpace::Default::kokkos_space>::host_mirror_type
1161
1166 typename Kokkos::View<Number *[dim][dim],
1167 MemorySpace::Default::kokkos_space>::host_mirror_type
1169
1174 typename Kokkos::View<Number *,
1175 MemorySpace::Default::kokkos_space>::host_mirror_type
1177
1182 typename Kokkos::View<
1185
1190 typename Kokkos::View<unsigned int *,
1191 MemorySpace::Default::kokkos_space>::host_mirror_type
1193
1197 typename Kokkos::View<Number *,
1198 MemorySpace::Default::kokkos_space>::host_mirror_type
1200
1204 unsigned int n_cells;
1205
1213 unsigned int first_cell;
1214
1218 typename Kokkos::View<
1221
1227
1228
1229
1233 unsigned int
1234 local_q_point_id(const unsigned int cell,
1235 const unsigned int n_q_points,
1236 const unsigned int q_point) const
1237 {
1238 return cell * n_q_points + q_point;
1239 }
1240
1241
1242
1247 get_quadrature_point(const unsigned int cell,
1248 const unsigned int q_point) const
1249 {
1250 return q_points(q_point, cell - first_cell);
1251 }
1252
1257 unsigned int
1258 inv_jacobian_index(const unsigned int cell,
1259 const unsigned int q_point) const
1260 {
1261 return data_index_offsets(cell) +
1262 ((cell_type(cell) ==
1264 q_point :
1265 0);
1266 }
1267
1271 Number
1272 JxW_value(const unsigned int cell, const unsigned int q_point) const
1273 {
1274 const unsigned int offset = data_index_offsets(cell);
1275 return (cell_type(cell) ==
1277 JxW(offset + q_point) :
1278 JxW(offset) * q_weights(q_point);
1279 }
1280 };
1281
1282
1283
1290 template <int dim, typename Number>
1291 DataHost<dim, Number>
1293 const typename ::Portable::MatrixFree<dim, Number>::PrecomputedData
1294 &data,
1295 const UpdateFlags &update_flags)
1296 {
1297 DataHost<dim, Number> data_host;
1298
1299 data_host.n_cells = data.n_cells;
1300 data_host.first_cell = data.first_cell;
1301 data_host.use_coloring = data.use_coloring;
1302
1303 const auto create_mirror_without_initializing = [](const auto &view) {
1304#if DEAL_II_KOKKOS_VERSION_GTE(3, 6, 0)
1305 return Kokkos::create_mirror(Kokkos::WithoutInitializing, view);
1306#else
1307 return Kokkos::create_mirror(view);
1308#endif
1309 };
1310
1311 MemorySpace::Default::kokkos_space::execution_space exec;
1312
1313 if (update_flags & update_quadrature_points)
1314 {
1315 data_host.q_points = create_mirror_without_initializing(data.q_points);
1316 Kokkos::deep_copy(exec, data_host.q_points, data.q_points);
1317 }
1318
1319 data_host.local_to_global =
1320 create_mirror_without_initializing(data.local_to_global);
1321 Kokkos::deep_copy(exec, data_host.local_to_global, data.local_to_global);
1322
1323 if (update_flags & update_gradients)
1324 {
1325 data_host.inv_jacobian =
1326 create_mirror_without_initializing(data.inv_jacobian);
1327 Kokkos::deep_copy(exec, data_host.inv_jacobian, data.inv_jacobian);
1328 }
1329
1330 if (update_flags & update_JxW_values)
1331 {
1332 data_host.JxW = create_mirror_without_initializing(data.JxW);
1333 Kokkos::deep_copy(exec, data_host.JxW, data.JxW);
1334 }
1335
1336 data_host.cell_type = create_mirror_without_initializing(data.cell_type);
1337 Kokkos::deep_copy(exec, data_host.cell_type, data.cell_type);
1338
1339 data_host.data_index_offsets =
1340 create_mirror_without_initializing(data.data_index_offsets);
1341 Kokkos::deep_copy(exec,
1342 data_host.data_index_offsets,
1343 data.data_index_offsets);
1344
1345 data_host.q_weights = create_mirror_without_initializing(data.q_weights);
1346 Kokkos::deep_copy(exec, data_host.q_weights, data.q_weights);
1347
1348 data_host.constraint_mask =
1349 create_mirror_without_initializing(data.constraint_mask);
1350 Kokkos::deep_copy(exec, data_host.constraint_mask, data.constraint_mask);
1351
1352 exec.fence();
1353
1354 return data_host;
1355 }
1356
1357
1358 /*----------------------- Inline functions ---------------------------------*/
1359
1360#ifndef DOXYGEN
1361
1362 template <int dim, typename Number>
1363 inline const std::vector<std::vector<
1366 {
1369 ExcMessage(
1370 "The MatrixFree object has been initialized for a specific "
1371 "multigrid level. This function is only available when working "
1372 "on active cells."));
1373 return graph;
1374 }
1375
1376
1377
1378 template <int dim, typename Number>
1379 inline const std::vector<std::vector<
1382 {
1385 ExcMessage("The MatrixFree object has been initialized for active cells. "
1386 "This function is only available when working on a specific "
1387 "multigrid level."));
1388 return level_graph;
1389 }
1390
1391
1392
1393 template <int dim, typename Number>
1394 inline const std::shared_ptr<const Utilities::MPI::Partitioner> &
1396 const unsigned int dof_handler_index) const
1397 {
1398 Assert(dof_handler_data.size() > 0, ExcNotInitialized());
1399 AssertIndexRange(dof_handler_index, dof_handler_data.size());
1400 return dof_handler_data[dof_handler_index].partitioner;
1401 }
1402
1403
1404
1405 template <int dim, typename Number>
1406 inline unsigned int
1408 {
1409 return mg_level;
1410 }
1411
1412
1413
1414 template <int dim, typename Number>
1415 inline const DoFHandler<dim> &
1417 const unsigned int dof_handler_index) const
1418 {
1419 Assert(dof_handler_data.size() > 0, ExcNotInitialized());
1420 AssertIndexRange(dof_handler_index, dof_handler_data.size());
1421
1422 return *dof_handler_data[dof_handler_index].dof_handler;
1423 }
1424
1425
1426 template <int dim, typename Number>
1429 const unsigned int color,
1430 const unsigned int index,
1431 const unsigned int dof_handler_index) const
1432 {
1433 if (mg_level == numbers::invalid_unsigned_int)
1434 {
1435 AssertIndexRange(color, get_colored_graph().size());
1436 AssertIndexRange(index, get_colored_graph()[color].size());
1437
1438 const unsigned int cell_level =
1439 get_colored_graph()[color][index]->level();
1440
1441 const unsigned int cell_index =
1442 get_colored_graph()[color][index]->index();
1443
1444 return typename DoFHandler<dim>::cell_iterator(
1445 &(get_dof_handler(dof_handler_index).get_triangulation()),
1446 cell_level,
1447 cell_index,
1448 &get_dof_handler(dof_handler_index));
1449 }
1450 else
1451 {
1452 AssertIndexRange(color, get_colored_level_graph().size());
1453 AssertIndexRange(index, get_colored_level_graph()[color].size());
1454
1455 const unsigned int cell_level =
1456 get_colored_level_graph()[color][index]->level();
1457
1458 const unsigned int cell_index =
1459 get_colored_level_graph()[color][index]->index();
1460
1461 return typename DoFHandler<dim>::cell_iterator(
1462 &(get_dof_handler(dof_handler_index).get_triangulation()),
1463 cell_level,
1464 cell_index,
1465 &get_dof_handler(dof_handler_index));
1466 }
1467 }
1468
1469
1470
1471 template <int dim, typename Number>
1472 inline unsigned int
1473 MatrixFree<dim, Number>::n_cells_per_color(const unsigned int color) const
1474 {
1475 AssertIndexRange(color, n_cells.size());
1476 return n_cells[color];
1477 }
1478
1479
1480
1481 template <int dim, typename Number>
1482 inline bool
1484 {
1485 return overlap_communication_computation;
1486 }
1487
1488#endif
1489
1490} // namespace Portable
1491
1493
1494#endif
unsigned int n_blocks() const
BlockType & block(const unsigned int i)
Abstract base class for mapping classes.
Definition mapping.h:318
DeviceBlockVector(const DeviceBlockVector &other)=default
Kokkos::Array< DeviceVector< Number >, n_max_dof_handlers > blocks
const DeviceVector< Number > & block(unsigned int index) const
DeviceBlockVector(const DeviceVector< Number > &src)
DeviceVector< Number > & block(unsigned int index)
DeviceBlockVector(const LinearAlgebra::distributed::BlockVector< Number, MemorySpace > &src)
void copy_constrained_values(const VectorType &src, VectorType &dst, const unsigned int dof_handler_index=0) const
const std::vector< std::vector< CellFilter > > & get_colored_graph() const
unsigned int get_mg_level() const
void copy_constrained_values(const LinearAlgebra::distributed::BlockVector< Number, MemorySpace::Default > &src, LinearAlgebra::distributed::BlockVector< Number, MemorySpace::Default > &dst) const
std::vector< std::vector< CellFilter > > graph
void reinit(const DoFHandler< dim > &dof_handler, const AffineConstraints< Number > &constraints, const Quadrature< 1 > &quad, const AdditionalData &additional_data=AdditionalData())
void reinit(const Mapping< dim > &mapping, const std::vector< const DoFHandler< dim > * > &dof_handler, const std::vector< const AffineConstraints< Number > * > &constraints, const Quadrature< 1 > &quad, const IteratorFiltersType &iterator_filter, const AdditionalData &additional_data=AdditionalData())
DoFHandler< dim >::cell_iterator get_cell_iterator(const unsigned int color, const unsigned int index, const unsigned int dof_handler_index=0) const
void reinit(const Mapping< dim > &mapping, const DoFHandler< dim > &dof_handler, const AffineConstraints< Number > &constraints, const Quadrature< 1 > &quad, const IteratorFiltersType &iterator_filter, const AdditionalData &additional_data=AdditionalData())
std::vector< std::vector< LevelCellFilter > > level_graph
bool use_overlap_communication_computation() const
PrecomputedData get_data(const unsigned int color, const unsigned int dof_handler_index=0) const
void distributed_cell_loop(const Functor &func, const LinearAlgebra::distributed::Vector< Number, MemorySpace::Default > &src, LinearAlgebra::distributed::Vector< Number, MemorySpace::Default > &dst) const
std::size_t memory_consumption() const
void initialize_dof_vector(LinearAlgebra::distributed::Vector< Number, MemorySpaceType > &vec, const unsigned int dof_handler_index=0) const
void distributed_cell_loop(const Functor &func, const LinearAlgebra::distributed::BlockVector< Number, MemorySpace::Default > &src, LinearAlgebra::distributed::BlockVector< Number, MemorySpace::Default > &dst) const
std::vector< unsigned int > first_cell
void serial_cell_loop(const Functor &func, const VectorType &src, VectorType &dst) const
void initialize_dof_vector(LinearAlgebra::distributed::BlockVector< Number, MemorySpaceType > &vec) const
const std::shared_ptr< const Utilities::MPI::Partitioner > & get_vector_partitioner(const unsigned int dof_handler_index=0) const
void evaluate_coefficients(Functor func) const
std::vector< DoFInfo > dof_handler_data
DataHost< dim, Number > copy_mf_data_to_host(const typename::Portable::MatrixFree< dim, Number >::PrecomputedData &data, const UpdateFlags &update_flags)
const DoFHandler< dim > & get_dof_handler(const unsigned int dof_handler_index=0) const
void reinit(const Mapping< dim > &mapping, const std::vector< const DoFHandler< dim > * > &dof_handler, const std::vector< const AffineConstraints< Number > * > &constraints, const Quadrature< 1 > &quad, const AdditionalData &additional_data=AdditionalData())
void internal_reinit(const Mapping< dim > &mapping, const std::vector< const DoFHandler< dim > * > &dof_handler, const std::vector< const AffineConstraints< Number > * > &constraints, const Quadrature< 1 > &quad, const IteratorFiltersType &iterator_filter, const std::shared_ptr< const MPI_Comm > &comm, const AdditionalData additional_data)
void set_constrained_values(const Number value, VectorType &dst, const unsigned int dof_handler_index=0) const
std::vector< MappingInfo > mapping_info
void reinit(const Mapping< dim > &mapping, const DoFHandler< dim > &dof_handler, const AffineConstraints< Number > &constraints, const Quadrature< 1 > &quad, const AdditionalData &additional_data=AdditionalData())
unsigned int n_cells_per_color(const unsigned int color) const
std::vector< unsigned int > n_cells
const std::vector< std::vector< LevelCellFilter > > & get_colored_level_graph() const
void cell_loop(const Functor &func, const VectorType &src, VectorType &dst) const
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_HOST_DEVICE
Definition config.h:171
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
unsigned int cell_index
#define Assert(cond, exc)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcNotInitialized()
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
typename ActiveSelector::cell_iterator cell_iterator
UpdateFlags
@ update_JxW_values
Transformed quadrature weights.
@ update_gradients
Shape function gradients.
@ update_quadrature_points
Transformed quadrature points.
std::vector< index_type > data
Definition mpi.cc:734
std::size_t size
Definition mpi.cc:733
const MPI_Comm comm
Definition mpi.cc:912
constexpr unsigned int n_max_dof_handlers
Kokkos::View< Number *, MemorySpace::Default::kokkos_space > DeviceVector
std::string to_string(const number value, const unsigned int digits=numbers::invalid_unsigned_int)
Definition utilities.cc:473
unsigned int n_cells(const internal::TriangulationImplementation::NumberCache< 1 > &c)
Definition tria.cc:15808
constexpr unsigned int invalid_unsigned_int
Definition types.h:228
::Kokkos::DefaultExecutionSpace::memory_space kokkos_space
Kokkos::View<::internal::MatrixFreeFunctions::ConstraintKinds *, MemorySpace::Default::kokkos_space >::host_mirror_type constraint_mask
Kokkos::View< Number *, MemorySpace::Default::kokkos_space >::host_mirror_type q_weights
Kokkos::View< types::global_dof_index **, MemorySpace::Default::kokkos_space >::host_mirror_type local_to_global
Kokkos::View< unsignedint *, MemorySpace::Default::kokkos_space >::host_mirror_type data_index_offsets
Kokkos::View< Number *, MemorySpace::Default::kokkos_space >::host_mirror_type JxW
Point< dim, Number > get_quadrature_point(const unsigned int cell, const unsigned int q_point) const
Kokkos::View<::internal::MatrixFreeFunctions::GeometryType *, MemorySpace::Default::kokkos_space >::host_mirror_type cell_type
Kokkos::View< Point< dim, Number > **, MemorySpace::Default::kokkos_space >::host_mirror_type q_points
Kokkos::View< Number *[dim][dim], MemorySpace::Default::kokkos_space >::host_mirror_type inv_jacobian
unsigned int inv_jacobian_index(const unsigned int cell, const unsigned int q_point) const
Number JxW_value(const unsigned int cell, const unsigned int q_point) const
unsigned int local_q_point_id(const unsigned int cell, const unsigned int n_q_points, const unsigned int q_point) const
AdditionalData(const UpdateFlags mapping_update_flags=update_gradients|update_JxW_values|update_quadrature_points, const bool use_coloring=false, const bool overlap_communication_computation=false, const unsigned int mg_level=numbers::invalid_unsigned_int, const unsigned int team_size=numbers::invalid_unsigned_int)
unsigned int local_q_point_id(const unsigned int cell, const unsigned int q_point) const
Kokkos::Array< SharedData< dim, Number >, n_max_dof_handlers > & shared_data
void for_each_quad_point(const Functor &func) const
Kokkos::TeamPolicy< MemorySpace::Default::kokkos_space::execution_space >::member_type TeamHandle
const Kokkos::Array< PrecomputedData, n_max_dof_handlers > & precomputed_data
Portable::MatrixFree< dim, Number >::point_type & get_quadrature_point(const unsigned int cell, const unsigned int q_point) const
::internal::MatrixFreeFunctions::ElementType element_type
std::shared_ptr< const Utilities::MPI::Partitioner > partitioner
std::vector< Kokkos::View<::internal::MatrixFreeFunctions::ConstraintKinds *, MemorySpace::Default::kokkos_space > > constraint_mask
Kokkos::View< Number *, MemorySpace::Default::kokkos_space > shape_gradients
std::vector< Kokkos::View< types::global_dof_index **, MemorySpace::Default::kokkos_space > > local_to_global
const DoFHandler< dim > * dof_handler
Kokkos::View< Number *, MemorySpace::Default::kokkos_space > constraint_weights
Kokkos::View< Number *, MemorySpace::Default::kokkos_space > co_shape_gradients
Kokkos::View< Number *, MemorySpace::Default::kokkos_space > shape_values
Kokkos::View< types::global_dof_index *, MemorySpace::Default::kokkos_space > constrained_dofs
std::vector< Kokkos::View<::internal::MatrixFreeFunctions::GeometryType *, MemorySpace::Default::kokkos_space > > cell_type
Kokkos::View< Number *, MemorySpace::Default::kokkos_space > q_weights
std::vector< Kokkos::View< Number *[dim][dim], MemorySpace::Default::kokkos_space > > inv_jacobian
std::vector< Kokkos::View< unsigned int *, MemorySpace::Default::kokkos_space > > data_index_offsets
std::vector< Kokkos::View< Number *, MemorySpace::Default::kokkos_space > > JxW
std::vector< Kokkos::View< point_type **, MemorySpace::Default::kokkos_space > > q_points
Kokkos::View< Number *, MemorySpace::Default::kokkos_space > shape_gradients
Kokkos::View< point_type **, MemorySpace::Default::kokkos_space > q_points
Number JxW_value(const int cell, const int q_point) const
Kokkos::View< Number *, MemorySpace::Default::kokkos_space > shape_values
Kokkos::View< Number *, MemorySpace::Default::kokkos_space > JxW
Kokkos::View< Number *, MemorySpace::Default::kokkos_space > constraint_weights
Kokkos::View<::internal::MatrixFreeFunctions::GeometryType *, MemorySpace::Default::kokkos_space > cell_type
Kokkos::View< Number *, MemorySpace::Default::kokkos_space > co_shape_gradients
Kokkos::View< Number *, MemorySpace::Default::kokkos_space > q_weights
::internal::MatrixFreeFunctions::ElementType element_type
unsigned int inv_jacobian_index(const int cell, const int q_point) const
Kokkos::View<::internal::MatrixFreeFunctions::ConstraintKinds *, MemorySpace::Default::kokkos_space > constraint_mask
Kokkos::View< Number *[dim][dim], MemorySpace::Default::kokkos_space > inv_jacobian
Kokkos::View< unsigned int *, MemorySpace::Default::kokkos_space > data_index_offsets
Kokkos::View< types::global_dof_index **, MemorySpace::Default::kokkos_space > local_to_global
Kokkos::View< Number ***, MemorySpace::Default::kokkos_space::execution_space::scratch_memory_space, Kokkos::MemoryTraits< Kokkos::Unmanaged > > SharedViewGradients
SharedViewScratchPad scratch_pad
Kokkos::View< Number *, MemorySpace::Default::kokkos_space::execution_space::scratch_memory_space, Kokkos::MemoryTraits< Kokkos::Unmanaged > > SharedViewScratchPad
void reinit(const TeamHandle &team_handle, const unsigned int n_q_points, const typename MatrixFree< dim, Number >::PrecomputedData &gpu_data)
Kokkos::TeamPolicy< MemorySpace::Default::kokkos_space::execution_space >::member_type TeamHandle
Kokkos::View< Number **, MemorySpace::Default::kokkos_space::execution_space::scratch_memory_space, Kokkos::MemoryTraits< Kokkos::Unmanaged > > SharedViewValues
SharedViewGradients gradients