deal.II version 9.7.0
\(\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
vector_access_internal.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2019 - 2025 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15
16#ifndef dealii_matrix_free_vector_access_internal_h
17#define dealii_matrix_free_vector_access_internal_h
18
19#include <deal.II/base/config.h>
20
22
26
27#include <boost/algorithm/string/join.hpp>
28
30
31
32namespace internal
33{
34 // below we use type-traits from matrix-free/type_traits.h
35
36
37
38 // access to serial const vectors that have operator[].
39 template <typename VectorType,
40 std::enable_if_t<is_serial_vector_or_array<VectorType>::value,
41 VectorType> * = nullptr>
42 inline typename VectorType::value_type
43 vector_access(const VectorType &vec, const unsigned int entry)
44 {
45 return vec[entry];
46 }
47
48
49
50 // access to serial non-const vectors that have operator[].
51 template <typename VectorType,
52 std::enable_if_t<is_serial_vector_or_array<VectorType>::value,
53 VectorType> * = nullptr>
54 inline typename VectorType::value_type &
55 vector_access(VectorType &vec, const unsigned int entry)
56 {
57 return vec[entry];
58 }
59
60
61
62 // access to distributed MPI vectors that have a local_element(uint)
63 // method to access data in local index space, which is what we use in
64 // DoFInfo and hence in read_dof_values etc.
65 template <
66 typename VectorType,
67 std::enable_if_t<has_local_element<VectorType>, VectorType> * = nullptr>
68 inline typename VectorType::value_type &
69 vector_access(VectorType &vec, const unsigned int entry)
70 {
71 return vec.local_element(entry);
72 }
73
74
75
76 // same for const access
77 template <
78 typename VectorType,
79 std::enable_if_t<has_local_element<VectorType>, VectorType> * = nullptr>
80 inline typename VectorType::value_type
81 vector_access(const VectorType &vec, const unsigned int entry)
82 {
83 return vec.local_element(entry);
84 }
85
86
87
88 template <
89 typename VectorType,
90 std::enable_if_t<has_add_local_element<VectorType>, VectorType> * = nullptr>
91 inline void
92 vector_access_add(VectorType &vec,
93 const unsigned int entry,
94 const typename VectorType::value_type &val)
95 {
96 vec.add_local_element(entry, val);
97 }
98
99
100
101 template <typename VectorType,
102 std::enable_if_t<!has_add_local_element<VectorType>, VectorType> * =
103 nullptr>
104 inline void
105 vector_access_add(VectorType &vec,
106 const unsigned int entry,
107 const typename VectorType::value_type &val)
108 {
109 vector_access(vec, entry) += val;
110 }
111
112
113
114 template <
115 typename VectorType,
116 std::enable_if_t<has_add_local_element<VectorType>, VectorType> * = nullptr>
117 inline void
119 const types::global_dof_index entry,
120 const typename VectorType::value_type &val)
121 {
122 vec.add(entry, val);
123 }
124
125
126
127 template <typename VectorType,
128 std::enable_if_t<!has_add_local_element<VectorType>, VectorType> * =
129 nullptr>
130 inline void
132 const types::global_dof_index entry,
133 const typename VectorType::value_type &val)
134 {
135 vec[entry] += val;
136 }
137
138
139
140 template <
141 typename VectorType,
142 std::enable_if_t<has_set_local_element<VectorType>, VectorType> * = nullptr>
143 inline void
144 vector_access_set(VectorType &vec,
145 const unsigned int entry,
146 const typename VectorType::value_type &val)
147 {
148 vec.set_local_element(entry, val);
149 }
150
151
152
153 template <typename VectorType,
154 std::enable_if_t<!has_set_local_element<VectorType>, VectorType> * =
155 nullptr>
156 inline void
157 vector_access_set(VectorType &vec,
158 const unsigned int entry,
159 const typename VectorType::value_type &val)
160 {
161 vector_access(vec, entry) = val;
162 }
163
164
165
166 // this is to make sure that the parallel partitioning in VectorType
167 // is really the same as stored in MatrixFree.
168 // version below is when has_partitioners_are_compatible == false
169 // FIXME: this is incorrect for PETSc/Trilinos MPI vectors
170 template <int dim,
171 typename Number,
172 typename VectorizedArrayType,
173 typename VectorType,
174 std::enable_if_t<!has_partitioners_are_compatible<VectorType>,
175 VectorType> * = nullptr>
176 inline void
178 const VectorType &vec,
179 const MatrixFree<dim, Number, VectorizedArrayType> & /*matrix_free*/,
181 {
182 AssertDimension(vec.size(), dof_info.vector_partitioner->size());
183 }
184
185
186
187 // same as above for has_partitioners_are_compatible == true
188 template <int dim,
189 typename Number,
190 typename VectorizedArrayType,
191 typename VectorType,
192 std::enable_if_t<has_partitioners_are_compatible<VectorType>,
193 VectorType> * = nullptr>
194 inline void
196 const VectorType &vec,
199 {
200 (void)vec;
201 (void)matrix_free;
202 (void)dof_info;
203
204 if constexpr (running_in_debug_mode())
205 {
206 if (vec.partitioners_are_compatible(*dof_info.vector_partitioner) ==
207 false)
208 {
209 unsigned int dof_index = numbers::invalid_unsigned_int;
210
211 for (unsigned int i = 0; i < matrix_free.n_components(); ++i)
212 if (&matrix_free.get_dof_info(i) == &dof_info)
213 {
214 dof_index = i;
215 break;
216 }
217
220
221 std::vector<std::string> dof_indices_with_compatible_partitioners;
222
223 for (unsigned int i = 0; i < matrix_free.n_components(); ++i)
224 if (vec.partitioners_are_compatible(
225 *matrix_free.get_dof_info(i).vector_partitioner))
226 dof_indices_with_compatible_partitioners.push_back(
227 std::to_string(i));
228
229 if (dof_indices_with_compatible_partitioners.empty())
230 {
231 Assert(false,
233 "The parallel layout of the given vector is "
234 "compatible neither with the Partitioner of the "
235 "current FEEvaluation with dof_handler_index=" +
236 std::to_string(dof_index) +
237 " nor with any Partitioner in MatrixFree. A "
238 "potential reason is that you did not use "
239 "MatrixFree::initialize_dof_vector() to get a "
240 "compatible vector."));
241 }
242 else
243 {
244 Assert(
245 false,
247 "The parallel layout of the given vector is "
248 "not compatible with the Partitioner of the "
249 "current FEEvaluation with dof_handler_index=" +
250 std::to_string(dof_index) +
251 ". However, the underlying "
252 "MatrixFree contains Partitioner objects that are compatible. "
253 "They have the following dof_handler_index values: " +
254 boost::algorithm::join(
255 dof_indices_with_compatible_partitioners, ", ") +
256 ". Did you want to pass any of these values to the "
257 "constructor of the current FEEvaluation object or "
258 "did you not use MatrixFree::initialize_dof_vector() "
259 "with dof_handler_index=" +
260 std::to_string(dof_index) +
261 " to get a "
262 "compatible vector?"));
263 }
264 }
265 }
266 }
267
268
269
270 // Below, three classes (VectorReader, VectorSetter,
271 // VectorDistributorLocalToGlobal) implement the same interface and can be
272 // used to to read from vector, set elements of a vector and add to elements
273 // of the vector.
274
275 // 1. A class to read data from vector
276 template <typename Number, typename VectorizedArrayType>
278 {
279 template <typename VectorType>
280 void
281 process_dof(const unsigned int index,
282 const VectorType &vec,
283 Number &res) const
284 {
285 res = vector_access(vec, index);
286 }
287
288
289
290 template <typename VectorNumberType>
291 void
292 process_dof(const VectorNumberType &global, Number &local) const
293 {
294 local = global;
295 }
296
297
298
299 template <typename VectorType>
300 void
301 process_dofs_vectorized(const unsigned int dofs_per_cell,
302 const unsigned int dof_index,
303 VectorType &vec,
304 VectorizedArrayType *dof_values,
305 std::bool_constant<true>) const
306 {
307 if constexpr (running_in_debug_mode())
308 {
309 // in debug mode, run non-vectorized version because this path
310 // has additional checks (e.g., regarding ghosting)
311 process_dofs_vectorized(dofs_per_cell,
312 dof_index,
313 vec,
314 dof_values,
315 std::bool_constant<false>());
316 }
317 else
318 {
319 const Number *vec_ptr = vec.begin() + dof_index;
320 for (unsigned int i = 0; i < dofs_per_cell;
321 ++i, vec_ptr += VectorizedArrayType::size())
322 dof_values[i].load(vec_ptr);
323 }
324 }
325
326
327
328 template <typename VectorType>
329 void
330 process_dofs_vectorized(const unsigned int dofs_per_cell,
331 const unsigned int dof_index,
332 const VectorType &vec,
333 VectorizedArrayType *dof_values,
334 std::bool_constant<false>) const
335 {
336 for (unsigned int i = 0; i < dofs_per_cell; ++i)
337 for (unsigned int v = 0; v < VectorizedArrayType::size(); ++v)
338 dof_values[i][v] =
339 vector_access(vec, dof_index + v + i * VectorizedArrayType::size());
340 }
341
342
343
344 template <typename VectorType>
345 void
346 process_dofs_vectorized_transpose(const unsigned int dofs_per_cell,
347 const unsigned int *dof_indices,
348 VectorType &vec,
349 const unsigned int constant_offset,
350 VectorizedArrayType *dof_values,
351 std::bool_constant<true>) const
352 {
354 vec.begin() + constant_offset,
355 dof_indices,
356 dof_values);
357 }
358
359
360
361 template <typename VectorType>
362 void
363 process_dofs_vectorized_transpose(const unsigned int dofs_per_cell,
364 const unsigned int *dof_indices,
365 const VectorType &vec,
366 const unsigned int constant_offset,
367 VectorizedArrayType *dof_values,
368 std::bool_constant<false>) const
369 {
370 for (unsigned int d = 0; d < dofs_per_cell; ++d)
371 for (unsigned int v = 0; v < VectorizedArrayType::size(); ++v)
372 dof_values[d][v] =
373 vector_access(vec, dof_indices[v] + constant_offset + d);
374 }
375
376
377
378 template <typename VectorType>
379 void
380 process_dofs_vectorized_transpose(const unsigned int dofs_per_cell,
381 const unsigned int *dof_indices,
382 VectorType &vec,
383 VectorizedArrayType *dof_values,
384 std::bool_constant<true> type) const
385 {
387 dofs_per_cell, dof_indices, vec, 0, dof_values, type);
388 }
389
390
391
392 template <typename VectorType>
393 void
394 process_dofs_vectorized_transpose(const unsigned int dofs_per_cell,
395 const unsigned int *dof_indices,
396 const VectorType &vec,
397 VectorizedArrayType *dof_values,
398 std::bool_constant<false> type) const
399 {
401 dofs_per_cell, dof_indices, vec, 0, dof_values, type);
402 }
403
404
405
406 template <typename Number2>
407 void
409 const unsigned int dofs_per_cell,
410 const std::array<Number2 *, VectorizedArrayType::size()> &global_ptr,
411 VectorizedArrayType *dof_values,
412 std::bool_constant<true>) const
413 {
415 global_ptr,
416 dof_values);
417 }
418
419
420
421 template <typename Number2>
422 void
424 const unsigned int,
425 const std::array<Number2 *, VectorizedArrayType::size()> &,
426 VectorizedArrayType *,
427 std::bool_constant<false>) const
428 {
430 }
431
432
433
434 // variant where VectorType::value_type is the same as Number -> can call
435 // gather
436 template <typename VectorType>
437 void
438 process_dof_gather(const unsigned int *indices,
439 VectorType &vec,
440 const unsigned int constant_offset,
441 typename VectorType::value_type *vec_ptr,
442 VectorizedArrayType &res,
443 std::bool_constant<true>) const
444 {
445 (void)constant_offset;
446 (void)vec;
447
448 if constexpr (running_in_debug_mode())
449 {
450 // in debug mode, run non-vectorized version because this path
451 // has additional checks (e.g., regarding ghosting)
452 Assert(vec_ptr == vec.begin() + constant_offset, ExcInternalError());
453 process_dof_gather(indices,
454 vec,
455 constant_offset,
456 vec_ptr,
457 res,
458 std::bool_constant<false>());
459 }
460 else
461 {
462 res.gather(vec_ptr, indices);
463 }
464 }
465
466
467
468 // variant where VectorType::value_type is not the same as Number -> must
469 // manually load the data
470 template <typename VectorType>
471 void
472 process_dof_gather(const unsigned int *indices,
473 const VectorType &vec,
474 const unsigned int constant_offset,
475 typename VectorType::value_type *,
476 VectorizedArrayType &res,
477 std::bool_constant<false>) const
478 {
479 for (unsigned int v = 0; v < VectorizedArrayType::size(); ++v)
480 res[v] = vector_access(vec, indices[v] + constant_offset);
481 }
482
483
484
485 template <typename VectorType>
486 void
488 const VectorType &vec,
489 Number &res) const
490 {
491 res = vec[index];
492 }
493
494
495
496 void
497 pre_constraints(const Number &, Number &res) const
498 {
499 res = Number();
500 }
501
502
503
504 template <typename VectorType>
505 void
506 process_constraint(const unsigned int index,
507 const Number weight,
508 const VectorType &vec,
509 Number &res) const
510 {
511 res += weight * vector_access(vec, index);
512 }
513
514
515
516 void
517 post_constraints(const Number &sum, Number &write_pos) const
518 {
519 write_pos = sum;
520 }
521
522
523
524 void
525 process_empty(VectorizedArrayType &res) const
526 {
527 res = VectorizedArrayType();
528 }
529 };
530
531
532
533 // 2. A class to add values to the vector during
534 // FEEvaluation::distribute_local_to_global() call
535 template <typename Number, typename VectorizedArrayType>
537 {
538 template <typename VectorType>
539 void
540 process_dof(const unsigned int index, VectorType &vec, Number &res) const
541 {
542 vector_access_add(vec, index, res);
543 }
544
545
546 template <typename VectorNumberType>
547 void
548 process_dof(VectorNumberType &global, Number &local) const
549 {
550 global += local;
551 }
552
553
554
555 template <typename VectorType>
556 void
557 process_dofs_vectorized(const unsigned int dofs_per_cell,
558 const unsigned int dof_index,
559 VectorType &vec,
560 VectorizedArrayType *dof_values,
561 std::bool_constant<true>) const
562 {
563 Number *vec_ptr = vec.begin() + dof_index;
564 for (unsigned int i = 0; i < dofs_per_cell;
565 ++i, vec_ptr += VectorizedArrayType::size())
566 {
567 VectorizedArrayType tmp;
568 tmp.load(vec_ptr);
569 tmp += dof_values[i];
570 tmp.store(vec_ptr);
571 }
572 }
573
574
575
576 template <typename VectorType>
577 void
578 process_dofs_vectorized(const unsigned int dofs_per_cell,
579 const unsigned int dof_index,
580 VectorType &vec,
581 VectorizedArrayType *dof_values,
582 std::bool_constant<false>) const
583 {
584 for (unsigned int i = 0; i < dofs_per_cell; ++i)
585 for (unsigned int v = 0; v < VectorizedArrayType::size(); ++v)
587 dof_index + v + i * VectorizedArrayType::size(),
588 dof_values[i][v]);
589 }
590
591
592
593 template <typename VectorType>
594 void
595 process_dofs_vectorized_transpose(const unsigned int dofs_per_cell,
596 const unsigned int *dof_indices,
597 VectorType &vec,
598 const unsigned int constant_offset,
599 VectorizedArrayType *dof_values,
600 std::bool_constant<true>) const
601 {
603 dofs_per_cell,
604 dof_values,
605 dof_indices,
606 vec.begin() + constant_offset);
607 }
608
609
610
611 template <typename VectorType>
612 void
613 process_dofs_vectorized_transpose(const unsigned int dofs_per_cell,
614 const unsigned int *dof_indices,
615 VectorType &vec,
616 const unsigned int constant_offset,
617 VectorizedArrayType *dof_values,
618 std::bool_constant<false>) const
619 {
620 for (unsigned int d = 0; d < dofs_per_cell; ++d)
621 for (unsigned int v = 0; v < VectorizedArrayType::size(); ++v)
623 dof_indices[v] + constant_offset + d,
624 dof_values[d][v]);
625 }
626
627
628
629 template <typename VectorType>
630 void
631 process_dofs_vectorized_transpose(const unsigned int dofs_per_cell,
632 const unsigned int *dof_indices,
633 VectorType &vec,
634 VectorizedArrayType *dof_values,
635 std::bool_constant<true> type) const
636 {
638 dofs_per_cell, dof_indices, vec, 0, dof_values, type);
639 }
640
641
642
643 template <typename VectorType>
644 void
645 process_dofs_vectorized_transpose(const unsigned int dofs_per_cell,
646 const unsigned int *dof_indices,
647 VectorType &vec,
648 VectorizedArrayType *dof_values,
649 std::bool_constant<false> type) const
650 {
652 dofs_per_cell, dof_indices, vec, 0, dof_values, type);
653 }
654
655
656
657 template <typename Number2>
658 void
660 const unsigned int dofs_per_cell,
661 std::array<Number2 *, VectorizedArrayType::size()> &global_ptr,
662 VectorizedArrayType *dof_values,
663 std::bool_constant<true>) const
664 {
666 dofs_per_cell,
667 dof_values,
668 global_ptr);
669 }
670
671
672
673 template <typename Number2>
674 void
676 const unsigned int,
677 std::array<Number2 *, VectorizedArrayType::size()> &,
678 VectorizedArrayType *,
679 std::bool_constant<false>) const
680 {
682 }
683
684
685
686 // variant where VectorType::value_type is the same as Number -> can call
687 // scatter
688 template <typename VectorType>
689 void
690 process_dof_gather(const unsigned int *indices,
691 VectorType &vec,
692 const unsigned int constant_offset,
693 typename VectorType::value_type *vec_ptr,
694 VectorizedArrayType &res,
695 std::bool_constant<true>) const
696 {
697 (void)constant_offset;
698 (void)vec_ptr;
699 (void)vec;
700
701#if DEAL_II_VECTORIZATION_WIDTH_IN_BITS < 512
702 for (unsigned int v = 0; v < VectorizedArrayType::size(); ++v)
703 vector_access(vec, indices[v] + constant_offset) += res[v];
704#else
705 // only use gather in case there is also scatter.
706 VectorizedArrayType tmp;
707 tmp.gather(vec_ptr, indices);
708 tmp += res;
709 tmp.scatter(indices, vec_ptr);
710#endif
711 }
712
713
714
715 // variant where VectorType::value_type is not the same as Number -> must
716 // manually append all data
717 template <typename VectorType>
718 void
719 process_dof_gather(const unsigned int *indices,
720 VectorType &vec,
721 const unsigned int constant_offset,
722 typename VectorType::value_type *,
723 VectorizedArrayType &res,
724 std::bool_constant<false>) const
725 {
726 for (unsigned int v = 0; v < VectorizedArrayType::size(); ++v)
727 vector_access_add(vec, indices[v] + constant_offset, res[v]);
728 }
729
730
731
732 template <typename VectorType>
733 void
735 VectorType &vec,
736 Number &res) const
737 {
739 }
740
741
742
743 void
744 pre_constraints(const Number &input, Number &res) const
745 {
746 res = input;
747 }
748
749
750
751 template <typename VectorType>
752 void
753 process_constraint(const unsigned int index,
754 const Number weight,
755 VectorType &vec,
756 Number &res) const
757 {
758 vector_access_add(vec, index, weight * res);
759 }
760
761
762
763 void
764 post_constraints(const Number &, Number &) const
765 {}
766
767
768
769 void
770 process_empty(VectorizedArrayType &) const
771 {}
772 };
773
774
775
776 // 3. A class to set elements of the vector
777 template <typename Number, typename VectorizedArrayType>
779 {
780 template <typename VectorType>
781 void
782 process_dof(const unsigned int index, VectorType &vec, Number &res) const
783 {
784 vector_access(vec, index) = res;
785 }
786
787
788
789 template <typename VectorNumberType>
790 void
791 process_dof(VectorNumberType &global, Number &local) const
792 {
793 global = local;
794 }
795
796
797
798 template <typename VectorType>
799 void
800 process_dofs_vectorized(const unsigned int dofs_per_cell,
801 const unsigned int dof_index,
802 VectorType &vec,
803 VectorizedArrayType *dof_values,
804 std::bool_constant<true>) const
805 {
806 Number *vec_ptr = vec.begin() + dof_index;
807 for (unsigned int i = 0; i < dofs_per_cell;
808 ++i, vec_ptr += VectorizedArrayType::size())
809 dof_values[i].store(vec_ptr);
810 }
811
812
813
814 template <typename VectorType>
815 void
816 process_dofs_vectorized(const unsigned int dofs_per_cell,
817 const unsigned int dof_index,
818 VectorType &vec,
819 VectorizedArrayType *dof_values,
820 std::bool_constant<false>) const
821 {
822 for (unsigned int i = 0; i < dofs_per_cell; ++i)
823 for (unsigned int v = 0; v < VectorizedArrayType::size(); ++v)
824 vector_access(vec, dof_index + v + i * VectorizedArrayType::size()) =
825 dof_values[i][v];
826 }
827
828
829
830 template <typename VectorType>
831 void
832 process_dofs_vectorized_transpose(const unsigned int dofs_per_cell,
833 const unsigned int *dof_indices,
834 VectorType &vec,
835 const unsigned int constant_offset,
836 VectorizedArrayType *dof_values,
837 std::bool_constant<true>) const
838 {
840 dofs_per_cell,
841 dof_values,
842 dof_indices,
843 vec.begin() + constant_offset);
844 }
845
846
847
848 template <typename VectorType, bool booltype>
849 void
850 process_dofs_vectorized_transpose(const unsigned int dofs_per_cell,
851 const unsigned int *dof_indices,
852 VectorType &vec,
853 const unsigned int constant_offset,
854 VectorizedArrayType *dof_values,
855 std::bool_constant<false>) const
856 {
857 for (unsigned int i = 0; i < dofs_per_cell; ++i)
858 for (unsigned int v = 0; v < VectorizedArrayType::size(); ++v)
859 vector_access(vec, constant_offset + dof_indices[v] + i) =
860 dof_values[i][v];
861 }
862
863
864
865 template <typename VectorType>
866 void
867 process_dofs_vectorized_transpose(const unsigned int dofs_per_cell,
868 const unsigned int *dof_indices,
869 VectorType &vec,
870 VectorizedArrayType *dof_values,
871 std::bool_constant<true> type) const
872 {
874 dofs_per_cell, dof_indices, vec, 0, dof_values, type);
875 }
876
877
878
879 template <typename VectorType, bool booltype>
880 void
881 process_dofs_vectorized_transpose(const unsigned int dofs_per_cell,
882 const unsigned int *dof_indices,
883 VectorType &vec,
884 VectorizedArrayType *dof_values,
885 std::bool_constant<false> type) const
886 {
888 dofs_per_cell, dof_indices, vec, 0, dof_values, type);
889 }
890
891
892
893 template <typename Number2>
894 void
896 const unsigned int dofs_per_cell,
897 std::array<Number2 *, VectorizedArrayType::size()> &global_ptr,
898 VectorizedArrayType *dof_values,
899 std::bool_constant<true>) const
900 {
902 dofs_per_cell,
903 dof_values,
904 global_ptr);
905 }
906
907
908
909 template <typename Number2>
910 void
912 const unsigned int,
913 std::array<Number2 *, VectorizedArrayType::size()> &,
914 VectorizedArrayType *,
915 std::bool_constant<false>) const
916 {
918 }
919
920
921
922 template <typename VectorType>
923 void
924 process_dof_gather(const unsigned int *indices,
925 VectorType &vec,
926 const unsigned int constant_offset,
927 typename VectorType::value_type *vec_ptr,
928 VectorizedArrayType &res,
929 std::bool_constant<true>) const
930 {
931 Assert(vec_ptr == vec.begin() + constant_offset, ExcInternalError());
932 res.scatter(indices, vec_ptr);
933 }
934
935
936
937 template <typename VectorType>
938 void
939 process_dof_gather(const unsigned int *indices,
940 VectorType &vec,
941 const unsigned int constant_offset,
942 typename VectorType::value_type *,
943 VectorizedArrayType &res,
944 std::bool_constant<false>) const
945 {
946 for (unsigned int v = 0; v < VectorizedArrayType::size(); ++v)
947 vector_access(vec, indices[v] + constant_offset) = res[v];
948 }
949
950
951
952 template <typename VectorType>
953 void
955 VectorType &vec,
956 Number &res) const
957 {
958 vec[index] = res;
959 }
960
961
962
963 void
964 pre_constraints(const Number &, Number &) const
965 {}
966
967
968
969 template <typename VectorType>
970 void
971 process_constraint(const unsigned int,
972 const Number,
973 VectorType &,
974 Number &) const
975 {}
976
977
978
979 void
980 post_constraints(const Number &, Number &) const
981 {}
982
983
984
985 void
986 process_empty(VectorizedArrayType &) const
987 {}
988 };
989} // namespace internal
990
991
993
994#endif
const internal::MatrixFreeFunctions::DoFInfo & get_dof_info(const unsigned int dof_handler_index_component=0) const
unsigned int n_components() const
types::global_dof_index size() const
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:40
constexpr bool running_in_debug_mode()
Definition config.h:78
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:41
#define DEAL_II_NOT_IMPLEMENTED()
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcMessage(std::string arg1)
Tpetra::Vector< Number, LO, GO, NodeType< MemorySpace > > VectorType
void vector_access_add(VectorType &vec, const unsigned int entry, const typename VectorType::value_type &val)
void vector_access_add_global(VectorType &vec, const types::global_dof_index entry, const typename VectorType::value_type &val)
void check_vector_compatibility(const VectorType &vec, const MatrixFree< dim, Number, VectorizedArrayType > &, const internal::MatrixFreeFunctions::DoFInfo &dof_info)
VectorType::value_type vector_access(const VectorType &vec, const unsigned int entry)
void vector_access_set(VectorType &vec, const unsigned int entry, const typename VectorType::value_type &val)
constexpr unsigned int invalid_unsigned_int
Definition types.h:238
unsigned int global_dof_index
Definition types.h:94
std::shared_ptr< const Utilities::MPI::Partitioner > vector_partitioner
Definition dof_info.h:593
void process_dof_gather(const unsigned int *indices, VectorType &vec, const unsigned int constant_offset, typename VectorType::value_type *vec_ptr, VectorizedArrayType &res, std::bool_constant< true >) const
void process_dofs_vectorized_transpose(const unsigned int dofs_per_cell, const unsigned int *dof_indices, VectorType &vec, VectorizedArrayType *dof_values, std::bool_constant< false > type) const
void pre_constraints(const Number &input, Number &res) const
void process_empty(VectorizedArrayType &) const
void process_dof(const unsigned int index, VectorType &vec, Number &res) const
void process_dofs_vectorized_transpose(const unsigned int dofs_per_cell, const unsigned int *dof_indices, VectorType &vec, const unsigned int constant_offset, VectorizedArrayType *dof_values, std::bool_constant< false >) const
void post_constraints(const Number &, Number &) const
void process_dofs_vectorized(const unsigned int dofs_per_cell, const unsigned int dof_index, VectorType &vec, VectorizedArrayType *dof_values, std::bool_constant< true >) const
void process_dofs_vectorized(const unsigned int dofs_per_cell, const unsigned int dof_index, VectorType &vec, VectorizedArrayType *dof_values, std::bool_constant< false >) const
void process_dofs_vectorized_transpose(const unsigned int dofs_per_cell, const unsigned int *dof_indices, VectorType &vec, const unsigned int constant_offset, VectorizedArrayType *dof_values, std::bool_constant< true >) const
void process_dofs_vectorized_transpose(const unsigned int dofs_per_cell, const unsigned int *dof_indices, VectorType &vec, VectorizedArrayType *dof_values, std::bool_constant< true > type) const
void process_dofs_vectorized_transpose(const unsigned int, std::array< Number2 *, VectorizedArrayType::size()> &, VectorizedArrayType *, std::bool_constant< false >) const
void process_dof_gather(const unsigned int *indices, VectorType &vec, const unsigned int constant_offset, typename VectorType::value_type *, VectorizedArrayType &res, std::bool_constant< false >) const
void process_dofs_vectorized_transpose(const unsigned int dofs_per_cell, std::array< Number2 *, VectorizedArrayType::size()> &global_ptr, VectorizedArrayType *dof_values, std::bool_constant< true >) const
void process_dof(VectorNumberType &global, Number &local) const
void process_constraint(const unsigned int index, const Number weight, VectorType &vec, Number &res) const
void process_dof_global(const types::global_dof_index index, VectorType &vec, Number &res) const
void pre_constraints(const Number &, Number &res) const
void post_constraints(const Number &sum, Number &write_pos) const
void process_dofs_vectorized_transpose(const unsigned int dofs_per_cell, const unsigned int *dof_indices, VectorType &vec, const unsigned int constant_offset, VectorizedArrayType *dof_values, std::bool_constant< true >) const
void process_dof_global(const types::global_dof_index index, const VectorType &vec, Number &res) const
void process_dofs_vectorized(const unsigned int dofs_per_cell, const unsigned int dof_index, const VectorType &vec, VectorizedArrayType *dof_values, std::bool_constant< false >) const
void process_dofs_vectorized_transpose(const unsigned int dofs_per_cell, const unsigned int *dof_indices, const VectorType &vec, const unsigned int constant_offset, VectorizedArrayType *dof_values, std::bool_constant< false >) const
void process_constraint(const unsigned int index, const Number weight, const VectorType &vec, Number &res) const
void process_dofs_vectorized_transpose(const unsigned int dofs_per_cell, const unsigned int *dof_indices, VectorType &vec, VectorizedArrayType *dof_values, std::bool_constant< true > type) const
void process_dof_gather(const unsigned int *indices, const VectorType &vec, const unsigned int constant_offset, typename VectorType::value_type *, VectorizedArrayType &res, std::bool_constant< false >) const
void process_dofs_vectorized(const unsigned int dofs_per_cell, const unsigned int dof_index, VectorType &vec, VectorizedArrayType *dof_values, std::bool_constant< true >) const
void process_dof(const VectorNumberType &global, Number &local) const
void process_empty(VectorizedArrayType &res) const
void process_dof(const unsigned int index, const VectorType &vec, Number &res) const
void process_dofs_vectorized_transpose(const unsigned int, const std::array< Number2 *, VectorizedArrayType::size()> &, VectorizedArrayType *, std::bool_constant< false >) const
void process_dofs_vectorized_transpose(const unsigned int dofs_per_cell, const unsigned int *dof_indices, const VectorType &vec, VectorizedArrayType *dof_values, std::bool_constant< false > type) const
void process_dofs_vectorized_transpose(const unsigned int dofs_per_cell, const std::array< Number2 *, VectorizedArrayType::size()> &global_ptr, VectorizedArrayType *dof_values, std::bool_constant< true >) const
void process_dof_gather(const unsigned int *indices, VectorType &vec, const unsigned int constant_offset, typename VectorType::value_type *vec_ptr, VectorizedArrayType &res, std::bool_constant< true >) const
void process_dofs_vectorized(const unsigned int dofs_per_cell, const unsigned int dof_index, VectorType &vec, VectorizedArrayType *dof_values, std::bool_constant< false >) const
void process_dofs_vectorized_transpose(const unsigned int dofs_per_cell, std::array< Number2 *, VectorizedArrayType::size()> &global_ptr, VectorizedArrayType *dof_values, std::bool_constant< true >) const
void process_empty(VectorizedArrayType &) const
void process_dofs_vectorized_transpose(const unsigned int dofs_per_cell, const unsigned int *dof_indices, VectorType &vec, VectorizedArrayType *dof_values, std::bool_constant< true > type) const
void process_dofs_vectorized_transpose(const unsigned int dofs_per_cell, const unsigned int *dof_indices, VectorType &vec, const unsigned int constant_offset, VectorizedArrayType *dof_values, std::bool_constant< false >) const
void process_dofs_vectorized_transpose(const unsigned int dofs_per_cell, const unsigned int *dof_indices, VectorType &vec, VectorizedArrayType *dof_values, std::bool_constant< false > type) const
void process_dofs_vectorized_transpose(const unsigned int dofs_per_cell, const unsigned int *dof_indices, VectorType &vec, const unsigned int constant_offset, VectorizedArrayType *dof_values, std::bool_constant< true >) const
void process_dof_global(const types::global_dof_index index, VectorType &vec, Number &res) const
void pre_constraints(const Number &, Number &) const
void process_dof_gather(const unsigned int *indices, VectorType &vec, const unsigned int constant_offset, typename VectorType::value_type *vec_ptr, VectorizedArrayType &res, std::bool_constant< true >) const
void process_dofs_vectorized(const unsigned int dofs_per_cell, const unsigned int dof_index, VectorType &vec, VectorizedArrayType *dof_values, std::bool_constant< true >) const
void process_dofs_vectorized_transpose(const unsigned int, std::array< Number2 *, VectorizedArrayType::size()> &, VectorizedArrayType *, std::bool_constant< false >) const
void process_constraint(const unsigned int, const Number, VectorType &, Number &) const
void process_dof(const unsigned int index, VectorType &vec, Number &res) const
void post_constraints(const Number &, Number &) const
void process_dof(VectorNumberType &global, Number &local) const
void process_dof_gather(const unsigned int *indices, VectorType &vec, const unsigned int constant_offset, typename VectorType::value_type *, VectorizedArrayType &res, std::bool_constant< false >) const
void vectorized_load_and_transpose(const unsigned int n_entries, const Number *in, const unsigned int *offsets, VectorizedArray< Number, width > *out)
void vectorized_transpose_and_store(const bool add_into, const unsigned int n_entries, const VectorizedArray< Number, width > *in, const unsigned int *offsets, Number *out)