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