deal.II version GIT relicensing-6834-g5b78e6bcdf 2026-10-01 11:20:01+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
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
376 unsigned int padding_length;
377
381 unsigned int row_start;
382
388
395
399 unsigned int scratch_pad_size;
400
405 DEAL_II_HOST_DEVICE unsigned int
406 inv_jacobian_index(const int cell, const int q_point) const
407 {
408 return data_index_offsets(cell) +
409 ((cell_type(cell) ==
411 q_point :
412 0);
413 }
414
420 JxW_value(const int cell, const int q_point) const
421 {
422 const unsigned int offset = data_index_offsets(cell);
423 return (cell_type(cell) ==
425 JxW(offset + q_point) :
426 JxW(offset) * q_weights(q_point);
427 }
428 };
429
430
438 struct Data
439 {
440 using TeamHandle = Kokkos::TeamPolicy<
441 MemorySpace::Default::kokkos_space::execution_space>::member_type;
442
447
448 const unsigned int n_q_points;
449 const unsigned int n_dof_handler;
450 const int cell_index;
451 const Kokkos::Array<PrecomputedData, n_max_dof_handlers>
453 Kokkos::Array<SharedData<dim, Number>, n_max_dof_handlers> &shared_data;
454
459 DEAL_II_HOST_DEVICE unsigned int
460 local_q_point_id(const unsigned int cell,
461 const unsigned int q_point) const
462 {
465
467 precomputed_data[0].q_points.extent(1),
468 ExcInternalError("q_points array has wrong size"));
469 Assert(n_q_points == precomputed_data[0].q_points.extent(0),
470 ExcInternalError("q_points array has wrong size"));
471
472 return (precomputed_data[0].row_start /
474 cell) *
475 n_q_points +
476 q_point;
477 }
478
479
480
486 get_quadrature_point(const unsigned int cell,
487 const unsigned int q_point) const
488 {
490 precomputed_data[0].q_points.extent(1),
494 Assert(n_q_points == precomputed_data[0].q_points.extent(0),
496 return precomputed_data[0].q_points(q_point, cell);
497 }
498
507 template <typename Functor>
509 for_each_quad_point(const Functor &func) const
510 {
511 Kokkos::parallel_for(Kokkos::TeamThreadRange(team_member, n_q_points),
512 [&](const int &q) { func(q); });
513 team_member.team_barrier();
514 }
515 };
516
521
525 unsigned int
527
538 template <typename IteratorFiltersType>
539 void
540 reinit(const Mapping<dim> &mapping,
541 const DoFHandler<dim> &dof_handler,
542 const AffineConstraints<Number> &constraints,
543 const Quadrature<1> &quad,
544 const IteratorFiltersType &iterator_filter,
545 const AdditionalData &additional_data = AdditionalData());
546
550 void
551 reinit(const Mapping<dim> &mapping,
552 const DoFHandler<dim> &dof_handler,
553 const AffineConstraints<Number> &constraints,
554 const Quadrature<1> &quad,
555 const AdditionalData &additional_data = AdditionalData());
556
560 void
561 reinit(const DoFHandler<dim> &dof_handler,
562 const AffineConstraints<Number> &constraints,
563 const Quadrature<1> &quad,
564 const AdditionalData &additional_data = AdditionalData());
565
566
570 template <typename IteratorFiltersType>
571 void
572 reinit(const Mapping<dim> &mapping,
573 const std::vector<const DoFHandler<dim> *> &dof_handler,
574 const std::vector<const AffineConstraints<Number> *> &constraints,
575 const Quadrature<1> &quad,
576 const IteratorFiltersType &iterator_filter,
577 const AdditionalData &additional_data = AdditionalData());
578
582 void
583 reinit(const Mapping<dim> &mapping,
584 const std::vector<const DoFHandler<dim> *> &dof_handler,
585 const std::vector<const AffineConstraints<Number> *> &constraints,
586 const Quadrature<1> &quad,
587 const AdditionalData &additional_data = AdditionalData());
588
593 get_data(const unsigned int color,
594 const unsigned int dof_handler_index = 0) const;
595
596 // clang-format off
619 // clang-format on
620 template <typename Functor, typename VectorType>
621 void
622 cell_loop(const Functor &func,
623 const VectorType &src,
624 VectorType &dst) const;
625
643 template <typename Functor>
644 void
645 evaluate_coefficients(Functor func) const;
646
653 template <typename VectorType>
654 void
655 copy_constrained_values(const VectorType &src,
656 VectorType &dst,
657 const unsigned int dof_handler_index = 0) const;
658
667 void
672 &dst) const;
673
681 template <typename VectorType>
682 void
683 set_constrained_values(const Number value,
684 VectorType &dst,
685 const unsigned int dof_handler_index = 0) const;
686
695 template <typename MemorySpaceType>
696 void
699 const unsigned int dof_handler_index = 0) const;
700
707 template <typename MemorySpaceType>
708 void
711 const;
712
719 const std::vector<std::vector<CellFilter>> &
721
728 const std::vector<std::vector<LevelCellFilter>> &
730
741 const std::shared_ptr<const Utilities::MPI::Partitioner> &
742 get_vector_partitioner(const unsigned int dof_handler_index = 0) const;
743
747 const DoFHandler<dim> &
748 get_dof_handler(const unsigned int dof_handler_index = 0) const;
749
755 unsigned int
757
766 get_cell_iterator(const unsigned int color,
767 const unsigned int index,
768 const unsigned int dof_handler_index = 0) const;
769
773 unsigned int
774 n_cells_per_color(const unsigned int color) const;
775
781 bool
783
787 std::size_t
789
790 private:
794 template <typename IteratorFiltersType>
795 void
797 const Mapping<dim> &mapping,
798 const std::vector<const DoFHandler<dim> *> &dof_handler,
799 const std::vector<const AffineConstraints<Number> *> &constraints,
800 const Quadrature<1> &quad,
801 const IteratorFiltersType &iterator_filter,
802 const std::shared_ptr<const MPI_Comm> &comm,
803 const AdditionalData additional_data);
804
809 template <typename Functor, typename VectorType>
810 void
811 serial_cell_loop(const Functor &func,
812 const VectorType &src,
813 VectorType &dst) const;
814
819 template <typename Functor>
820 void
822 const Functor &func,
824 &src,
826 const;
827
831 template <typename Functor>
832 void
834 const Functor &func,
838 &dst) const;
839
840
844 int my_id;
845
852
858
863 unsigned int mg_level;
864
869 unsigned int team_size;
870
871
877 {
882 std::vector<
883 Kokkos::View<point_type **, MemorySpace::Default::kokkos_space>>
885
890 std::vector<
891 Kokkos::View<Number *[dim][dim], MemorySpace::Default::kokkos_space>>
893
898 std::vector<Kokkos::View<Number *, MemorySpace::Default::kokkos_space>>
900
905 std::vector<
909
915 std::vector<
916 Kokkos::View<unsigned int *, MemorySpace::Default::kokkos_space>>
918
922 Kokkos::View<Number *, MemorySpace::Default::kokkos_space> q_weights;
923 };
924
929 std::vector<MappingInfo> mapping_info;
930
934 struct DoFInfo
935 {
940
947
951 unsigned int scratch_pad_size;
952
956 unsigned int fe_degree;
957
961 unsigned int n_components;
962
967
971 unsigned int dofs_per_cell;
972
976 unsigned int n_constrained_dofs;
977
982 std::vector<Kokkos::View<types::global_dof_index **,
985
989 Kokkos::View<types::global_dof_index *,
992
996 std::vector<
1000
1004 Kokkos::View<Number *, MemorySpace::Default::kokkos_space> shape_values;
1005
1009 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
1011
1015 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
1017
1021 Kokkos::View<Number *, MemorySpace::Default::kokkos_space>
1023
1028
1033 std::shared_ptr<const Utilities::MPI::Partitioner> partitioner;
1034 };
1035
1039 std::vector<DoFInfo> dof_handler_data;
1040
1044 unsigned int q_points_per_cell;
1045
1049 unsigned int n_colors;
1050
1054 std::vector<unsigned int> n_cells;
1055
1060 unsigned int padding_length;
1061
1065 std::vector<unsigned int> row_start;
1066
1067
1072 std::vector<std::vector<CellFilter>> graph;
1073
1078 std::vector<std::vector<LevelCellFilter>> level_graph;
1079
1080 friend class internal::ReinitHelper<dim, Number>;
1081 };
1082
1083
1084
1085 template <int dim, typename Number>
1087 {
1088 using TeamHandle = Kokkos::TeamPolicy<
1089 MemorySpace::Default::kokkos_space::execution_space>::member_type;
1090
1091 using SharedViewValues = Kokkos::View<
1092 Number **,
1093 MemorySpace::Default::kokkos_space::execution_space::scratch_memory_space,
1094 Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
1095 using SharedViewGradients = Kokkos::View<
1096 Number ***,
1097 MemorySpace::Default::kokkos_space::execution_space::scratch_memory_space,
1098 Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
1099 using SharedViewScratchPad = Kokkos::View<
1100 Number *,
1101 MemorySpace::Default::kokkos_space::execution_space::scratch_memory_space,
1102 Kokkos::MemoryTraits<Kokkos::Unmanaged>>;
1103
1108 void
1109 reinit(const TeamHandle &team_handle,
1110 const unsigned int n_q_points,
1111 const typename MatrixFree<dim, Number>::PrecomputedData &gpu_data)
1112 {
1113 values = SharedViewValues(team_handle.team_shmem(),
1114 n_q_points,
1115 gpu_data.n_components);
1116 gradients = SharedViewGradients(team_handle.team_shmem(),
1117 n_q_points,
1118 dim,
1119 gpu_data.n_components);
1120 scratch_pad = SharedViewScratchPad(team_handle.team_shmem(),
1121 gpu_data.scratch_pad_size);
1122 }
1123
1128
1133
1138 };
1139
1140
1141
1146 template <int dim, typename Number>
1148 {
1152 typename Kokkos::View<Point<dim, Number> **,
1153 MemorySpace::Default::kokkos_space>::host_mirror_type
1155
1160 typename Kokkos::View<types::global_dof_index **,
1161 MemorySpace::Default::kokkos_space>::host_mirror_type
1163
1168 typename Kokkos::View<Number *[dim][dim],
1169 MemorySpace::Default::kokkos_space>::host_mirror_type
1171
1176 typename Kokkos::View<Number *,
1177 MemorySpace::Default::kokkos_space>::host_mirror_type
1179
1184 typename Kokkos::View<
1187
1192 typename Kokkos::View<unsigned int *,
1193 MemorySpace::Default::kokkos_space>::host_mirror_type
1195
1199 typename Kokkos::View<Number *,
1200 MemorySpace::Default::kokkos_space>::host_mirror_type
1202
1206 unsigned int n_cells;
1207
1211 unsigned int padding_length;
1212
1216 unsigned int row_start;
1217
1221 typename Kokkos::View<
1224
1230
1231
1232
1236 unsigned int
1237 local_q_point_id(const unsigned int cell,
1238 const unsigned int n_q_points,
1239 const unsigned int q_point) const
1240 {
1241 return (row_start / padding_length + cell) * n_q_points + q_point;
1242 }
1243
1244
1245
1250 get_quadrature_point(const unsigned int cell,
1251 const unsigned int q_point) const
1252 {
1253 return q_points(q_point, cell);
1254 }
1255
1260 unsigned int
1261 inv_jacobian_index(const unsigned int cell,
1262 const unsigned int q_point) const
1263 {
1264 return data_index_offsets(cell) +
1265 ((cell_type(cell) ==
1267 q_point :
1268 0);
1269 }
1270
1274 Number
1275 JxW_value(const unsigned int cell, const unsigned int q_point) const
1276 {
1277 const unsigned int offset = data_index_offsets(cell);
1278 return (cell_type(cell) ==
1280 JxW(offset + q_point) :
1281 JxW(offset) * q_weights(q_point);
1282 }
1283 };
1284
1285
1286
1293 template <int dim, typename Number>
1294 DataHost<dim, Number>
1296 const typename ::Portable::MatrixFree<dim, Number>::PrecomputedData
1297 &data,
1298 const UpdateFlags &update_flags)
1299 {
1300 DataHost<dim, Number> data_host;
1301
1302 data_host.n_cells = data.n_cells;
1303 data_host.padding_length = data.padding_length;
1304 data_host.row_start = data.row_start;
1305 data_host.use_coloring = data.use_coloring;
1306
1307 const auto create_mirror_without_initializing = [](const auto &view) {
1308#if DEAL_II_KOKKOS_VERSION_GTE(3, 6, 0)
1309 return Kokkos::create_mirror(Kokkos::WithoutInitializing, view);
1310#else
1311 return Kokkos::create_mirror(view);
1312#endif
1313 };
1314
1315 MemorySpace::Default::kokkos_space::execution_space exec;
1316
1317 if (update_flags & update_quadrature_points)
1318 {
1319 data_host.q_points = create_mirror_without_initializing(data.q_points);
1320 Kokkos::deep_copy(exec, data_host.q_points, data.q_points);
1321 }
1322
1323 data_host.local_to_global =
1324 create_mirror_without_initializing(data.local_to_global);
1325 Kokkos::deep_copy(exec, data_host.local_to_global, data.local_to_global);
1326
1327 if (update_flags & update_gradients)
1328 {
1329 data_host.inv_jacobian =
1330 create_mirror_without_initializing(data.inv_jacobian);
1331 Kokkos::deep_copy(exec, data_host.inv_jacobian, data.inv_jacobian);
1332 }
1333
1334 if (update_flags & update_JxW_values)
1335 {
1336 data_host.JxW = create_mirror_without_initializing(data.JxW);
1337 Kokkos::deep_copy(exec, data_host.JxW, data.JxW);
1338 }
1339
1340 data_host.cell_type = create_mirror_without_initializing(data.cell_type);
1341 Kokkos::deep_copy(exec, data_host.cell_type, data.cell_type);
1342
1343 data_host.data_index_offsets =
1344 create_mirror_without_initializing(data.data_index_offsets);
1345 Kokkos::deep_copy(exec,
1346 data_host.data_index_offsets,
1347 data.data_index_offsets);
1348
1349 data_host.q_weights = create_mirror_without_initializing(data.q_weights);
1350 Kokkos::deep_copy(exec, data_host.q_weights, data.q_weights);
1351
1352 data_host.constraint_mask =
1353 create_mirror_without_initializing(data.constraint_mask);
1354 Kokkos::deep_copy(exec, data_host.constraint_mask, data.constraint_mask);
1355
1356 exec.fence();
1357
1358 return data_host;
1359 }
1360
1361
1362 /*----------------------- Inline functions ---------------------------------*/
1363
1364#ifndef DOXYGEN
1365
1366 template <int dim, typename Number>
1367 inline const std::vector<std::vector<
1370 {
1373 ExcMessage(
1374 "The MatrixFree object has been initialized for a specific "
1375 "multigrid level. This function is only available when working "
1376 "on active cells."));
1377 return graph;
1378 }
1379
1380
1381
1382 template <int dim, typename Number>
1383 inline const std::vector<std::vector<
1386 {
1389 ExcMessage("The MatrixFree object has been initialized for active cells. "
1390 "This function is only available when working on a specific "
1391 "multigrid level."));
1392 return level_graph;
1393 }
1394
1395
1396
1397 template <int dim, typename Number>
1398 inline const std::shared_ptr<const Utilities::MPI::Partitioner> &
1400 const unsigned int dof_handler_index) const
1401 {
1402 Assert(dof_handler_data.size() > 0, ExcNotInitialized());
1403 AssertIndexRange(dof_handler_index, dof_handler_data.size());
1404 return dof_handler_data[dof_handler_index].partitioner;
1405 }
1406
1407
1408
1409 template <int dim, typename Number>
1410 inline unsigned int
1412 {
1413 return mg_level;
1414 }
1415
1416
1417
1418 template <int dim, typename Number>
1419 inline const DoFHandler<dim> &
1421 const unsigned int dof_handler_index) const
1422 {
1423 Assert(dof_handler_data.size() > 0, ExcNotInitialized());
1424 AssertIndexRange(dof_handler_index, dof_handler_data.size());
1425
1426 return *dof_handler_data[dof_handler_index].dof_handler;
1427 }
1428
1429
1430 template <int dim, typename Number>
1433 const unsigned int color,
1434 const unsigned int index,
1435 const unsigned int dof_handler_index) const
1436 {
1437 if (mg_level == numbers::invalid_unsigned_int)
1438 {
1439 AssertIndexRange(color, get_colored_graph().size());
1440 AssertIndexRange(index, get_colored_graph()[color].size());
1441
1442 const unsigned int cell_level =
1443 get_colored_graph()[color][index]->level();
1444
1445 const unsigned int cell_index =
1446 get_colored_graph()[color][index]->index();
1447
1448 return typename DoFHandler<dim>::cell_iterator(
1449 &(get_dof_handler(dof_handler_index).get_triangulation()),
1450 cell_level,
1451 cell_index,
1452 &get_dof_handler(dof_handler_index));
1453 }
1454 else
1455 {
1456 AssertIndexRange(color, get_colored_level_graph().size());
1457 AssertIndexRange(index, get_colored_level_graph()[color].size());
1458
1459 const unsigned int cell_level =
1460 get_colored_level_graph()[color][index]->level();
1461
1462 const unsigned int cell_index =
1463 get_colored_level_graph()[color][index]->index();
1464
1465 return typename DoFHandler<dim>::cell_iterator(
1466 &(get_dof_handler(dof_handler_index).get_triangulation()),
1467 cell_level,
1468 cell_index,
1469 &get_dof_handler(dof_handler_index));
1470 }
1471 }
1472
1473
1474
1475 template <int dim, typename Number>
1476 inline unsigned int
1477 MatrixFree<dim, Number>::n_cells_per_color(const unsigned int color) const
1478 {
1479 AssertIndexRange(color, n_cells.size());
1480 return n_cells[color];
1481 }
1482
1483
1484
1485 template <int dim, typename Number>
1486 inline bool
1488 {
1489 return overlap_communication_computation;
1490 }
1491
1492#endif
1493
1494} // namespace Portable
1495
1497
1498#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
unsigned int get_padding_length() 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::vector< unsigned int > row_start
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
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