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